Results 1 to 3 of 3

Thread: Can't use openGL in MacOSX

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2004

    Can't use openGL in MacOSX

    I am a new developer in Mac OS X.
    I tried to compile some openGL programs with FLTK ( I always get a "Bus error" when I try to run it. When I looked into it using gdb, it always occures where I initialize some array and pass that into openGL, say

    GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
    GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
    GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
    GLfloat light_position[] = { 0.0, 0.3, 0.3, 0.0 };

    GLfloat lmodel_ambient[] = { 0.4, 0.4, 0.4, 1.0 };

    > glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);

    I get error in the line indicated. When I gdb that part of code, it seems that the array light_ambient is changed when the code is executed. I wonder if openGL in Mac blows up the stack
    Any help? I am interested what kind of windowing toolkit you are using.

    By the way, the above code compiles and works in linux.

  2. #2
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Bay Area, CA, USA

    Re: Can't use openGL in MacOSX

    Well it should work on the face of things.

    That is a static and if it's in scope (which it must be to compile) then it should work.

    Are you sure you don't declare it again somewhere in the scope of your glLight call.

    Also make sure that the array is big enough for the parameters (it seems to be with your example but I dunno if that's the exact code you're getting your crash on).

    Hmm... just a thought but maybe that glLight call on the Mac remembers the pointer and tries to reference it out of scope but that makes no sense, the pointer would probably still work unless it's on the stack (i.e. unless you declare inside the function), but this would be a serious implementation bug on the Mac. That still doesn't explain gdb showing altered contents so I'm back to thinking you are declaring that pointer again somewhere.

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2001
    Copenhagen, Denmark

    Re: Can't use openGL in MacOSX

    I use the Mac OpenGL everyday, and have code like that littered all over the place. It just works.

    Some other things that might be wrong (shooting in the dark, bear with me):
    * Is FLTK softlinking OpenGL, and has a wrong or NULL address for glLight?
    * Try running the program under openGL profiler (Found in /Developer/Applications/Graphic Tools). Enable breakpointing on errors and see if anything pops up.
    * Try the Mac-opengl mailing list. Lots of the apple devs hand out there.


Similar Threads

  1. setting up OpenGL via terminal on MacOSx 10.5
    By cutting_crew in forum OpenGL: macOS
    Replies: 5
    Last Post: 12-13-2008, 09:41 AM
  2. OpenGL versions / Extensions under MacOSX
    By imported_Groovounet in forum OpenGL: macOS
    Replies: 5
    Last Post: 10-01-2007, 02:11 AM
  3. texture resolution on MacOSX
    By rtomada in forum OpenGL: macOS
    Replies: 3
    Last Post: 01-01-2004, 03:08 PM
  4. bus error with gl4java for MacOSX
    By apclem in forum OpenGL: macOS
    Replies: 3
    Last Post: 07-30-2003, 07:21 AM
  5. Macosx CGDirect Display
    By Claudio in forum OpenGL: macOS
    Replies: 0
    Last Post: 06-22-2001, 04:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean