Newbie trying to understand NeHe's Tutorials - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Newbie trying to understand NeHe's Tutorials (/thread-1433.html)
Newbie trying to understand NeHe's Tutorials - mikey - Apr 18, 2009 10:37 AM
OK, after AnotherJake's kind advice, I set off looking for Neon Helium. Wasn't hard to find.
I think, OK, lets do the first tutorial, - and yes I did read "If you're running Mac OSX 1.0" - and I compile it in Xcode 3.1 and It gives me 3 errors!
Quote:Building target â€œOpenGL Testsâ€ of project â€œOpenGL Testsâ€ with configuration â€œDebugâ€ â€” (3 errors)
Am I doing something wrong? Very unlike me
If I'm not, could someone point me towards some newer OpenGL with C tutorials?
Newbie trying to understand NeHe's Tutorials - AnotherJake - Apr 18, 2009 11:33 AM
Oh man... I just went to NeHe and checked out some of the tutorials. Yeah, they're getting pretty old. I would suggest that perhaps the best approach might be to stick to the GLUT examples (don't do the OS X ones). You can get started with GLUT using onesadcookie's GLUT tutorial. Then you might be able to use the GLUT code from the other NeHe tutorials.
Newbie trying to understand NeHe's Tutorials - StealthyCoin - Apr 18, 2009 11:36 AM
Hah, I just went and did the same. And was just thinking about that tutorial but couldn't find it. Thats what I learned OpenGL with, its much much more clear and gooderful and concise and informative.
Newbie trying to understand NeHe's Tutorials - AnotherJake - Apr 18, 2009 11:39 AM
Hehe.. "gooderful"... That is mighty truthy of you!
Newbie trying to understand NeHe's Tutorials - kodex - Apr 18, 2009 04:37 PM
Apple has some more up to date OpenGL Sample code, granted its rather hard for a beginner to understand it is still a pretty good start.
On a similar note, why is it almost impossible to find Mac OpenGL stuff that compiles with no warnings/errors?
Newbie trying to understand NeHe's Tutorials - AnotherJake - Apr 18, 2009 05:32 PM
kodex Wrote:On a similar note, why is it almost impossible to find Mac OpenGL stuff that compiles with no warnings/errors?
Good question. It is probably due to all the changes that have occurred to OS X over the years, and the original authors not bothering to update things. Can't say I blame them though since examples are usually free.
Newbie trying to understand NeHe's Tutorials - mikey - Apr 19, 2009 11:28 AM
Bytheway, I was 'playing with Scratch' (It's great for noobs to programming) and I thought, hey, I could make a 3D projection program!
3 months later It was still not working
This made me think what a good job the OpenGL Programmers have done
Newbie trying to understand NeHe's Tutorials - AnotherJake - Apr 19, 2009 12:12 PM
Doing 3D graphics from the ground up is quite a massive undertaking, depending on how far you want to take it. OpenGL was built on the shoulders of giants so to speak. There has been much research and experimentation done by many folks which over the decades has led us to where we are now. OpenGL and Direct3D are the two most well-known results.
If you're really curious about how it all comes together, there are many sources of info. These guys have a large collection of resources, which is a companion site to the book. I got the first edition several years ago, but haven't kept up. It's pretty overwhelming.
An in-depth exercise in creating a full 3D software rasterizer is found in the book, Tricks of the 3D Game Programming Gurus. Looks like it's out of print, but available used. It's a massive tome of information on the subject which walks you through the whole process. I made it up to the texturing section.
A vastly simplified, but fun set of tutorials can be found here.
You can find all kinds of other info if you google for 3d software rasterization.
Newbie trying to understand NeHe's Tutorials - mikey - Apr 20, 2009 10:15 AM
OK, I completed OneSadCookie's tutorial, and now I would like to make it, say, a circle.
Is this right?
So If that drew a square, should I replace "(GL_QUADS)" with say, "(GL_CIRCLE)"? and If I did, what should the 'glVertex2f(etc);' be? I mean, should I tell the function the centrepoint and diameter, or the four corners?
Oh yes, what's the 'glVertex2f' for?
Newbie trying to understand NeHe's Tutorials - AnotherJake - Apr 20, 2009 10:34 AM
At this point, now that you can get GLUT running, you should look to the NeHe tutorials and the "Red Book" for further guidance. There are a lot of questions you'll have, in addition to the ones you just asked.
I'll offer a few quick answers here:
Tells OpenGL that the next set of data you will be sending it will be for making quads. It expects that you will be sending data formatted so that there are four vertices for each quad.
glVertex2f( 0.0f, 0.0f);
glVertex2f( 0.0f, 128.0f);
Those are the four vertices. Next you call
To tell OpenGL that your done specifying data for the quad.
There is no GL_CIRCLE. If you hold down the command key and double click on GL_QAUDS, it will reveal the primitive types available to you in the gl.h header.
What you would want to do to make a circle is probably use a triangle fan. Then you use a little trigonometry to specify vertices evenly spaced around the central vertex. It's pretty easy, but you should study up on how to use the other primitives first by studying up at NeHe or reading the Red Book. You can also use glu quadrics, although I don't personally use them myself.
glPopMatrix(); is what you would call somewhere after a call to glPushMatrix();. Yes, it is a stack, but it is a stack of matrices. The current matrix determines how all those vertices you specified will be transformed mathematically in 3D space. Calling push will copy the current matrix and push it onto a new layer in the stack. That way you can modify it by adding another transform to it or even clear it, and then pop it when your done to back up to where you were. You will need to study up some more to learn exactly how these transformations are handled.
The "2f" at the end of glVertex2f is an OpenGL notation standard which means 2 floats. If it were glVertex3f it would expect 3 floats. Again, reading the Red Book will explain this clearly.
Newbie trying to understand NeHe's Tutorials - AnotherJake - Apr 20, 2009 10:53 AM
I should add: You are at the beginning of the steepest part of the learning curve for OpenGL. This stuff is *really* hard for beginners to pick up, so don't feel bad about not "getting it" right now.
Also, not to add to your confusion, but I should mention that most of the stuff you're learning right now with glBegin/glEnd and glPushMatrix/glPopMatrix (along with glTranslate, glRotate and glScale) will supposedly not be around in future versions of OpenGL. Further, many of those primitive types listed in my previous post aren't available in OpenGL ES, which is the version of OpenGL used on iPhone. Heck, iPhone doesn't even support glBegin/glEnd! Wuh?! You heard me right, you're learning stuff now that is already slated to be obsolete -- like as if it weren't hard enough to learn already!
Okay, so now you know that. But, I will say that it is good to learn what you're learning because there is an enormous amount of code out there using it, which you will need to reference in the future, so you'll need to know it anyway.
So my advice, as you're learning OpenGL is to be particularly enthusiastic about tutorials which explain how to use glDrawArrays and glDrawElements, and VBOs later too, since those are going to be standard moving forward.