so i use init() for 1-time stuff. now you said that in the keylistener i should set a boolean to recompute the projection matrix .. assuming i do that , how would the display() function of opengl get called ? wont i need to explicitly call it from my keylistener ?

so i am calling the display() and init() every time => redrawing the whole scene. i am wondering since opengl is a state machine there should be a way to just recompute the projection according to the new angle instead of drawing the whole thing again ... any ideas how would i do that ?

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.

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

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org