AGLContext & GLUT


i’m trying to setup a pBuffer with 10.3 using glut, trying to do some write-once-compile-every-were code. I want to keep system depended code as small as possible.

I set up the pBuffer with:

AGLContext aglcontxt, current;
AGLPixelFormat aglpixfmt;
AGLPbuffer pbuffer;

GLint attrib[] = { AGL_RGBA, AGL_DEPTH_SIZE, 16, AGL_NONE };
aglpixfmt = aglChoosePixelFormat (NULL, 0, attrib);
aglcontxt = aglCreateContext (aglpixfmt, NULL);
aglCreatePBuffer(1024, 1024, GL_TEXTURE_2D, GL_RGBA, 0, &pbuffer);
aglSetPBuffer (aglcontxt, pbuffer, 0, 0, NULL);

and draw like this:

current = aglGetCurrentContext();



but it’s not working :stuck_out_tongue:
My iddea was to save whatever context glut created
into ‘current’ and then just switch back after writing to the pbuffer.
What i’m doing wrong?

You should read the PBuffer sample code from apple or read the spec. Tons of thing are missing in your code :

glBindTexture(target, texhandle); is missing after the aglCreatePBuffer

aglTexImagePBuffer (aglcontext, pbuffer, GL_FRONT) is missing after the aglCreatePBuffer

aglSetPBuffer is missing after the setcurrentcontext


are missing …

Also, I don’t think aglGetCurrentContext will give you a valid context if the current context is not an AGL context (it will be an NSOpenGLContext with GLUT). Using CGL rather than AGL will avoid this problem.

PBuffer is very tricky on MacOS. There is three API, three implementations (AGL, CGL, NSOpenGL) which are far from being similar.

I hope that one day, the GL_EXT_frame_buffer_object will be available and get us ride of the PBuffer nightmare. But now, you need to do that.

Oh, by the way, don’t forget that PBuffer requires MacOS 10.3.

Thanks for your reply’s.
Ok … i’d better kick glut and do my own window, since mixing would be more complicated than doing it from scratch.
I was just dreaming of an easy way, like using extensions in unix’es compared to windows.

So i’ve read that AGL is just a thin layer above CGL? Whats AGL’s sense related to CGL then? I hope its ‘real’ pBuffer and not just a window at -1024; 0 …

AGL is the ‘old’ OpenGL API used by MacOS 9. It is using CGL on MacOS X.

Now why not using CGL only ? Because if your application is running a window, you can’t use it. You cannot create an ‘CGL’ context for a windowed application (go figure why …)

So you will still have to uses AGL if your application is 'windowed.

If your application is ‘fullscreen’ only, uses CGL, and stay clear away from AGL : Mainly, because it is broken in MacOS 10.4 when running in full screen (this was confirmed by other person already).

For the PBuffer and its internals. It’s the Big Mystery. I’ve posted some questions in the past, but nobody was able to answer them : Here a few ones :

  • PBuffers and Depth component running on various videos cards ? Does it work ? how to initialize ? What’s happening on ATI 9x / Xx00 series (On Windows, you cannot create depth component PBuffer on ATI. Only nVidia supports it) ?

  • PBuffers and NSOpenGL ? How to initialize it correctly (very capricious this one, with different behaviours on each different revision of MacOSX and very poorly documented),

  • Are PBuffers double buffered like on Windows ?

  • PBuffers with floating point texture which were ‘undocumented’ in MacOS 10.3, but now documented in 10.4 (Well, just 1 line about it) ?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.