Skip to content

Commit 9731c3e

Browse files
committed
Moved to glad
1 parent 07d1e3f commit 9731c3e

21 files changed

+35904
-53
lines changed

.github/workflows/ci.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
1818
- name: Get dependencies
1919
run: |
20-
brew install glew glfw yaml-cpp vulkan-headers vulkan-loader vulkan-tools vulkan-utility-libraries vulkan-validationlayers vulkan-extensionlayer
20+
brew install glfw yaml-cpp vulkan-headers vulkan-loader vulkan-tools vulkan-utility-libraries vulkan-validationlayers vulkan-extensionlayer
2121
- name: Install framework
2222
shell: bash
2323
run: ./install.sh ci
@@ -38,7 +38,7 @@ jobs:
3838
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
3939
- name: Get dependencies
4040
run: |
41-
sudo apt update && sudo apt-get install x11-xserver-utils libgl1-mesa-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev gcc make g++ libxmu-dev libxi-dev libgl-dev libglu1-mesa-dev libvulkan1 mesa-vulkan-drivers vulkan-tools libvulkan-dev libasound2-dev libflac-dev libogg-dev libtool libvorbis-dev libopus-dev libsndfile1-dev libglew-dev libssl-dev zlib1g zlib1g-dev libglfw3 libglfw3-dev libyaml-cpp-dev libxkbcommon-dev
41+
sudo apt update && sudo apt-get install x11-xserver-utils libgl1-mesa-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev gcc make g++ libxmu-dev libxi-dev libgl-dev libglu1-mesa-dev libvulkan1 mesa-vulkan-drivers vulkan-tools libvulkan-dev libasound2-dev libflac-dev libogg-dev libtool libvorbis-dev libopus-dev libsndfile1-dev libssl-dev zlib1g zlib1g-dev libglfw3 libglfw3-dev libyaml-cpp-dev libxkbcommon-dev
4242
- name: Install framework
4343
shell: bash
4444
run: ./install.sh ci
@@ -77,7 +77,7 @@ jobs:
7777
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
7878
- name: Get dependencies
7979
run: |
80-
sudo apt update && sudo apt-get install x11-xserver-utils libgl1-mesa-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev gcc make g++ libxmu-dev libxi-dev libgl-dev libglu1-mesa-dev libvulkan1 mesa-vulkan-drivers vulkan-tools libvulkan-dev libasound2-dev libflac-dev libogg-dev libtool libvorbis-dev libopus-dev libsndfile1-dev libglew-dev libssl-dev zlib1g zlib1g-dev libglfw3 libglfw3-dev libyaml-cpp-dev libxkbcommon-dev
80+
sudo apt update && sudo apt-get install x11-xserver-utils libgl1-mesa-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev gcc make g++ libxmu-dev libxi-dev libgl-dev libglu1-mesa-dev libvulkan1 mesa-vulkan-drivers vulkan-tools libvulkan-dev libasound2-dev libflac-dev libogg-dev libtool libvorbis-dev libopus-dev libsndfile1-dev libssl-dev zlib1g zlib1g-dev libglfw3 libglfw3-dev libyaml-cpp-dev libxkbcommon-dev
8181
- uses: mymindstorm/setup-emsdk@v14
8282
- name: Install framework
8383
run: ./install.sh ci

.github/workflows/update-dependencies.yaml

+11-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,17 @@ jobs:
5151
mv cimgui.cpp cimgui.h ../
5252
cd .. || exit
5353
rm -rf dear_bindings
54-
cd ../../../../ || exit
54+
cd ../../glad || exit
55+
rm -rf include src || exit
56+
git clone https://github.com/Dav1dde/glad.git --recursive
57+
cd glad
58+
python3 -m venv venv
59+
source venv/bin/activate
60+
pip install -r requirements.txt
61+
python3 -m glad --api gl:core,gles1, gles2, glsc2 --out-path ../
62+
cd ..
63+
rm -rf glad
64+
cd ../../../ || exit
5565
(git add . && git commit -m "auto" && git push origin HEAD:auto && echo "out=s" >> $GITHUB_OUTPUT) || echo "out=?" >> $GITHUB_OUTPUT
5666
- name: Create PR
5767
if: "steps.mod.outputs.out != '?'"

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
[submodule "Framework/ThirdParty/yaml-cpp"]
1010
path = Framework/ThirdParty/yaml-cpp
1111
url = https://github.com/MadLadSquad/yaml-cpp.git
12-
[submodule "Framework/ThirdParty/glew"]
13-
path = Framework/ThirdParty/glew
14-
url = https://github.com/MadLadSquad/glew-cmake.git
1512
[submodule "Framework/ThirdParty/imgui"]
1613
path = Framework/ThirdParty/imgui
1714
url = https://github.com/MadLadSquad/imgui.git

Framework/Renderer/OpenGL/OpenGLRenderer.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#include <ImGui/ImGui.hpp>
44
#include <Interfaces/WindowInterface.hpp>
55
#ifndef __APPLE__
6-
#include <GL/glew.h>
6+
#include <glad/include/glad/gl.h>
7+
#elifdef __EMSCRIPTEN__
8+
#include <glad/include/glad/gles2.h>
79
#else
810
#include <OpenGL/GL.h>
911
#endif

Framework/Renderer/OpenGL/OpenGLTexture.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "OpenGLTexture.hpp"
22
#ifndef __APPLE__
3-
#include <GL/glew.h>
3+
#include <glad/include/glad/gl.h>
4+
#elifdef __EMSCRIPTEN__
5+
#include <glad/include/glad/gles2.h>
46
#else
57
#include <OpenGL/GL.h>
68
#endif

Framework/Renderer/Window/Callbacks.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ void UImGui::WindowInternal::framebufferSizeCallback(GLFWwindow* window, const i
3737

3838
if (!Renderer::data().bVulkan)
3939
glViewport(0, 0, width, height);
40+
#ifndef __EMSCRIPTEN__
4041
else
4142
Renderer::get().vulkan.draw.bRebuildSwapchain = true;
43+
#endif
4244

4345
for (auto& a : windowInst->windowResizeCallbackList)
4446
a(width, height);

Framework/Renderer/Window/Platform.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
#endif
1515

1616
#ifndef __APPLE__
17-
#include <GL/glew.h>
17+
#include <glad/include/glad/gl.h>
18+
#elifdef __EMSCRIPTEN__
19+
#include <glad/include/glad/gles2.h>
1820
#else
1921
#include <OpenGL/GL.h>
2022
#include "macOS/MacOSWindowPlatform.h"

Framework/Renderer/Window/Window.cpp

+5-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#define STB_IMAGE_IMPLEMENTATION
22
#include "Window.hpp"
33
#ifndef __APPLE__
4-
#include <GL/glew.h>
4+
#include <glad/include/glad/gl.h>
5+
#elifdef __EMSCRIPTEN__
6+
#include <glad/include/glad/gles2.h>
57
#else
68
#include <OpenGL/GL.h>
79
#endif
@@ -123,10 +125,6 @@ void UImGui::WindowInternal::createWindow() noexcept
123125
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); // Have to set this to NO_API because that's how Vulkan is done in it
124126
else
125127
{
126-
#if !__APPLE__ && !__EMSCRIPTEN__
127-
// Add GLFW window flags and enable OpenGL
128-
glewExperimental = GL_TRUE;
129-
#endif
130128
#ifdef __EMSCRIPTEN__
131129
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
132130
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
@@ -199,13 +197,8 @@ void UImGui::WindowInternal::createWindow() noexcept
199197
if (!Renderer::data().bVulkan)
200198
{
201199
#if !__APPLE__ && !__EMSCRIPTEN__
202-
if (glewInit() != GLEW_OK)
203-
{
204-
glfwDestroyWindow(windowMain);
205-
glfwTerminate();
206-
Logger::log("GLEW initialisation failed!", ULOG_LOG_TYPE_ERROR);
207-
return;
208-
}
200+
const int version = gladLoadGL(glfwGetProcAddress);
201+
Logger::log("Successfully loaded OpenGL ", ULOG_LOG_TYPE_SUCCESS, GLAD_VERSION_MAJOR(version), ".", GLAD_VERSION_MINOR(version));
209202
#endif
210203
glEnable(GL_MULTISAMPLE);
211204
glEnable(GL_DEPTH_TEST);

0 commit comments

Comments
 (0)