Jump to content
  • Advertisement
Sign in to follow this  
Ashkan

OpenGL OpenGL calls having no effect across dll boundaries?

This topic is 4133 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on an already built and tested application that's using OpenGL as its base rendering API. The application is an executable file with a bunch of accompanying DLLs. I've also some other rendering code in another DLL that I would like to call from inside the application. So, some of the objects will be rendered from inside the application via direct calls to OpenGL API, and some are to be rendered using calls to functions inside the DLL that use OpenGL themselves. Right? So I passed the window handle, the device context and the rendering context to the DLL and I was expecting everything to go smooth. I wrote a small function inside the DLL to render a simple triangle and much to my surprise, I noticed that the transformations applied from inside the executable have no effect on the position of the rendered triangle. The code looks something like this:
// code inside the .exe

// 1) initialize the renderer inside the exe
// 2) pass the window handle, the device context and the rendering context to the dll

// Render a bunch of objects using direct calls to OpenGL

// some transformations, for example:
glTranslatef( 10.0f, 10.0f, 10.0f );

// render the triangle; this function resides inside the dll
RenderTriangle();
The above transformation has no effect. I wonder why this is happening. Will passing the transformation matrix along solve this problem? Can this approach result in later unexpected behavior? Thanks alot

Share this post


Link to post
Share on other sites
Advertisement
Are you linked to the GL library or are you obtaining function pointers from the system's library?

Share this post


Link to post
Share on other sites
Try doing the glTranslatef in the DLL. If that doesn't work then maybe there's a bug elsewhere in your code(?)

Also, I haven't used OpenGL before, but a possible problem is that your EXE and DLL are statically linking some global variables from a .LIB file which include the current transform matrices. If true, that means that your DLL and EXE would each have their own copies of static OpenGL matrix variables.

The solution would be (if it's possible) to try to find an OpenGL lib that only includes the function imports and no global variables. Then if the OpenGL DLL includes those global variables, transforms should be shared between anything in the same process.

Share this post


Link to post
Share on other sites
Not sure what Nypyren is talking about.

You can put your GL code in a DLL. For example, glu32.dll has GL code that everyone uses and many other 3rd party libs, including my own, make GL calls.

An app will have a GL context and any calls you make, they go to that context.

Perhaps your context is not current or there are some errors. Use glGetError and GetLastError and whatever debugging tools you have, like GLIntercept or gDebuger

Share this post


Link to post
Share on other sites
Make sure you call your opengl functions in the same thread as the opengl context. If you create a context in one thread and call opengl functions from another, nothing will happen.

Edit: What V-man said: make sure your opengl context is current in the correct thread.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!