Using PowerPlant w/ OGL

Hi everyone. I’m new to programming on the Mac, but have some experience on PCs. In any case, I want to get started programming on the Mac, and have been planning to use PowerPlant as a framework in order to help get up to speed faster.

Just to get my feet wet, I would like to just get a basic PowerPlant app going, which would draw a basic OpenGL demo into a PP created window. Unfortunately, the code is choking, and I cannot figure out what I am doing wrong.

There are two possible quick solutions, as I can see it. If anyone has such an app, or could put one together quick (trivial app) and could direct me to it, that would be great. Otherwise, if someone can point out what I’m doing wrong here, that would be great too.

Basically, here’s what I am doing…

LWindow* theWindow = LWindow::CreateWindow(PPob_SampleWindow, this);

theScreen = (CGrafPtr) theWindow->GetMacPort();

  	gOpenGLContext = SetupAGL( ( AGLDrawable )theScreen );

Reshape3D( 300, 200 );

  	DrawGL( gOpenGLContext );

SetupAGL() chooses a pixel format, creates an AGL context, attaches the window to the context, and makes the context the current context.

DrawGL() goes like this…

void DrawGL( AGLContext context )

// Enable depth testing
glClearDepth( 1.0 );
glDepthFunc( GL_LESS );
glEnable( GL_DEPTH_TEST );

// Clear color buffer to black
glClearColor( 0, 0, 0, 1 );

// Load the identity matrix

// Copy the offscreen buffer to the screen
aglSwapBuffers( context );

Basically, it just clears the window to black, at this point.

The code chokes when I clear the buffers, and when I swap the buffers, so I am pretty sure the problem is in properly allocating the buffers somewhere. I’m not sure how to do this right. Can someone help me out in this? Not sure whether the PP code or the OGL code is what is the matter.

Thanks alot in advance.


Hmmm, I don’t use powerplant, but I might be able to help. May I ask what your SetupGL code looks like?



I am not sure but if reshape3D does what I think it does (meaning changing the size of the window) you have a problem. You either have to reshape the window first and then attach it to the context or update the context after you resize the window. Attaching a window to an OpenGL context creates buffers that depends on the window size. If your window changes, OpenGL has no idea about it. That could be a source of problem.


I’m guessing he’s using it to set the perspective (much like in my AGL & DSp tutorial). It should be fine, if that’s all it’s doing.


Hi, spencer.

I make a OpenGL app for Mac with PowerPlant. I am not sure a problem in your code. But I know some C++ classes for OGL drawing. They are very useful and easy to use like LPane class.

One is CGLPane available from the site below:

Another is GLPane:

I use CGLPane. Thanks for reading my poor English. Bye.


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