开发者

Color single pixel in XNA

Give a Coordinate, how can I color a sing开发者_开发技巧le pixel in XNA? i.e.

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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜