Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Where does OpenGL draw to?

  1. #1
    Intern Contributor
    Join Date
    Aug 2000
    Location
    St. Andrews, Fife, Scotland
    Posts
    61

    Where does OpenGL draw to?

    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????
    From the man with the
    mac and hence the
    mission POSSIBLE.

  2. #2
    Junior Member Newbie
    Join Date
    Jan 2002
    Location
    High Desert of California
    Posts
    1

    Re: Where does OpenGL draw to?

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •