Show Posts
|
|
Pages: [1]
|
|
3
|
Game Development / Newbie & Debugging Questions / Re: OpenGl transformation question newbie
|
on: 2008-11-18 06:39:27
|
|
hmm .. .i am not sure if i follow ur advice completely.
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 ?
thanks -ankit
|
|
|
|
|
4
|
Game Development / Newbie & Debugging Questions / Re: OpenGl transformation question newbie
|
on: 2008-11-18 01:00:54
|
lhkbob, thank you so much ! fixing the camera project did the trick  have another noob question. i added code so that every time the user presses the right key i change the camera rotate angle to rotate the final projection. it works fine except that right now what i do is (pseudocode) 1 2 3 4 5 6 7 8 9
| void keypressed(....) { if key(==right key) { angle+=2.0f; init(); display(); } } |
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 ? thanks -ankit
|
|
|
|
|
6
|
Game Development / Newbie & Debugging Questions / Re: OpenGl transformation question newbie
|
on: 2008-11-16 08:57:23
|
ok ..makes sense .. so i modified my code and now i can see the axis with the desired view however there is a small problem in the code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| final GL gl = drawable.getGL(); final GLU glu = new GLU(); gl.glClear(GL.GL_COLOR_BUFFER_BIT|GL.GL_DEPTH_BUFFER_BIT); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0.0f, 0.0f, -1.0f); gl.glRotatef(45.0f, 1.0f, 0.0f, 0.0f); gl.glRotatef(45.0f, 0.0f, 1.0f, 0.0f);
gl.glColor3f(0.0f, 0.0f, 0.0f); gl.glBegin(GL.GL_LINES); gl.glColor3f(0.0f, 1.0f, 0.0f); gl.glVertex3f( -1.5f, 0.0f, 0.0f ); gl.glVertex3f( 1.5f, 0.0f, 0.0f ); gl.glColor3f(1.0f, 0.0f, 0.0f); gl.glVertex3f( 0.0f, -1.5f, 0.0f ); gl.glVertex3f( 0.0f, 1.5f, 0.0f ); gl.glColor3f(0.0f, 0.0f, 1.0f); gl.glVertex3f( 0.0f, 0.0f, -1.5f ); gl.glVertex3f( 0.0f, 0.0f, 1.5f ); gl.glEnd(); gl.glFlush(); |
the output that i get is :   my question .. why cant i see the -ve part of the axis ? thanks again -ankit
|
|
|
|
|
7
|
Game Development / Newbie & Debugging Questions / OpenGl transformation question newbie
|
on: 2008-11-15 23:13:05
|
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. what i want to see is all 3 axes in something like * * * * * * * * ******************* ** * * * * * * 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| gl.glClear(GL.GL_COLOR_BUFFER_BIT|gl.GL_DEPTH_BUFFER_BIT); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); gl.glClearColor(1.0f,1.0f,1.0f,0); gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glColor3f(0.0f, 0.0f, 0.0f); gl.glBegin(GL.GL_LINES); gl.glVertex3f( -0.5f, 0.0f, 0.0f ); 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); |
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
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|