PDA

View Full Version : Cocoa and OpenGL




mbabauer
Aug 16, 2006, 08:30 AM
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?



Palad1
Aug 16, 2006, 10:23 AM
Hello,

Last time I checked, there's a class which already does all the dirty glut work in the Cocoa Framework. Check NSOpenGLView (http://www.cocoadev.com/index.pl?NSOpenGLView) out

slooksterPSV
Aug 16, 2006, 11:30 AM
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.

mbabauer
Aug 17, 2006, 08:45 AM
Hello,

Last time I checked, there's a class which already does all the dirty glut work in the Cocoa Framework. Check NSOpenGLView (http://www.cocoadev.com/index.pl?NSOpenGLView) out

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.

Palad1
Aug 17, 2006, 09:01 AM
Orange book?

I learned OpenGL from the Red Book (http://fly.srk.fer.hr/~unreal/theredbook/) which explains basic OpenGL stuff, but the Orange book (http://www.3dshaders.com/joomla/) is a tad too advanced for starting as it deals with shaders.

So go Red => Orange :D

Cheers,
Palad1

Soulstorm
Aug 17, 2006, 09:20 AM
Also, most of the sample code is in C/C++...is Objective-C not optimized enough for OpenGL to be practical?
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.

Palad1
Aug 17, 2006, 10:42 AM
Well, OpenGL is a procedural library. Sometimes it's just nice to stop working with classes & get back to structs and pointers ;)

mbabauer
Aug 18, 2006, 11:54 AM
Well, OpenGL is a procedural library. Sometimes it's just nice to stop working with classes & get back to structs and pointers ;)

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.

Palad1
Aug 18, 2006, 12:23 PM
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

mbabauer
Aug 18, 2006, 01:33 PM
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

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 :) .

Palad1
Aug 18, 2006, 04:45 PM
You are welcome! Good luck with OpenGL.

Sweetness! You are the man/woman!
Ahem.. dude (dudette?) check my avatar out. That should give you an idea (hint beard) :D