Thanks for anticipation! MatrixMode is not the problem , even i tried. The current matrix mode is already in ModelviewMode.
the problem i have is, i want some thing like this
---------------
Do standard intialization of OpenGL...
Create and BeginList list1;
Add some drawing commands in the display list1 with default transformation Modelview matrix (1)
Load a custom Modelview matrix
add more more drawing commands with custom modelview in the same display list1 (this draws fine)(2)
End Display list1
---------------
The paint function, which is called on each paintwindow call,
--------------------
do some translation/transformation
Call list1;
---------------------
And later, on a mouse handler function ,
-----------------
Clear every thing ;
some calls to gltranslate, glRotate, etc
Call the display list1 again
----------------------
Now in the mouse handler function, the rotation/scaling/transformation applied to the Current modelview matrix are reflected in the drawing at level. But not in the drawing drawn at level 2.
The drawing at level 2 remeins always static..does not moves or accepts any transformation further applied.
How could i do so ?
The problem seem to me that, the modelview matrix i load, does not accept transformations later, like calls to glRotate etc. Why could it be so ?
Any idea?
problem with glLoadMatrix
Ah, now I see the problem :)
Notice that glLoadMatrix function _replaces_ the current matrix! Perhaps you want to apply a glMultMatrix instead, hence applying the 2nd transformation w/o dropping the 1st one. But notice that in that case the transformation of stage (2) local, i.e. it is applied before the current MODELVIEW matrix when entering the routine.
Notice that glLoadMatrix function _replaces_ the current matrix! Perhaps you want to apply a glMultMatrix instead, hence applying the 2nd transformation w/o dropping the 1st one. But notice that in that case the transformation of stage (2) local, i.e. it is applied before the current MODELVIEW matrix when entering the routine.
Quote:Original post by Tahir
The problem seem to me that, the modelview matrix i load, does not accept transformations later, like calls to glRotate etc. Why could it be so ?
To clarify my previous post a bit: If you apply a composed transformation like this one (notice the order!)
glTranslatef(...);
glRotatef(...);
glVertex3f(p.x,p.y,p.z);
to a point p then its mathematical equivalent is (notice that I use column vectors as usual for OpenGL)
T * R * p
where T denotes the translation and R the rotation, then the effect is that the point p is 1st rotated by R and the result is then translated by T (although OpenGL does this in 1 step).
Hence, if you do this
glTranslatef(...);
glRotatef(...);
glMultMatrix(...);
glVertex3f(p.x,p.y,p.z);
then your own matrix is applied 1st, and the already pushed translation and rotation acts on the result your own transformation has left.
[Edited by - haegarr on November 24, 2006 7:19:58 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement