Sign in to follow this  
Endar

OpenGL direct x color - OGL color

Recommended Posts

Just wondering about the color format direct x. I'm currently using openGL and whenever I'm specifying an array of color elements for use with vertex arrays, I always need to run this loop:
// convert colors into a format OGL understands (from a single int,
// to a series of chars)
for(int i=0; i < vertex_count*4; i+=4){
	color_buffer[i] = v[i/4].color.getRed();
	color_buffer[i+1] = v[i/4].color.getGreen();
	color_buffer[i+2] = v[i/4].color.getBlue();
	color_buffer[i+3] = v[i/4].color.getAlpha();
}
Because the format that my color objects are in is ARGB, whereas OpenGL uses RGBA. What does direct x use? The reason why I'm wondering is that is would undoubtedly be easier/faster to just change the internal format of my color object to RGBA and instead of the loop above, just assign it an int at a time. I mean, it's probably not a bottleneck now, but it might be in the future and I'd rather optimise all the small things now, and a big thing later, than all the small things and big things later. Edit:: Second question: if you're using lighting, does everything have to have a material applied to it? (using OGL if it matters) Because I just finished my md2 loader, so do I have to go back and add a material to it, or will it work just fine with only the normals and nothing extra? [Edited by - Endar on December 5, 2005 5:19:26 AM]

Share this post


Link to post
Share on other sites
DirectX uses the ARGB convention.
May I ask why you need to know how DirectX work when you're using OpenGL ? Because if OpenGL is using RGBA and you're developing for OpenGL, then you should store your data as RGBA, it would be easier / faster, no ?

Share this post


Link to post
Share on other sites
I'm planning to learn direct x later on when I can use openGL "fluently". So, I was just wondering because I'll be re-using most of the current support/util code for my engine.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this