Cocoa and OpenGL

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

  1. mbabauer
    Expand Collapse
    macrumors regular

    Joined:
    Feb 14, 2006
    #1
    I am going to start playing with OpenGL, so I've downloaded the samples from the Apple site. I did have a question, however...is 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/C++...is Objective-C not optimized enough for OpenGL to be practical?
     
  2. Palad1
    Expand Collapse
    macrumors 6502a

    Palad1

    Joined:
    Feb 24, 2004
    Location:
    London, UK
    #2
    NSOpenGLView

    Hello,

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

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #3
    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.

    GLEnable(GL_LIGHTS)
    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. mbabauer
    Expand Collapse
    thread starter macrumors regular

    Joined:
    Feb 14, 2006
    #4
    Thanks

    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. Palad1
    Expand Collapse
    macrumors 6502a

    Palad1

    Joined:
    Feb 24, 2004
    Location:
    London, UK
    #5
    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

    Cheers,
    Palad1
     
  6. Soulstorm
    Expand Collapse
    macrumors 68000

    Soulstorm

    Joined:
    Feb 1, 2005
    #6
    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. Palad1
    Expand Collapse
    macrumors 6502a

    Palad1

    Joined:
    Feb 24, 2004
    Location:
    London, UK
    #7
    Well, OpenGL is a procedural library. Sometimes it's just nice to stop working with classes & get back to structs and pointers ;)
     
  8. mbabauer
    Expand Collapse
    thread starter macrumors regular

    Joined:
    Feb 14, 2006
    #8
    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. Palad1
    Expand Collapse
    macrumors 6502a

    Palad1

    Joined:
    Feb 24, 2004
    Location:
    London, UK
    #9
    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 )
    edit:

    Got them:
    OpenGL Programming Guide ISBN 0321335732
    OpenGL Shading Language ISBN 0321334892
     
  10. mbabauer
    Expand Collapse
    thread starter macrumors regular

    Joined:
    Feb 14, 2006
    #10
    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. Palad1
    Expand Collapse
    macrumors 6502a

    Palad1

    Joined:
    Feb 24, 2004
    Location:
    London, UK
    #11
    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