glColor*f vs glColor*ub

Started by
13 comments, last by Zeu5 20 years, 11 months ago
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.
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.
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.
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
______________________________Madman
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?

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.

This idea is really cool.Unfortunately the loop is also taking some time...

The PAIN is coming...this summer!!!In cinemas everywhere.
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


OpenGL immediate calls are generally very slow, try using a vertex array
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.

This topic is closed to new replies.

Advertisement