Rotate triangles and set the gluLookAt

I am new in this field and I’ve searched this subject on the internet. What I found is only about one triangle, but I created many triangles which are related with each others and I can’t rotate it. Here is my code:

[b]glPushMatrix();
glRotatef(angle, 0, 1, 0); ///

glColor3f(-1.0, -1.0, -1.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
for (int i = 0; i < 17; i++)
{
    for (int j = 0; j < 21; j++)
    {
        glBegin(GL_TRIANGLES);

        glVertex3f(xT, mat[i][j], zT);    
        glVertex3f(xT + 20, mat[i+1][j], zT);   
        glVertex3f(xT, mat[i][j+1], zT + 20);  

        glVertex3f(xT, mat[i][j+1], zT + 20);   
        glVertex3f(xT + 20, mat[i+1][j], zT);  
        glVertex3f(xT + 20, mat[i+1][j+1], zT + 20); 

        glEnd();

        zT += 20.0;

    }

    xT += 20.0;
    zT = 0.0;
}
xT = 0.0;

glPopMatrix();

[/b]min xT = 0.0 and max xT = 320 and min zT = 0.0 and max zT = 420

It crates a mountainous field and I want to see all area. My questions are:

What should my gluLookAt function be like?
How can I rotate this area by its origin?

If you want a view that’s not horizontal, rotate about the X axis before rotating about the Y axis.

You are rotating it about its origin, which is one of its corners. If you want to rotate about the centre, call glTranslatef(-10,0,-10) after the rotations.

You may also need something like glTranslatef(0,0,-30) before the rotations so that the viewpoint isn’t in the middle of the object.

https://www.opengl.org/discussion_boards/showthread.php/197952-Rotate-triangles-and-set-the-gluLookAt?p=1280673#post1280673

Please don’t do that.

[QUOTE=mhagain;1280679]Khronos Forums - Khronos Standards community discussions

Please don’t do that.[/QUOTE]

too late dude and i am new here i dont know the delete the previous post, can you delete it for me ? Thanks.

[b]alihuseyin[/b], I’ve deleted your other thread. Please read the:

Forum Posting Guidelines

[QUOTE=GClements;1280677]If you want a view that’s not horizontal, rotate about the X axis before rotating about the Y axis.

You are rotating it about its origin, which is one of its corners. If you want to rotate about the centre, call glTranslatef(-10,0,-10) after the rotations.

You may also need something like glTranslatef(0,0,-30) before the rotations so that the viewpoint isn’t in the middle of the object.[/QUOTE]

Unluckily it did not work, I lose the view of this field when I adjust those parameters.

You don’t need to use gluLookAt. Just position and scale your data so that they are in the default camera FOV. The default camera is located at the origin and is pointed in the -Z direction (i.e. into the screen). This is why GClements says to translate by -30 in Z. Here is a version of your code and the image it generates. I used random numbers for the y values of the vertices.

[ATTACH=CONFIG]1335[/ATTACH]

[ATTACH=CONFIG]1336[/ATTACH]