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);
theWindow->Show();
theWindow->EstablishPort();
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 );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );// Load the identity matrix
glLoadIdentity();// 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.
Spencer