# Thread: OpenGl transformation question newbie

1. Member
Join Date
Nov 2008
Posts
22
Rep Power
0

## 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.

Java 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.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

2. Senior Member
Join Date
Sep 2008
Posts
564
Rep Power
9
you need to rotate the camera to face the origin

#### Posting Permissions

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