Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Christoph

Color problem in .NET

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

Hi, I want to create simple coloured vertices. The problem is that DirectX expects an BGR-Integer-Value (correct me if this isnt right). None of the functions in VB .NET returns such an integer (neither Color.ToARGB nor RGB()), which means that all colors are presented in a wrong way. Does anybody know how I can pass a color stored in a color object, so that it is readable for DX? Or can you describe a function which creates an integer from 3 Byte-Values (Red, Green and Blue)? Thank you!

Share this post


Link to post
Share on other sites
Advertisement
hm, that wuld be nice; but it definitely does not work.

Filling the backbuffer with green is no problem

d3dDev.Clear(ClearFlags.Target Or ClearFlags.ZBuffer, Color.Green, 1.0F, 0.0F)

But this

Dim v As CustomVertex.PositionColored() = CType(vb.Lock(0, 0), CustomVertex.PositionColored())
v(cnt).Color = Color.Green.ToArgb

produces a very dark green. I now realized that all colors are presented too dark. What could be the mistake? I don''t use lighting or materials...

Share this post


Link to post
Share on other sites
Color.Green is not 0x00FF00. It's a color Microsoft created, so to speak.

Why not just 0x00FF00 instead? Most (All?) Direct3D C# methods give you the option for Drawing.Color or int. If you want to use the color class that much:

Color.FromArgb(0, 255, 0).ToArgb();

** EDIT **
What about lighting (Ambient light, etc.)

[edited by - Nullmind on May 7, 2004 1:22:19 PM]

Share this post


Link to post
Share on other sites
I have the solution. Before rendering the coloured vertices, I have to call d3dDevice.SetTexture (0, Nothing)
But why does DX consider textures when rendering vertices without texture coordinates???

Share this post


Link to post
Share on other sites
quote:
Original post by Christoph
I have the solution. Before rendering the coloured vertices, I have to call d3dDevice.SetTexture (0, Nothing)
But why does DX consider textures when rendering vertices without texture coordinates???


It considers textures because it was configured to do so. If you look at the Texture Stage States the default is to modulate the colour by the texture. If you want the colour to come solely from the diffuse colour, then configure it to do so.


Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites

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