Showing a couple of triangles

Very beginner question:

I have a couple of triangles:

(code from display method)

glColor3f(1.0, 1.0, 1.0);
glBegin(GL_TRIANGLES);
	glVertex3f(-25.0,-25.0,0.5);
	glVertex3f(-25.0,25.0,0.7);
	glVertex3f(25.0,25.0,0.9);

	glVertex3f(-24.0,-25.0,0.0);
	glVertex3f(26.0,25.0,0.0);
	glVertex3f(26.0,-25.0,0.0);
glEnd();

If I put in my reshape method the commands:

void reshape(int w, int h)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-50.0, 50.0, -50.0, 50.0, -1.0, 0.5);
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

I can see the two triangles in the middle of the screen. Now I would like to see them with a camera… I tried:

void reshape(int w, int h)
{
gluLookAt(0.0,0.0,100.0,0.0,0.0,0.0,0.0,1.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0,1.0,1.5,20.0);
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

and I don’t see anything
Anybody can help me here? I need to position a camera at a reasonable distance, looking at the point (0,0,0). I don’t understand the order of method calls… If anybody can explain me how and why I have to follow a specific order I would extremely appreciate it!!! Thanks!!!

You have two matrix to work with projection and model.

glLookat should be before you start drawing and after you setup the ortho and view port.

gluLookat

glColor3f(1.0, 1.0, 1.0);
glBegin(GL_TRIANGLES);
glVertex3f(-25.0,-25.0,0.5);
glVertex3f(-25.0,25.0,0.7);
glVertex3f(25.0,25.0,0.9);
glVertex3f(-24.0,-25.0,0.0);
glVertex3f(26.0,25.0,0.0);
glVertex3f(26.0,-25.0,0.0);
glEnd();

Originally posted by franz1999:
[b]Very beginner question:

I have a couple of triangles:

(code from display method)

glColor3f(1.0, 1.0, 1.0);
glBegin(GL_TRIANGLES);
glVertex3f(-25.0,-25.0,0.5);
glVertex3f(-25.0,25.0,0.7);
glVertex3f(25.0,25.0,0.9);

  glVertex3f(-24.0,-25.0,0.0);
  glVertex3f(26.0,25.0,0.0);
  glVertex3f(26.0,-25.0,0.0);

glEnd();

If I put in my reshape method the commands:

void reshape(int w, int h)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-50.0, 50.0, -50.0, 50.0, -1.0, 0.5);
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

I can see the two triangles in the middle of the screen. Now I would like to see them with a camera… I tried:

void reshape(int w, int h)
{
gluLookAt(0.0,0.0,100.0,0.0,0.0,0.0,0.0,1.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0,1.0,1.5,20.0);
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

and I don’t see anything
Anybody can help me here? I need to position a camera at a reasonable distance, looking at the point (0,0,0). I don’t understand the order of method calls… If anybody can explain me how and why I have to follow a specific order I would extremely appreciate it!!! Thanks!!![/b]

[This message has been edited by nexusone (edited 02-22-2003).]

Ok, forget it. I got it working, thanks!

[This message has been edited by franz1999 (edited 02-22-2003).]