Handmade Hero » Forums » Code » OpenGL Functions in game.dll versus Win32.exe
Mebourne
Scott Hunt
21 posts

Father, Thinker, Mechanical Engineer @NASA, and C/C++ Hobby Enthusiast / @TexxStudio

#10312 OpenGL Functions in game.dll versus Win32.exe
2 months, 2 weeks ago

Good evening everyone,

I'm currently only up to Episode 163, but have watched a few of Casey's later OpenGL episodes. What I'm curious is if there is anyway to share a GLEW or even custom global variable setup pointing to the driver OpenGL functions from the Win32 .exe to the Game .dll to call all the OpenGL calls (glBindBuffer, glShaderProgram) outside of the platform specific layer?

Setting up global variables pointing to the opengl functions didn't seem to work in the DLL, I suspect I would need some time of declspec export?

Trying with glew, initializing glew in the Win32 exe didn't export all the functions to the dll.

Is the only way to achieve this is have all the openGL calls in his opengl.cpp included on the Win32 side as Casey has setup?

Thanks in advance.

None
ratchetfreak
238 posts
#10315 OpenGL Functions in game.dll versus Win32.exe
2 months, 2 weeks ago

add them to the parameters of GameUpdateAndRender
Mebourne
Scott Hunt
21 posts

Father, Thinker, Mechanical Engineer @NASA, and C/C++ Hobby Enthusiast / @TexxStudio

#10316 OpenGL Functions in game.dll versus Win32.exe
2 months, 2 weeks ago

Thanks ratchetfreak, that seems to be working perfectly.

Created an OpenGLAPI struct and put an instance in the EngineMemory that gets passed through an update and render style call to the DLL.

Not looking forward to all the defines and function prototypes I'll need to make (GL_VERTEX_SHADER, GLenum, etc.) to do this properly ;)

Curious what others are doing if you don't mind sharing.

None
wheatdog
Tim Liou
2 posts

None

#10342 OpenGL Functions in game.dll versus Win32.exe
2 months, 2 weeks ago

Interesting! I thought about this question recently. I am also curious about how people achieve it.

None
onatto
1 posts
#10345 OpenGL Functions in game.dll versus Win32.exe
2 months, 2 weeks ago Edited by Jeroen van Rijn on Jan. 11, 2017, 11:03 p.m. Reason: fix url

Generating a loader using https://bitbucket.org/alfonse/glloadgen/wiki/Home and calling ogl_LoadFunctions() every time the DLL is reloaded should work. Even if the loading fails when it can't load all the functions/extensions, it will load all the function pointers it can.