To glTranslate, or not to glTranslate
Looking back on tutorials, many use the glTranslate command to move the imaginary center so that they used vertices that are more size oriented (they never change unless the object gets larger or smaller) whereas I'm just using glVertex and using the absolute values of my object.
Which way do you use/Which way is better for efficiency and uses?
Which way do you use/Which way is better for efficiency and uses?
Every single vertex is always transformed with both the modelview and projection matrix (even if they are the identity matrices) regardless of the vertex's position, so there is no difference in efficiency. You should use whatever is more convenient for you to think about.
Suppose I wanted to be able to rotate my objects. How complicated would it be to simply use the absolute coordinates to do such? I suppose it would be much easier doing glTranslate and glRotate for that but I'm rather partial to absolute coordinates.
If you wanted to rotate your objects ahead of time, you would just figure out the rotation matrix you wanted to use and then just multiply each vertex by the matrix yourself instead of having OpenGL do it. Of course, if you did this every frame yourself, it would be less efficient than if OpenGL had done it for you.
Having all your vertices in absolute world coords can make things like shadows easier in some cases.
Kelvin
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Rotating your vertexes manualy takes 3D vector math...
(but you probebly knew that)
Me too...
I hate having to use the glRotatef function...
I mostly just use it those for camera functions.
I very rarely use glTranslatef (only if I need to rotate objects around there center)...
Just a thought, but wouldn't each and every video card have different efficiency.
Like I said I don't try to use the translation calls except glRotatef with
camera functions.
(but you probebly knew that)
Nick Wrote:I'm rather partial to absolute coordinates
Me too...
I hate having to use the glRotatef function...
I mostly just use it those for camera functions.
I very rarely use glTranslatef (only if I need to rotate objects around there center)...
Quote:Which way do you use/Which way is better for efficiency and uses?
Just a thought, but wouldn't each and every video card have different efficiency.
Like I said I don't try to use the translation calls except glRotatef with
camera functions.
Global warming is caused by hobos and mooses
BinarySpike Wrote:Just a thought, but wouldn't each and every video card have different efficiency.
No. Unless I'm greatly mistaken, OpenGL's vertex transformations happen on the CPU.
 Alex Diener
I thought it happened on the GPU, since most new games require HT&L support, or Hardware Transform and Lighting. I presume that means that the coordinates are transformed on the GPU :/
â€”
BearIsCoding
perhaps I'm misunderstanding, or perhaps you're greatly mistaken
hardware transform and lighting cards (geforces, radeons) do the vertex transformations in hardware.
hardware transform and lighting cards (geforces, radeons) do the vertex transformations in hardware.
*except Radeon 7000.
You learn something new every day, I guess. My mistake.
 Alex Diener.
 Alex Diener.
Nick Wrote:Suppose I wanted to be able to rotate my objects. How complicated would it be to simply use the absolute coordinates to do such? I suppose it would be much easier doing glTranslate and glRotate for that but I'm rather partial to absolute coordinates.
Unless you were doing some wierd vertex level stuff  like morphing  it would actually be quite a waste of OpenGL to use anything other than glTranslate, glRotate and glScale.
1. All vertices are passed through the projection matrix and the model view matrix, whether you use glTranslate, glRotate, or glScale or not. glTranslate, glRotate, and glScale merely allow you to set up the model view matrix. Just because you don't use them, doesn't actually mean you're bypassing OpenGL's matrix operations. Think of the model view matrix as an accumulator. Each time you use glTranslate, glRotate, or glScale, you're accumulating transformations. Let's say you start out with the identity matrix, I, and you apply a scaling, S, a rotation, R, and a translation, T. To get the final result, you get a model view matrix which is the matrix product M = TRSI. All these transformations are "accumulated" into the model view matrix, M, and it is this transformation matrix that is applied to each vertex, not the 4 individual I, S, R, and T matrices.
2. If you just use glVertex, and do all the matrix math yourself, you will have to maintain two copies of your geometry  one to keep the original geometry, and one to hold the transformed geometry. Otherwise, due to finite precision, your geometry will deform after iterative transformations, as you seem to have observed in another post. And even then, the transformed vertices will still each go through the model view matrix. This means that you are performing a lot of extra work for nothing. As an exercise in linear algebra, it may be interesting, but unless you were writing the rendering engine from the bit up, it's really not the way to go.
3. OpenGL's matrix operations are optimized and probably leverage fast vector operations on the PowerPC and graphics cards.
Possibly Related Threads...
Thread:  Author  Replies:  Views:  Last Post  
glRotate,glTranslate problems  PowerMacX  4  3,694 
Jan 19, 2004 12:03 AM Last Post: kelvin 

glRotate and glTranslate are messing up my lighting?!?  Jake  5  4,036 
Oct 17, 2003 01:08 PM Last Post: MacFiend 