Matrix vs. openGL calls

Started by
4 comments, last by waterlink2002 21 years, 11 months ago
Hi! openGL internally use matrices to implement its operations as move, scale or rotate. But i''ve read some docs about the use of matrices (like this one http://skal.planet-d.net/demo/matrixfaq.htm#Q4) I don''t understand completly some thing. It is that if a want to make (ie.) a rotation why not to make a simply call to glRotatef(...) instead of implementing all those thing about matrices and so and operation function such CMatrix::operator* etc, etc. openGL internally use matrices, so the simple question is, its necesary for me to implement something about matrices or can I use glRotatef (ie.). Thanks! Sorry my english.
Advertisement
The fact is you can use matrices for many other things than just throwing graphics at the screen. You can use them for moving things about, targetting etc. for this you actually need at least a copy of the matrix in your programs memory. While it is possible to get matrices from OpenGL, it is typically very slow so it is better to maintain matrices you need in your program (and do any operations on them there) and then pass them off to the GL. However if your program doesn''t need to use matrices other than for viewing then don''t bother and keep them all in the GL.

To answer your question in short - no there is no need to implement matrix math unless it turns out you need to. (almost circular )
Thanks JuNC.

Now I have another point of view of these things about matrices. Thanks again.
quote:
While it is possible to get matrices from OpenGL, it is typically very slow so it is better to maintain matrices you need in your program (and do any operations on them there) and then pass them off to the GL.


I''m very interested about this, do you have more informations about it? Do you mean we should never use the glRotate, glMultMatrix functions or is using the openGL inner matrices is only slow because of the the glGet overhead for copying the matrix data?
quote:Original post by Diodor
I''m very interested about this, do you have more informations about it? Do you mean we should never use the glRotate, glMultMatrix functions or is using the openGL inner matrices is only slow because of the the glGet overhead for copying the matrix data?


glRotate(), glMultMatrix(), ... functions are fine (moreover, they may be T&L accelerated). But calling glGet() is slow, like any function retrieving data from the video card.
quote:
glRotate(), glMultMatrix(), ... functions are fine (moreover, they may be T&L accelerated). But calling glGet() is slow, like any function retrieving data from the video card.


Yep, thats exactly what I meant, maybe I didn''t phrase it very well, I wasn''t saying don''t use glRotate etc (I do all the time).

This topic is closed to new replies.

Advertisement