Alright, I'm trying to get an NSOpenGLView working, and so far, have had mixed success. I've been able to get the rendering working, no problem. I did this by subclassing NSOpenGLView, and overriding the drawRect function. Great.
Now, when the view gets resized, I want to adjust the perspective using gluPerspective. gluPerspective takes a GLfloat which I want to be the ratior of width to height. I cannot get this working. This is mostly a cocoa problem, not an opengl one. When the view is resized, I override the resize function, and was trying to get the appropriate values as follows:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
NSRect* myRect = [<font color = purple>self</font> frame];
GLfloat myWidth = [myRect width]; <font color = brown>// These calls dont work</font>
GLfloat myHeight = [myRect height];
GLfloat myWidth2 = [ [myRect size] width ]; <font color = brown>// These dont either</font>
GLfloat myWidth2 = [ [myRect size] height ];
</font>[/code]
I also tried various casts, and such. The Cocoa (java) api docs implement the functions exactly as I need them, but are in java, whereas I need c. This has to be pretty simple, so why am I having such a hard time? Anyone want to help me out here...
Also, why is it so hard to find the objC documentation as opposed to the Java docs? And does anyone have further examples of calling OpenGL with Cocoa, both in a view similar to what I mention above, and in full screen mode?
Thanks.
Spencer