loki74
2006.06.29, 07:20 PM
Okay, so I'm a pretty fresh newb when it comes to Xcode (moving over from VB on PC and RB on Mac) so forgive me if the answer to this is easy... but I can't think of what could be causing this!
Basically, I need to refresh my window so that my OpenGL updates will show.
I've read that the way to do this is with the InvalWindowRect() function. So I do this:
int main(int argc, char* argv[])
{
IBNibRef nibRef;
EventTypeSpec eventType;
EventHandlerUPP handlerUPP;
OSStatus err;
err = CreateNibReference(CFSTR("main"), &nibRef);
require_noerr( err, CantGetNibRef );
err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar"));
require_noerr( err, CantSetMenuBar );
err = CreateWindowFromNib(nibRef, CFSTR("MainWindow"), &window);
require_noerr( err, CantCreateWindow );
DisposeNibReference(nibRef);
eventType.eventClass = kEventClassWindow;
eventType.eventKind = kEventWindowResizeCompleted;
handlerUPP = NewEventHandlerUPP(mainWindow_Resized);
InstallWindowEventHandler (window, handlerUPP, 1, &eventType, NULL, NULL);
DisposeEventHandlerUPP (handlerUPP);
ShowWindow(window);
initGL(window);
resizeGL ();
DrawGLScene();
GetWindowPortBounds (window, &windowBounds);
InvalWindowRect (window, &windowBounds);
RunApplicationEventLoop();
CantCreateWindow:
CantSetMenuBar:
CantGetNibRef:
return err;
}
Basically, I need to refresh my window so that my OpenGL updates will show.
I've read that the way to do this is with the InvalWindowRect() function. So I do this:
int main(int argc, char* argv[])
{
IBNibRef nibRef;
EventTypeSpec eventType;
EventHandlerUPP handlerUPP;
OSStatus err;
err = CreateNibReference(CFSTR("main"), &nibRef);
require_noerr( err, CantGetNibRef );
err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar"));
require_noerr( err, CantSetMenuBar );
err = CreateWindowFromNib(nibRef, CFSTR("MainWindow"), &window);
require_noerr( err, CantCreateWindow );
DisposeNibReference(nibRef);
eventType.eventClass = kEventClassWindow;
eventType.eventKind = kEventWindowResizeCompleted;
handlerUPP = NewEventHandlerUPP(mainWindow_Resized);
InstallWindowEventHandler (window, handlerUPP, 1, &eventType, NULL, NULL);
DisposeEventHandlerUPP (handlerUPP);
ShowWindow(window);
initGL(window);
resizeGL ();
DrawGLScene();
GetWindowPortBounds (window, &windowBounds);
InvalWindowRect (window, &windowBounds);
RunApplicationEventLoop();
CantCreateWindow:
CantSetMenuBar:
CantGetNibRef:
return err;
}