Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Cocoa - OpenGL integration issues

Cocoa - OpenGL integration issues
Thread Tools
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Aug 29, 2001, 12:50 AM
 
I recently started getting back into some OpenGL programming but I am hitting a snag along the way (the same snag I had last time I tried to do this). It appears as though I can't get an OpenGLView in one of my program's windows to behave properly. It will work with basic lighting and shapes but I am running into huge problems with depth and perspective. No shape will be drawn if it is outside a -1.0 to +1.0 range in each axis. I assume that this is a problem with default perspective yet any calls to "gluPerspective" render the OpenGLView black. Also, none of my shapes appear to "shrink" into the distance like they probably should when their leading edge and trailing edges are at different distances from the viewer.

Can anyone shed some light on this? I don't know what I can do and all the tutorials I have found work directly with glut and don't even use the cocoa elements I need for this to look right.

Thanks,
Jeff.
Spectral Class
"Shedding Light on Innovation"
     
Senior User
Join Date: Mar 2000
Location: Ithaca, NY
Status: Offline
Reply With Quote
Sep 1, 2001, 01:01 PM
 
It sounds like perhaps you're either not using the correct matrix stack or you're not loading an identity matrix before calling gluPerspective(). Your code for setting the perspective should look something like this:

glMatrixMode(GL_PROJECTION);
glLoadIdentity(); //important!
gluPerspective(foo, bar, baz, quux);

If you don't load the identity matrix before calling gluPerspective(), it will multiply whatever matrix is already present by the perspective matrix, giving you gibberish for a projection matrix. I've done this a couple times myself, and the result is usually a black screen like you're describing.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:52 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2