Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

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

  1. #1
    Guest

    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!\n");
    SetRect(&contentRect, 100,100,100,100);
    err=CreateNewWindow(kDocumentWindowClass,kWindowSt andardDocumentAttributes,&contentRect, &theWindow);
    if(err==FALSE)printf("Error in CreateNewWindow\n");

    ShowWindow(theWindow);
    printf("End main!\n");
    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.

    Thanks
    @ + Daz

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2001
    Location
    Wellington, New Zealand
    Posts
    548

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

    (LOL)

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

    You really want:

    Code :
    err=CreateNewWindow(kDocumentWindowClass,kWindowStandardDocumentAttributes,&amp;contentRect, &amp;theWindow);
    if(err!=noErr)printf("Error in CreateNewWindow\n");
    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).]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •