Jump to content
  • Advertisement

Archived

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

Zeu5

glColor*f vs glColor*ub

This topic is 5552 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I''m wondering about the internal rappresentation of colors in OpenGL. It is more efficient to use the floating-point version of glColor or the unsigned-byte one? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
i think ub is better because ur sending less data across (1 byte as opposed to 4 bytes for float) i''m not sure how it stores it internally though.

Share this post


Link to post
Share on other sites
quote:
Original post by _walrus
i think ub is better because ur sending less data across (1 byte as opposed to 4 bytes for float) i''m not sure how it stores it internally though.


They are clamped in range [0....1]

The PAIN is coming...this summer!!!In cinemas everywhere.

Share this post


Link to post
Share on other sites
Try benching :D

QuerryPerformanceCounter(x);
for(int i=0;i{
glColor4f(0,0,0);
glColor4f(255,255,255);
}
QuerryPerformanceCounter(y);
res=y-x;

and same for ''f'', but remember that difference should be 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
Just couldn''t stop :D

______________________________
Madman

Share this post


Link to post
Share on other sites
quote:
Original post by _Madman_
Try benching :D

QuerryPerformanceCounter(x);
for(int i=0;i{
glColor4f(0,0,0);
glColor4f(255,255,255);
}
QuerryPerformanceCounter(y);
res=y-x;

and same for ''f'', but remember that difference should be 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
Just couldn''t stop :D

______________________________
Madman


What''s it? The grade of your mental sanity?

Share this post


Link to post
Share on other sites
quote:
Original post by _Madman_
QuerryPerformanceCounter(x);
for(int i=0;i{
glColor4f(0,0,0);
glColor4f(255,255,255);
}
QuerryPerformanceCounter(y);
res=y-x;



I guess this is the benchmark relative to "glColor3ub", not "glColor4f", btw thanks for the idea.

Share this post


Link to post
Share on other sites
This idea is really cool.Unfortunately the loop is also taking some time...

The PAIN is coming...this summer!!!In cinemas everywhere.

Share this post


Link to post
Share on other sites
quote:
Original post by _Madman_
Try benching :D

QuerryPerformanceCounter(x);
for(int i=0;i{
glColor4f(0,0,0);
glColor4f(255,255,255);
}
QuerryPerformanceCounter(y);
res=y-x;

and same for ''f'', but remember that difference should be 0.000000000000000000000000000000000000000000000000000000...0001
Just couldn''t stop :D

______________________________
Madman



There would be a difference, at least in storage of color data and loading of files (since less data to load in from files, but as far as just rendering i couldn''t tell u, but since where sending less data across it is potentially faster, unless there is an interal conversion to floats between 0 and 1).

10,000 verticies using floats (4 bytes each) to store for rgba: 4*4*10,000 = ~155k

10,000 verticies using unsigned byte (1 bytes each) to store: 1*4*10,000=~39k


Share this post


Link to post
Share on other sites
OpenGL immediate calls are generally very slow, try using a vertex array

Share this post


Link to post
Share on other sites
And we get back to the question.Quake2 is based on immediate mode and i don''t find it slow.Especially when i have played it on P 120 with 16 ram and 2 mb video....

The PAIN is coming...this summer!!!In cinemas everywhere.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!