Skip to content

Commit fc03b87

Browse files
committed
Initialize GLEW if libprojectM uses it.
1 parent cb6c2ff commit fc03b87

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Diff for: src/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ else()
4343
)
4444
endif()
4545

46+
# GLEW needs to be initialized if libprojectM depends on it.
47+
if(TARGET GLEW::glew OR TARGET GLEW::glew_s)
48+
target_compile_definitions(projectMSDL
49+
PRIVATE
50+
USE_GLEW
51+
)
52+
endif()
53+
4654
set_source_files_properties(ProjectMSDLApplication.cpp PROPERTIES
4755
COMPILE_DEFINITIONS PROJECTMSDL_CONFIG_LOCATION=\"${DEFAULT_CONFIG_PATH}\"
4856
)

Diff for: src/SDLRenderingWindow.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
#include <Poco/Util/Application.h>
1010

11+
#ifdef USE_GLEW
12+
#include <GL/glew.h>
13+
#endif
14+
1115
#include <SDL2/SDL_opengl.h>
1216

1317
const char* SDLRenderingWindow::name() const
@@ -266,6 +270,18 @@ void SDLRenderingWindow::CreateSDLWindow()
266270
SDL_GL_MakeCurrent(_renderingWindow, _glContext);
267271
UpdateSwapInterval();
268272

273+
#ifdef USE_GLEW
274+
auto glewError = glewInit();
275+
if (glewError != GLEW_OK)
276+
{
277+
auto errorMessage = "Could not initialize GLEW. Error: " + std::string(reinterpret_cast<const char*>(glewGetErrorString(glewError)));
278+
poco_fatal(_logger, errorMessage);
279+
throw Poco::Exception(errorMessage);
280+
}
281+
282+
poco_debug_f1(_logger, "Initialized GLEW: %s", std::string(reinterpret_cast<const char*>(glewGetString(GLEW_VERSION))));
283+
#endif
284+
269285
if (_config->getBool("fullscreen", false))
270286
{
271287
Fullscreen();

0 commit comments

Comments
 (0)