LWJGL Forum

Programming => OpenGL => Topic started by: Iron on December 08, 2009, 15:38:33

Title: 3D-Graphics
Post by: Iron on December 08, 2009, 15:38:33
hey,
after searching for an hour or two on the internet, and in this forum i didn't fond what i was looking for....

so here's my question:
how can i make 3d graphics in OpenGL?

i tryed simply
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

        GL11.glPushMatrix();
        {
            GL11.glTranslatef(width/2, height/2,depth);
            GL11.glRotatef(depth, 0, 0, depth);
            GL11.glBegin(GL11.GL_QUADS);
            {
                GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glVertex3f(-50, -50f, 0);
                GL11.glColor3f(1.0f, 0.0f, 1.0f); GL11.glVertex3f(50, -50f, 0);
                GL11.glColor3f(1.0f, 0.0f, 0.0f); GL11.glVertex3f(50, 50, 0);
                GL11.glColor3f(0.0f, 1.0f, 1.0f); GL11.glVertex3f(-50, 50, 0);
            }
            GL11.glEnd();
        }
        GL11.glPopMatrix();

but it didn't work... that means i could only see what was on the level 0 (z-acsis)...

hope you can help me..
Title: Re: 3D-Graphics
Post by: kappa on December 08, 2009, 15:52:50
you have to setup a 3d view before you can start using 3d with opengl. Have a look at glOrtho, glFrustum and gluPerspective.
Title: Re: 3D-Graphics
Post by: elias4444 on December 08, 2009, 15:57:36
You might want to check out the Nehe tutorials at http://nehe.gamedev.net/ (http://nehe.gamedev.net/), or consider buying a book to help you learn OpenGL.
Title: Re: 3D-Graphics
Post by: Iron on December 08, 2009, 16:37:09
Quote from: javalwjgl on December 08, 2009, 15:52:50
you have to setup a 3d view before you can start using 3d with opengl. Have a look at glOrtho, glFrustum and gluPerspective.

hmm thats what i have thougt, wrong initialisation... but i didn't find the good way anywhere....
Quote from: elias4444 on December 08, 2009, 15:57:36
You might want to check out the Nehe tutorials at http://nehe.gamedev.net/ (http://nehe.gamedev.net/), or consider buying a book to help you learn OpenGL.

could you suggest me a good book, please.

so here's my init
GL11.glViewport(0, 0, disp.getWidth(), disp.getHeight());
       GL11.glMatrixMode(GL11.GL_PROJECTION);
  GL11.glLoadIdentity();
       GLU.gluOrtho2D(0, disp.getWidth(), 0, disp.getHeight());
  GL11.glMatrixMode(GL11.GL_MODELVIEW);
  GL11.glLoadIdentity();
       GL11.glEnable(GL11.GL_LINE_SMOOTH);
       GL11.glEnable(GL11.GL_TEXTURE_2D);


i hope you can tell me how to modify it
Title: Re: 3D-Graphics
Post by: kappa on December 08, 2009, 17:20:32
yup your view is set to 2d, grab the Red Book for Opengl http://www.glprogramming.com/red/ (google can probably find you a pdf version of it) Chapter 3 should contain all you need to know.
Title: Re: 3D-Graphics
Post by: Evil-Devil on December 09, 2009, 16:32:16
@book: OpenGL Superbible is a good one. It starts with the plain basics and won't teach to much math (other books do better) and at 2/3 of the book it will switch over to shaders.