3

I'm drawing a Texture2D like this

//background_texture is white in color
spritebatch.Draw(content.Load<Texture2D>("background_texture"), 
     new Rectangle(10, 10, 100, 100),
     Color.Red)

The texture is white; however, on screen it's displayed as red.

Why is the draw method requiring a Color?
How does one simply draw the texture, and only the texture without having Color.something distort the graphic?

0

3 Answers 3

5

take a look at the documentation here: http://msdn.microsoft.com/en-us/library/ff433986.aspx

you want to try Color.White, that additional parameter of a color typically refers to a tint, while a white "tint" should display the sprite without a tint

2
  • Requiring a tint is plain silly in my mind. Why not just have another overload method without a Color parameter, so we can have some options here, what's the with unnecessary Color.white? And what if someone wanted a white tint? But thanks though
    – cblupo
    Jul 22, 2014 at 16:24
  • What do you believe "a white tint" is? Jul 22, 2014 at 17:35
1

Color.White does not change the color of your image. Use

spritebatch.Draw(content.Load<Texture2D>("background_texture"), 
 new Rectangle(10, 10, 100, 100),
 Color.White);

Instead of Color.Red, which applies a tint.
Note: Be careful. Intellisense will want to make this Color.Wheat, so be sure to type the first 3 letters before you hit space.

-1

Color.White is uneccesary because in default sprite shader it looks like this:

PixelShader.... { ....

return Texture * Color; }

Where color is Color that is given from Vertex shader defined by that Color in spritebatch.Draw... if it would be null, black, it would create invisible sprites. Whole point is that by this you set vertex color of each vertex that is used as multiplicative to texture you set for sprite.

1
  • How's that "unnecessary" if it's a mandatory API parameter?
    – ForNeVeR
    Dec 24, 2022 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.