Results 1 to 2 of 2
  1. #1
    ankitmcgill is offline Member
    Join Date
    Nov 2008
    Posts
    22
    Rep Power
    0

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

  2. #2
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    7

Similar Threads

  1. Replies: 0
    Last Post: 09-28-2008, 12:02 PM
  2. Newbie search array question
    By CirKuT in forum New To Java
    Replies: 19
    Last Post: 09-14-2008, 07:26 AM
  3. Newbie question; Vectors
    By Kern in forum New To Java
    Replies: 7
    Last Post: 08-03-2008, 07:59 AM
  4. SWT OpenGL snippet: draw a square
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 06-28-2008, 10:29 PM
  5. Newbie question about Static methods
    By SCS17 in forum New To Java
    Replies: 9
    Last Post: 02-06-2008, 09:03 AM

Posting Permissions

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