开发者

Color single pixel in XNA

开发者 https://www.devze.com 2022-12-24 18:20 出处:网络
Give a Coordinate, how can I color a sing开发者_开发技巧le pixel in XNA? i.e. Coordinate(10,11).Color = Color.RedIf you\'re planning on doing a lot of pixels, for something like a particle system, it

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

精彩评论

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

关注公众号