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 5 of 5

Thread: GL w/o GLUT

Hybrid View

  1. #1
    Guest

    GL w/o GLUT

    I have OpenGL Set up to an extent in my code w/o using GLUT(using AGL Calls etc...), is there any place I can find information on programming for GL and getting the environment set up without using something like GLUT?

  2. #2
    Intern Contributor
    Join Date
    Aug 2000
    Location
    USA
    Posts
    99

    Re: GL w/o GLUT

    It's not too tough... something like this should do (pretend the AGL_FXN() macros aren't there, I just quickly pasted this from some of my code :

    /*---------- globals */

    static WindowPtr agl_window= NULL;
    static AGLContext agl_device_context= NULL;

    /*---------- code */

    boolean gl_platform_initialize(
    word width,
    word height,
    word depth)
    {
    #pragma unused(depth)
    boolean initialized= FALSE;
    Rect window_rect= {0,0,0,0};

    assert(agl_window == NULL);

    window_rect.right= width;
    window_rect.bottom= height;

    agl_window= NewCWindow(NULL, &window_rect, "\p", false, plainDBox, (WindowPtr)-1L, false, 0L);

    if (agl_window)
    {
    OSStatus err;
    RGBColor black_color= {0,0,0};
    GLint pixel_attributes[] = {AGL_ACCELERATED, AGL_RGBA, AGL_DOUBLEBUFFER, AGL_NONE};
    AGLPixelFormat pixel_format;

    err= SetWindowContentColor(agl_window, &black_color);
    assert(err == noErr);
    SetPort((GrafPort *)GetWindowPort(agl_window));
    ShowWindow(agl_window);

    pixel_format= AGL_FXN(aglChoosePixelFormat)(NULL, 0, pixel_attributes);
    if (pixel_format)
    {
    agl_device_context= AGL_FXN(aglCreateContext)(pixel_format, NULL);
    if (agl_device_context)
    {
    initialized= (AGL_FXN(aglSetDrawable)(agl_device_context, (CGrafPort *)agl_window) &&
    AGL_FXN(aglSetCurrentContext)(agl_device_context)) ;
    }
    AGL_FXN(aglDestroyPixelFormat)(pixel_format);
    }
    }

    return initialized;
    }

  3. #3
    Guest

    Re: GL w/o GLUT

    Good for you! Don't use GLUT...its cheating and it takes a lot of control away from you. I couldn't really find anything on GL w/o GLUT on the web but if you have any specific questions, email me at peterius@simons-rock.edu. I've done most everything that GLUT can do without GLUT.

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    Baltimore, MD, USA
    Posts
    2

    Re: GL w/o GLUT

    Hi,
    The above example is a bit confusing to me. Can someone help with a simple example. How about code to open a window, and draw a triangle. It's simple, but it would be very helpful to me. I'm using project builder.

    Thanks,
    David

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2001
    Posts
    1

    Re: GL w/o GLUT

    Originally posted by dstys:
    The above example is a bit confusing to me. Can someone help with a simple example. How about code to open a window, and draw a triangle. It's simple, but it would be very helpful to me. I'm using project builder.
    Project Builder? Would this mean you are programming in OSX? Cocoa with ObjectiveC perhaps? If so, I'd be willing to help you get started. Feel free to email me at rbates@mac.com. I'm fairly new myself, but I've been making progress.

    BTW, Nehe Productions has some descent tutorials on thier site. They use GLUT though. Here they are: http://nehe.gamedev.net/opengl.asp

    Ryan

    [This message has been edited by Ryan Bates (edited 01-18-2001).]

Posting Permissions

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