PDA

View Full Version : Where does OpenGL draw to?



tdavie
08-26-2000, 05:24 AM
Hi,
Does anyone know where OpenGL draws to. I have just tried to switch from using GLUT to using MacOS toolbox comands to create windows and menus (to offer more flexability). I used this simple piece of code to set up a window set as the current drawing port:

InitGraf(&qd.thePort);
InitFonts();
InitWindows();
InitMenus();
TEInit();
InitDialogs(nil);
InitCursor();

MaxApplZone ();

SetRect (&bounds, 100, 100, 100 + kWindowWidth, 100 + kWindowHeight);
window = NewCWindow (NULL, &bounds, "\pIt's a polyhedra", true, documentProc, (WindowPtr)-1L, true, 0);
SetPort (window);

I then tried to draw to it with OpenGL and got a blank screen, what is going on, and what should be going on????

Nobody
08-26-2000, 02:17 PM
OpenGL draws to an OpenGL Context. You have to create an OpenGL context (This includes creating a Pixel Format), attach it to your window and also make sure you set your OpenGL context as the current one.

Just like you can have multiple windows, you can have more than one OpenGL context, and OpenGL commands are applied to the current context.

You can do this using the AGL library. Apple has a good example of how to do this full screen called Open GL Draw Sprocket. It uses Draw Sprocket to do some gamma fades and it asks the user to select a Display if the user has more than one. The code can be easily modified to run in a window and not full screen. In fact, even when running full screen, the context needs to be attached to a window.

Good Luck.
Nobody