PDA

View Full Version : where did they get the coordinates from?

grimoire
05-02-2004, 05:45 PM
I am still on the NeHe tutorials and I understand everything except for where they got the coordinates from.
void Display(void){
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glTranslatef(-1.5,0.0,-6.0);
glBegin(GL_POLYGON);
glVertex3f(0.0,1.0,0.0);
glVertex3f(1.0,-1.0,0.0);
glVertex3f(-1.0,-1.0,0.0);
glEnd();
glTranslatef(3.0,0.0,0.0);
glVertex3f(-1.0,1.0,0.0);
glVertex3f(1.0,1.0,0.0);
glVertex3f(1.0,-1.0,0.0);
glVertex3f(-1.0,-1.0,0.0);
glEnd();
glutSwapBuffers();
}and they created the coordinate system with this
gluPerspective(45.0,(GLfloat)Width/(GLfloat)Height,0.1,100.0);How did they know to translate and how did they get those numbers??

not_yet
05-02-2004, 06:53 PM
the coordinates are just made up

the writer just decided to move 3 in the x direction etc

if you like change the 3 to something else, and run the code

as long as you stay in the viewing area where you move to is your choice

cheers

grimoire
05-03-2004, 08:22 AM
How big is the viewing area then?

grimoire
05-03-2004, 08:28 AM
Here is my understanding. You make a sheet of graph paper with the gluperspective function I made it from .1 to 100 then I went to the center GlLoadIdentity(); then I moved 1.5 to the left and 6 out(How much can I see now of the whole thing) and I wrote the coordinates(I don't understand how the writer knew it would look like that(are the coordinates from where you are or from the center?)) and finally when he/she moved from the center, and wrote 1 for the y coordinate and then when you display it the triangle is below the x intercept?

chowe6685
05-03-2004, 08:59 AM
look at the opengl specification to fully understand how opengl treats the coordinates you supply it with. In theory one could invert those transformations to find out exactly what object space coordinates coorespond to what window coordinates. In practice for simple demoes, I find it easiest just to pick something that looks nice.

not_yet
05-03-2004, 10:13 AM
in the glTranslate command note the -6 for the 'z' value. This means that everything is moved along the negative 'z' axis, ie: into the screen. Your looking at your objects from (0,0,0).

Have a look at the opengl programming guide, chapter 3, its available on this site under documentation.

cheers