Ocular Engine
Ocular::Graphics::D3D11GraphicsDriver Class Reference
Inheritance diagram for Ocular::Graphics::D3D11GraphicsDriver:
Ocular::Graphics::GraphicsDriver Ocular::Core::AEventListener

Public Member Functions

virtual bool initialize () override
 
virtual void clearBuffers (Core::Color const &clearColor=Core::Color::DefaultClearGray()) override
 
virtual void clearDepthBuffer (float value=1.0f) override
 
virtual void clearStencilBuffer (uint32_t value=0) override
 
virtual void swapBuffers () override
 
virtual void setRenderTexture (RenderTexture *texture) override
 
virtual void setDepthTexture (DepthTexture *texture) override
 
virtual MaterialcreateMaterial () const override
 
virtual ViewportcreateViewport (float x, float y, float width, float height, float minDepth=0.0f, float maxDepth=1.0f) const override
 
virtual TexturecreateTexture (TextureDescriptor const &descriptor) const override
 
virtual Texture2DcreateTexture2D (TextureDescriptor const &descriptor) const override
 
virtual RenderTexturecreateRenderTexture (TextureDescriptor const &descriptor) const override
 
virtual DepthTexturecreateDepthTexture (TextureDescriptor const &descriptor) const override
 
virtual uint32_t getMaxBoundTextures () const override
 
virtual VertexShadercreateVertexShader () const override
 
virtual GeometryShadercreateGeometryShader () const override
 
virtual FragmentShadercreateFragmentShader () const override
 
virtual PreTessellationShadercreatePreTessellationShader () const override
 
virtual PostTessellationShadercreatePostTessellationShader () const override
 
virtual UniformBuffercreateUniformBuffer (UniformBufferType type) const override
 
virtual IndexBuffercreateIndexBuffer () const override
 
virtual VertexBuffercreateVertexBuffer () const override
 
virtual GPUBuffercreateGPUBuffer (GPUBufferDescriptor const &descriptor) const override
 
virtual bool renderMesh (Mesh *mesh, uint32_t submesh=0) override
 
virtual bool renderBounds (Core::SceneObject *object, Math::BoundsType type) override
 
OD3D11Device * getD3DDevice () const
 
OD3D11DeviceContext * getD3DDeviceContext () const
 
OD3DSwapChain * getD3DSwapChain () const
 
- Public Member Functions inherited from Ocular::Graphics::GraphicsDriver
virtual RenderStategetRenderState ()
 
virtual void drawDebugLine (Math::Vector3f const &start, Math::Vector3f const &stop, Core::Color const &color, uint64_t lifetime=30000)
 
virtual void drawDebugCircle (Math::Vector3f const &center, float radius, Math::Vector3f const &normal, Core::Color const &color, uint32_t segments=64, uint64_t lifetime=30000)
 
virtual void renderDebug ()
 
void clearFrameStats ()
 
FrameStats getLastFrameStats () const
 

Static Public Member Functions

static bool ConvertTextureDescriptor (TextureDescriptor const &source, D3D11_TEXTURE2D_DESC &dest)
 
static bool ConvertTextureDescriptor (D3D11_TEXTURE2D_DESC const &source, TextureDescriptor &dest)
 

Protected Member Functions

virtual bool onEvent (std::shared_ptr< Core::AEvent > event) override
 
void resizeSwapChain (uint32_t width, uint32_t height)
 
bool validateWindow (std::shared_ptr< Core::AWindow > window, HWND &hwnd) const
 
bool createDeviceAndSwapChain (Core::WindowWin32 const *window, HWND const hwnd)
 
DXGI_SWAP_CHAIN_DESC createSwapChainDescription (Core::WindowWin32 const *window) const
 
bool fetchDeviceAndSwapChain1 (ID3D11Device *device, ID3D11DeviceContext *context, Core::WindowWin32 const *window)
 
bool fetchDeviceAndSwapChain2 (ID3D11Device *device, ID3D11DeviceContext *context, Core::WindowWin32 const *window)
 
void printD3DDebug ()
 
- Protected Member Functions inherited from Ocular::Graphics::GraphicsDriver
void addDrawCall (uint32_t numIndices)
 
- Protected Member Functions inherited from Ocular::Core::AEventListener
virtual bool onEvent (std::shared_ptr< AEvent > event)=0
 

Static Protected Member Functions

static bool ValidateTextureDescriptor (TextureDescriptor const &descriptor)
 

Additional Inherited Members

- Protected Attributes inherited from Ocular::Graphics::GraphicsDriver
FrameStats m_LastFrameStats
 
FrameStats m_CurrFrameStats
 
Debug m_Debug
 
RenderStatem_RenderState
 

Member Function Documentation

void Ocular::Graphics::D3D11GraphicsDriver::clearBuffers ( Core::Color const &  clearColor = Core::Color::DefaultClearGray())
overridevirtual

Clears the backbuffer RTV, and currently bound depth/stencil buffers.

The backbuffer is cleared to the specified color value. The depth buffer is cleared to 1.0. The stencil buffer is cleared to 0.

Parameters
[in]clearColor

Reimplemented from Ocular::Graphics::GraphicsDriver.

void Ocular::Graphics::D3D11GraphicsDriver::clearDepthBuffer ( float  value = 1.0f)
overridevirtual

Clears the active depth buffer to the specified value.

Parameters
[in]value

Reimplemented from Ocular::Graphics::GraphicsDriver.

void Ocular::Graphics::D3D11GraphicsDriver::clearStencilBuffer ( uint32_t  value = 0)
overridevirtual

Clears the active stencil buffer to the specified value.

Parameters
[in]value

Reimplemented from Ocular::Graphics::GraphicsDriver.

DepthTexture * Ocular::Graphics::D3D11GraphicsDriver::createDepthTexture ( TextureDescriptor const &  descriptor) const
overridevirtual

Creates a new API-specific implementation of the DepthTexture class.

Parameters
[in]descriptor
Returns
Returns the new instantiated texture. The caller must assume ownership of the texture and handle any cleanup. May return NULL if texture creation failed.

Reimplemented from Ocular::Graphics::GraphicsDriver.

FragmentShader * Ocular::Graphics::D3D11GraphicsDriver::createFragmentShader ( ) const
overridevirtual

Creates a new API-specific implementation of the FragmentShader class.

Returns
Returns the new instantiated shader. The caller must assume ownership of the shader and handle any cleanup. May return NULL if shader creation failed.

Reimplemented from Ocular::Graphics::GraphicsDriver.

GeometryShader * Ocular::Graphics::D3D11GraphicsDriver::createGeometryShader ( ) const
overridevirtual

Creates a new API-specific implementation of the GeometryShader class.

Returns
Returns the new instantiated shader. The caller must assume ownership of the shader and handle any cleanup. May return NULL if shader creation failed.

Reimplemented from Ocular::Graphics::GraphicsDriver.

GPUBuffer * Ocular::Graphics::D3D11GraphicsDriver::createGPUBuffer ( GPUBufferDescriptor const &  descriptor) const
overridevirtual

Creates a new API-specific GPU Buffer. The type of underlying buffer depends on the parameters specified in the descriptor.

Parameters
[in]descriptor
Returns
Returns the new GPU Buffer. If the provided descriptor does not describe a valid buffer, then NULL is returned.

Reimplemented from Ocular::Graphics::GraphicsDriver.

IndexBuffer * Ocular::Graphics::D3D11GraphicsDriver::createIndexBuffer ( ) const
overridevirtual

Creates a new API-specific implementation of the IndexBuffer class.

Returns
Returns the new instantiated buffer. The caller must assume ownership of the buffer and handle any cleanup. May return NULL if buffer creation failed.

Reimplemented from Ocular::Graphics::GraphicsDriver.

Material * Ocular::Graphics::D3D11GraphicsDriver::createMaterial ( ) const
overridevirtual

Creates a new API-specific implementation of the Material class.

Returns
Returns the new instantiated material. The caller must assume ownership of the texture and handle any cleanup. May return NULL if texture creation failed.

Reimplemented from Ocular::Graphics::GraphicsDriver.

PostTessellationShader * Ocular::Graphics::D3D11GraphicsDriver::createPostTessellationShader ( ) const
overridevirtual

Creates a new API-specific implementation of the PostTessellationShader class.

Returns
Returns the new instantiated shader. The caller must assume ownership of the shader and handle any cleanup. May return NULL if shader creation failed.

Reimplemented from Ocular::Graphics::GraphicsDriver.

PreTessellationShader * Ocular::Graphics::D3D11GraphicsDriver::createPreTessellationShader ( ) const
overridevirtual

Creates a new API-specific implementation of the PreTessellationShader class.

Returns
Returns the new instantiated shader. The caller must assume ownership of the shader and handle any cleanup. May return NULL if shader creation failed.

Reimplemented from Ocular::Graphics::GraphicsDriver.

RenderTexture * Ocular::Graphics::D3D11GraphicsDriver::createRenderTexture ( TextureDescriptor const &  descriptor) const
overridevirtual

Creates a new API-specific implementation of the RenderTexture class.

Parameters
[in]descriptor
Returns
Returns the new instantiated texture. The caller must assume ownership of the texture and handle any cleanup. May return NULL if texture creation failed.

Reimplemented from Ocular::Graphics::GraphicsDriver.

Texture * Ocular::Graphics::D3D11GraphicsDriver::createTexture ( TextureDescriptor const &  descriptor) const
overridevirtual

Creates a new API-specific implementation of the Texture class.

Parameters
[in]descriptor
Returns
Returns the new instantiated texture. The caller must assume ownership of the texture and handle any cleanup. May return NULL if texture creation failed.

Reimplemented from Ocular::Graphics::GraphicsDriver.

Texture2D * Ocular::Graphics::D3D11GraphicsDriver::createTexture2D ( TextureDescriptor const &  descriptor) const
overridevirtual

Creates a new API-specific implementation of the Texture2D class.

Parameters
[in]descriptor
Returns
Returns the new instantiated texture. The caller must assume ownership of the texture and handle any cleanup. May return NULL if texture creation failed.

Reimplemented from Ocular::Graphics::GraphicsDriver.

UniformBuffer * Ocular::Graphics::D3D11GraphicsDriver::createUniformBuffer ( UniformBufferType  type) const
overridevirtual

Creates a new API-specific implementation of the UniformBuffer class.

Returns
Returns the new instantiated buffer. The caller must assume ownership of the buffer and handle any cleanup. May return NULL if buffer creation failed.

Reimplemented from Ocular::Graphics::GraphicsDriver.

VertexBuffer * Ocular::Graphics::D3D11GraphicsDriver::createVertexBuffer ( ) const
overridevirtual

Creates a new API-specific implementation of the VertexBuffer class.

Returns
Returns the new instantiated buffer. The caller must assume ownership of the buffer and handle any cleanup. May return NULL if buffer creation failed.

Reimplemented from Ocular::Graphics::GraphicsDriver.

VertexShader * Ocular::Graphics::D3D11GraphicsDriver::createVertexShader ( ) const
overridevirtual

Creates a new API-specific implementation of the VertexShader class.

Returns
Returns the new instantiated shader. The caller must assume ownership of the shader and handle any cleanup. May return NULL if shader creation failed.

Reimplemented from Ocular::Graphics::GraphicsDriver.

uint32_t Ocular::Graphics::D3D11GraphicsDriver::getMaxBoundTextures ( ) const
overridevirtual

Returns the maximum number of textures that can be bound to a single shader. This is primarily for use when assigning textures to materials, but can be used in other locations as well.

Reimplemented from Ocular::Graphics::GraphicsDriver.

bool Ocular::Graphics::D3D11GraphicsDriver::initialize ( )
overridevirtual

Initializes the GraphicsDriver implementation.

Returns
FALSE if initialization failed (this should be a fatal event).

Initialization follows the steps below:

1. Verify the window
2. Create the device, device context, and swap chain
3. Set the default render states

Reimplemented from Ocular::Graphics::GraphicsDriver.

bool Ocular::Graphics::D3D11GraphicsDriver::renderBounds ( Core::SceneObject object,
Math::BoundsType  type 
)
overridevirtual

Renders the bounds of the specified SceneObject

Parameters
[in]object
[in]type

Reimplemented from Ocular::Graphics::GraphicsDriver.

bool Ocular::Graphics::D3D11GraphicsDriver::renderMesh ( Mesh mesh,
uint32_t  submesh = 0 
)
overridevirtual

Renders the specified mesh and it's vertex and index buffers.

Parameters
[in]meshMesh to render.
[in]submeshIndex of the SubMesh to render.
Returns
TRUE if rendered successfully.

Reimplemented from Ocular::Graphics::GraphicsDriver.

void Ocular::Graphics::D3D11GraphicsDriver::setDepthTexture ( DepthTexture texture)
overridevirtual

Sets the Depth Texture to direct all depth operations towards.

Parameters
[in]texture

Reimplemented from Ocular::Graphics::GraphicsDriver.

void Ocular::Graphics::D3D11GraphicsDriver::setRenderTexture ( RenderTexture texture)
overridevirtual

Sets the Render Texture to direct all rendering operations towards.

Parameters
[in]texture

Reimplemented from Ocular::Graphics::GraphicsDriver.

void Ocular::Graphics::D3D11GraphicsDriver::swapBuffers ( )
overridevirtual

Swaps the back and front buffers.

Reimplemented from Ocular::Graphics::GraphicsDriver.

bool Ocular::Graphics::D3D11GraphicsDriver::ValidateTextureDescriptor ( TextureDescriptor const &  descriptor)
staticprotected

For the following restrictions, see the D3D11_USAGE flag values at:
https://msdn.microsoft.com/en-us/library/windows/desktop/ff476259(v=vs.85).aspx

Note: currently does not support STAGING

Usage Flags CPU Read CPU Write GPU Read GPU Write
DEFAULT Y Y
DYNAMIC Y Y
IMMUTABLE Y
STAGING Y Y Y Y

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