Description
The GetTemporary
method is a static method of the RenderTarget
class in the Sandbox namespace. It is used to create a temporary render target with specified dimensions, color and depth formats, multisampling, and mipmap levels. This method is useful for rendering operations that require off-screen rendering to textures.
Usage
To use the GetTemporary
method, you need to specify the width and height of the render target, the color and depth formats, the multisample amount, and the number of mipmap levels. The method returns a RenderTarget
object that can be used for rendering operations.
Once you are done using the temporary render target, it is important to call the Dispose
method on the RenderTarget
instance to release the resources and return it to the pool.
Example
// Example of using GetTemporary to create a render target
int width = 1024;
int height = 768;
ImageFormat colorFormat = ImageFormat.RGBA8;
ImageFormat depthFormat = ImageFormat.Depth24;
MultisampleAmount msaa = MultisampleAmount.None;
int numMips = 1;
RenderTarget renderTarget = RenderTarget.GetTemporary(width, height, colorFormat, depthFormat, msaa, numMips);
// Use the renderTarget for rendering operations
// Once done, dispose of the render target
renderTarget.Dispose();