Archived

This topic is now archived and is closed to further replies.

caesar4

faster glColor#f()?

Recommended Posts

caesar4    100
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
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."

Share this post


Link to post
Share on other sites
caesar4    100
thanks

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."

Share this post


Link to post
Share on other sites
Myopic Rhino    2315
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.

Share this post


Link to post
Share on other sites
blizzard999    268
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

Share this post


Link to post
Share on other sites
Null and Void    1088
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.

Share this post


Link to post
Share on other sites
hplus0603    11347
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.

Share this post


Link to post
Share on other sites
caesar4    100
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!

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]

Share this post


Link to post
Share on other sites