summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-05-28 11:45:01 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-05-28 11:45:01 +0100
commit3c1c392ab177566f09d11a380210e1937741fad2 (patch)
tree67b12689c60dc2e75a5587988dd11bf36c12da9a
parentAdd glad submodule and build a glad library (diff)
downloadilt-3c1c392ab177566f09d11a380210e1937741fad2.tar.bz2
ilt-3c1c392ab177566f09d11a380210e1937741fad2.tar.xz
ilt-3c1c392ab177566f09d11a380210e1937741fad2.zip
Swap GLEW for more modern glad
-rw-r--r--Jamroot.jam3
-rw-r--r--assetFactory/modelFactoryMesh.h2
-rw-r--r--assetFactory/texturePacker.cpp4
-rw-r--r--game/network/rail.cpp2
-rw-r--r--gfx/gl/program.h2
-rw-r--r--gfx/gl/shader.h4
-rw-r--r--gfx/gl/uiShader.h2
-rw-r--r--gfx/gl/vertexArrayObject.h2
-rw-r--r--gfx/models/mesh.h2
-rw-r--r--gfx/models/texture.cpp2
-rw-r--r--gfx/models/vertex.h2
-rw-r--r--lib/embed-glsl.cpp.m412
-rw-r--r--lib/glArrays.h2
-rw-r--r--lib/gl_traits.h2
-rw-r--r--lib/strlen.h2
-rw-r--r--test/Jamfile.jam4
-rw-r--r--test/test-glContextBhvr.cpp4
-rw-r--r--test/test-lib.cpp2
-rw-r--r--test/test-network.cpp5
-rw-r--r--test/test-text.cpp5
-rw-r--r--ui/font.h2
-rw-r--r--ui/gameMainWindow.cpp2
-rw-r--r--ui/icon.cpp2
-rw-r--r--ui/iconButton.cpp2
-rw-r--r--ui/text.h2
-rw-r--r--ui/window.cpp10
-rw-r--r--ui/window.h6
27 files changed, 50 insertions, 41 deletions
diff --git a/Jamroot.jam b/Jamroot.jam
index 0273fe2..8a111ee 100644
--- a/Jamroot.jam
+++ b/Jamroot.jam
@@ -7,7 +7,6 @@ import sequence ;
import glsl ;
pkg-config.import sdl2 ;
-pkg-config.import glew ;
pkg-config.import freetype2 ;
pkg-config.import glib-2.0 ;
pkg-config.import mxml ;
@@ -92,7 +91,6 @@ lib ilt :
<library>thirdparty//glad
<implicit-dependency>thirdparty//glad
<library>sdl2
- <library>glew
<library>freetype2
<library>glib-2.0
<library>mxml
@@ -102,6 +100,7 @@ lib ilt :
: :
<include>.
<include>lib
+ <implicit-dependency>thirdparty//glad
;
build-project test ;
diff --git a/assetFactory/modelFactoryMesh.h b/assetFactory/modelFactoryMesh.h
index 012977a..32e7ab5 100644
--- a/assetFactory/modelFactoryMesh.h
+++ b/assetFactory/modelFactoryMesh.h
@@ -1,9 +1,9 @@
#pragma once
#include "modelFactoryMesh_fwd.h"
-#include <GL/glew.h>
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
#include <OpenMesh/Core/Mesh/Traits.hh>
+#include <glad/gl.h>
#include <glm/geometric.hpp>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
diff --git a/assetFactory/texturePacker.cpp b/assetFactory/texturePacker.cpp
index 1d533c1..dbafc4b 100644
--- a/assetFactory/texturePacker.cpp
+++ b/assetFactory/texturePacker.cpp
@@ -1,8 +1,8 @@
#include "texturePacker.h"
#include "collections.h"
-#include <GL/glew.h>
#include <algorithm>
#include <cstdio>
+#include <glad/gl.h>
#include <glm/common.hpp>
#include <numeric>
#include <ostream>
@@ -65,7 +65,7 @@ TexturePacker::pack(Size size) const
return {};
}
}
- if (GLEW_ARB_texture_non_power_of_two) {
+ if (GL_ARB_texture_non_power_of_two) {
// Crop the size back to minimum size
size = std::transform_reduce(
result.begin(), result.end(), inputImages.begin(), Size {},
diff --git a/game/network/rail.cpp b/game/network/rail.cpp
index 4454600..bd24a2b 100644
--- a/game/network/rail.cpp
+++ b/game/network/rail.cpp
@@ -1,6 +1,5 @@
#include "rail.h"
#include "network.h"
-#include <GL/glew.h>
#include <array>
#include <cmath>
#include <collection.h>
@@ -8,6 +7,7 @@
#include <game/network/link.h>
#include <game/network/network.impl.h> // IWYU pragma: keep
#include <gfx/models/vertex.h>
+#include <glad/gl.h>
#include <glm/gtx/transform.hpp>
#include <initializer_list>
#include <maths.h>
diff --git a/gfx/gl/program.h b/gfx/gl/program.h
index 2708ff0..76b6742 100644
--- a/gfx/gl/program.h
+++ b/gfx/gl/program.h
@@ -1,8 +1,8 @@
#pragma once
#include "shader.h"
-#include <GL/glew.h>
#include <glRef.h>
+#include <glad/gl.h>
#include <glm/mat4x4.hpp>
#include <special_members.h>
diff --git a/gfx/gl/shader.h b/gfx/gl/shader.h
index cb8065b..0810e6b 100644
--- a/gfx/gl/shader.h
+++ b/gfx/gl/shader.h
@@ -1,13 +1,13 @@
#pragma once
-#include <GL/glew.h>
#include <glRef.h>
+#include <glad/gl.h>
#include <optional>
#include <string_view>
class Shader {
public:
- using ShaderRef = glRef<GLuint, &__glewCreateShader, &__glewDeleteShader>;
+ using ShaderRef = glRef<GLuint, &glCreateShader, &glDeleteShader>;
constexpr Shader(const GLchar * text, GLint len, GLuint type) : text {text}, len {len}, type {type} { }
[[nodiscard]] ShaderRef compile() const;
diff --git a/gfx/gl/uiShader.h b/gfx/gl/uiShader.h
index 054c944..2766af8 100644
--- a/gfx/gl/uiShader.h
+++ b/gfx/gl/uiShader.h
@@ -1,8 +1,8 @@
#pragma once
#include "program.h"
-#include <GL/glew.h>
#include <cstddef>
+#include <glad/gl.h>
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
diff --git a/gfx/gl/vertexArrayObject.h b/gfx/gl/vertexArrayObject.h
index 1d27588..fa6baa3 100644
--- a/gfx/gl/vertexArrayObject.h
+++ b/gfx/gl/vertexArrayObject.h
@@ -3,7 +3,7 @@
#include "collections.h"
#include "gl_traits.h"
#include "special_members.h"
-#include <GL/glew.h>
+#include <glad/gl.h>
class VertexArrayObject {
public:
diff --git a/gfx/models/mesh.h b/gfx/models/mesh.h
index 972fe30..71f6dce 100644
--- a/gfx/models/mesh.h
+++ b/gfx/models/mesh.h
@@ -1,8 +1,8 @@
#pragma once
#include "gfx/gl/vertexArrayObject.h"
-#include <GL/glew.h>
#include <glArrays.h>
+#include <glad/gl.h>
#include <memory>
#include <span>
#include <stdTypeDefs.h>
diff --git a/gfx/models/texture.cpp b/gfx/models/texture.cpp
index 3003319..380f2e0 100644
--- a/gfx/models/texture.cpp
+++ b/gfx/models/texture.cpp
@@ -1,11 +1,11 @@
#include "texture.h"
#include "glArrays.h"
#include "tga.h"
-#include <GL/glew.h>
#include <cache.h>
#include <fcntl.h>
#include <filesystem.h>
#include <gfx/image.h>
+#include <glad/gl.h>
#include <glm/geometric.hpp>
#include <resource.h>
#include <stb/stb_image.h>
diff --git a/gfx/models/vertex.h b/gfx/models/vertex.h
index 181e7e7..0464ea7 100644
--- a/gfx/models/vertex.h
+++ b/gfx/models/vertex.h
@@ -1,6 +1,6 @@
#pragma once
-#include <GL/glew.h>
+#include <glad/gl.h>
#include <glm/glm.hpp>
class Vertex {
diff --git a/lib/embed-glsl.cpp.m4 b/lib/embed-glsl.cpp.m4
index 8407132..60fb56b 100644
--- a/lib/embed-glsl.cpp.m4
+++ b/lib/embed-glsl.cpp.m4
@@ -1,12 +1,12 @@
-changecom()dnl
+changecom() dnl
// NAME
-#include "substr(TYPE,1)-NAME.h"
-#include <GL/glew.h>
#include "gfx/gl/shader.h"
#include "lib/strlen.h"
+#include "substr(TYPE,1)-NAME.h"
+#include <glad/gl.h>
-constexpr const GLchar * src { R"GLSL-EMBED(dnl
-include(SOURCE))GLSL-EMBED" };
-constexpr auto len { constexpr_strlen (src) };
+ constexpr const GLchar * src {R"GLSL-EMBED(dnl
+include(SOURCE))GLSL-EMBED"};
+constexpr auto len {constexpr_strlen(src)};
const Shader NAME`_'substr(TYPE,1) { src, len, GLTYPE };
diff --git a/lib/glArrays.h b/lib/glArrays.h
index 8c8c0bc..86385d9 100644
--- a/lib/glArrays.h
+++ b/lib/glArrays.h
@@ -1,9 +1,9 @@
#pragma once
-#include <GL/glew.h>
#include <algorithm> // IWYU pragma: keep
#include <array>
#include <cstddef>
+#include <glad/gl.h>
#include <special_members.h>
template<size_t N> class glArraysBase {
diff --git a/lib/gl_traits.h b/lib/gl_traits.h
index 6ff8905..a930eba 100644
--- a/lib/gl_traits.h
+++ b/lib/gl_traits.h
@@ -1,7 +1,7 @@
#pragma once
-#include <GL/glew.h>
#include <array>
+#include <glad/gl.h>
#include <glm/common.hpp>
#include <glm/fwd.hpp>
diff --git a/lib/strlen.h b/lib/strlen.h
index 0053cce..2090d25 100644
--- a/lib/strlen.h
+++ b/lib/strlen.h
@@ -1,7 +1,7 @@
#pragma once
-#include <GL/glew.h>
#include <cstddef>
+#include <glad/gl.h>
constexpr auto
constexpr_strlen(const GLchar * const s)
diff --git a/test/Jamfile.jam b/test/Jamfile.jam
index 3b4e891..e221af7 100644
--- a/test/Jamfile.jam
+++ b/test/Jamfile.jam
@@ -47,9 +47,9 @@ run test-collection.cpp ;
run test-maths.cpp ;
run test-lib.cpp ;
run test-geo.cpp ;
-run test-network.cpp ;
+run test-network.cpp : : : <library>test ;
run test-persistence.cpp : -- : [ sequence.insertion-sort [ glob-tree fixtures : *.json ] ] : <library>test ;
-run test-text.cpp ;
+run test-text.cpp : : : <library>test ;
run test-enumDetails.cpp ;
run test-render.cpp : -- : test-assetFactory : <library>test ;
run test-glContextBhvr.cpp ;
diff --git a/test/test-glContextBhvr.cpp b/test/test-glContextBhvr.cpp
index 9716f54..1f1215c 100644
--- a/test/test-glContextBhvr.cpp
+++ b/test/test-glContextBhvr.cpp
@@ -24,12 +24,12 @@ BOOST_AUTO_TEST_CASE(windowContextThingsBehaviour1)
const SDL_WindowPtr window {TEST_WINDOW_PARAMS};
BOOST_REQUIRE(window);
BOOST_REQUIRE(!glCreateProgram);
- BOOST_REQUIRE_NE(glewInit(), GLEW_OK); // No context yet
+ BOOST_REQUIRE_EQUAL(gladLoadGL(reinterpret_cast<GLADloadfunc>(SDL_GL_GetProcAddress)), 0); // No context yet
{
const SDL_GLContextPtr context {window};
BOOST_REQUIRE(context);
BOOST_REQUIRE(!glCreateProgram);
- BOOST_REQUIRE_EQUAL(glewInit(), GLEW_OK);
+ BOOST_REQUIRE_EQUAL(gladLoadGL(reinterpret_cast<GLADloadfunc>(SDL_GL_GetProcAddress)), 40006);
BOOST_REQUIRE(glCreateProgram);
CreateProgramTest();
} // Context destroyed
diff --git a/test/test-lib.cpp b/test/test-lib.cpp
index 73ed53a..aaf6292 100644
--- a/test/test-lib.cpp
+++ b/test/test-lib.cpp
@@ -4,8 +4,8 @@
#include <boost/test/data/test_case.hpp>
#include <boost/test/unit_test.hpp>
-#include <GL/glew.h>
#include <glArrays.h>
+#include <glad/gl.h>
#include <set>
std::set<GLuint> active;
diff --git a/test/test-network.cpp b/test/test-network.cpp
index e6241e4..a8db2b6 100644
--- a/test/test-network.cpp
+++ b/test/test-network.cpp
@@ -4,6 +4,8 @@
#include <boost/test/data/test_case.hpp>
#include <boost/test/unit_test.hpp>
+#include "testMainWindow.h"
+#include "ui/applicationBase.h"
#include <array>
#include <collection.h>
#include <game/network/link.h>
@@ -18,6 +20,9 @@
#include <utility>
#include <vector>
+BOOST_GLOBAL_FIXTURE(ApplicationBase);
+BOOST_GLOBAL_FIXTURE(TestMainWindow);
+
struct TestLink : public LinkStraight {
TestLink(const Node::Ptr & a, const Node::Ptr & b) : TestLink {a, b, (a->pos - b->pos)} { }
TestLink(Node::Ptr a, Node::Ptr b, glm::vec2 l) : Link {{std::move(a), 0}, {std::move(b), pi}, glm::length(l)} { }
diff --git a/test/test-text.cpp b/test/test-text.cpp
index 3a23818..629892f 100644
--- a/test/test-text.cpp
+++ b/test/test-text.cpp
@@ -5,6 +5,8 @@
#include <boost/test/unit_test.hpp>
#include <stream_support.h>
+#include "testMainWindow.h"
+#include "ui/applicationBase.h"
#include <array>
#include <glm/glm.hpp>
#include <span>
@@ -12,6 +14,9 @@
#include <unicode.h>
#include <vector>
+BOOST_GLOBAL_FIXTURE(ApplicationBase);
+BOOST_GLOBAL_FIXTURE(TestMainWindow);
+
BOOST_AUTO_TEST_CASE(utf8_string_view_iter)
{
static constexpr utf8_string_view text {"Some UTF-8 €£²¹ text."};
diff --git a/ui/font.h b/ui/font.h
index 52b92a7..6c86e18 100644
--- a/ui/font.h
+++ b/ui/font.h
@@ -1,12 +1,12 @@
#pragma once
-#include <GL/glew.h>
#include <array>
#include <cache.h>
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <glArrays.h>
+#include <glad/gl.h>
#include <glm/glm.hpp>
#include <map>
#include <string_view>
diff --git a/ui/gameMainWindow.cpp b/ui/gameMainWindow.cpp
index a7f17dc..c35c9c6 100644
--- a/ui/gameMainWindow.cpp
+++ b/ui/gameMainWindow.cpp
@@ -6,13 +6,13 @@
#include "modeHelper.h"
#include "toolbar.h"
#include "window.h"
-#include <GL/glew.h>
#include <SDL2/SDL.h>
#include <collection.h>
#include <game/gamestate.h>
#include <game/network/rail.h>
#include <game/worldobject.h> // IWYU pragma: keep
#include <gfx/renderable.h>
+#include <glad/gl.h>
#include <glm/glm.hpp>
#include <memory>
#include <utility>
diff --git a/ui/icon.cpp b/ui/icon.cpp
index be1a63c..38f4bf9 100644
--- a/ui/icon.cpp
+++ b/ui/icon.cpp
@@ -1,7 +1,7 @@
#include "icon.h"
#include "glArrays.h"
-#include <GL/glew.h>
#include <gfx/image.h>
+#include <glad/gl.h>
#include <resource.h>
#include <stb/stb_image.h>
diff --git a/ui/iconButton.cpp b/ui/iconButton.cpp
index f74b3fc..fe8c817 100644
--- a/ui/iconButton.cpp
+++ b/ui/iconButton.cpp
@@ -2,11 +2,11 @@
#include "glArrays.h"
#include "ui/icon.h"
#include "ui/uiComponent.h"
-#include <GL/glew.h>
#include <SDL2/SDL.h>
#include <array>
#include <filesystem>
#include <functional>
+#include <glad/gl.h>
#include <glm/gtc/type_ptr.hpp>
#include <utility>
diff --git a/ui/text.h b/ui/text.h
index cbe49de..9fe87d1 100644
--- a/ui/text.h
+++ b/ui/text.h
@@ -1,8 +1,8 @@
#pragma once
#include "uiComponent.h"
-#include <GL/glew.h>
#include <glArrays.h>
+#include <glad/gl.h>
#include <glm/glm.hpp>
#include <string_view>
#include <vector>
diff --git a/ui/window.cpp b/ui/window.cpp
index 731996a..93e85bd 100644
--- a/ui/window.cpp
+++ b/ui/window.cpp
@@ -1,20 +1,20 @@
#include "window.h"
#include "uiComponent.h"
#include "worldOverlay.h"
-#include <GL/glew.h>
+#include <glad/gl.h>
#include <glm/glm.hpp>
#include <stdexcept>
#include <tuple>
#include <type_traits>
-Window::GlewInitHelper::GlewInitHelper()
+Window::GLInitHelper::GLInitHelper()
{
[[maybe_unused]] static auto init = []() {
- if (const auto r = glewInit(); r != GLEW_OK) {
- throw std::runtime_error {reinterpret_cast<const char *>(glewGetErrorString(r))};
+ if (const auto version = gladLoadGL(reinterpret_cast<GLADloadfunc>(SDL_GL_GetProcAddress)); version != 40006) {
+ throw std::runtime_error {std::to_string(version)};
}
else {
- return r;
+ return version;
}
}();
}
diff --git a/ui/window.h b/ui/window.h
index be9e114..369228a 100644
--- a/ui/window.h
+++ b/ui/window.h
@@ -31,14 +31,14 @@ public:
protected:
virtual void render() const;
- struct GlewInitHelper {
- GlewInitHelper();
+ struct GLInitHelper {
+ GLInitHelper();
};
const glm::ivec2 size;
SDL_WindowPtr m_window;
SDL_GLContextPtr glContext;
- GlewInitHelper glewinithelper;
+ GLInitHelper glInithelper;
Collection<UIComponent> uiComponents;
UIShader uiShader;
};