PDA

View Full Version : Some beginner questions



Captain Nemo
09-14-2017, 12:44 AM
Hi,
recently i started with OpenGL and ist really a big mountain of quite new Information to know about programming in 3D.
I Code in eclipse with the lwjgl 2.9.3, cause it is most completed in itself i guess, im quite old fashioned, but id like to do it that way.
So, it would be nice if somebody could suggest me a free-e-book for download about OpenGL especially in Java.

And i have another concrete questions about Transformations and other stuff:

The glRotatef() takes in an angle Parameter. How do i have to say i want to have a 60 degrees angle?
How can i achieve that a rectangle grid by Rotation goes into the room? What do i have to rotate,the complete coordinatesystem or every vertexobject or both and how can i get that?

I just wanna do some Basic operations with primitives and im a real beginner. I just have the Knowledge about 3D from School and some youtubetutorials.

Here is my render function where i draw some Kind of grid with linestrip, cause the trianglestrip always fills each form, what i dont want to have:


public static void render(){

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,WIDTH,HEIGHT,0,1,-1);
glMatrixMode(GL_MODELVIEW);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glPushMatrix();

glTranslatef(WIDTH/2,HEIGHT/2,0);
glRotatef(60.0f,1f,0f,0f);
glTranslatef(-WIDTH/2,-HEIGHT/2,0);

for(int y = 0;y<rows;y++){
glBegin(GL_LINE_STRIP);
for(int x = 0;x<cols;x++){
glVertex2f(x*scale,(y+1)*scale);
glVertex2f((x+1)*scale,y*scale);
glVertex2f((x+1)*scale,(y+1)*scale);
glVertex2f(x*scale,(y+1)*scale);
glVertex2f(x*scale,y*scale);
glVertex2f((x+1)*scale,y*scale);
}
glEnd();
}

glPopMatrix();
}

My aim is to create some Kind of smooth Terrain like a hilllandscape, i hope u can imagine. But first i need to rotate the grid correctly before i can insert some random z-values for each vertex.

If somebody knows what i mean, pls help me.

Captain Nemo

Carmine
09-15-2017, 01:08 PM
Don't understand what your problem is. What happens when you run this code? Do you see anything?