Freigeben über


GraphicsDevice Class

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Performs primitive-based rendering, creates resources, handles system-level variables, and creates shaders.

Inheritance Hierarchy

System.Object
  Microsoft.Xna.Framework.Graphics.GraphicsDevice

Namespace:  Microsoft.Xna.Framework.Graphics
Assembly:  Microsoft.Xna.Framework.Graphics (in Microsoft.Xna.Framework.Graphics.dll)

Syntax

'Declaration
Public MustInherit Class GraphicsDevice
public abstract class GraphicsDevice

The GraphicsDevice type exposes the following members.

Properties

  Name Description
Public property Adapter Gets the graphics adapter.
Public property BlendFactor Gets or sets the color used for a constant-blend factor during alpha blending. The default value is White.
Public property BlendState Gets or sets a system-defined instance of a blend state object initialized for alpha blending. The default value is Opaque.
Public property DepthStencilState Gets or sets a system-defined instance of a depth-stencil state object. The default value is Default.
Public property Indices Gets or sets index data. The default value is null.
Public property MultiSampleMask Gets or sets a bitmask controlling modification of the samples in a multisample render target. The default value is -1 (0xffffffff).
Public property PresentationParameters Gets the presentation parameters associated with this graphics device.
Public property RasterizerState Gets or sets rasterizer state. The default value is CullCounterClockwise.
Public property ReferenceStencil Gets or sets a reference value for stencil testing. The default value is zero.
Public property SamplerStates Gets a collection of SamplerState objects for the current GraphicsDevice.
Public property ScissorRectangle Gets or sets the rectangle used for scissor testing. By default, the size matches the render target size.
Public property Textures Gets the collection of textures that have been assigned to the texture stages of the device.
Public property Viewport Gets or sets a viewport identifying the portion of the render target to receive draw calls.

Top

Methods

  Name Description
Public method Clear(Color) Clears resource buffers.
Public method Clear(ClearOptions, Color, Single, Int32) Clears resource buffers.
Public method DrawIndexedPrimitives Renders the specified geometric primitive, based on indexing into an array of vertices.
Public method DrawPrimitives Renders a sequence of non-indexed geometric primitives of the specified type from the current set of data input streams.
Public method GetRenderTargets Gets a render target surface.
Public method GetVertexBuffers Gets the vertex buffers.
Public method SetRenderTarget(RenderTarget2D) Sets a new render target for this GraphicsDevice.
Public method SetRenderTarget(RenderTargetCube, CubeMapFace) Sets a new render target for this GraphicsDevice.
Public method SetRenderTargets Sets an array of render targets.
Public method SetVertexBuffer(VertexBuffer) Sets or binds a vertex buffer to the device.
Public method SetVertexBuffer(VertexBuffer, Int32) Sets or binds a vertex buffer to the device.
Public method SetVertexBuffers Sets the vertex buffers.

Top

Extension Methods

  Name Description
Public Extension Method GetPixelShader Gets the PixelShader that is associated with the specified GraphicsDevice. (Defined by GraphicsDeviceExtensions.)
Public Extension Method GetVertexShader Gets the VertexShader associated with the specified GraphicsDevice. (Defined by GraphicsDeviceExtensions.)
Public Extension Method SetPixelShader Associates the specified PixelShader with the specified GraphicsDevice. (Defined by GraphicsDeviceExtensions.)
Public Extension Method SetPixelShaderConstantFloat4<T>(Int32, T%) Overloaded. Sets a constant register to a generic data type which is passed to the pixel shader on the graphics device. (Defined by GraphicsDeviceExtensions.)
Public Extension Method SetPixelShaderConstantFloat4<T>(Int32, Int32, T%) Overloaded. Sets a constant register to a generic data type which is passed to the pixel shader on the graphics device. (Defined by GraphicsDeviceExtensions.)
Public Extension Method SetVertexShader Associates the specified VertexShader with the specified GraphicsDevice. (Defined by GraphicsDeviceExtensions.)
Public Extension Method SetVertexShaderConstantFloat4<T>(Int32, T%) Overloaded. Sets a constant register to a generic data type which is passed to the vertex shader on the graphics device. (Defined by GraphicsDeviceExtensions.)
Public Extension Method SetVertexShaderConstantFloat4<T>(Int32, Int32, T%) Overloaded. Sets a constant register to a generic data type which is passed to the vertex shader on the graphics device. (Defined by GraphicsDeviceExtensions.)

Top

Version Information

Silverlight

Supported in: 5

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.