Cocoa and OpenGL

Discussion in 'Mac Programming' started by mbabauer, Aug 16, 2006.

  1. macrumors regular

    I am going to start playing with OpenGL, so I've downloaded the samples from the Apple site. I did have a question, it advisable to write a custom component for Interface Builder to display the OpenGL output, using GLUT, or is there a better approach? Most of the sample code doesn't use NIFs at all, in lue of using Carbon components directly from the code. Also, most of the sample code is in C/ Objective-C not optimized enough for OpenGL to be practical?
  2. macrumors 6502a




    Last time I checked, there's a class which already does all the dirty glut work in the Cocoa Framework. Check NSOpenGLView out
  3. macrumors 68030


    OpenGL Is C/C++ - there isn't an Objective-GL or Objective-OpenGL (wish there was), but you could make your own objective-c library for OpenGL.

    you could make the function
    [GLFunction glEnable:[GLItem GL_LIGHTS]] or
    [GLFunction glEnable:GL_LIGHTS]
    It'd be pretty simple, just take a while cause there is: GLFloat GLInt, etc. etc.
  4. macrumors regular


    Thanks, I think this is what I was looking for.

    As a side note, most of the sample code says it comes from some "Orange Book". What is this Orange Book, do I need it, and where do I get it? I did some 3D stuff, including OpenGL and even built my own raytracer in College many, many years ago, but I am sure its all different now.
  5. macrumors 6502a


    Orange book?

    I learned OpenGL from the Red Book which explains basic OpenGL stuff, but the Orange book is a tad too advanced for starting as it deals with shaders.

    So go Red => Orange :D

  6. macrumors 68000


    Objective C is a pure Superset of C (unlike C++), so, the same things you can do with Objective C, you can also do with C.

    And it's not that Objective C is not optimized for OpenGL... It's that OpenGL wasn't written to take advantage of all the capabilities of Objective C.
  7. macrumors 6502a


    Well, OpenGL is a procedural library. Sometimes it's just nice to stop working with classes & get back to structs and pointers ;)
  8. macrumors regular

    Yeah, I am WAY rusty on those, though. I have been primarily a Java developer for work, and all those C/C++ and assembler things I learned in collage have quite a few cobwebs on them.

    But, as I always say, and have proven time and time again, once you know one language you pretty much know them all...its a matter of learning the new syntax and the quirks, and doing a LOT of googling :D .

    BTW, whats the actual title of the "Red Book" and the "Orange Book". Oh, and authors would be great...makes it easier to find on Amazon.
  9. macrumors 6502a


    iirc, red book is 'opengl programming guide', orange is 'opengl shading language'.

    just google or wikipediate them.

    (yeah, I now, you shouldn't verb nouns... :D )

    Got them:
    OpenGL Programming Guide ISBN 0321335732
    OpenGL Shading Language ISBN 0321334892
  10. macrumors regular

    Sweetness! You are the man/woman!

    BTW: I heard Webster is trying to add google as a verb to the dictionary, which apparently google is trying to stop. So, come next release, saying "I googled it" will not be a missuse of the word at all :) .
  11. macrumors 6502a


    You are welcome! Good luck with OpenGL.

    Ahem.. dude (dudette?) check my avatar out. That should give you an idea (hint beard) :D

Share This Page