Programming OpenGL in a program already using OpenGL?

Considering that I am programming within another program using OpenGL (say, in theory, I have no idea how they are using it).

Is it possible to customize my context, but I want, and pop it off the stack and everything should work as expected, or SHOULD I know how my (caller) program is using OpenGL to avoid accidental delusion?

Also, how can I start initializing OpenGL if it has already been initialized?

Thanks for any advice you have.

0


a source to share


3 answers


To answer your first question, you can probably succeed with calling glPushAttrib (GL_ALL_ATTRIB_BITS) before calling program functions and calling glPopAtrib () afterwards. Note that this can be slow if you do it frequently (say every frame in a loop).



I'm not sure what you mean by initializing OpenGL. Do you want to customize the rendering context? Setting up viewport and projection? Disable or enable certain features? You can always check if certain states are enabled (using glGet functions), but it all depends on how your program and the other program are working.

0


a source


I was told that in theory OpenGL should work in any context as long as you restore the previous context again.



0


a source


What exactly do you want to do with OpenGL? Are you trying to navigate in the same window? Do you want to make your own window? If you just want to draw in your window, and the fact that an existing application is using OpenGL is just a coincidence, then you might be able to just create a completely new context and ignore existing things. The only problem is that you will need to make the existing context current when you are done with what you are doing, and make your context current when you want to do something with it. Existing code won't need to make its own context relevant and can lead to accidental drawing into your context if you're not careful.

If you want to draw into an existing window, then your use will almost certainly require some idea of ​​what the existing material is doing.

0


a source







All Articles