Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Some beginner questions

  1. #1
    Newbie Newbie
    Join Date
    Sep 2017
    Posts
    1

    Some beginner questions

    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:

    Code :
    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

  2. #2
    Member Regular Contributor
    Join Date
    Apr 2012
    Location
    Los Angeles
    Posts
    387
    Don't understand what your problem is. What happens when you run this code? Do you see anything?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •