Jump to content
  • Advertisement
Sign in to follow this  
deathkrush

OpenGL DirectX equivalent of glColor4f?

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

Does anybody know if there is a function in DirectX that does the same thing as a call to glColor4f in OpenGL? Basically, I want to do stuff like:
device.RenderState.Lighting = false; //disable lighting

if(collided)
   glColor4f(1.0f,0.0f,0.0f,1.0f);
else
   glColor4f(1.0f,1.0f,1.0f,1.0f);
collisionSphere.DrawSubset(0); //draw the collision sphere

device.RenderState.Lighting = false; //enable lighting

//draw scene normally
...

DirectX has per-vertex colors using PositionColored format, but that doesn't help me. I want to be able to quickly disable lighting and set a constant color for all vertices like in OpenGL. I'm doing this in C# and DX9.0, but anything in C++ would help as well. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
If you're using pixel shaders, use a shader parameter for that. If you're using texture stages, you can use the texture factor (D3DTA_TFACTOR and D3DRS_TEXTUREFACTOR in C++).

Share this post


Link to post
Share on other sites
Quote:
Original post by ET3D
If you're using pixel shaders, use a shader parameter for that. If you're using texture stages, you can use the texture factor (D3DTA_TFACTOR and D3DRS_TEXTUREFACTOR in C++).


I'm not using shaders and multitexturing. Actually, I would rather disable textures while drawing single color geometry.

Share this post


Link to post
Share on other sites
Texture stages aren't "multitexturing". Texture stages, like pixel shaders, are simply a way to define a colour output based on parameters like texture coordinates, vertex colours and global colours. Once you understand that, and that you *have* to use them (since you have to define what the output colour will be) life will be easier.

The "fixed function" pixel pipeline, defined using texture stages, is one way to define the colour output. You can set texture stages that will output a single colour, if you want. It's very easy. So I'd suggest reading about them. Or just learn about pixel shaders, if you don't mind limiting your target hardware a bit (and the majority of cards support them).

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!