quote: Dick''s Lemma: "Just because you`re paranoid doesn`t mean they`re not out to get you." The Programmer''s dilemma: "Programming is like sex: One mistake and you''re providing support for a lifetime."
faster glColor#f()?
facts:
the glColor#f() functions take floats
the video can have a max bpp of 32 bits, 8 alpha, 8r,8g,8b
converting float to a byte takes CPU CYCLES
questions:
i have been unable to find a usable OpenGL 1.2 function reference and don''t know for any other alternatives
if any, can someone pleez enlighten me
thanks
by the way do you know how much faster is it?
by the way do you know how much faster is it?
quote:
Dick''s Lemma:
"Just because you`re paranoid doesn`t mean they`re not out to get you."
The Programmer''s dilemma:
"Programming is like sex: One mistake and you''re providing
support for a lifetime."
Internally, OpenGL stores all color values as floats, and only converts them to integers when actually updating the color buffer. By using one of the integer versions of glColor(), you''re *causing* extra work, not saving it.
quote:Original post by Myopic Rhino
Internally, OpenGL stores all color values as floats, and only converts them to integers when actually updating the color buffer. By using one of the integer versions of glColor(), you''re *causing* extra work, not saving it.
However you pass 3,4 bytes instead of 12,16 to video card...the conversion on video card can be fast
Read Myopic''s post again. The driver will decide what format the video card wants the data in and the variety of glColor you call will likely not have an effect on the eventual conversion that is done to pass the data to the video card. The OpenGL implementation should store the data as floats no matter what format the video card wants. General advice: pass the color to OpenGL in the format you store it in with a preference towards using floating point data for that.
If you''re going to be passing lots of color information to the video card: you should be using vertex arrays (in whatever format you choose to store it, given memory constraints) or vertex buffer objects anyway.
If you''re going to be passing lots of color information to the video card: you should be using vertex arrays (in whatever format you choose to store it, given memory constraints) or vertex buffer objects anyway.
Btw, I did some testing on this, and using floats was about 5-10% faster than anything else, which is completely consistent with what I said.
If you''re calling glColor at all, you''re clearly not on the fast path. glDrawRangeElements() with enabled arrays for the vertex elements you use is the fast path.
Also, the GL behaves AS IF it''s storing floats. However, whatever it does internally varies greatly by implementation. One possible implementation is to first convert to floats to be able to answer the query for current color, and then sending the color to the hardware in the hardware native format, which may be 10 bits fixed precision for all you know.
Storing colors as unsigned bytes in a vertex array is the fastest way to get lots of colored vertices to the card -- it is faster than storing then as floats in the same vertex array.
Also, the GL behaves AS IF it''s storing floats. However, whatever it does internally varies greatly by implementation. One possible implementation is to first convert to floats to be able to answer the query for current color, and then sending the color to the hardware in the hardware native format, which may be 10 bits fixed precision for all you know.
Storing colors as unsigned bytes in a vertex array is the fastest way to get lots of colored vertices to the card -- it is faster than storing then as floats in the same vertex array.
thanks alot (not sarcastically)
saved me much work as this problem was caught early in my project's development.
the furum system of knowledge works!
[edited by - caesar4 on January 6, 2004 7:20:53 PM]
saved me much work as this problem was caught early in my project's development.
the furum system of knowledge works!
quote:
Dick's Lemma:
"Just because you`re paranoid doesn`t mean they`re not out to get you."
The Programmer's dilemma:
"Programming is like sex: One mistake and you're providing
support for a lifetime."
[edited by - caesar4 on January 6, 2004 7:20:53 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement