Jump to content
  • Advertisement
Sign in to follow this  
Endar

OpenGL direct x color - OGL color

This topic is 4704 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

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 = 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
Advertisement
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
Sign in to follow this  

  • 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!