tesch1/turbobadger

Windows demo crashes due to "glewInit()" not being called anywhere

Closed this issue · 3 comments

I just got latest code and built with VS 2019 on Windows.

Running the demo fails because all of the gl function pointers are NULL, to get it running I had to add a call to glewInit() in TBRendererGL c'tor

Cheers

Thaks for the note! Would you be able to submit a patch? I dont run Windows, so have no way to test any fix.


src/tb/renderers/tb_renderer_gl.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/src/tb/renderers/tb_renderer_gl.cpp b/src/tb/renderers/tb_renderer_gl.cpp
index 04a6d1a..387f897 100644
--- a/src/tb/renderers/tb_renderer_gl.cpp
+++ b/src/tb/renderers/tb_renderer_gl.cpp
@@ -206,6 +206,16 @@ TBRendererGL::TBRendererGL()
 		"  gl_FragColor = color * texture2D(tex, uvo); \n"
 		"}                                             \n";
 
+#if defined(TB_SYSTEM_WINDOWS)
+	GLenum err = glewInit();
+	if (GLEW_OK != err)
+	{
+		TBDebugOut("glewInit failed.\n");
+		return;
+	}
+#endif
+
+
 	GLuint vertexShader;
 	GLuint fragmentShader;
 	GLint linked;

That should do the trick.