Very simple OpenGL problem - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Very simple OpenGL problem (/thread-2901.html)
Very simple OpenGL problem - evangs - Dec 8, 2007 12:09 PM
I've been working through the NeHe tutorials (http://nehe.gamedev.net), and I'm stumped on the 2nd lesson. I think it has to do with the way the viewport is being setup in my program. I'm not using the boilerplate code that is provided at the website. Instead, I'm using the code suggested by Apple's documentation.
Here is the code.
Now, I know the rendering context is setup and that stuff is being rendered. However, it seems I am "zoomed" too close to the scene as I only see part of the triangle and can't see the quad. I think the problem lies with the glTranslatef call at the start of the rendering fragment. I've tried various values for the z-axis, but I can't ever get it to display the entire scene. I see part of the scene for a z-axis value of -1 or +1 (funnily enough, I see the same part of the scene!). Any larger values and I get a black scene.
This is probably a very very simple problem but I can't seem to figure out what else I need change to get it to work right.
Very simple OpenGL problem - reubert - Dec 8, 2007 04:59 PM
What you see is a combination of your projection and modelview matrices. I like to think of it as setting up the "camera" usually with a call to glOrtho or gluPerspective in the projection matrix. In Lesson02's case I think this is gluPerspective, with a 45 degree FOV and near and far clip planes of 0.1 and 100.
My guess is you are not setting up the projection matrix correctly, perhaps you are not calling gluPerspective, or are setting the far clip plane to 1.0, and everything is getting clipped when beyond that.
Very simple OpenGL problem - evangs - Dec 9, 2007 01:47 AM
OK, I've now got it working by taking the -reshape code from the supplied Cocoa example. Also, I've had trouble with getting the Quad to render but replacing the Quad rendering code with stuff that creates a triangle causes two triangles to be correctly rendered. Then putting the Quad rendering code back in causes the Quad to render correctly.
I also make sure to clean before each build so that's pretty strange. But at least it works now and I can proceed.
Very simple OpenGL problem - OneSadCookie - Dec 9, 2007 02:57 AM
If you're using Xcode 3 (Leopard) people are having problems with their programs showing bizarre impossible behavior that's only fixed by quitting and relaunching Xcode.
Of course, you could just be confused
Very simple OpenGL problem - evangs - Dec 9, 2007 11:45 PM
I'm using Xcode 2.5, but it does seem that some problems can be fixed by just quitting Xcode and relaunching it. This is especially true as some of the behavior I see just cannot be explained (i.e. Quad not rendering when it should, etc).
Very simple OpenGL problem - reubert - Dec 10, 2007 12:25 AM
I saw such problems on Tiger 2.5 xcode too. I would make modifications that didn't seem to hold, then quit and relaunch and sure enough the changes weren't there.
Haven't seen it on Leopard, but man was that annoying.
Very simple OpenGL problem - lightbringer - Dec 10, 2007 04:06 AM
reubert Wrote:I saw such problems on Tiger 2.5 xcode too. I would make modifications that didn't seem to hold, then quit and relaunch and sure enough the changes weren't there.
With version 2.x I haven't noticed any funky behavior of that sort (AFAIK the only unintended behavior I've had with Xcode is crashing, and that was a 1.x thing). Having some code not stick without a relaunch sounds very odd.
If I'm one of the lucky ones, then yay.
Very simple OpenGL problem - AnotherJake - Dec 10, 2007 07:51 AM
It has happened to me with 2.x. Cleaning the project wouldn't even get it to work. However, I recall modifying the code further around the spot that didn't take (maybe just as simple as adding a space and deleting it) and *then* it would pick it up. Totally bizarre...
Very simple OpenGL problem - Fenris - Dec 10, 2007 09:11 AM
If you're running with ZeroLink, this can happen. If you're quick to hit the build button after making a change and saving, the linker can miss that compilation unit, and zero-links the old object file. My tip is to hit Run without saving the file, and then answering Yes on the dialog button that comes up. That way, it almost never happens to me. If it happens to you, just touch the file (as AnotherJake said) and run it again.
Very simple OpenGL problem - reubert - Dec 10, 2007 12:36 PM
Quote:If you're running with ZeroLink, this can happenWasn't the issue in my case, ZeroLink is permanently set in the off position clean builds or small edits and re-saving didn't help. I was starting to suspect hard drive problems, but with XCode3 fixing it, and others mentioning the same problem I guess it is a 2.x (or tiger) thing.
Very simple OpenGL problem - wyrmmage - Dec 10, 2007 01:32 PM
I've had this problem too; it is particularly annoying when you're trying to fix a bug in your code and you new code doesn't seem to fix it, so you pass on and keep looking elsewhere...