summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitmodules3
-rw-r--r--Jamroot.jam9
-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--thirdparty/Jamfile.jam7
l---------thirdparty/gl.xml1
m---------thirdparty/glad0
-rw-r--r--thirdparty/glad.jam20
-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
32 files changed, 85 insertions, 43 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..0ce5431
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "thirdparty/glad"]
+ path = thirdparty/glad
+ url = https://github.com/Dav1dde/glad
diff --git a/Jamroot.jam b/Jamroot.jam
index 95b3135..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 ;
@@ -58,8 +57,8 @@ always main ;
run iliketrains : -- : [ sequence.insertion-sort [ glob-tree-ex res : *.* ] ] : : main ;
lib ilt :
- [ glob-tree *.cpp *.?s *.t?s : application bin test ]
- [ lib generated : [ glob-tree *.ll *.c ] :
+ [ glob-tree *.cpp *.?s *.t?s : application bin test thirdparty ]
+ [ lib generated : [ glob-tree *.ll *.c : bin thirdparty ] :
<include>.
<include>lib
<link>static
@@ -89,8 +88,9 @@ lib ilt :
<toolset>gcc,<variant>debug:<cflags>-Wuseless-cast
<include>.
<include>lib
+ <library>thirdparty//glad
+ <implicit-dependency>thirdparty//glad
<library>sdl2
- <library>glew
<library>freetype2
<library>glib-2.0
<library>mxml
@@ -100,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/thirdparty/Jamfile.jam b/thirdparty/Jamfile.jam
new file mode 100644
index 0000000..bee3392
--- /dev/null
+++ b/thirdparty/Jamfile.jam
@@ -0,0 +1,7 @@
+import glad ;
+lib glad : gl.xml :
+ <link>static
+ <cflags>-fPIC
+ <warnings>off
+ <warnings-as-errors>off
+ ;
diff --git a/thirdparty/gl.xml b/thirdparty/gl.xml
new file mode 120000
index 0000000..bfea0d8
--- /dev/null
+++ b/thirdparty/gl.xml
@@ -0,0 +1 @@
+glad/glad/files/gl.xml \ No newline at end of file
diff --git a/thirdparty/glad b/thirdparty/glad
new file mode 160000
+Subproject 2348b07c1ab4504d60398713781d8a57880234f
diff --git a/thirdparty/glad.jam b/thirdparty/glad.jam
new file mode 100644
index 0000000..f89750c
--- /dev/null
+++ b/thirdparty/glad.jam
@@ -0,0 +1,20 @@
+import generators : register-standard ;
+import feature : feature ;
+import toolset : flags ;
+
+generators.register-standard glad.generate.c : XML : C(%) H(glad/%) XML ;
+feature glad.pythonpath : thirdparty/glad : path ;
+feature glad.profile : core compatibility ;
+feature glad.version : 4.6 ;
+flags glad.generate.c PYTHONPATH <glad.pythonpath> ;
+flags glad.generate.c PROFILE <glad.profile> ;
+flags glad.generate.c VERSION <glad.version> ;
+
+actions glad.generate.c
+{
+ rm -rf $(1:D)
+ PYTHONPATH=$(PYTHONPATH) python -m glad --api=$(2:B):$(PROFILE)=$(VERSION) --merge --out-path=$(1[3]:D) --reproducible --quiet c
+ mv $(1[3]:D)/src/$(1[1]:BS) $(1[1])
+ mkdir -p $(1[2]:D)
+ mv $(1[3]:D)/include/glad/$(1[2]:BS) $(1[2])
+}
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;
};