Class Framebuffer
Namespace: ValveResourceFormat.Renderer
Assembly: Renderer.dll
OpenGL framebuffer object with color and depth attachments.
public class FramebufferInheritance
Derived
Constructors
Framebuffer(string)
Creates a new named OpenGL framebuffer object.
public Framebuffer(string name)Parameters
name string
Debug label applied to the framebuffer object.
Properties
ClearColor
Color used to clear the color attachment.
public Color4 ClearColor { get; set; }Property Value
ClearMask
Buffer bits cleared when is called.
public ClearBufferMask ClearMask { get; set; }Property Value
ClearBufferMask
Color
Color attachment texture, or null if none.
public RenderTexture? Color { get; protected set; }Property Value
ColorFormat
Pixel format of the color attachment.
public ImageFormat? ColorFormat { get; protected set; }Property Value
Depth
Depth attachment texture, or null if none.
public RenderTexture? Depth { get; protected set; }Property Value
DepthFormat
Pixel format of the depth attachment.
public ImageFormat? DepthFormat { get; protected set; }Property Value
DepthLayers
Number of layers of the depth attachment. More than one allocates it as a texture array; use to select the layer rendering writes to.
public int DepthLayers { get; set; }Property Value
FboHandle
OpenGL framebuffer object handle.
public int FboHandle { get; }Property Value
GLDefaultFramebuffer
Creates a instance wrapping the default OpenGL framebuffer (handle 0).
public static Framebuffer GLDefaultFramebuffer { get; }Property Value
Height
Height of the framebuffer in pixels.
public int Height { get; protected set; }Property Value
InitialStatus
Framebuffer completeness status set after is called.
public FramebufferErrorCode InitialStatus { get; }Property Value
FramebufferErrorCode
Name
Debug name of the framebuffer, also applied as its object label.
public string Name { get; }Property Value
NumMips
Number of mip levels for color attachments.
public int NumMips { get; set; }Property Value
NumSamples
Number of MSAA samples; 0 means no multisampling.
public int NumSamples { get; set; }Property Value
Target
Texture target used for attachments ( or ).
public TextureTarget Target { get; protected set; }Property Value
TextureTarget
TargetState
The framebuffer target this object was last bound to.
public FramebufferTarget TargetState { get; set; }Property Value
FramebufferTarget
Width
Width of the framebuffer in pixels.
public int Width { get; protected set; }Property Value
Methods
AttachColorMipLevel(int)
Attaches a specific mip level of the color texture to the color attachment point.
public void AttachColorMipLevel(int mipLevel)Parameters
mipLevel int
Zero-based mip level to attach.
AttachDepthLayer(int)
Attaches a specific layer of the layered depth texture to the depth attachment point.
public void AttachDepthLayer(int layer)Parameters
layer int
Zero-based layer to attach.
Bind(FramebufferTarget)
Binds this framebuffer to the specified target.
public void Bind(FramebufferTarget targetState)Parameters
targetState FramebufferTarget
BindAndClear(FramebufferTarget)
Binds this framebuffer and clears it with and .
public void BindAndClear(FramebufferTarget targetState = FramebufferTarget.Framebuffer)Parameters
targetState FramebufferTarget
ChangeFormat(ImageFormat?, ImageFormat?)
Changes the attachment formats and recreates the GPU attachments at the current dimensions.
public void ChangeFormat(ImageFormat? colorFormat, ImageFormat? depthFormat)Parameters
colorFormat ImageFormat?
depthFormat ImageFormat?
Delete()
Deletes the framebuffer object and all its attached textures.
public void Delete()Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)Parameters
obj object?
The object to compare with the current object.
Returns
true if the specified object is equal to the current object; otherwise, false.
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()Returns
A hash code for the current object.
GetMipSize(int)
Returns the pixel dimensions of the framebuffer at the given mip level.
public Vector2i GetMipSize(int level)Parameters
level int
Zero-based mip level.
Returns
HasValidDimensions()
Returns true if both and are greater than zero.
public bool HasValidDimensions()Returns
Initialize()
Allocates GPU textures for all attachments and throws if the framebuffer is not complete.
public void Initialize()Prepare(string, int, int, int, ImageFormat?, ImageFormat?)
Creates and configures a framebuffer without allocating GPU attachments; call to allocate.
public static Framebuffer Prepare(string name, int width, int height, int msaa, ImageFormat? colorFormat, ImageFormat? depthFormat)Parameters
name string
Debug label for the framebuffer.
width int
Width in pixels.
height int
Height in pixels.
msaa int
Number of MSAA samples; 0 disables multisampling.
colorFormat ImageFormat?
Color attachment format, or null for depth-only.
depthFormat ImageFormat?
Depth attachment format, or null for color-only.
Returns
Resize(int, int, int)
Updates the MSAA sample count and resizes the framebuffer, recreating attachments if the dimensions or the sample count changed.
public void Resize(int width, int height, int msaa)Parameters
width int
height int
msaa int
Resize(int, int)
Resizes the framebuffer, recreating attachments if dimensions changed.
public bool Resize(int width, int height)Parameters
width int
height int
Returns
true if the dimensions changed and attachments were recreated.
SetColorSamplerState(TextureMinFilter, TextureMagFilter, RsTextureAddressMode)
Sets the filtering and wrap mode of the color attachment. The state is remembered and re-applied whenever the attachment is recreated by a resize or a format change.
public void SetColorSamplerState(TextureMinFilter minFilter, TextureMagFilter magFilter, RsTextureAddressMode wrapMode)Parameters
minFilter TextureMinFilter
magFilter TextureMagFilter
wrapMode RsTextureAddressMode
SetShadowDepthSamplerState(bool)
Configures depth comparison sampling on the depth attachment for shadow map reads.
public void SetShadowDepthSamplerState(bool lEqualCompare = false)Parameters
lEqualCompare bool
Set when the shadow map is rendered with conventional z. The default matches a reversed-z shadow map: the comparison passes where the reference is at least as close to the light as the stored depth.
Operators
operator ==(Framebuffer?, Framebuffer?)
Returns true if both framebuffers wrap the same OpenGL handle.
public static bool operator ==(Framebuffer? left, Framebuffer? right)Parameters
left Framebuffer?
right Framebuffer?
Returns
operator !=(Framebuffer?, Framebuffer?)
Returns true if the framebuffers wrap different OpenGL handles.
public static bool operator !=(Framebuffer? left, Framebuffer? right)Parameters
left Framebuffer?
right Framebuffer?

