Re: [PyOpenGL-Users] get Translation inside matrix stack
Brought to you by:
mcfletch
From: Black <py...@bl...> - 2008-07-22 19:18:30
|
When you use build a display list using GL_COMPILE, the various state variables aren't affected, the commands themselves are just being stored. Since glGet is one of the commands that isn't stored, it gets executed immediately and you have the problem you are seeing. You can try GL_COMPILE_AND_EXECUTE. I tend not to use it as it doesn't work on the system that I use, but it might work for you. Since it is executing the OpenGL commands as they are stored, glGet should get the correct result. The bigger question to ask is what you are using the information for? The glGet won't be stored, so the effect will be the same as keeping track of it yourself. However, if you are trying to get changing behavior out of your display list based on conditions outside of it, display lists are probably not the right answer anyway... On Jul 22, 2008, at 1:12 PM, Prashant Saxena wrote: > Thanks, > > Yes, I am doing this inside the glNewList(GL_COMPILE). > Is there any way to solve the problem or do I calculate manually? > > > ----- Original Message ---- > From: Black <py...@bl...> > To: pyo...@li... > Sent: Tuesday, July 22, 2008 10:24:27 PM > Subject: Re: [PyOpenGL-Users] get Translation inside matrix stack > > Two quick things to check: > a) Is the MODELVIEW matrix the current matrix (i.e., the one being > affected by the glTranslates)? > If not, well, it should be > b) Are you doing this while constructing a display list with > glNewList(GL_COMPILE)? > If so, the matrix isn't being updated and this won't work > > On Jul 22, 2008, at 12:32 PM, Prashant Saxena wrote: > > > I am sorry but I didn't get any success with your code. I tried > this: > > > > glPushMatrix() > > glTranslate(5,0,0) > > glTranslate(10,0,0) > > glTranslate(5,0,0) > > # To get total increment of x axis(which is 5+10+5=20) > > modelview = glGetFloatv( GL_MODELVIEW_MATRIX ) > > print modelview > > glPopMatrix() > > > > but I am getting this: > > [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], > > [0.0, 0.0, 0.0, 1.0]] > > Which does,'t solve my problem. > > > > ----- Original Message ---- > > From: Prashant Saxena <ani...@ya...> > > To: Gary Herron <gh...@is...> > > Sent: Tuesday, July 22, 2008 9:59:38 PM > > Subject: Re: [PyOpenGL-Users] get Translation inside matrix stack > > > > I am sorry but I didn't get any success with your code. I tried > this: > > > > glPushMatrix() > > glTranslate(5,0,0) > > glTranslate(10,0,0) > > glTranslate(5,0,0) > > # To get total increment of x axis(which is 5+10+5=20) > > modelview = glGetFloatv( GL_MODELVIEW_MATRIX ) > > print modelview > > glPopMatrix() > > > > but I am getting this: > > [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], > > [0.0, 0.0, 0.0, 1.0]] > > Which does,'t solve my problem. > > > > > > ----- Original Message ---- > > From: Gary Herron <gh...@is...> > > Cc: pyo...@li... > > Sent: Tuesday, July 22, 2008 8:48:24 PM > > Subject: Re: [PyOpenGL-Users] get Translation inside matrix stack > > > > Shantytown Saxena wrote: > > > > > > glPushMatrix() > > > glTranslate(5,0,0) > > > glTranslate(10,0,0) > > > glTranslate(5,0,0) > > > # How do I get here total increment of x axis(which is 5+10+5=20) > > > before I Pop up. > > > glPopMatrix() > > > > All the transformations are recorded by OpenGL in a 4x4 matrix. > > You can recover that matrix like this: > > > > buff = (ctypes.c_double*16)() > > pyglet.gl.glGetDoublev(stack, buff) > > > > If you started with the identity and did no other transformations > > you'll > > find the 20 in that 4x4 array. > > > > In either the [0,3] or [3,0] element. (I've forgotten which way > > Opengl > > stores the array now.) > > > > Gary Herron > > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > > > > ------------------------------------------------------------------------- > > > This SF.Net email is sponsored by the Moblin Your Move Developer's > > challenge > > > Build the coolest Linux based applications with Moblin SDK & win > > great prizes > > > Grand prize is a trip for two to an Open Source event anywhere in > > the world > > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > > > > > ------------------------------------------------------------------------ > > > > > > _______________________________________________ > > > PyOpenGL Homepage > > > http://pyopengl.sourceforge.net > > > _______________________________________________ > > > PyOpenGL-Users mailing list > > > PyO...@li... > > > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > > > > > > > > > > ------------------------------------------------------------------------- > > This SF.Net email is sponsored by the Moblin Your Move Developer's > > challenge > > Build the coolest Linux based applications with Moblin SDK & win > > great prizes > > Grand prize is a trip for two to an Open Source event anywhere in > > the world > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > _______________________________________________ > > PyOpenGL Homepage > > http://pyopengl.sourceforge.net > > _______________________________________________ > > PyOpenGL-Users mailing list > > PyO...@li... > > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > > > > > > > ------------------------------------------------------------------------- > > This SF.Net email is sponsored by the Moblin Your Move Developer's > > challenge > > Build the coolest Linux based applications with Moblin SDK & win > > great prizes > > Grand prize is a trip for two to an Open Source event anywhere in > > the world > > http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________ > > PyOpenGL Homepage > > http://pyopengl.sourceforge.net > > _______________________________________________ > > PyOpenGL-Users mailing list > > PyO...@li... > > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > > |