Graphics subsystem. Manages the application window, rendering state and GPU resources. More...

#include <OGLGraphics.h>

Inheritance diagram for Urho3D::Graphics:
[legend]
Collaboration diagram for Urho3D::Graphics:
[legend]

Public Member Functions

 Graphics (Context *context)
 Construct.
 
virtual ~Graphics ()
 Destruct. Release the Direct3D11 device and close the window.
 
void SetExternalWindow (void *window)
 Set external window handle. Only effective before setting the initial screen mode.
 
void SetWindowTitle (const String &windowTitle)
 Set window title.
 
void SetWindowIcon (Image *windowIcon)
 Set window icon.
 
void SetWindowPosition (const IntVector2 &position)
 Set window position. Sets initial position if window is not created yet.
 
void SetWindowPosition (int x, int y)
 Set window position. Sets initial position if window is not created yet.
 
bool SetMode (int width, int height, bool fullscreen, bool borderless, bool resizable, bool vsync, bool tripleBuffer, int multiSample)
 Set screen mode. Return true if successful.
 
bool SetMode (int width, int height)
 Set screen resolution only. Return true if successful.
 
void SetSRGB (bool enable)
 Set whether the main window uses sRGB conversion on write.
 
void SetFlushGPU (bool enable)
 Set whether to flush the GPU command buffer to prevent multiple frames being queued and uneven frame timesteps. Default off, may decrease performance if enabled.
 
void SetOrientations (const String &orientations)
 Set allowed screen orientations as a space-separated list of "LandscapeLeft", "LandscapeRight", "Portrait" and "PortraitUpsideDown". Affects currently only iOS platform.
 
bool ToggleFullscreen ()
 Toggle between full screen and windowed mode. Return true if successful.
 
void Close ()
 Close the window.
 
bool TakeScreenShot (Image &destImage)
 Take a screenshot. Return true if successful.
 
bool BeginFrame ()
 Begin frame rendering. Return true if device available and can render.
 
void EndFrame ()
 End frame rendering and swap buffers.
 
void Clear (unsigned flags, const Color &color=Color(0.0f, 0.0f, 0.0f, 0.0f), float depth=1.0f, unsigned stencil=0)
 Clear any or all of rendertarget, depth buffer and stencil buffer. More...
 
bool ResolveToTexture (Texture2D *destination, const IntRect &viewport)
 Resolve multisampled backbuffer to a texture rendertarget. The texture's size should match the viewport size.
 
void Draw (PrimitiveType type, unsigned vertexStart, unsigned vertexCount)
 Draw non-indexed geometry.
 
void Draw (PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned minVertex, unsigned vertexCount)
 Draw indexed geometry.
 
void DrawInstanced (PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned minVertex, unsigned vertexCount, unsigned instanceCount)
 Draw indexed, instanced geometry. An instancing vertex buffer must be set.
 
void SetVertexBuffer (VertexBuffer *buffer)
 Set vertex buffer.
 
bool SetVertexBuffers (const PODVector< VertexBuffer * > &buffers, const PODVector< unsigned > &elementMasks, unsigned instanceOffset=0)
 Set multiple vertex buffers.
 
bool SetVertexBuffers (const Vector< SharedPtr< VertexBuffer > > &buffers, const PODVector< unsigned > &elementMasks, unsigned instanceOffset=0)
 Set multiple vertex buffers.
 
void SetIndexBuffer (IndexBuffer *buffer)
 Set index buffer.
 
void SetShaders (ShaderVariation *vs, ShaderVariation *ps)
 Set shaders. More...
 
void SetShaderParameter (StringHash param, const float *data, unsigned count)
 Set shader float constants.
 
void SetShaderParameter (StringHash param, float value)
 Set shader float constant.
 
void SetShaderParameter (StringHash param, bool value)
 Set shader boolean constant.
 
void SetShaderParameter (StringHash param, const Color &color)
 Set shader color constant.
 
void SetShaderParameter (StringHash param, const Vector2 &vector)
 Set shader 2D vector constant.
 
void SetShaderParameter (StringHash param, const Matrix3 &matrix)
 Set shader 3x3 matrix constant.
 
void SetShaderParameter (StringHash param, const Vector3 &vector)
 Set shader 3D vector constant.
 
void SetShaderParameter (StringHash param, const Matrix4 &matrix)
 Set shader 4x4 matrix constant.
 
void SetShaderParameter (StringHash param, const Vector4 &vector)
 Set shader 4D vector constant.
 
void SetShaderParameter (StringHash param, const Matrix3x4 &matrix)
 Set shader 3x4 matrix constant.
 
void SetShaderParameter (StringHash param, const Variant &value)
 Set shader constant from a variant. Supported variant types: bool, float, vector2, vector3, vector4, color.
 
bool NeedParameterUpdate (ShaderParameterGroup group, const void *source)
 Check whether a shader parameter group needs update. Does not actually check whether parameters exist in the shaders.
 
bool HasShaderParameter (StringHash param)
 Check whether a shader parameter exists on the currently set shaders.
 
bool HasTextureUnit (TextureUnit unit)
 Check whether the current pixel shader uses a texture unit.
 
void ClearParameterSource (ShaderParameterGroup group)
 Clear remembered shader parameter source group.
 
void ClearParameterSources ()
 Clear remembered shader parameter sources.
 
void ClearTransformSources ()
 Clear remembered transform shader parameter sources.
 
void SetTexture (unsigned index, Texture *texture)
 Set texture.
 
void SetDefaultTextureFilterMode (TextureFilterMode mode)
 Set default texture filtering mode.
 
void SetTextureAnisotropy (unsigned level)
 Set texture anisotropy.
 
void SetTextureParametersDirty ()
 Dirty texture parameters of all textures (when global settings change.)
 
void ResetRenderTargets ()
 Reset all rendertargets, depth-stencil surface and viewport.
 
void ResetRenderTarget (unsigned index)
 Reset specific rendertarget.
 
void ResetDepthStencil ()
 Reset depth-stencil surface.
 
void SetRenderTarget (unsigned index, RenderSurface *renderTarget)
 Set rendertarget.
 
void SetRenderTarget (unsigned index, Texture2D *texture)
 Set rendertarget.
 
void SetDepthStencil (RenderSurface *depthStencil)
 Set depth-stencil surface.
 
void SetDepthStencil (Texture2D *texture)
 Set depth-stencil surface.
 
void SetViewport (const IntRect &rect)
 Set viewport.
 
void SetBlendMode (BlendMode mode)
 Set blending mode.
 
void SetColorWrite (bool enable)
 Set color write on/off.
 
void SetCullMode (CullMode mode)
 Set hardware culling mode.
 
void SetDepthBias (float constantBias, float slopeScaledBias)
 Set depth bias.
 
void SetDepthTest (CompareMode mode)
 Set depth compare.
 
void SetDepthWrite (bool enable)
 Set depth write on/off.
 
void SetFillMode (FillMode mode)
 Set polygon fill mode.
 
void SetScissorTest (bool enable, const Rect &rect=Rect::FULL, bool borderInclusive=true)
 Set scissor test.
 
void SetScissorTest (bool enable, const IntRect &rect)
 Set scissor test.
 
void SetStencilTest (bool enable, CompareMode mode=CMP_ALWAYS, StencilOp pass=OP_KEEP, StencilOp fail=OP_KEEP, StencilOp zFail=OP_KEEP, unsigned stencilRef=0, unsigned compareMask=M_MAX_UNSIGNED, unsigned writeMask=M_MAX_UNSIGNED)
 Set stencil test.
 
void SetClipPlane (bool enable, const Plane &clipPlane=Plane::UP, const Matrix3x4 &view=Matrix3x4::IDENTITY, const Matrix4 &projection=Matrix4::IDENTITY)
 Set a custom clipping plane. The plane is specified in world space, but is dependent on the view and projection matrices.
 
void BeginDumpShaders (const String &fileName)
 Begin dumping shader variation names to an XML file for precaching.
 
void EndDumpShaders ()
 End dumping shader variations names.
 
void PrecacheShaders (Deserializer &source)
 Precache shader variations from an XML file generated with BeginDumpShaders().
 
bool IsInitialized () const
 Return whether rendering initialized.
 
GraphicsImplGetImpl () const
 Return graphics implementation, which holds the actual API-specific resources.
 
void * GetExternalWindow () const
 Return OS-specific external window handle. Null if not in use.
 
const StringGetWindowTitle () const
 Return window title.
 
const StringGetApiName () const
 Return graphics API name.
 
IntVector2 GetWindowPosition () const
 Return window position.
 
int GetWidth () const
 Return window width.
 
int GetHeight () const
 Return window height.
 
int GetMultiSample () const
 Return multisample mode (1 = no multisampling.)
 
bool GetFullscreen () const
 Return whether window is fullscreen.
 
bool GetResizable () const
 Return whether window is resizable.
 
bool GetBorderless () const
 Return whether window is borderless.
 
bool GetVSync () const
 Return whether vertical sync is on.
 
bool GetTripleBuffer () const
 Return whether triple buffering is enabled.
 
bool GetSRGB () const
 Return whether the main window is using sRGB conversion on write.
 
bool GetFlushGPU () const
 Return whether the GPU command buffer is flushed each frame.
 
const StringGetOrientations () const
 Return allowed screen orientations.
 
bool IsDeviceLost () const
 Return whether Direct3D device is lost, and can not yet render. Always false on D3D11.
 
unsigned GetNumPrimitives () const
 Return number of primitives drawn this frame.
 
unsigned GetNumBatches () const
 Return number of batches drawn this frame.
 
unsigned GetDummyColorFormat () const
 Return dummy color texture format for shadow maps. Is "NULL" (consume no video memory) if supported.
 
unsigned GetShadowMapFormat () const
 Return shadow map depth texture format, or 0 if not supported.
 
unsigned GetHiresShadowMapFormat () const
 Return 24-bit shadow map depth texture format, or 0 if not supported.
 
bool GetInstancingSupport () const
 Return whether hardware instancing is supported..
 
bool GetLightPrepassSupport () const
 Return whether light pre-pass rendering is supported.
 
bool GetDeferredSupport () const
 Return whether deferred rendering is supported.
 
bool GetHardwareShadowSupport () const
 Return whether shadow map depth compare is done in hardware.
 
bool GetReadableDepthSupport () const
 Return whether a readable hardware depth format is available.
 
bool GetSRGBSupport () const
 Return whether sRGB conversion on texture sampling is supported.
 
bool GetSRGBWriteSupport () const
 Return whether sRGB conversion on rendertarget writing is supported.
 
PODVector< IntVector2GetResolutions () const
 Return supported fullscreen resolutions.
 
PODVector< int > GetMultiSampleLevels () const
 Return supported multisampling levels. More...
 
IntVector2 GetDesktopResolution () const
 Return the desktop resolution.
 
unsigned GetFormat (CompressedFormat format) const
 Return hardware format for a compressed image format, or 0 if unsupported.
 
ShaderVariationGetShader (ShaderType type, const String &name, const String &defines=String::EMPTY) const
 Return a shader variation by name and defines.
 
ShaderVariationGetShader (ShaderType type, const char *name, const char *defines) const
 Return a shader variation by name and defines.
 
VertexBufferGetVertexBuffer (unsigned index) const
 Return current vertex buffer by index.
 
IndexBufferGetIndexBuffer () const
 Return current index buffer.
 
ShaderVariationGetVertexShader () const
 Return current vertex shader.
 
ShaderVariationGetPixelShader () const
 Return current pixel shader.
 
TextureUnit GetTextureUnit (const String &name)
 Return texture unit index by name.
 
const StringGetTextureUnitName (TextureUnit unit)
 Return texture unit name by index.
 
TextureGetTexture (unsigned index) const
 Return current texture by texture unit index.
 
TextureFilterMode GetDefaultTextureFilterMode () const
 Return default texture filtering mode.
 
RenderSurfaceGetRenderTarget (unsigned index) const
 Return current rendertarget by index.
 
RenderSurfaceGetDepthStencil () const
 Return current depth-stencil surface.
 
IntRect GetViewport () const
 Return the viewport coordinates.
 
unsigned GetTextureAnisotropy () const
 Return texture anisotropy.
 
BlendMode GetBlendMode () const
 Return blending mode.
 
bool GetColorWrite () const
 Return whether color write is enabled.
 
CullMode GetCullMode () const
 Return hardware culling mode.
 
float GetDepthConstantBias () const
 Return depth constant bias.
 
float GetDepthSlopeScaledBias () const
 Return depth slope scaled bias.
 
CompareMode GetDepthTest () const
 Return depth compare mode.
 
bool GetDepthWrite () const
 Return whether depth write is enabled.
 
FillMode GetFillMode () const
 Return polygon fill mode.
 
bool GetStencilTest () const
 Return whether stencil test is enabled.
 
bool GetScissorTest () const
 Return whether scissor test is enabled.
 
const IntRectGetScissorRect () const
 Return scissor rectangle coordinates.
 
CompareMode GetStencilTestMode () const
 Return stencil compare mode.
 
StencilOp GetStencilPass () const
 Return stencil operation to do if stencil test passes.
 
StencilOp GetStencilFail () const
 Return stencil operation to do if stencil test fails.
 
StencilOp GetStencilZFail () const
 Return stencil operation to do if depth compare fails.
 
unsigned GetStencilRef () const
 Return stencil reference value.
 
unsigned GetStencilCompareMask () const
 Return stencil compare bitmask.
 
unsigned GetStencilWriteMask () const
 Return stencil write bitmask.
 
bool GetUseClipPlane () const
 Return whether a custom clipping plane is in use.
 
IntVector2 GetRenderTargetDimensions () const
 Return rendertarget width and height.
 
void WindowResized ()
 Window was resized through user interaction. Called by Input subsystem.
 
void WindowMoved ()
 Window was moved through user interaction. Called by Input subsystem.
 
void Maximize ()
 Maximize the Window.
 
void Minimize ()
 Minimize the Window.
 
void AddGPUObject (GPUObject *object)
 Add a GPU object to keep track of. Called by GPUObject.
 
void RemoveGPUObject (GPUObject *object)
 Remove a GPU object. Called by GPUObject.
 
void * ReserveScratchBuffer (unsigned size)
 Reserve a CPU-side scratch buffer.
 
void FreeScratchBuffer (void *buffer)
 Free a CPU-side scratch buffer.
 
void CleanupScratchBuffers ()
 Clean up too large scratch buffers.
 
void CleanUpShaderPrograms (ShaderVariation *variation)
 Clean up shader parameters when a shader variation is released or destroyed.
 
ConstantBufferGetOrCreateConstantBuffer (ShaderType type, unsigned index, unsigned size)
 Get or create a constant buffer. Will be shared between shaders if possible.
 
 Graphics (Context *context_)
 Construct.
 
virtual ~Graphics ()
 Destruct. Release the OpenGL context and close the window.
 
void SetExternalWindow (void *window)
 Set external window handle. Only effective before setting the initial screen mode. On Windows it is necessary to set up OpenGL pixel format manually for the window.
 
void SetWindowIcon (Image *windowIcon)
 Set window icon.
 
void SetWindowTitle (const String &windowTitle)
 Set window title.
 
void SetWindowPosition (const IntVector2 &position)
 Set window position.
 
void SetWindowPosition (int x, int y)
 Set window position.
 
bool SetMode (int width, int height, bool fullscreen, bool borderless, bool resizable, bool vsync, bool tripleBuffer, int multiSample)
 Set screen mode. Return true if successful.
 
bool SetMode (int width, int height)
 Set screen resolution only. Return true if successful.
 
void SetSRGB (bool enable)
 Set whether the main window uses sRGB conversion on write.
 
void SetFlushGPU (bool enable)
 Set whether to flush the GPU command buffer to prevent multiple frames being queued and uneven frame timesteps. Not yet implemented on OpenGL.
 
void SetForceGL2 (bool enable)
 Set forced use of OpenGL 2 even if OpenGL 3 is available. Must be called before setting the screen mode for the first time. Default false.
 
void SetOrientations (const String &orientations)
 Set allowed screen orientations as a space-separated list of "LandscapeLeft", "LandscapeRight", "Portrait" and "PortraitUpsideDown". Affects currently only iOS platform.
 
bool ToggleFullscreen ()
 Toggle between full screen and windowed mode. Return true if successful.
 
void Close ()
 Close the window.
 
bool TakeScreenShot (Image &destImage)
 Take a screenshot. Return true if successful.
 
bool BeginFrame ()
 Begin frame rendering. Return true if device available and can render.
 
void EndFrame ()
 End frame rendering and swap buffers.
 
void Clear (unsigned flags, const Color &color=Color(0.0f, 0.0f, 0.0f, 0.0f), float depth=1.0f, unsigned stencil=0)
 Clear any or all of rendertarget, depth buffer and stencil buffer.
 
bool ResolveToTexture (Texture2D *destination, const IntRect &viewport)
 Resolve multisampled backbuffer to a texture rendertarget. The texture's size should match the viewport size.
 
void Draw (PrimitiveType type, unsigned vertexStart, unsigned vertexCount)
 Draw non-indexed geometry.
 
void Draw (PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned minVertex, unsigned vertexCount)
 Draw indexed geometry.
 
void DrawInstanced (PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned minVertex, unsigned vertexCount, unsigned instanceCount)
 Draw indexed, instanced geometry.
 
void SetVertexBuffer (VertexBuffer *buffer)
 Set vertex buffer.
 
bool SetVertexBuffers (const PODVector< VertexBuffer * > &buffers, const PODVector< unsigned > &elementMasks, unsigned instanceOffset=0)
 Set multiple vertex buffers.
 
bool SetVertexBuffers (const Vector< SharedPtr< VertexBuffer > > &buffers, const PODVector< unsigned > &elementMasks, unsigned instanceOffset=0)
 Set multiple vertex buffers.
 
void SetIndexBuffer (IndexBuffer *buffer)
 Set index buffer.
 
void SetShaders (ShaderVariation *vs, ShaderVariation *ps)
 Set shaders.
 
void SetShaderParameter (StringHash param, const float *data, unsigned count)
 Set shader float constants.
 
void SetShaderParameter (StringHash param, float value)
 Set shader float constant.
 
void SetShaderParameter (StringHash param, const Color &color)
 Set shader color constant.
 
void SetShaderParameter (StringHash param, const Vector2 &vector)
 Set shader 2D vector constant.
 
void SetShaderParameter (StringHash param, const Matrix3 &matrix)
 Set shader 3x3 matrix constant.
 
void SetShaderParameter (StringHash param, const Vector3 &vector)
 Set shader 3D vector constant.
 
void SetShaderParameter (StringHash param, const Matrix4 &matrix)
 Set shader 4x4 matrix constant.
 
void SetShaderParameter (StringHash param, const Vector4 &vector)
 Set shader 4D vector constant.
 
void SetShaderParameter (StringHash param, const Matrix3x4 &matrix)
 Set shader 4x3 matrix constant.
 
void SetShaderParameter (StringHash param, const Variant &value)
 Set shader constant from a variant. Supported variant types: bool, float, vector2, vector3, vector4, color.
 
bool NeedParameterUpdate (ShaderParameterGroup group, const void *source)
 Check whether a shader parameter group needs update. Does not actually check whether parameters exist in the shaders.
 
bool HasShaderParameter (StringHash param)
 Check whether a shader parameter exists on the currently set shaders.
 
bool HasTextureUnit (TextureUnit unit)
 Check whether the current pixel shader uses a texture unit.
 
void ClearParameterSource (ShaderParameterGroup group)
 Clear remembered shader parameter source group.
 
void ClearParameterSources ()
 Clear remembered shader parameter sources.
 
void ClearTransformSources ()
 Clear remembered transform shader parameter sources.
 
void SetTexture (unsigned index, Texture *texture)
 Set texture.
 
void SetTextureForUpdate (Texture *texture)
 Bind texture unit 0 for update. Called by Texture.
 
void SetDefaultTextureFilterMode (TextureFilterMode mode)
 Set default texture filtering mode.
 
void SetTextureAnisotropy (unsigned level)
 Set texture anisotropy.
 
void SetTextureParametersDirty ()
 Dirty texture parameters of all textures (when global settings change.)
 
void ResetRenderTargets ()
 Reset all rendertargets, depth-stencil surface and viewport.
 
void ResetRenderTarget (unsigned index)
 Reset specific rendertarget.
 
void ResetDepthStencil ()
 Reset depth-stencil surface.
 
void SetRenderTarget (unsigned index, RenderSurface *renderTarget)
 Set rendertarget.
 
void SetRenderTarget (unsigned index, Texture2D *texture)
 Set rendertarget.
 
void SetDepthStencil (RenderSurface *depthStencil)
 Set depth-stencil surface.
 
void SetDepthStencil (Texture2D *texture)
 Set depth-stencil surface.
 
void SetViewport (const IntRect &rect)
 Set viewport.
 
void SetBlendMode (BlendMode mode)
 Set blending mode.
 
void SetColorWrite (bool enable)
 Set color write on/off.
 
void SetCullMode (CullMode mode)
 Set hardware culling mode.
 
void SetDepthBias (float constantBias, float slopeScaledBias)
 Set depth bias.
 
void SetDepthTest (CompareMode mode)
 Set depth compare.
 
void SetDepthWrite (bool enable)
 Set depth write on/off.
 
void SetFillMode (FillMode mode)
 Set polygon fill mode.
 
void SetScissorTest (bool enable, const Rect &rect=Rect::FULL, bool borderInclusive=true)
 Set scissor test.
 
void SetScissorTest (bool enable, const IntRect &rect)
 Set scissor test.
 
void SetStencilTest (bool enable, CompareMode mode=CMP_ALWAYS, StencilOp pass=OP_KEEP, StencilOp fail=OP_KEEP, StencilOp zFail=OP_KEEP, unsigned stencilRef=0, unsigned compareMask=M_MAX_UNSIGNED, unsigned writeMask=M_MAX_UNSIGNED)
 Set stencil test.
 
void SetClipPlane (bool enable, const Plane &clipPlane=Plane::UP, const Matrix3x4 &view=Matrix3x4::IDENTITY, const Matrix4 &projection=Matrix4::IDENTITY)
 Set a custom clipping plane. The plane is specified in world space, but is dependent on the view and projection matrices.
 
void BeginDumpShaders (const String &fileName)
 Begin dumping shader variation names to an XML file for precaching.
 
void EndDumpShaders ()
 End dumping shader variations names.
 
void PrecacheShaders (Deserializer &source)
 Precache shader variations from an XML file generated with BeginDumpShaders().
 
bool IsInitialized () const
 Return whether rendering initialized.
 
GraphicsImplGetImpl () const
 Return graphics implementation, which holds the actual API-specific resources.
 
void * GetExternalWindow () const
 Return OS-specific external window handle. Null if not in use.
 
const StringGetWindowTitle () const
 Return window title.
 
const StringGetApiName () const
 Return graphics API name.
 
IntVector2 GetWindowPosition () const
 Return window position.
 
int GetWidth () const
 Return window width.
 
int GetHeight () const
 Return window height.
 
int GetMultiSample () const
 Return multisample mode (1 = no multisampling.)
 
bool GetFullscreen () const
 Return whether window is fullscreen.
 
bool GetBorderless () const
 Return whether window is borderless.
 
bool GetResizable () const
 Return whether window is resizable.
 
bool GetVSync () const
 Return whether vertical sync is on.
 
bool GetTripleBuffer () const
 Return whether triple buffering is enabled.
 
bool GetSRGB () const
 Return whether the main window is using sRGB conversion on write.
 
bool GetFlushGPU () const
 Return whether the GPU command buffer is flushed each frame. Not yet implemented on OpenGL.
 
bool GetForceGL2 () const
 Return whether OpenGL 2 use is forced.
 
const StringGetOrientations () const
 Return allowed screen orientations.
 
bool IsDeviceLost () const
 Return whether device is lost, and can not yet render.
 
unsigned GetNumPrimitives () const
 Return number of primitives drawn this frame.
 
unsigned GetNumBatches () const
 Return number of batches drawn this frame.
 
unsigned GetDummyColorFormat () const
 Return dummy color texture format for shadow maps. 0 if not needed, may be nonzero on OS X to work around an Intel driver issue.
 
unsigned GetShadowMapFormat () const
 Return shadow map depth texture format, or 0 if not supported.
 
unsigned GetHiresShadowMapFormat () const
 Return 24-bit shadow map depth texture format, or 0 if not supported.
 
bool GetInstancingSupport () const
 Return whether hardware instancing is supported.
 
bool GetLightPrepassSupport () const
 Return whether light pre-pass rendering is supported.
 
bool GetDeferredSupport () const
 Return whether deferred rendering is supported.
 
bool GetAnisotropySupport () const
 Return whether anisotropic texture filtering is supported.
 
bool GetHardwareShadowSupport () const
 Return whether shadow map depth compare is done in hardware. Always true on OpenGL.
 
bool GetReadableDepthSupport () const
 Return whether a readable hardware depth format is available.
 
bool GetSRGBSupport () const
 Return whether sRGB conversion on texture sampling is supported.
 
bool GetSRGBWriteSupport () const
 Return whether sRGB conversion on rendertarget writing is supported.
 
PODVector< IntVector2GetResolutions () const
 Return supported fullscreen resolutions.
 
PODVector< int > GetMultiSampleLevels () const
 Return supported multisampling levels.
 
IntVector2 GetDesktopResolution () const
 Return the desktop resolution.
 
unsigned GetFormat (CompressedFormat format) const
 Return hardware format for a compressed image format, or 0 if unsupported.
 
ShaderVariationGetShader (ShaderType type, const String &name, const String &defines=String::EMPTY) const
 Return a shader variation by name and defines.
 
ShaderVariationGetShader (ShaderType type, const char *name, const char *defines) const
 Return a shader variation by name and defines.
 
VertexBufferGetVertexBuffer (unsigned index) const
 Return current vertex buffer by index.
 
IndexBufferGetIndexBuffer () const
 Return index buffer.
 
ShaderVariationGetVertexShader () const
 Return vertex shader.
 
ShaderVariationGetPixelShader () const
 Return pixel shader.
 
ShaderProgramGetShaderProgram () const
 Return shader program.
 
TextureUnit GetTextureUnit (const String &name)
 Return texture unit index by name.
 
const StringGetTextureUnitName (TextureUnit unit)
 Return texture unit name by index.
 
TextureGetTexture (unsigned index) const
 Return texture by texture unit index.
 
TextureFilterMode GetDefaultTextureFilterMode () const
 Return default texture filtering mode.
 
RenderSurfaceGetRenderTarget (unsigned index) const
 Return rendertarget by index.
 
RenderSurfaceGetDepthStencil () const
 Return depth-stencil surface.
 
Texture2DGetDepthTexture () const
 Return readable depth-stencil texture. Not created automatically on OpenGL.
 
IntRect GetViewport () const
 Return the viewport coordinates.
 
unsigned GetTextureAnisotropy () const
 Return texture anisotropy.
 
BlendMode GetBlendMode () const
 Return blending mode.
 
bool GetColorWrite () const
 Return whether color write is enabled.
 
CullMode GetCullMode () const
 Return hardware culling mode.
 
float GetDepthConstantBias () const
 Return depth constant bias.
 
float GetDepthSlopeScaledBias () const
 Return depth slope scaled bias.
 
CompareMode GetDepthTest () const
 Return depth compare mode.
 
bool GetDepthWrite () const
 Return whether depth write is enabled.
 
FillMode GetFillMode () const
 Return polygon fill mode.
 
bool GetStencilTest () const
 Return whether stencil test is enabled.
 
bool GetScissorTest () const
 Return whether scissor test is enabled.
 
const IntRectGetScissorRect () const
 Return scissor rectangle coordinates.
 
CompareMode GetStencilTestMode () const
 Return stencil compare mode.
 
StencilOp GetStencilPass () const
 Return stencil operation to do if stencil test passes.
 
StencilOp GetStencilFail () const
 Return stencil operation to do if stencil test fails.
 
StencilOp GetStencilZFail () const
 Return stencil operation to do if depth compare fails.
 
unsigned GetStencilRef () const
 Return stencil reference value.
 
unsigned GetStencilCompareMask () const
 Return stencil compare bitmask.
 
unsigned GetStencilWriteMask () const
 Return stencil write bitmask.
 
bool GetUseClipPlane () const
 Return whether a custom clipping plane is in use.
 
IntVector2 GetRenderTargetDimensions () const
 Return rendertarget width and height.
 
void WindowResized ()
 Window was resized through user interaction. Called by Input subsystem.
 
void WindowMoved ()
 Window was moved through user interaction. Called by Input subsystem.
 
void AddGPUObject (GPUObject *object)
 Add a GPU object to keep track of. Called by GPUObject.
 
void RemoveGPUObject (GPUObject *object)
 Remove a GPU object. Called by GPUObject.
 
void * ReserveScratchBuffer (unsigned size)
 Reserve a CPU-side scratch buffer.
 
void FreeScratchBuffer (void *buffer)
 Free a CPU-side scratch buffer.
 
void CleanupScratchBuffers ()
 Clean up too large scratch buffers.
 
void CleanupRenderSurface (RenderSurface *surface)
 Clean up a render surface from all FBOs.
 
void CleanupShaderPrograms (ShaderVariation *variation)
 Clean up shader programs when a shader variation is released or destroyed.
 
ConstantBufferGetOrCreateConstantBuffer (unsigned bindingIndex, unsigned size)
 Reserve a constant buffer.
 
void Release (bool clearGPUObjects, bool closeWindow)
 Release/clear GPU objects and optionally close the window.
 
void Restore ()
 Restore GPU objects and reinitialize state. Requires an open window.
 
void Maximize ()
 Maximize the Window.
 
void Minimize ()
 Minimize the Window.
 
void MarkFBODirty ()
 Mark the FBO needing an update.
 
void SetVBO (unsigned object)
 Bind a VBO, avoiding redundant operation.
 
void SetUBO (unsigned object)
 Bind a UBO, avoiding redundant operation.
 
- Public Member Functions inherited from Urho3D::Object
 Object (Context *context)
 Construct.
 
virtual ~Object ()
 Destruct. Clean up self from event sender & receiver structures.
 
virtual Urho3D::StringHash GetType () const =0
 Return type hash.
 
virtual Urho3D::StringHash GetBaseType () const =0
 Return base class type hash.
 
virtual const Urho3D::StringGetTypeName () const =0
 Return type name.
 
virtual void OnEvent (Object *sender, StringHash eventType, VariantMap &eventData)
 Handle event.
 
void SubscribeToEvent (StringHash eventType, EventHandler *handler)
 Subscribe to an event that can be sent by any sender.
 
void SubscribeToEvent (Object *sender, StringHash eventType, EventHandler *handler)
 Subscribe to a specific sender's event.
 
void UnsubscribeFromEvent (StringHash eventType)
 Unsubscribe from an event.
 
void UnsubscribeFromEvent (Object *sender, StringHash eventType)
 Unsubscribe from a specific sender's event.
 
void UnsubscribeFromEvents (Object *sender)
 Unsubscribe from a specific sender's events.
 
void UnsubscribeFromAllEvents ()
 Unsubscribe from all events.
 
void UnsubscribeFromAllEventsExcept (const PODVector< StringHash > &exceptions, bool onlyUserData)
 Unsubscribe from all events except those listed, and optionally only those with userdata (script registered events.)
 
void SendEvent (StringHash eventType)
 Send event to all subscribers.
 
void SendEvent (StringHash eventType, VariantMap &eventData)
 Send event with parameters to all subscribers. More...
 
VariantMapGetEventDataMap () const
 Return a preallocated map for event data. Used for optimization to avoid constant re-allocation of event data maps.
 
ContextGetContext () const
 Return execution context.
 
ObjectGetSubsystem (StringHash type) const
 Return subsystem by type.
 
ObjectGetEventSender () const
 Return active event sender. Null outside event handling.
 
EventHandlerGetEventHandler () const
 Return active event handler. Null outside event handling.
 
bool HasSubscribedToEvent (StringHash eventType) const
 Return whether has subscribed to an event without specific sender.
 
bool HasSubscribedToEvent (Object *sender, StringHash eventType) const
 Return whether has subscribed to a specific sender's event.
 
bool HasEventHandlers () const
 Return whether has subscribed to any event.
 
template<class T >
T * GetSubsystem () const
 Template version of returning a subsystem.
 
const StringGetCategory () const
 Return object category. Categories are (optionally) registered along with the object factory. Return an empty string if the object category is not registered.
 
- Public Member Functions inherited from Urho3D::RefCounted
 RefCounted ()
 Construct. Allocate the reference count structure and set an initial self weak reference.
 
virtual ~RefCounted ()
 Destruct. Mark as expired and also delete the reference count structure if no outside weak references exist.
 
void AddRef ()
 Increment reference count. Can also be called outside of a SharedPtr for traditional reference counting.
 
void ReleaseRef ()
 Decrement reference count and delete self if no more references. Can also be called outside of a SharedPtr for traditional reference counting.
 
int Refs () const
 Return reference count.
 
int WeakRefs () const
 Return weak reference count.
 
RefCountRefCountPtr ()
 Return pointer to the reference count structure.
 

Static Public Member Functions

static unsigned GetAlphaFormat ()
 Return the API-specific alpha texture format.
 
static unsigned GetLuminanceFormat ()
 Return the API-specific luminance texture format.
 
static unsigned GetLuminanceAlphaFormat ()
 Return the API-specific luminance alpha texture format.
 
static unsigned GetRGBFormat ()
 Return the API-specific RGB texture format.
 
static unsigned GetRGBAFormat ()
 Return the API-specific RGBA texture format.
 
static unsigned GetRGBA16Format ()
 Return the API-specific RGBA 16-bit texture format.
 
static unsigned GetRGBAFloat16Format ()
 Return the API-specific RGBA 16-bit float texture format.
 
static unsigned GetRGBAFloat32Format ()
 Return the API-specific RGBA 32-bit float texture format.
 
static unsigned GetRG16Format ()
 Return the API-specific RG 16-bit texture format.
 
static unsigned GetRGFloat16Format ()
 Return the API-specific RG 16-bit float texture format.
 
static unsigned GetRGFloat32Format ()
 Return the API-specific RG 32-bit float texture format.
 
static unsigned GetFloat16Format ()
 Return the API-specific single channel 16-bit float texture format.
 
static unsigned GetFloat32Format ()
 Return the API-specific single channel 32-bit float texture format.
 
static unsigned GetLinearDepthFormat ()
 Return the API-specific linear depth texture format.
 
static unsigned GetDepthStencilFormat ()
 Return the API-specific hardware depth-stencil texture format.
 
static unsigned GetReadableDepthFormat ()
 Return the API-specific readable hardware depth format, or 0 if not supported.
 
static unsigned GetFormat (const String &formatName)
 Return the API-specific texture format from a textual description, for example "rgb".
 
static const Vector2GetPixelUVOffset ()
 Return UV offset required for pixel perfect rendering.
 
static unsigned GetMaxBones ()
 Return maximum number of supported bones for skinning.
 
static unsigned GetAlphaFormat ()
 Return the API-specific alpha texture format.
 
static unsigned GetLuminanceFormat ()
 Return the API-specific luminance texture format.
 
static unsigned GetLuminanceAlphaFormat ()
 Return the API-specific luminance alpha texture format.
 
static unsigned GetRGBFormat ()
 Return the API-specific RGB texture format.
 
static unsigned GetRGBAFormat ()
 Return the API-specific RGBA texture format.
 
static unsigned GetRGBA16Format ()
 Return the API-specific RGBA 16-bit texture format.
 
static unsigned GetRGBAFloat16Format ()
 Return the API-specific RGBA 16-bit float texture format.
 
static unsigned GetRGBAFloat32Format ()
 Return the API-specific RGBA 32-bit float texture format.
 
static unsigned GetRG16Format ()
 Return the API-specific RG 16-bit texture format.
 
static unsigned GetRGFloat16Format ()
 Return the API-specific RG 16-bit float texture format.
 
static unsigned GetRGFloat32Format ()
 Return the API-specific RG 32-bit float texture format.
 
static unsigned GetFloat16Format ()
 Return the API-specific single channel 16-bit float texture format.
 
static unsigned GetFloat32Format ()
 Return the API-specific single channel 32-bit float texture format.
 
static unsigned GetLinearDepthFormat ()
 Return the API-specific linear depth texture format.
 
static unsigned GetDepthStencilFormat ()
 Return the API-specific hardware depth-stencil texture format.
 
static unsigned GetReadableDepthFormat ()
 Return the API-specific readable hardware depth format, or 0 if not supported.
 
static unsigned GetFormat (const String &formatName)
 Return the API-specific texture format from a textual description, for example "rgb".
 
static const Vector2GetPixelUVOffset ()
 Return UV offset required for pixel perfect rendering.
 
static unsigned GetMaxBones ()
 Return maximum number of supported bones for skinning.
 
static bool GetGL3Support ()
 Return whether is using an OpenGL 3 context.
 

Private Member Functions

 OBJECT (Graphics)
 
bool OpenWindow (int width, int height, bool resizable, bool borderless)
 Create the application window.
 
void CreateWindowIcon ()
 Create the application window icon.
 
void AdjustWindow (int &newWidth, int &newHeight, bool &newFullscreen, bool &newBorderless)
 Adjust the window for new resolution and fullscreen mode.
 
bool CreateDevice (int width, int height, int multiSample)
 Create the D3D11 device and swap chain. Requires an open window. Can also be called again to recreate swap chain. Return true on success.
 
bool UpdateSwapChain (int width, int height)
 Update swap chain state for a new mode and create views for the backbuffer & default depth buffer. Return true on success.
 
void CheckFeatureSupport ()
 Check supported rendering features.
 
void ResetCachedState ()
 Reset cached rendering state.
 
void SetTextureUnitMappings ()
 Initialize texture unit mappings.
 
void PrepareDraw ()
 Process dirtied state before draw.
 
 OBJECT (Graphics)
 
void CreateWindowIcon ()
 Create the application window icon.
 
void CheckFeatureSupport ()
 Check supported rendering features.
 
void PrepareDraw ()
 Prepare for draw call. Update constant buffers and setup the FBO.
 
void CleanupFramebuffers ()
 Clean up all framebuffers. Called when destroying the context.
 
void ResetCachedState ()
 Reset cached rendering state.
 
void SetTextureUnitMappings ()
 Initialize texture unit mappings.
 
unsigned CreateFramebuffer ()
 Create a framebuffer using either extension or core functionality.
 
void DeleteFramebuffer (unsigned fbo)
 Delete a framebuffer using either extension or core functionality.
 
void BindFramebuffer (unsigned fbo)
 Bind a framebuffer using either extension or core functionality.
 
void BindColorAttachment (unsigned index, unsigned target, unsigned object)
 Bind a framebuffer color attachment using either extension or core functionality.
 
void BindDepthAttachment (unsigned object, bool isRenderBuffer)
 Bind a framebuffer depth attachment using either extension or core functionality.
 
void BindStencilAttachment (unsigned object, bool isRenderBuffer)
 Bind a framebuffer stencil attachment using either extension or core functionality.
 
bool CheckFramebuffer ()
 Check FBO completeness using either extension or core functionality.
 

Private Attributes

Mutex gpuObjectMutex_
 Mutex for accessing the GPU objects vector from several threads.
 
GraphicsImplimpl_
 Implementation.
 
String windowTitle_
 Window title.
 
ImagewindowIcon_
 Window Icon File Name.
 
void * externalWindow_
 External window, null if not in use (default.)
 
int width_
 Window width.
 
int height_
 Window height.
 
IntVector2 position_
 Window position.
 
int multiSample_
 Multisampling mode.
 
bool fullscreen_
 Fullscreen flag.
 
bool borderless_
 Borderless flag.
 
bool resizable_
 Resizable flag.
 
bool vsync_
 Vertical sync flag.
 
bool tripleBuffer_
 Triple buffering flag.
 
bool flushGPU_
 Flush GPU command buffer flag.
 
bool sRGB_
 sRGB conversion on write flag for the main window.
 
bool lightPrepassSupport_
 Light pre-pass rendering support flag. More...
 
bool deferredSupport_
 Deferred rendering support flag.
 
bool hardwareShadowSupport_
 Hardware shadow map depth compare support flag.
 
bool instancingSupport_
 Instancing support flag.
 
bool sRGBSupport_
 sRGB conversion on read support flag.
 
bool sRGBWriteSupport_
 sRGB conversion on write support flag.
 
unsigned numPrimitives_
 Number of primitives this frame.
 
unsigned numBatches_
 Number of batches this frame.
 
unsigned maxScratchBufferRequest_
 Largest scratch buffer request this frame.
 
PODVector< GPUObject * > gpuObjects_
 GPU objects.
 
Vector< ScratchBufferscratchBuffers_
 Scratch buffers.
 
unsigned dummyColorFormat_
 Shadow map dummy color texture format.
 
unsigned shadowMapFormat_
 Shadow map depth texture format.
 
unsigned hiresShadowMapFormat_
 Shadow map 24-bit depth texture format.
 
VertexBuffervertexBuffers_ [MAX_VERTEX_STREAMS]
 Vertex buffers in use.
 
unsigned elementMasks_ [MAX_VERTEX_STREAMS]
 Element masks by vertex buffer. More...
 
IndexBufferindexBuffer_
 Index buffer in use.
 
unsigned long long vertexDeclarationHash_
 Current vertex declaration hash.
 
unsigned primitiveType_
 Current primitive type.
 
ShaderVariationvertexShader_
 Vertex shader in use.
 
ShaderVariationpixelShader_
 Pixel shader in use.
 
Texturetextures_ [MAX_TEXTURE_UNITS]
 Textures in use.
 
HashMap< String, TextureUnit > textureUnits_
 Texture unit mappings.
 
RenderSurfacerenderTargets_ [MAX_RENDERTARGETS]
 Rendertargets in use.
 
RenderSurfacedepthStencil_
 Depth-stencil surface in use.
 
IntRect viewport_
 Viewport coordinates.
 
unsigned textureAnisotropy_
 Texture anisotropy level.
 
BlendMode blendMode_
 Blending mode.
 
bool colorWrite_
 Color write enable.
 
CullMode cullMode_
 Hardware culling mode.
 
float constantDepthBias_
 Depth constant bias.
 
float slopeScaledDepthBias_
 Depth slope scaled bias.
 
CompareMode depthTestMode_
 Depth compare mode.
 
bool depthWrite_
 Depth write enable flag.
 
FillMode fillMode_
 Polygon fill mode.
 
IntRect scissorRect_
 Scissor test rectangle.
 
bool scissorTest_
 Scissor test enable flag.
 
CompareMode stencilTestMode_
 Stencil test compare mode.
 
StencilOp stencilPass_
 Stencil operation on pass.
 
StencilOp stencilFail_
 Stencil operation on fail.
 
StencilOp stencilZFail_
 Stencil operation on depth fail.
 
unsigned stencilRef_
 Stencil test reference value.
 
unsigned stencilCompareMask_
 Stencil compare bitmask.
 
unsigned stencilWriteMask_
 Stencil write bitmask.
 
Vector4 clipPlane_
 Current custom clip plane in post-projection space.
 
bool stencilTest_
 Stencil test enable flag.
 
bool useClipPlane_
 Custom clip plane enable flag.
 
bool renderTargetsDirty_
 Rendertargets dirty flag.
 
bool texturesDirty_
 Textures dirty flag.
 
bool vertexDeclarationDirty_
 Vertex declaration dirty flag.
 
bool blendStateDirty_
 Blend state dirty flag.
 
bool depthStateDirty_
 Depth state dirty flag.
 
bool rasterizerStateDirty_
 Rasterizer state dirty flag.
 
bool scissorRectDirty_
 Scissor rect dirty flag.
 
bool stencilRefDirty_
 Stencil ref dirty flag.
 
unsigned blendStateHash_
 Hash of current blend state.
 
unsigned depthStateHash_
 Hash of current depth state.
 
unsigned rasterizerStateHash_
 Hash of current rasterizer state.
 
unsigned firstDirtyTexture_
 First dirtied texture unit.
 
unsigned lastDirtyTexture_
 Last dirtied texture unit.
 
unsigned firstDirtyVB_
 First dirtied vertex buffer.
 
unsigned lastDirtyVB_
 Last dirtied vertex buffer.
 
TextureFilterMode defaultTextureFilterMode_
 Default texture filtering mode.
 
HashMap< unsigned long long,
SharedPtr< VertexDeclaration > > 
vertexDeclarations_
 Vertex declarations.
 
HashMap< unsigned, SharedPtr
< ConstantBuffer > > 
constantBuffers_
 Constant buffers. More...
 
PODVector< ConstantBuffer * > dirtyConstantBuffers_
 Currently dirty constant buffers. More...
 
ShaderProgramMap shaderPrograms_
 Shader programs. More...
 
ShaderProgramshaderProgram_
 Shader program in use.
 
const void * shaderParameterSources_ [MAX_SHADER_PARAMETER_GROUPS]
 Remembered shader parameter sources.
 
String shaderPath_
 Base directory for shaders.
 
String shaderExtension_
 File extension for shaders.
 
WeakPtr< ShaderlastShader_
 Last used shader in shader variation query.
 
String lastShaderName_
 Last used shader name in shader variation query.
 
SharedPtr< ShaderPrecacheshaderPrecache_
 Shader precache utility.
 
String orientations_
 Allowed screen orientations.
 
String apiName_
 Graphics API name.
 
bool forceGL2_
 Force OpenGL 2 use flag.
 
bool anisotropySupport_
 Anisotropic filtering support flag.
 
bool dxtTextureSupport_
 DXT format support flag.
 
bool etcTextureSupport_
 ETC1 format support flag.
 
bool pvrtcTextureSupport_
 PVRTC formats support flag.
 
unsigned textureTypes_ [MAX_TEXTURE_UNITS]
 OpenGL texture types in use.
 
ConstantBuffercurrentConstantBuffers_ [MAX_SHADER_PARAMETER_GROUPS *2]
 Currently bound constant buffers.
 
unsigned lastInstanceOffset_
 Last used instance data offset.
 
HashMap< int, SharedPtr
< Texture2D > > 
depthTextures_
 Map for additional depth textures, to emulate Direct3D9 ability to mix render texture and backbuffer rendering.
 

Static Private Attributes

static const Vector2 pixelUVOffset
 Pixel perfect UV offset.
 
static bool gl3Support = false
 Flag for OpenGL 3 support.
 

Additional Inherited Members

- Protected Attributes inherited from Urho3D::Object
Contextcontext_
 Execution context.
 

Detailed Description

Graphics subsystem. Manages the application window, rendering state and GPU resources.

Member Function Documentation

void Urho3D::Graphics::Clear ( unsigned  flags,
const Color color = Color(0.0f, 0.0f, 0.0f, 0.0f),
float  depth = 1.0f,
unsigned  stencil = 0 
)

Clear any or all of rendertarget, depth buffer and stencil buffer.

Todo:
Any user-set scissor test will be lost

Here is the call graph for this function:

Here is the caller graph for this function:

PODVector< int > Urho3D::Graphics::GetMultiSampleLevels ( ) const

Return supported multisampling levels.

Todo:
Implement properly, if possible

Here is the call graph for this function:

Here is the caller graph for this function:

void Urho3D::Graphics::SetShaders ( ShaderVariation vs,
ShaderVariation ps 
)

Set shaders.

Todo:
Causes overhead and string manipulation per drawcall

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

HashMap< unsigned, SharedPtr< ConstantBuffer > > Urho3D::Graphics::constantBuffers_
private

Constant buffers.

All constant buffers.

PODVector< ConstantBuffer * > Urho3D::Graphics::dirtyConstantBuffers_
private

Currently dirty constant buffers.

Dirty constant buffers.

unsigned Urho3D::Graphics::elementMasks_
private

Element masks by vertex buffer.

Element mask in use.

bool Urho3D::Graphics::lightPrepassSupport_
private

Light pre-pass rendering support flag.

Light prepass support flag.

ShaderProgramMap Urho3D::Graphics::shaderPrograms_
private

Shader programs.

Linked shader programs.


The documentation for this class was generated from the following files:
  • /home/travis/build/urho3d/Urho3D/Source/Urho3D/Graphics/Direct3D11/D3D11Graphics.h
  • /home/travis/build/urho3d/Urho3D/Source/Urho3D/Graphics/OpenGL/OGLGraphics.h
  • /home/travis/build/urho3d/Urho3D/Source/Urho3D/Graphics/Direct3D11/D3D11Graphics.cpp
  • /home/travis/build/urho3d/Urho3D/Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp