Original Post
Hello,
I am in need of some newbie help. I simply want to plot some pixels to a surface but, C# directx documentation has me confused. I am attempting to convert the Zen of Direct3d to C#, so the RenderPoints code I show below has some of that code commented out.
In my code, I think I need to:
1. Clear back buffer
2. Lock the back buffer
3. Plot the pixels onto the back buffer
4. Unlock back buffer
5. Present back buffer
My surface is 800 X 600. I am confused on how to call the
BackSurf.LockedRectangle method and then plot the pixels.
Could anyone provide some sample code of locking the backbuffer and plotting a couple of pixels that I could digest and learn from?
Here is my current code:
private void RenderPoints()
{
if (device == null)
return;
if (pause)
return;
//Clear the backbuffer to a blue color
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, System.Drawing.Color.Blue, 1.0f, 0);
device.BeginScene();
// Get back buffer
Surface BackSurf;
BackSurf = device.GetBackBuffer(0,0, Microsoft.DirectX.Direct3D.BackBufferType.Mono);
/* Lock the back buffer
No idea what to do here. Dont understand the ranks, typelock
and and what LockRectangle array is returning.
*/
//byte[] data = BackSurf.LockRectangle(?????);
/* Set 10,000 pixels at random locations to a shade of red
Not sure yet what to do, but when i figure out lockedrectangle, will turn my attention to this.
*/
// Unlock the back buffer
BackSurf.UnlockRectangle(0);
// Release the back buffer
BackSurf.ReleaseGraphics();
// Present the back buffer to the primary surface
//End the scene
device.EndScene();
device.Present();
}