tags:

views:

165

answers:

2

Give a Coordinate, how can I color a single pixel in XNA? i.e.

Coordinate(10,11).Color = Color.Red

+3  A: 

If you're planning on doing a lot of pixels, for something like a particle system, it would be better to use a shader. You'll probably run into performance issues eventually just using a SpriteBatch.

Jim Perry
+1  A: 

There's two ways depending on what coordinates you mean:

For screen coordinates the easiest way is to have a Texture2D that holds nothing but a single white pixel, then drawing it with SpriteBatch and passing whatever color you want to the Draw method.

For 3D space coordinates you want to use a PointList.

There's a bit more complicated things you could do as well: use Texture2D.SetData to make your own single white pixel texture at run time. Or, it's also possible to use a PointList and project to screen space.

Bob