use glTranslate for each primitive?

Started by
4 comments, last by Gammastrahler 22 years, 9 months ago
hello again, for my ego-shooter engine, i currently use one call to glTranslate() to move through my 3d-world. this is pretty simple, but on the other side, i need to specify the absolute coordinates for every polygon in 3d space which can be annoying... since i need to readjust 10 times in many cases..... but i wan´t to rewrite my engine so that every polygon hold a x,y,z val for position and only the dimensions in relative units. this would mean that i have to call glTranslate() for every polygon. but i think it could slow down the game, because the matrix would be recalculated for every poly each frame.... any idea? thanks & greets gammastrahler
Advertisement
quote:Original post by Gammastrahler
but i wan´t to rewrite my engine so that every polygon hold a x,y,z val for position and only the dimensions in relative units. this would mean that i have to call glTranslate() for every polygon.

You are talking about polygons. Do you not use models?
It seems like you are moving by using glTranslate and that can also be little confusing.

Some pseudo code for the standard way:

glLoadIdentity();
gluLookAt(...); // move here
for(allModels) {
glPushMatrix();
translateAndRotateModelToTheProperPlace(...);
drawModel(...);
glPopMatrix();
}



@obelix:

no, i´m currently using no models, all polygons i use are coded coordinate by coordinate in c++.

the pseudo-code you stated is exactly what i mean, but as i said, you must translate and rotate for each model or poly, and i think that would slow down the engine, does it?

thanks
gammastrahler!
Yes, it would slow down the engine if you called it for each polygon. A model has many polygons so it does not make any difference. You can always write a function that transform your new format to absolute vertex coordinates. I think that you should write a editor before you get mad by hardcoding everything.
Perhaps can a editor made for another game like Quake be used?
Why dont you use gluLookAt(); instead of translating and rotating your scene.
What about useing glTranslate to every vertex instead of every polygon

This topic is closed to new replies.

Advertisement