PDA

View Full Version : GL w/o GLUT



12-27-2000, 07:57 PM
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?

DJ Tricky S
12-30-2000, 06:26 AM
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;
}

01-05-2001, 04:15 PM
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.

dstys
01-18-2001, 01:13 PM
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

Ryan Bates
01-18-2001, 01:49 PM
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).]