PDA

View Full Version : Need help to supply colors as unsigned char...



jobo70
02-19-2007, 07:09 AM
Hello...

I have data that have colors as unsigned char for
RGBA (from 0 to 255).

I would like to know if there is a way to supply those to glColorPointer()...

For now, unless I change the data format, the only way I can supply a color is:



glColor4f((currColor.red * ONEOVER255), (currColor.green * ONEOVER255), (currColor.blue * ONEOVER255), (currColor.alpha * ONEOVER255));No need to say that all of these conversions to float variables are not really effficient...

And unless I create a new array at run-time, with
these conversions, I cannot use glColorPointer...

Can someone help me ?

RigidBody
02-19-2007, 07:13 AM
where is the problem? you can set the second parameter, which defines the data type, to GL_UNSIGNED_BYTE.

jobo70
02-19-2007, 07:31 AM
Ok... I'll try it...

jobo70
02-19-2007, 07:47 AM
It works... Thanx. I did't tought it was so simple.

Is there a way to supply them with glColor, instead of using glColor4f ? I still some have
helper objects rendering functions that still render primitives with glBegin and glEnd, and I want to remove the conversion thing...

ehart
02-19-2007, 10:22 AM
Just use glColor4ub.

-Evan