GraphicsDevice

class GraphicsDevice : System.Object, System.IDisposable
readonly TextureCollection VertexTextures
readonly SamplerStateCollection VertexSamplerStates
readonly TextureCollection Textures
readonly SamplerStateCollection SamplerStates
readonly bool IsDisposed
readonly bool IsContentLost
readonly GraphicsAdapter Adapter
GraphicsMetrics Metrics

The rendering information for debugging and profiling. The metrics are reset every frame after draw within M:Microsoft.Xna.Framework.Graphics.GraphicsDevice.Present.

readonly GraphicsDebug GraphicsDebug

Access debugging APIs for the graphics subsystem.

RasterizerState RasterizerState
Color BlendFactor

The color used as blend factor when alpha blending.

BlendState BlendState
DepthStencilState DepthStencilState
readonly DisplayMode DisplayMode
readonly GraphicsDeviceStatus GraphicsDeviceStatus
readonly PresentationParameters PresentationParameters
Viewport Viewport
readonly GraphicsProfile GraphicsProfile
Rectangle ScissorRectangle
readonly int RenderTargetCount
IndexBuffer Indices
bool ResourcesLost
readonly System.Object Handle

Returns a handle to internal device object. Valid only on DirectX platforms. For usage, convert this to SharpDX.Direct3D11.Device.

void PlatformResolveRenderTargets()
void PlatformBeginApplyState()
void PlatformApplyState(bool applyShaders)
Parameters:
  • applyShaders (bool) –
public void Flush()

Sends queued-up commands in the command buffer to the graphics processing unit (GPU).

Microsoft.Xna.Framework.Graphics.GraphicsCapabilities get_GraphicsCapabilities()
public void add_DeviceLost(System.EventHandler<EventArgs> value)
Parameters:
  • value (System.EventHandler<EventArgs>) –
public void remove_DeviceLost(System.EventHandler<EventArgs> value)
Parameters:
  • value (System.EventHandler<EventArgs>) –
public void add_DeviceReset(System.EventHandler<EventArgs> value)
Parameters:
  • value (System.EventHandler<EventArgs>) –
public void remove_DeviceReset(System.EventHandler<EventArgs> value)
Parameters:
  • value (System.EventHandler<EventArgs>) –
public void add_DeviceResetting(System.EventHandler<EventArgs> value)
Parameters:
  • value (System.EventHandler<EventArgs>) –
public void remove_DeviceResetting(System.EventHandler<EventArgs> value)
Parameters:
  • value (System.EventHandler<EventArgs>) –
public void add_ResourceCreated(System.EventHandler<ResourceCreatedEventArgs> value)
Parameters:
  • value (System.EventHandler<ResourceCreatedEventArgs>) –
public void remove_ResourceCreated(System.EventHandler<ResourceCreatedEventArgs> value)
Parameters:
  • value (System.EventHandler<ResourceCreatedEventArgs>) –
public void add_ResourceDestroyed(System.EventHandler<ResourceDestroyedEventArgs> value)
Parameters:
  • value (System.EventHandler<ResourceDestroyedEventArgs>) –
public void remove_ResourceDestroyed(System.EventHandler<ResourceDestroyedEventArgs> value)
Parameters:
  • value (System.EventHandler<ResourceDestroyedEventArgs>) –
public void add_Disposing(System.EventHandler<EventArgs> value)
Parameters:
  • value (System.EventHandler<EventArgs>) –
public void remove_Disposing(System.EventHandler<EventArgs> value)
Parameters:
  • value (System.EventHandler<EventArgs>) –
void add_PresentationChanged(System.EventHandler<EventArgs> value)
Parameters:
  • value (System.EventHandler<EventArgs>) –
void remove_PresentationChanged(System.EventHandler<EventArgs> value)
Parameters:
  • value (System.EventHandler<EventArgs>) –
bool get_IsRenderTargetBound()
DepthFormat get_ActiveDepthFormat()
int GetClampedMultisampleCount(int multiSampleCount)
Parameters:
  • multiSampleCount (int) –
void Initialize()
void ApplyState(bool applyShaders)
Parameters:
  • applyShaders (bool) –
public void Clear(Color color)
Parameters:
  • color (Microsoft.Xna.Framework.Color) –
public void Clear(ClearOptions options, Color color, float depth, int stencil)
Parameters:
  • options (Microsoft.Xna.Framework.Graphics.ClearOptions) –
  • color (Microsoft.Xna.Framework.Color) –
  • depth (float) –
  • stencil (int) –
public void Clear(ClearOptions options, Vector4 color, float depth, int stencil)
Parameters:
  • options (Microsoft.Xna.Framework.Graphics.ClearOptions) –
  • color (Microsoft.Xna.Framework.Vector4) –
  • depth (float) –
  • stencil (int) –
public void Dispose()
void AddResourceReference(System.WeakReference resourceReference)
Parameters:
  • resourceReference (System.WeakReference) –
void RemoveResourceReference(System.WeakReference resourceReference)
Parameters:
  • resourceReference (System.WeakReference) –
public void Present()
public void Reset()
public void Reset(PresentationParameters presentationParameters)
Parameters:
  • presentationParameters (Microsoft.Xna.Framework.Graphics.PresentationParameters) –
void OnDeviceResetting()

Trigger the DeviceResetting event Currently internal to allow the various platforms to send the event at the appropriate time.

void OnDeviceReset()

Trigger the DeviceReset event to allow games to be notified of a device reset. Currently internal to allow the various platforms to send the event at the appropriate time.

public void SetRenderTarget(RenderTarget2D renderTarget)
Parameters:
  • renderTarget (Microsoft.Xna.Framework.Graphics.RenderTarget2D) –
public void SetRenderTarget(RenderTargetCube renderTarget, CubeMapFace cubeMapFace)
Parameters:
  • renderTarget (Microsoft.Xna.Framework.Graphics.RenderTargetCube) –
  • cubeMapFace (Microsoft.Xna.Framework.Graphics.CubeMapFace) –
public void SetRenderTargets(Microsoft.Xna.Framework.Graphics.RenderTargetBinding[] renderTargets)
Parameters:
  • renderTargets (Microsoft.Xna.Framework.Graphics.RenderTargetBinding[]) –
void ApplyRenderTargets(Microsoft.Xna.Framework.Graphics.RenderTargetBinding[] renderTargets)
Parameters:
  • renderTargets (Microsoft.Xna.Framework.Graphics.RenderTargetBinding[]) –
public Microsoft.Xna.Framework.Graphics.RenderTargetBinding[] GetRenderTargets()
public void GetRenderTargets(Microsoft.Xna.Framework.Graphics.RenderTargetBinding[] outTargets)
Parameters:
  • outTargets (Microsoft.Xna.Framework.Graphics.RenderTargetBinding[]) –
public void SetVertexBuffer(VertexBuffer vertexBuffer)
Parameters:
  • vertexBuffer (Microsoft.Xna.Framework.Graphics.VertexBuffer) –
public void SetVertexBuffer(VertexBuffer vertexBuffer, int vertexOffset)
Parameters:
  • vertexBuffer (Microsoft.Xna.Framework.Graphics.VertexBuffer) –
  • vertexOffset (int) –
public void SetVertexBuffers(Microsoft.Xna.Framework.Graphics.VertexBufferBinding[] vertexBuffers)
Parameters:
  • vertexBuffers (Microsoft.Xna.Framework.Graphics.VertexBufferBinding[]) –
Microsoft.Xna.Framework.Graphics.Shader get_VertexShader()
void set_VertexShader(Microsoft.Xna.Framework.Graphics.Shader value)
Parameters:
  • value (Microsoft.Xna.Framework.Graphics.Shader) –
Microsoft.Xna.Framework.Graphics.Shader get_PixelShader()
void set_PixelShader(Microsoft.Xna.Framework.Graphics.Shader value)
Parameters:
  • value (Microsoft.Xna.Framework.Graphics.Shader) –
void SetConstantBuffer(ShaderStage stage, int slot, Microsoft.Xna.Framework.Graphics.ConstantBuffer buffer)
Parameters:
  • stage (Microsoft.Xna.Framework.Graphics.ShaderStage) –
  • slot (int) –
  • buffer (Microsoft.Xna.Framework.Graphics.ConstantBuffer) –
public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount)

Draw geometry by indexing into the vertex buffer.

Parameters:
  • primitiveType (Microsoft.Xna.Framework.Graphics.PrimitiveType) – The type of primitives in the index buffer.
  • baseVertex (int) – Used to offset the vertex range indexed from the vertex buffer.
  • minVertexIndex (int) – This is unused and remains here only for XNA API compatibility.
  • numVertices (int) – This is unused and remains here only for XNA API compatibility.
  • startIndex (int) – The index within the index buffer to start drawing from.
  • primitiveCount (int) – The number of primitives to render from the index buffer.
public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int startIndex, int primitiveCount)

Draw geometry by indexing into the vertex buffer.

Parameters:
  • primitiveType (Microsoft.Xna.Framework.Graphics.PrimitiveType) – The type of primitives in the index buffer.
  • baseVertex (int) – Used to offset the vertex range indexed from the vertex buffer.
  • startIndex (int) – The index within the index buffer to start drawing from.
  • primitiveCount (int) – The number of primitives to render from the index buffer.
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, Microsoft.Xna.Framework.Graphics.T[] vertexData, int vertexOffset, int primitiveCount)
Type Parameters:
 
  • T
Parameters:
  • primitiveType (Microsoft.Xna.Framework.Graphics.PrimitiveType) –
  • vertexData (Microsoft.Xna.Framework.Graphics.T[]) –
  • vertexOffset (int) –
  • primitiveCount (int) –
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, Microsoft.Xna.Framework.Graphics.T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration)
Type Parameters:
 
  • T
Parameters:
  • primitiveType (Microsoft.Xna.Framework.Graphics.PrimitiveType) –
  • vertexData (Microsoft.Xna.Framework.Graphics.T[]) –
  • vertexOffset (int) –
  • primitiveCount (int) –
  • vertexDeclaration (Microsoft.Xna.Framework.Graphics.VertexDeclaration) –
public void DrawPrimitives(PrimitiveType primitiveType, int vertexStart, int primitiveCount)

Draw primitives of the specified type from the currently bound vertexbuffers without indexing.

Parameters:
  • primitiveType (Microsoft.Xna.Framework.Graphics.PrimitiveType) – The type of primitives to draw.
  • vertexStart (int) – Index of the vertex to start at.
  • primitiveCount (int) – The number of primitives to draw.
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, Microsoft.Xna.Framework.Graphics.T[] vertexData, int vertexOffset, int numVertices, System.Int16[] indexData, int indexOffset, int primitiveCount)
Type Parameters:
 
  • T
Parameters:
  • primitiveType (Microsoft.Xna.Framework.Graphics.PrimitiveType) –
  • vertexData (Microsoft.Xna.Framework.Graphics.T[]) –
  • vertexOffset (int) –
  • numVertices (int) –
  • indexData (System.Int16[]) –
  • indexOffset (int) –
  • primitiveCount (int) –
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, Microsoft.Xna.Framework.Graphics.T[] vertexData, int vertexOffset, int numVertices, System.Int16[] indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration)
Type Parameters:
 
  • T
Parameters:
  • primitiveType (Microsoft.Xna.Framework.Graphics.PrimitiveType) –
  • vertexData (Microsoft.Xna.Framework.Graphics.T[]) –
  • vertexOffset (int) –
  • numVertices (int) –
  • indexData (System.Int16[]) –
  • indexOffset (int) –
  • primitiveCount (int) –
  • vertexDeclaration (Microsoft.Xna.Framework.Graphics.VertexDeclaration) –
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, Microsoft.Xna.Framework.Graphics.T[] vertexData, int vertexOffset, int numVertices, System.Int32[] indexData, int indexOffset, int primitiveCount)
Type Parameters:
 
  • T
Parameters:
  • primitiveType (Microsoft.Xna.Framework.Graphics.PrimitiveType) –
  • vertexData (Microsoft.Xna.Framework.Graphics.T[]) –
  • vertexOffset (int) –
  • numVertices (int) –
  • indexData (System.Int32[]) –
  • indexOffset (int) –
  • primitiveCount (int) –
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, Microsoft.Xna.Framework.Graphics.T[] vertexData, int vertexOffset, int numVertices, System.Int32[] indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration)
Type Parameters:
 
  • T
Parameters:
  • primitiveType (Microsoft.Xna.Framework.Graphics.PrimitiveType) –
  • vertexData (Microsoft.Xna.Framework.Graphics.T[]) –
  • vertexOffset (int) –
  • numVertices (int) –
  • indexData (System.Int32[]) –
  • indexOffset (int) –
  • primitiveCount (int) –
  • vertexDeclaration (Microsoft.Xna.Framework.Graphics.VertexDeclaration) –
public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, int instanceCount)

Draw instanced geometry from the bound vertex buffers and index buffer.

Parameters:
  • primitiveType (Microsoft.Xna.Framework.Graphics.PrimitiveType) – The type of primitives in the index buffer.
  • baseVertex (int) – Used to offset the vertex range indexed from the vertex buffer.
  • minVertexIndex (int) – This is unused and remains here only for XNA API compatibility.
  • numVertices (int) – This is unused and remains here only for XNA API compatibility.
  • startIndex (int) – The index within the index buffer to start drawing from.
  • primitiveCount (int) – The number of primitives in a single instance.
  • instanceCount (int) – The number of instances to render.
public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int startIndex, int primitiveCount, int instanceCount)

Draw instanced geometry from the bound vertex buffers and index buffer.

Parameters:
  • primitiveType (Microsoft.Xna.Framework.Graphics.PrimitiveType) – The type of primitives in the index buffer.
  • baseVertex (int) – Used to offset the vertex range indexed from the vertex buffer.
  • startIndex (int) – The index within the index buffer to start drawing from.
  • primitiveCount (int) – The number of primitives in a single instance.
  • instanceCount (int) – The number of instances to render.
Rectangle GetDefaultTitleSafeArea(int x, int y, int width, int height)
Parameters:
  • x (int) –
  • y (int) –
  • width (int) –
  • height (int) –
Rectangle GetTitleSafeArea(int x, int y, int width, int height)
Parameters:
  • x (int) –
  • y (int) –
  • width (int) –
  • height (int) –
void SetHardwareFullscreen()
void CreateSizeDependentResources()
void OnPresentationChanged()
SharpDX.DXGI.SampleDescription GetSupportedSampleDescription(SharpDX.DXGI.Format format, int multiSampleCount)
Parameters:
  • format (SharpDX.DXGI.Format) –
  • multiSampleCount (int) –
public void SetRenderTarget(RenderTarget2D renderTarget, int arraySlice)
Parameters:
  • renderTarget (Microsoft.Xna.Framework.Graphics.RenderTarget2D) –
  • arraySlice (int) –
public void SetRenderTarget(RenderTarget3D renderTarget, int arraySlice)
Parameters:
  • renderTarget (Microsoft.Xna.Framework.Graphics.RenderTarget3D) –
  • arraySlice (int) –