Ritchie's Abstractions 0.2
Platform abstractions that make Toolbox work
Loading...
Searching...
No Matches
GraphicsDevice Class Referenceabstract

Abstraction of a 3D graphics rendering backend. More...

Inheritance diagram for GraphicsDevice:

Classes

class  GraphicsResource
 Base type for all graphics-related resources. More...
 

Public Member Functions

void ClearDepth ()
 Clear the depth buffer.
 
void ClearStencilBuffer ()
 Clear the stencil buffer.
 
void Present ()
 Present the current frame.
 
void Clear (Vector4 clearColor)
 Clear the screen with the given color.
 
void SetFrameBuffer (FrameBuffer? newFramebuffer)
 Change the active frame buffer.
 
void DrawElements (PrimitiveType primitiveType, int elementCount)
 Draw the specified number of elements from the active index buffer as a set of primitives of the specified type. In other words, triangle maker go vroom vroom.
 
void SetShaderPipeline (ShaderPipeline newPipeline)
 Change the active shader pipeline.
 
void SetSamplerState (int textureSlot, SamplerState samplerState)
 Set the sampler settings for the specified texture slot.
 
void SetVertexBuffer< TElement > (VertexBuffer< TElement > newBuffer)
 Change the active vertex buffer.
 
void SetIndexBuffer< TIndex > (IndexBuffer< TIndex > newBuffer)
 Change the active element buffer.
 
void SetConstantBuffer (int slot, ConstantBuffer? newBuffer)
 Change the ConstantBuffer assigned to the given constant buffer slot.
 
void SetTexture (int slot, Texture? newTexture)
 Change the texture to sample from when sampling the given slot.
 
virtual bool SupportsShaderStage (ShaderStage stage)
 Determines whether the specified shader stage is supported on this graphics device's platform.
 
void Dispose ()
 

Protected Member Functions

 GraphicsDevice (GraphicsPlatform platformType)
 Creates a new GraphicsDevice instance representing the specified platform.
 
void MakeCurrent ()
 Make this instance the active one.
 
void Deactivate ()
 Deactivate this device. Must be called on the active device before making a new device active.
 
virtual void Dispose (bool disposing)
 Called when it's time to take out the trash.
 

Properties

static bool IsAvailable [get]
 Gets a value indicating whether a GraphicsDevice is currently active for rendering.
 
FrameBufferFrameBuffer [get]
 Gets the currently-active framebuffer.
 
Rectangle ScissorRectangle [get, set]
 Gets or sets the scissor test rectangle. This is a bounding box in window units where rendering is valid. In the next draw call, any fragments that fall outside of these bounds will be discarded if scissor testing is enabled.
 
Rectangle Viewport [get, set]
 Gets or sets the viewport rectangle. This is the area within the window that graphics will be drawn to.
 
static ? GraphicsDevice Current [get]
 Gets the currently-active GraphicsDevice instance.
 
DepthStencilState DepthStencilState [get, set]
 Gets or sets the DepthStencilState value indicating depth and stencil test settings for the next draw call.
 
bool IsCurrent [get]
 Gets a value indicating whether this GraphicsDevice is the current one."/>
 
GraphicsPlatform GraphicsPlatform [get]
 Gets a GraphicsPlatform val8ue indicating what graphics platform this instance implements.
 
RasterizerState RasterizerState [get, set]
 Gets or sets a RasterizerState value indicating rasterizer settings for the next draw operation.
 
BlendState BlendState [get, set]
 Gets or sets a BlendState value indicating blending settings for the next draw operation.
 

Detailed Description

Abstraction of a 3D graphics rendering backend.

Constructor & Destructor Documentation

◆ GraphicsDevice()

GraphicsDevice ( GraphicsPlatform platformType)
inlineprotected

Creates a new GraphicsDevice instance representing the specified platform.

Parameters
platformTypeA value indicating what graphics platform this instance implements.

Member Function Documentation

◆ Clear()

void Clear ( Vector4 clearColor)
abstract

Clear the screen with the given color.

Parameters
clearColorAny color.

◆ Dispose()

virtual void Dispose ( bool disposing)
inlineprotectedvirtual

Called when it's time to take out the trash.

Parameters
disposingValue indicating whether it is time for you to take out your trash.

◆ DrawElements()

void DrawElements ( PrimitiveType primitiveType,
int elementCount )
abstract

Draw the specified number of elements from the active index buffer as a set of primitives of the specified type. In other words, triangle maker go vroom vroom.

Parameters
primitiveTypeThe type of primitive to draw. Triangles? Dots?
elementCountThe number of elements to draw. This is not the number of triangles to draw, but rather the number of points to draw that form each triangle.

◆ SetConstantBuffer()

void SetConstantBuffer ( int slot,
ConstantBuffer? newBuffer )
abstract

Change the ConstantBuffer assigned to the given constant buffer slot.

Parameters
slotThe slot to change
newBufferThe new buffer to assign to the slot. If null is given, the slot is deactivated.

◆ SetFrameBuffer()

void SetFrameBuffer ( FrameBuffer? newFramebuffer)
abstract

Change the active frame buffer.

Parameters
newFramebufferA new frame buffer to render to. If given null, the default frame buffer will be used.

◆ SetIndexBuffer< TIndex >()

void SetIndexBuffer< TIndex > ( IndexBuffer< TIndex > newBuffer)
abstract

Change the active element buffer.

Parameters
newBufferThe new element buffer to use.
Template Parameters
TIndexAny numeric type used to store vertex indices
Type Constraints
TIndex :unmanaged 
TIndex :INumber<TIndex> 

◆ SetSamplerState()

void SetSamplerState ( int textureSlot,
SamplerState samplerState )
abstract

Set the sampler settings for the specified texture slot.

Parameters
textureSlotValue indicating which texture slot to change.
samplerStateA SamplerState value indicating sampler settings for this slot.

◆ SetShaderPipeline()

void SetShaderPipeline ( ShaderPipeline newPipeline)
abstract

Change the active shader pipeline.

Parameters
newPipelineA new ShaderPipeline to use. Must at least have a valid vertex and fragment shader stage.

◆ SetTexture()

void SetTexture ( int slot,
Texture? newTexture )
abstract

Change the texture to sample from when sampling the given slot.

Parameters
slotThe slot to change
newTextureA new texture to sample from. If given null, the slot is deactivated.

◆ SetVertexBuffer< TElement >()

void SetVertexBuffer< TElement > ( VertexBuffer< TElement > newBuffer)
abstract

Change the active vertex buffer.

Parameters
newBufferThe new buffer to use.
Template Parameters
TElementAny vertex data type.
Type Constraints
TElement :unmanaged 

◆ SupportsShaderStage()

virtual bool SupportsShaderStage ( ShaderStage stage)
inlinevirtual

Determines whether the specified shader stage is supported on this graphics device's platform.

Parameters
stageAny shader stage.
Returns
True if supported, false otherwise.

You should use this before creating shaders of the given stage. Otherwise, you'll crash. Have fun!


The documentation for this class was generated from the following file: