OpenGl transformation question newbie

• 11-16-2008, 03:25 AM
ankitmcgill
OpenGl transformation question newbie
Hi all,

i am a complete newbie to opengl taking a computer graphics course this semester. we just did transformations so i am playing around with some code to make sure i understand them. however there seems to be some basic flaw in my understanding as i always get output different that what i predicted.

I have posted a sample code below and hoping someone would be kind enough to walk me through it to point what i am not getting right.

the code below is supposed to draw x,y and z axis with the viewpoint situated at (1,1,1) so that i can see all the axis.

Code:

```gl.glClear(GL.GL_COLOR_BUFFER_BIT|gl.GL_DEPTH_BUFFER_BIT);  //clear gl buffers gl.glMatrixMode(GL.GL_MODELVIEW); //set the current matrix as modelview gl.glLoadIdentity(); //load identity matrix => locate viewpoint at (0,0,0) gl.glClearColor(1.0f,1.0f,1.0f,0); //clear window with white gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glColor3f(0.0f, 0.0f, 0.0f); //set drawing color as black         gl.glBegin(GL.GL_LINES);  //draw all three axis within -0.5 to +0.5 with viewer at (0,0,0). this when rendered will show a     gl.glVertex3f( -0.5f, 0.0f, 0.0f ); // a plus sign since z axis would be 'hidden'     gl.glVertex3f( 0.5f, 0.0f, 0.0f );             gl.glVertex3f( 0.0f, -0.5f, 0.0f );     gl.glVertex3f( 0.0f, 0.5f, 0.0f );                 gl.glVertex3f( 0.0f, 0.0f, -0.5f );     gl.glVertex3f( 0.0f, 0.0f, 0.5f );             gl.glEnd(); gl.glTranslatef(1.0f, 1.0f, 1.0f); //finally move the viewer to (1,1,1) to get the desired view```
when i run this all i see is half a part of of the plus sign drawn at the top right corner of the gl canvas.

thank you for all the help
-ankit
• 11-16-2008, 04:46 AM
emceenugget
you need to rotate the camera to face the origin