Description
The GrabFrameTexture
method in the Sandbox.Graphics
class is used to create a render target texture from the current frame. This method is useful for capturing the current frame's rendering output into a texture, which can then be used for various post-processing effects or for saving the frame as an image.
Usage
To use the GrabFrameTexture
method, you need to provide the following parameters:
targetName
(string): The name of the render target. This is used to identify the texture within the rendering system.
renderAttributes
(RenderAttributes): A set of attributes that define how the rendering should be performed. This includes settings like resolution, format, and other rendering options.
withMips
(bool): A boolean value indicating whether mipmaps should be generated for the texture. Mipmaps are useful for improving texture quality at different distances and angles.
The method returns a RenderTarget
object, which represents the captured frame texture.
Example
// Example of using GrabFrameTexture
string targetName = "MyRenderTarget";
RenderAttributes renderAttributes = new RenderAttributes
{
// Set desired attributes
};
bool withMips = true;
RenderTarget frameTexture = Sandbox.Graphics.GrabFrameTexture(targetName, renderAttributes, withMips);
// Use the frameTexture for further processing or rendering