Hi,
at the Moment im learning OPENGL and after creating different Applikations with (transformed) Geometric Primitives just like Cubes,Quads and Triangles,
im figuring out to get deeper in this 3D thang.
So, i thought about a Terrain in 3D. To do this I created some Triangles, just imagine as a 2D-Field of triangles. After that Creation i thought about rotating this whole field arround the x-axis lets say 160 degrees. In my mind that is absolut logically, but when im trying to Code it i dont get the wished results.
My Problem is only the drawying, cause if i translate the field to the Center of the window and then im rotating it finally i translate it back just as its said in some books, result shows me no depth. I expectect the triangle field to become smaller in the Background and larger in the foreground, but it seems there is no depth in it.
private void initGL(){
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,WIDTH,HEIGHT,0,10,-10);
glMatrixMode(GL_MODELVIEW);
}
public void renderGL(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPolygonMode(GL11.GL_FRONT_AND_BACK,GL11.GL_LINE);
glPushMatrix();
glTranslatef(WIDTH/2, HEIGHT/2, 0);
glRotated(160, 1.0, 0, 0);
glTranslatef(-WIDTH/2,-HEIGHT/2, 0);
for(int y = 0;y<rows;y++){
glBegin(GL_TRIANGLE_STRIP);
for(int x = 0;x<cols;x++){
vertex(x*scl,y*scl);
vertex(x*scl,(y+1)*scl);
}
glEnd();
}
glPopMatrix();
}
public void vertex(int x,int y){
glVertex2i(x,y);
glVertex2i(x,y);
glVertex2i(x,y);
}
This is my relevant Code i got, but as i said im new to OpenGL and i dont know all the tricks yet.
Tomm9080