How can I use a Shader in XNA to color single pixels?

Posted by George Johnston on Stack Overflow See other posts from Stack Overflow or by George Johnston
Published on 2010-04-03T02:00:22Z Indexed on 2010/04/03 2:03 UTC
Read the original article Hit count: 388

Filed under:
|

I have a standard 800x600 window in my XNA project. My goal is to color each individual pixel based on a rectangle array which holds boolean values. Currently I am using a 1x1 Texture and drawing each sprite in my array.

I am very new to XNA and come from a GDI background, so I am doing what I would have done in GDI, but it doesn't scale very well. I have been told in another question to use a Shader, but after much research, I still haven't been able to find out how to accomplish this goal.

My application loops through the X and Y coordinates of my rectangular array, does calculations based on each value, and reassigns/moves the array around. At the end, I need to update my "Canvas" with the new values. A smaller sample of my array would look like:

0,0,0,0,0,0,0
0,0,0,0,0,0,0
0,0,0,0,0,0,0
1,1,1,1,1,1,1
1,1,1,1,1,1,1

How can I use a shader to color each pixel?

© Stack Overflow or respective owner

Related posts about XNA

Related posts about c#