Sign in to follow this  

OpenGL called from a DLL loses its context

This topic is 3336 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 developing (with Visual Studio C++ 2005) a screen saver (yet an other one, sigh...) that is built on plugins : The main part (.exe) manages all the windows/display/events stuff. The plugins (.dll) produce the bitmap to be displayed (I already made some nice ones). A plugin has some entry points as "init" (that is called once, at beginning) and "next" (that is iteratively called until the mouse is moved). Now I'm trying to create a new plugin (ie dll) that uses OpenGL to compute 3D images. In the "init" function I init all the OpenGL stuff : . glutInit( &argc,argv ) ; . glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH ) ; . glutInitWindowSize( sizex,sizey ) ; . glutCreateWindow( "dummy" ) ; . glClearColor( 0.0f,0.0f,0.0f,1.0f ) ; . glShadeModel( GL_SMOOTH ) ; . glFrontFace( GL_CW ) ; . glCullFace( GL_BACK ) ; . glEnable( GL_CULL_FACE ) ; . blah blah... In the "next" function I render the scene and get the bitmap : . glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ; . glLoadIdentity() ; . glBegin( GL_QUADS ) ; . glVertex3d ... . blah blah... . glEnd() ; . glFlush() ; . glutSwapBuffers() ; . glutPostRedisplay() ; . glReadPixels( 0,0,sizex,sizey,GL_RGB,GL_UNSIGNED_BYTE,bitmap ) ; So... here is the issue : In the "next" function, nothing works... the whole OpenGL context (ie state) seems to be lost. If I hack my code and call directly "next" from "init", it works fine. It is like if returning from a DLL function makes OpenGL lose its context. I don't know about calling a DLL (OpenGL32.dll) since another DLL (my plugin)... Do you have any idea on how OpenGL manages its own context ? I thought that since my DLL is loaded in memory, its own DLLs are also maintained in memory with their own context... but I may be wrong... Thanks for any advice. Gaspos

Share this post


Link to post
Share on other sites

This topic is 3336 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this