Graphicsclass

Used to render to the screen using your Graphics Card, or whatever you kids are using in your crazy future computers. Whatever it is I'm sure it isn't fungible and everyone has free money and no-one has to ever work.

objectGraphics
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public static abstract sealed class Sandbox.Graphics

Methods40

Showing 40 methods

public static void Blit(Sandbox.Material material, Sandbox.RenderAttributes attributes = null)PUBLICSTATIC

Draw a screen space quad using the passed material. Your material should be using a screenspace shader so it will actually render to the screen and not in worldspace at 0,0,0

ParameterTypeDescription
materialMaterial
attributes = nullRenderAttributes
Returns:void

public static Sandbox.Rect DrawIcon(Sandbox.Rect rect, string iconName, Color color, float fontSize = 20, Sandbox.TextFlag alignment = 132)PUBLICSTATIC

Calls DrawText with "Material Icons" font. You can get a list of icons here https://fonts.google.com/icons?selected=Material+Icons

ParameterTypeDescription
rectRect
iconNamestring
colorColor
fontSize = 20float
alignment = 132TextFlag
Returns:Rect

public static void DrawModel(Sandbox.Model model, Transform transform, Sandbox.RenderAttributes attributes = null)PUBLICSTATIC

Draws a single model at the given Transform immediately.

ParameterTypeDescription
modelModelThe model to draw
transformTransformTransform to draw the model at
attributes = nullRenderAttributesOptional attributes to apply only for this draw call
Returns:void

public static void DrawRoundedRectangle(Sandbox.Rect rect, Color color, Vector4 cornerRadius = null, Vector4 borderWidth = null, Color borderColor = null)PUBLICSTATIC

Draw a rounded rectangle, with optional border, in Material.UI.Box

ParameterTypeDescription
rectRect
colorColor
cornerRadius = nullVector4
borderWidth = nullVector4
borderColor = nullColor
Returns:void

public static void FlushGPU()PUBLICSTATIC

Forces the GPU to flush all pending commands and wait for completion. Useful when you need to ensure GPU work is finished before proceeding. Can be called outside of a render block.

Returns:void

public static void GenerateMipMaps(Sandbox.Texture texture, Sandbox.Graphics.DownsampleMethod downsampleMethod = 0, int initialMip = 0, int numMips = -1)PUBLICSTATIC

Generate the mip maps for this texture. Obviously the texture needs to support mip maps.

ParameterTypeDescription
textureTexture
downsampleMethod = 0DownsampleMethod
initialMip = 0int
numMips = -1int
Returns:void

public static Sandbox.RenderTarget GrabDepthTexture(string targetName = DepthTexture, Sandbox.RenderAttributes renderAttributes = null)PUBLICSTATIC

Grabs the current depth texture and stores it in targetName on renderAttributes.

ParameterTypeDescription
targetName = DepthTexturestring
renderAttributes = nullRenderAttributes
Returns:RenderTarget

public static void Render(Sandbox.SceneObject obj, System.Nullable`1<Transform> transform = null, System.Nullable`1<Color> color = null, Sandbox.Material material = null)PUBLICSTATIC

ParameterTypeDescription
objSceneObject
transform = nullNullable<Transform>
color = nullNullable<Color>
material = nullMaterial
Returns:void

public static bool RenderToTexture(Sandbox.SceneCamera camera, Sandbox.Texture target)PUBLICSTATICOBSOLETE

Render this camera to the specified texture target

Obsolete: Use CameraComponent.RenderToTexture

ParameterTypeDescription
cameraSceneCamera
targetTexture
Returns:bool

public static void SetupLighting(Sandbox.SceneObject obj, Sandbox.RenderAttributes targetAttributes = null)PUBLICSTATIC

Setup the lighting attributes for this current object. Place them in the targetAttributes

ParameterTypeDescription
objSceneObject
targetAttributes = nullRenderAttributes
Returns:void

Properties12

Showing 12 properties

public static Sandbox.RenderAttributes Sandbox.Graphics.Attributes { get; set; }PUBLICSTATICGETSET

Access to the current render context's attributes. These will be used to set attributes in materials/shaders. This is cleared at the end of the render block.

Returns:RenderAttributes

public static Vector3 Sandbox.Graphics.CameraPosition { get; set; }PUBLICSTATICGETSET

The camera position of the currently rendering view

Returns:Vector3

public static Rotation Sandbox.Graphics.CameraRotation { get; set; }PUBLICSTATICGETSET

The camera rotation of the currently rendering view

Returns:Rotation

public static Transform Sandbox.Graphics.CameraTransform { get; set; }PUBLICSTATICGETSET

The camera transform of the currently rendering view

Returns:Transform

public static float Sandbox.Graphics.FieldOfView { get; set; }PUBLICSTATICGETSET

The field of view of the currently rendering camera view, in degrees.

Returns:float

public static Sandbox.Frustum Sandbox.Graphics.Frustum { get; set; }PUBLICSTATICGETSET

The frustum of the currently rendering camera view.

Returns:Frustum

public static bool Sandbox.Graphics.IsActive { get; set; }PUBLICSTATICGETSET

If true then we're currently rendering and you are safe to use the contents of this class

Returns:bool

public static Sandbox.SceneLayerType Sandbox.Graphics.LayerType { get; set; }PUBLICSTATICGETSET

The current layer type. This is useful to tell whether you're meant to be drawing opaque, transparent or shadow. You mainly don't need to think about this, but when you do, it's here.

Returns:SceneLayerType

public static Sandbox.RenderTarget Sandbox.Graphics.RenderTarget { get; set; }PUBLICSTATICGETSET

Get or set the current render target. Setting this will bind the render target and change the viewport to match it.

Returns:RenderTarget

public static ulong Sandbox.Graphics.VideoMemoryBudget { get; set; }PUBLICSTATICGETSET

GPU video memory budget in bytes, as reported by the OS (WDDM).

Returns:ulong

public static ulong Sandbox.Graphics.VideoMemoryUsed { get; set; }PUBLICSTATICGETSET

GPU video memory currently used by the engine's render system in bytes. This includes textures, buffers, and all other GPU allocations tracked by the engine.

Returns:ulong

public static Sandbox.Rect Sandbox.Graphics.Viewport { get; set; }PUBLICSTATICGETSET

In pixel size, where are we rendering to?

Returns:Rect

On this page

Methodspublic static System.Void Blit(Sandbox.Material material, Sandbox.RenderAttributes attributes = null)public static System.Void Clear(Color color, System.Boolean clearColor = True, System.Boolean clearDepth = True, System.Boolean clearStencil = True)public static System.Void Clear(System.Boolean clearColor = True, System.Boolean clearDepth = True)public static System.Void CopyTexture(Sandbox.Texture srcTexture, Sandbox.Texture dstTexture, System.Int32 srcMipSlice = 0, System.Int32 srcArraySlice = 0, System.Int32 srcMipLevels = 1, System.Int32 dstMipSlice = 0, System.Int32 dstArraySlice = 0, System.Int32 dstMipLevels = 1)public static System.Void CopyTexture(Sandbox.Texture srcTexture, Sandbox.Texture dstTexture, System.Int32 srcMipSlice = 0, System.Int32 srcArraySlice = 0, System.Int32 dstMipSlice = 0, System.Int32 dstArraySlice = 0)public static System.Void CopyTexture(Sandbox.Texture srcTexture, Sandbox.Texture dstTexture)public static System.Void Draw(System.Collections.Generic.List`1<Sandbox.Vertex> vertices, System.Int32 vertCount, Sandbox.Material material, Sandbox.RenderAttributes attributes = null, Sandbox.Graphics.PrimitiveType primitiveType = 5)public static System.Void Draw(System.Span`1<Sandbox.Vertex> vertices, System.Int32 vertCount, Sandbox.Material material, Sandbox.RenderAttributes attributes = null, Sandbox.Graphics.PrimitiveType primitiveType = 5)public static System.Void Draw(System.Span`1<Sandbox.Vertex> vertices, System.Int32 vertCount, System.Span`1<System.UInt16> indices, System.Int32 indexCount, Sandbox.Material material, Sandbox.RenderAttributes attributes = null, Sandbox.Graphics.PrimitiveType primitiveType = 5)public static System.Void Draw(Sandbox.GpuBuffer`1<T> vertexBuffer, Sandbox.GpuBuffer indexBuffer, Sandbox.Material material, System.Int32 startIndex = 0, System.Int32 indexCount = 0, Sandbox.RenderAttributes attributes = null, Sandbox.Graphics.PrimitiveType primitiveType = 5)public static System.Void Draw(Sandbox.GpuBuffer`1<T> vertexBuffer, Sandbox.Material material, System.Int32 startVertex = 0, System.Int32 vertexCount = 0, Sandbox.RenderAttributes attributes = null, Sandbox.Graphics.PrimitiveType primitiveType = 5)public static Sandbox.Rect DrawIcon(Sandbox.Rect rect, System.String iconName, Color color, System.Single fontSize = 20, Sandbox.TextFlag alignment = 132)public static System.Void DrawModel(Sandbox.Model model, Transform transform, Sandbox.RenderAttributes attributes = null)public static System.Void DrawModelInstanced(Sandbox.Model model, System.Int32 count, Sandbox.RenderAttributes attributes = null)public static System.Void DrawModelInstanced(Sandbox.Model model, System.Span`1<Transform> transforms, Sandbox.RenderAttributes attributes = null)public static System.Void DrawModelInstanced(Sandbox.Model model, System.Span`1<Transform> transforms, System.Int32 lodLevel, Sandbox.RenderAttributes attributes = null)public static System.Void DrawModelInstancedIndirect(Sandbox.Model model, Sandbox.GpuBuffer transformBuffer, Sandbox.GpuBuffer indirectArgs, System.Int32 argsOffset = 0, System.Int32 lodLevel = 0, Sandbox.RenderAttributes attributes = null)public static System.Void DrawModelInstancedIndirect(Sandbox.Model model, Sandbox.GpuBuffer buffer, System.Int32 bufferOffset = 0, Sandbox.RenderAttributes attributes = null)public static System.Void DrawQuad(Sandbox.Rect rect, Sandbox.Material material, Color color, Sandbox.RenderAttributes attributes = null)public static System.Void DrawRoundedRectangle(Sandbox.Rect rect, Color color, Vector4 cornerRadius = null, Vector4 borderWidth = null, Color borderColor = null)public static Sandbox.Rect DrawText(Sandbox.Rect position, Sandbox.TextRendering.Scope scope, Sandbox.TextFlag flags = 132)public static Sandbox.Rect DrawText(Sandbox.Rect position, System.String text, Color color, System.String fontFamily = Roboto, System.Single fontSize = 20, System.Single fontWeight = 450, Sandbox.TextFlag flags = 132)public static Sandbox.Rect DrawText(Vector2 position, System.String text, Color color, System.String fontFamily = Roboto, System.Single fontSize = 20, System.Single fontWeight = 450)public static System.Void FlushGPU()public static System.Void GenerateMipMaps(Sandbox.Texture texture, Sandbox.Graphics.DownsampleMethod downsampleMethod = 0, System.Int32 initialMip = 0, System.Int32 numMips = -1)public static Sandbox.RenderTarget GrabDepthTexture(System.String targetName = DepthTexture, Sandbox.RenderAttributes renderAttributes = null)public static Sandbox.RenderTarget GrabFrameTexture(System.String targetName = FrameTexture, Sandbox.RenderAttributes renderAttributes = null, Sandbox.Graphics.DownsampleMethod downsampleMethod = -1, System.Int32 maxMips = 0)public static System.Void GrabFrameTexture(System.String targetName, Sandbox.RenderAttributes renderAttributes, System.Boolean withMips)public static Sandbox.Rect MeasureText(Sandbox.Rect position, Sandbox.TextRendering.Scope scope, Sandbox.TextFlag flags = 132)public static Sandbox.Rect MeasureText(Sandbox.Rect position, System.String text, System.String fontFamily = Roboto, System.Single fontSize = 20, System.Single fontWeight = 450, Sandbox.TextFlag flags = 132)public static System.Void Render(Sandbox.SceneObject obj, System.Nullable`1<Transform> transform = null, System.Nullable`1<Color> color = null, Sandbox.Material material = null)public static System.Boolean RenderToTexture(Sandbox.SceneCamera camera, Sandbox.Texture target)public static System.Void ResourceBarrierTransition(Sandbox.GpuBuffer buffer, Sandbox.Rendering.ResourceState before, Sandbox.Rendering.ResourceState after)public static System.Void ResourceBarrierTransition(Sandbox.GpuBuffer buffer, Sandbox.Rendering.ResourceState state)public static System.Void ResourceBarrierTransition(Sandbox.Texture texture, Sandbox.Rendering.ResourceState state, System.Int32 mip = -1)public static System.Void ResourceBarrierTransition(Sandbox.GpuBuffer`1<T> buffer, Sandbox.Rendering.ResourceState before, Sandbox.Rendering.ResourceState after)public static System.Void ResourceBarrierTransition(Sandbox.GpuBuffer`1<T> buffer, Sandbox.Rendering.ResourceState state)public static System.Void SetupLighting(Sandbox.SceneObject obj, Sandbox.RenderAttributes targetAttributes = null)public static System.Void UavBarrier(Sandbox.GpuBuffer buffer)public static System.Void UavBarrier(Sandbox.Texture texture)Propertiespublic static Sandbox.RenderAttributes Sandbox.Graphics.Attributes { get; set; }public static Vector3 Sandbox.Graphics.CameraPosition { get; set; }public static Rotation Sandbox.Graphics.CameraRotation { get; set; }public static Transform Sandbox.Graphics.CameraTransform { get; set; }public static System.Single Sandbox.Graphics.FieldOfView { get; set; }public static Sandbox.Frustum Sandbox.Graphics.Frustum { get; set; }public static System.Boolean Sandbox.Graphics.IsActive { get; set; }public static Sandbox.SceneLayerType Sandbox.Graphics.LayerType { get; set; }public static Sandbox.RenderTarget Sandbox.Graphics.RenderTarget { get; set; }public static System.UInt64 Sandbox.Graphics.VideoMemoryBudget { get; set; }public static System.UInt64 Sandbox.Graphics.VideoMemoryUsed { get; set; }public static Sandbox.Rect Sandbox.Graphics.Viewport { get; set; }Metadata