I am playing with pyopengl (and qt) and I have some problems. I am a
newcomer to opengl and pyopengl.
I am able to draw an object and rotato/zoom/move it.
My problem now is that I'd like to draw the object in 4 viewport (no problem
here) but with different point of view.
Basically I am trying to draw the 3 basic orthogonal view (XY, XZ, YZ) and a
I am not interested in a 2D view for the orthogonal projections, since I
will need the full 3D object anyway.
Now I get this simply rotating the object around the axis as I need, but I
am not sure this is the correct thing to do.
Looking around it seems that the correct solution is to move the camera to
have the correct point of view.
So what are the correct way ? Rotate the object or move the camera ?
And if the correct way is to move the camera, where I can find a simple
My idea is to make something like this:
glViewport(0, 0, w, h)
gluLookAt(eyeX, eyeY, eyeZ,
centerX, centerY, centerZ,
upX, upY, upZ);
and then render my object
but I cannot understand if this is correct and where I must do it.
I suspect that I must do it in the display function, setting the values of
the parameters for gluLookAt in some other places (I am thinking about
of the viewport)
Is this the correct approach ? If not, where is my error ?
thanks in advance
duncan duncan wrote:
> So what are the correct way ? Rotate the object or move the camera ?
There isn't really any difference between these -- they're
just two different ways of thinking about the same thing.
If thinking in terms of rotating the object works for you,
then there's nothing wrong with that.
However, as you develop your application further, you
may find it helpful to think of the object-to-camera
transformation as consisting of two stages:
1) Transform from object to world coordinates
2) Transform from world to camera coordinates
Then you can implement operations such as "move the
object along the x axis" by changing the object-to-world
part of the transformation, and not have to worry about
what direction the x axis is pointing relative to the
Setting up such a 2-stage transformation would go something
gluPerspective(...) # or gluOrtho for an orthographic projection
gluLookAt(...) # Establish world-to-camera transform
# Render object
Note that gluLookAt is used on the modelview matrix, not
the projection matrix.