Results 1 to 2 of 2
- 11-16-2008, 02:25 AM #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.
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.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.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
thank you for all the help
-ankit
- 11-16-2008, 03:46 AM #2
Senior Member
- Join Date
- Sep 2008
- Posts
- 564
- Rep Power
- 5
Similar Threads
-
A newbie question: How do I take a J2ME open source and create a project
By Anona in forum CLDC and MIDPReplies: 0Last Post: 09-28-2008, 11:02 AM -
Newbie search array question
By CirKuT in forum New To JavaReplies: 19Last Post: 09-14-2008, 06:26 AM -
Newbie question; Vectors
By Kern in forum New To JavaReplies: 7Last Post: 08-03-2008, 06:59 AM -
SWT OpenGL snippet: draw a square
By Java Tip in forum SWTReplies: 0Last Post: 06-28-2008, 09:29 PM -
Newbie question about Static methods
By SCS17 in forum New To JavaReplies: 9Last Post: 02-06-2008, 08:03 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks