Displaying ONE simple window with Carbon, and then OpenGL/GLUT frameworks

Hi all,
I intend to port a win32 application using OpenGL in C to Mac, using Carbon (for the windowing and OpenGL for the core functions). I’d like to begin by a little training and I can’t get myself displaying a simple window. I don’t want any Nib files, I wanna create everything from scratch (no resource file neither).
Here is my code :
#include <stdio.h>
#include <Carbon/Carbon.h>

int main (/int argc, const char * argv[]/) {

 WindowRef         theWindow; 
 Rect              contentRect; 
 OSStatus          err; 
 printf("Start main!

SetRect(&contentRect, 100,100,100,100);
err=CreateNewWindow(kDocumentWindowClass,kWindowStandardDocumentAttributes,&contentRect, &theWindow);
if(err==FALSE)printf("Error in CreateNewWindow

 printf("End main!

return 0;

I’ve read the tutorial on Apple.com, the Nehe’s one for GLUT as well by it doesn’t help, and when I use the debugger, I see that CreateNewWindow returns an error, but WHAT ??

All I want is a simple window with Hello in there.
Pretty simple, and then I’ll build upon that.

Can anyone help me ?
I don’t know what to do with this “CreateNewWindow”…In Carbon, we can also use NewCWindow, but I can’t get this working neither. I’ve got a good background with Java, but how do you dump the stack in C ?

I’ve tried to use GLUT, but it’s pretty hairy to use this when you want a multi window application on top of OpenGL.

@ + Daz


CreateNewWindow returns an OSErr. For OSErrs, noErr is defined as 0, so your if statement is actually checking if CreateNewWindow succeeds.

You really want:

err=CreateNewWindow(kDocumentWindowClass,kWindowStandardDocumentAttributes,&contentRect, &theWindow);
if(err!=noErr)printf("Error in CreateNewWindow

Future pointer: Apple’s Carbon or OpenGL mailing lists, or the iDevGames.com forums are more likely to get you answers than here.

[This message has been edited by OneSadCookie (edited 03-10-2003).]

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