PlayStation Mobile has the ability to render to a user defined offscreen frame buffer. This can be useful for a number of reasons: rendering to a texture, doing post processing before displaying, or, as we will see in this recipe, taking a screenshot.
Load PlayStation Mobile Studio and create a new project. This time we are going to be reusing the code we created way back at the start of the chapter during Creating a Simple 3D scene. The complete project is available as Ch7_Example7
.
Using
AppMain.cs
from the earlier recipe, add the following code to themain
loop:if((GamePad.GetData(0).Buttons & GamePadButtons.Start) == GamePadButtons.Start){ var frameBuffer = new FrameBuffer(); var screenshotTexture = new Texture2D( graphics.Screen.Width, graphics.Screen.Height, false, PixelFormat.Rgba, PixelBufferOption.Renderable); frameBuffer.SetColorTarget(screenshotTexture,0); frameBuffer.SetDepthTarget(null); graphics...