Jump to content
  • Advertisement
Sign in to follow this  
oliver_mpt

OpenGL Newbie color question

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

Hello ! I'm new to DirectX, coming from OpenGL. I've noticed that 3D objects must have a color parameter for each vertex. In the case of an object with uniform color, I would like to change its color, in order to redraw it several times with different colors. Is there a way without changing the color in all vertices ? it seems pretty inneficient to me. In particular, we have the option to store the vertex and index buffers in different memories to optimize loading speed. In that case accessing to all vertices to change color is particularly not efficient. Is there something like glColor in OpenGL that allow me to change the current color - DO I need absolutely to store it in ALL vertex ? regards, Olivier

Share this post


Link to post
Share on other sites
Advertisement
Are you referring to the fixed function pipeline?

IMHO the best solution is to write a simple shader.
Don't use the vertex color, set a float4 parameter and in the pixel shader just output that color.

Share this post


Link to post
Share on other sites
You don't *have* to have colour per vertex, unless you are using the fixed function pipeline to render with. You could have a vertex structure like this...

float x, y, z; // Position
float nx, ny, nz; // Normal

And then use a shader to render with what ever colour you like.

If you *are* using the FFP then I think the only way is with vertex format...

float x, y, z; // Position
float nx, ny, nz; // Normal
DWORD colour; // Colour

Which means changing each vertex colour before rendering - which shouldn't be a major problem depending on how many vertices you are dealing with.

For the most efficient way, I think go the shader route - FFP rendering is becoming obsolete.

Share this post


Link to post
Share on other sites
Hi,

With FFP you can use the material parameters to change the object color. No need to have per-vertex color.

Cheers!

Share this post


Link to post
Share on other sites
Hello

Thanks for all the answers,

I'm not sure I unsderstand, though.
doest it read FFP = directX9 and shader route = DX10 ?

I need absolutely Windows XP compatibility, so as far as I understand no DX10.

can you clarify a bit for me ? (I told you: newbie question ;-))

Oliver

Share this post


Link to post
Share on other sites
No shaders have been around for a while I think since D3D8 even...so you can have shaders in D3D9 no need for D3D10...until tomorrow...then D3D11...D3D12 etc :)

Share this post


Link to post
Share on other sites
Quote:

I'm not sure I unsderstand, though.
doest it read FFP = directX9 and shader route = DX10 ?

Not exactly.

DirectX9 = FFP or shaders, depends on what you decide to use.
DirectX10 = shaders, there's no FFP.

Share this post


Link to post
Share on other sites
For D3D9, I'd suggest using pixel shaders whether you use FFP or shaders for the vertices. They're simply a lot easier to understand and program than texture stages.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!