floats and ints
While it''s not necessary, I want to store my position and rotation as int''s(''unsigned long int'' is even better for position) but glTranslate() and glRotate() only seem to take floats and doubles. Custom matrices also seem to take only floats. So, any ideas other than int to float conversion?
most gl calls that have parameters such as glTranslate and glRotate.. allow you to change the parameters. However you could always caste(sp), but Im not sure of the speed loss when constantly casting too and from a value type
glTranslate3d(..);
3 doubles
or glTranslate2i(..);
2 integers. etc. Im pretty sure that works, just experiment.
as far as unsigned ints and and all the other special types aren''t directly supported, at least I believe so.
glTranslate3d(..);
3 doubles
or glTranslate2i(..);
2 integers. etc. Im pretty sure that works, just experiment.
as far as unsigned ints and and all the other special types aren''t directly supported, at least I believe so.
any ogl function that accepts ints will convert to floats internally - look in the msdn for things like glColor3i, or glVertex3i, etc.
Even if there were a glTranslatei( there''s only f and d ), it''d still convert to float.
Just my 2cp
-- Succinct 8Þ
Even if there were a glTranslatei( there''s only f and d ), it''d still convert to float.
Just my 2cp
-- Succinct 8Þ
Just to put in some arbitrary boundaries for the game world. The plan was that each whole integer would represent a tenth of a millimeter, giving approximately 430 km of space.
casting from integers to floats is often a fairly expensive operation, not what you want for an optimized graphics routine. Why do you want to do this, anyway?
EDIT: if you're trying to set boundaries for your world, this is the WRONG way to do it. Trying to bound things by minimum/maximum integers will merely lead to constant, hard-to-find overflow bugs.
Don't listen to me. I've had too much coffee.
[edited by - sneftel on December 13, 2002 11:39:40 PM]
EDIT: if you're trying to set boundaries for your world, this is the WRONG way to do it. Trying to bound things by minimum/maximum integers will merely lead to constant, hard-to-find overflow bugs.
Don't listen to me. I've had too much coffee.
[edited by - sneftel on December 13, 2002 11:39:40 PM]
quote:Original post by Anonymous Poster
arbitrary boundaries
2^32 seemed a good number as any, as you can tell, the design has not progressed significantly
int to float conversion isn''t that slow, actually. Float to int is slow. Still, most 3D hardware will internally convert anything to floating point, so there is not much point in using intergers externally. Note that most 3D cards will do the floating point conversion on the GPU, which is actually very fast.
Integers have a great advantage over floating point values, which might justify their use in some very special cases: the delta between two values is independent of their scale. Ie. the ''space'' between two successive values will always be 1 unit, if the value is 10 or 1 billion. That''s not the case with floating point numbers: the delta between two representable values will increase, as their value increases. In other words: floating point values lose gradually precision, the higher the value they represent.
However, because of the implicit floating point conversion most consumer level hardware applies, the above advantage of fixed point coordinates is lead ad absurdum.
So in conclusion: use floats.
/ Yann
Integers have a great advantage over floating point values, which might justify their use in some very special cases: the delta between two values is independent of their scale. Ie. the ''space'' between two successive values will always be 1 unit, if the value is 10 or 1 billion. That''s not the case with floating point numbers: the delta between two representable values will increase, as their value increases. In other words: floating point values lose gradually precision, the higher the value they represent.
However, because of the implicit floating point conversion most consumer level hardware applies, the above advantage of fixed point coordinates is lead ad absurdum.
So in conclusion: use floats.
/ Yann
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement