PDA

View Full Version : Seperate OpenGL Rendering Function



SeanAustin
07-16-2009, 05:14 AM
I'm trying to seperate my rendering calls into a seperate .cpp file.
Right now I use

glutInitDisplayMode ( GLUT_RGBA | GLUT_DOUBLE );
glutInitWindowSize ( 350, 350 );
glutCreateWindow ( " Active Brain " );

in my main function. Then have the rendering in the init() and display() functions all insight the one .cpp file.

I want to be able to pass a window to a .cpp function, as if it were an API, and have the rendering begin.

Is there a way to do this? Am I make any sense at all?

Dark Photon
07-20-2009, 06:04 PM
I want to be able to pass a window to a .cpp function, as if it were an API, and have the rendering begin.

Is there a way to do this? Am I make any sense at all?
Not perfectly. I can infer several things you might be asking.

Are you asking how you can create a window by some other means, and then render to it with GL? That is have some generic draw code that will render on any window?

Sure. You can do this with native wgl or GLX, or it looks like you can even do this with GLUT too. You just glutCreateWindow your windows, store off the window ID, and then glutSetWindow to make one of them active. Then your draw code just draws on whatever the active window is.