Cogs.Core
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Cogs::IGraphicsDevice Class Referenceabstract

Represents a graphics device used to manage graphics resources and issue drawing commands. More...

#include <IGraphicsDevice.h>

Inheritance diagram for Cogs::IGraphicsDevice:
Cogs::GraphicsDeviceD3D11 Cogs::GraphicsDeviceD3D12 Cogs::GraphicsDeviceGL20 Cogs::GraphicsDeviceGLES30 Cogs::GraphicsDeviceNull Cogs::GraphicsDeviceVK Cogs::GraphicsDeviceWebGPU

Public Member Functions

virtual ~IGraphicsDevice ()=default
 Destructor.
 
virtual bool initializeThread ()
 Initialize the graphics device for operation on the current thread.
 
virtual SharedGraphicsContextcreateSharedContext ()
 Create a shared graphics context that can be used to activate another thread for rendering.
 
virtual void activateSharedContext (SharedGraphicsContext *)
 Activates the given shared context on the calling thread.
 
virtual void releaseSharedContext (SharedGraphicsContext *)
 Releases the given shared context.
 
virtual bool initialize ()=0
 Initializes the graphics device with the settings previous set through calling setSettings.
 
virtual bool isInitializationFinished ()
 Check if async initialization is finished.
 
virtual ResourceStatistics getResourceStatistics ()
 
virtual std::string getIdentifier () const
 Get the graphics device identifier.
 
virtual GraphicsDeviceType getType () const
 Get the type of the graphics device.
 
virtual void setSize (int width, int height)=0
 Set the size of the main drawing buffer used by the graphics device in pixels.
 
virtual bool getSize (int &width, int &height) const =0
 Retrieve the size previously set by setSize.
 
virtual void beginFrame ()=0
 Signal the beginning of a new frame to the graphics device.
 
virtual void endFrame (uint32_t syncInterval=0, uint32_t presentFlags=PresentFlags::None)=0
 Signal the end of a frame to the graphics device.
 
virtual void waitForCommandSync ()
 Wait for any GPU commands on the current device to finish before returning.
 
virtual void releaseResources ()=0
 Release all resources allocated.
 
virtual ISwapChaincreateSwapChain (struct WindowData *)
 Create a new swap chain for the specified window.
 
virtual void deleteSwapChain (ISwapChain *)
 Deletes the specified swap chain.
 
virtual IContextgetImmediateContext ()=0
 Get a pointer to the immediate context used to issue commands to the graphics device.
 
virtual IBuffersgetBuffers ()=0
 Get a pointer to the buffer management interface.
 
virtual ITexturesgetTextures ()=0
 Get a pointer to the texture management interface.
 
virtual IRenderTargetsgetRenderTargets ()=0
 Get a pointer to the render target management interface.
 
virtual IEffectsgetEffects ()=0
 Get a pointer to the effect management interface.
 
virtual IPipelineStatesgetPipelineStates ()=0
 Get a pointer to the pipeline state management interface.
 
virtual ICapabilitiesgetCapabilities ()=0
 Get a pointer to the capability management interface used to query the graphics device capability flags.
 
virtual ISwapChaingetDefaultSwapChain ()=0
 Get a pointer to the default swap chain for this graphics device.
 
virtual ISyncObjectsgetSyncObjects ()=0
 Get a pointer to the sync object management interface.
 
virtual void * getNativeDevice ()
 
virtual bool setSettings (const GraphicsDeviceSettings &newSettings)
 Updates the settings associated with this device.
 
const GraphicsDeviceSettingsgetSettings () const
 

Static Public Member Functions

static void fillGraphicsSettings (struct WindowData *windowData, int requestedSampleCount)
 Set platform specific graphics settings used for window creation e.g.: XVisualInfo on Linux.
 

Protected Attributes

GraphicsDeviceSettings settings
 
std::vector< ISwapChain * > swapChains
 

Detailed Description

Represents a graphics device used to manage graphics resources and issue drawing commands.

Definition at line 168 of file IGraphicsDevice.h.

Member Function Documentation

◆ activateSharedContext()

virtual void Cogs::IGraphicsDevice::activateSharedContext ( SharedGraphicsContext )
inlinevirtual

Activates the given shared context on the calling thread.

See also
createSharedContext.
Parameters
contextPointer to a shared graphics context.

Reimplemented in Cogs::GraphicsDeviceGL20.

Definition at line 201 of file IGraphicsDevice.h.

◆ beginFrame()

virtual void Cogs::IGraphicsDevice::beginFrame ( )
pure virtual

◆ createSharedContext()

virtual SharedGraphicsContext * Cogs::IGraphicsDevice::createSharedContext ( )
inlinevirtual

Create a shared graphics context that can be used to activate another thread for rendering.

When using OpenGL on the windows platform, rendering contexts have to be made separate for each thread. These contexts must also be made current on their respective threads to enable calling GL functions there.

This function must be called from the same thread that the device was created on.

See also
activateSharedContext
Returns
A pointer to a graphics context that can be activated on another thread.

Reimplemented in Cogs::GraphicsDeviceGL20.

Definition at line 192 of file IGraphicsDevice.h.

◆ createSwapChain()

virtual ISwapChain * Cogs::IGraphicsDevice::createSwapChain ( struct WindowData )
inlinevirtual

Create a new swap chain for the specified window.

Returns
A pointer to the newly created swap chain.

Reimplemented in Cogs::GraphicsDeviceD3D11, and Cogs::GraphicsDeviceGL20.

Definition at line 283 of file IGraphicsDevice.h.

◆ deleteSwapChain()

virtual void Cogs::IGraphicsDevice::deleteSwapChain ( ISwapChain )
inlinevirtual

Deletes the specified swap chain.

The swap chain must have been previously created through a call to createSwapChain.

Reimplemented in Cogs::GraphicsDeviceD3D11, and Cogs::GraphicsDeviceGL20.

Definition at line 288 of file IGraphicsDevice.h.

◆ endFrame()

virtual void Cogs::IGraphicsDevice::endFrame ( uint32_t  syncInterval = 0,
uint32_t  presentFlags = PresentFlags::None 
)
pure virtual

Signal the end of a frame to the graphics device.

When the graphics device itself is responsible for managing the device context (e.g in D3D11), and the PresentFlags::NoSwap flag is not set, this will swap the back buffer to make the result of previous drawing visible.

Parameters
syncIntervalSynchronization interval.
  • 0 - No synchronization, presentation occurs immediately.
  • 1 - Synchronize presentation after 1 vertical blank.
presentFlagsA combination of PresentFlags controlling the presentation of the rendered frame.
See also
PresentFlags

Implemented in Cogs::GraphicsDeviceD3D11, Cogs::GraphicsDeviceD3D12, Cogs::GraphicsDeviceGL20, Cogs::GraphicsDeviceGLES30, Cogs::GraphicsDeviceVK, Cogs::GraphicsDeviceNull, and Cogs::GraphicsDeviceWebGPU.

Referenced by Cogs::Core::Renderer::endFrame().

◆ fillGraphicsSettings()

void Cogs::IGraphicsDevice::fillGraphicsSettings ( struct WindowData windowData,
int  requestedSampleCount 
)
static

Set platform specific graphics settings used for window creation e.g.: XVisualInfo on Linux.

Definition at line 17 of file IGraphicsDevice.cpp.

◆ getBuffers()

virtual IBuffers * Cogs::IGraphicsDevice::getBuffers ( )
pure virtual

◆ getCapabilities()

virtual ICapabilities * Cogs::IGraphicsDevice::getCapabilities ( )
pure virtual

◆ getDefaultSwapChain()

virtual ISwapChain * Cogs::IGraphicsDevice::getDefaultSwapChain ( )
pure virtual

Get a pointer to the default swap chain for this graphics device.

Returns
A pointer to the default swap chain.

Implemented in Cogs::GraphicsDeviceD3D11, Cogs::GraphicsDeviceD3D12, Cogs::GraphicsDeviceNull, Cogs::GraphicsDeviceGL20, Cogs::GraphicsDeviceGLES30, Cogs::GraphicsDeviceVK, and Cogs::GraphicsDeviceWebGPU.

◆ getEffects()

virtual IEffects * Cogs::IGraphicsDevice::getEffects ( )
pure virtual

Get a pointer to the effect management interface.

Returns
A pointer to the effect management interface.

Implemented in Cogs::GraphicsDeviceD3D11, Cogs::GraphicsDeviceD3D12, Cogs::GraphicsDeviceNull, Cogs::GraphicsDeviceGL20, Cogs::GraphicsDeviceGLES30, Cogs::GraphicsDeviceVK, and Cogs::GraphicsDeviceWebGPU.

◆ getIdentifier()

virtual std::string Cogs::IGraphicsDevice::getIdentifier ( ) const
inlinevirtual

Get the graphics device identifier.

Returns
A string containing the name of the currently initialized graphics device.

Reimplemented in Cogs::GraphicsDeviceD3D11, Cogs::GraphicsDeviceD3D12, Cogs::GraphicsDeviceNull, Cogs::GraphicsDeviceGL20, Cogs::GraphicsDeviceGLES30, Cogs::GraphicsDeviceVK, and Cogs::GraphicsDeviceWebGPU.

Definition at line 227 of file IGraphicsDevice.h.

◆ getImmediateContext()

virtual IContext * Cogs::IGraphicsDevice::getImmediateContext ( )
pure virtual

Get a pointer to the immediate context used to issue commands to the graphics device.

Returns
A pointer to the context interface.

Implemented in Cogs::GraphicsDeviceD3D11, Cogs::GraphicsDeviceD3D12, Cogs::GraphicsDeviceNull, Cogs::GraphicsDeviceGL20, Cogs::GraphicsDeviceGLES30, Cogs::GraphicsDeviceVK, and Cogs::GraphicsDeviceWebGPU.

Referenced by Cogs::Core::Renderer::render(), and Cogs::Core::Renderer::renderScreenshot().

◆ getNativeDevice()

virtual void * Cogs::IGraphicsDevice::getNativeDevice ( )
inlinevirtual

Definition at line 353 of file IGraphicsDevice.h.

◆ getPipelineStates()

virtual IPipelineStates * Cogs::IGraphicsDevice::getPipelineStates ( )
pure virtual

Get a pointer to the pipeline state management interface.

Returns
A pointer to the pipeline state management interface.

Implemented in Cogs::GraphicsDeviceD3D11, Cogs::GraphicsDeviceD3D12, Cogs::GraphicsDeviceVK, Cogs::GraphicsDeviceNull, Cogs::GraphicsDeviceGL20, Cogs::GraphicsDeviceGLES30, and Cogs::GraphicsDeviceWebGPU.

◆ getRenderTargets()

virtual IRenderTargets * Cogs::IGraphicsDevice::getRenderTargets ( )
pure virtual

◆ getResourceStatistics()

Cogs::ResourceStatistics Cogs::IGraphicsDevice::getResourceStatistics ( )
virtual

Reimplemented in Cogs::GraphicsDeviceGL20.

Definition at line 11 of file IGraphicsDevice.cpp.

◆ getSettings()

const GraphicsDeviceSettings & Cogs::IGraphicsDevice::getSettings ( ) const
inline

Definition at line 364 of file IGraphicsDevice.h.

◆ getSize()

virtual bool Cogs::IGraphicsDevice::getSize ( int &  width,
int &  height 
) const
pure virtual

◆ getSyncObjects()

virtual ISyncObjects * Cogs::IGraphicsDevice::getSyncObjects ( )
pure virtual

Get a pointer to the sync object management interface.

Returns
A pointer to the sync object management interface.

Implemented in Cogs::GraphicsDeviceD3D11, Cogs::GraphicsDeviceD3D12, Cogs::GraphicsDeviceNull, Cogs::GraphicsDeviceGL20, Cogs::GraphicsDeviceGLES30, Cogs::GraphicsDeviceVK, and Cogs::GraphicsDeviceWebGPU.

◆ getTextures()

virtual ITextures * Cogs::IGraphicsDevice::getTextures ( )
pure virtual

◆ getType()

virtual GraphicsDeviceType Cogs::IGraphicsDevice::getType ( ) const
inlinevirtual

◆ initialize()

virtual bool Cogs::IGraphicsDevice::initialize ( )
pure virtual

Initializes the graphics device with the settings previous set through calling setSettings.

Implemented in Cogs::GraphicsDeviceD3D11, Cogs::GraphicsDeviceD3D12, Cogs::GraphicsDeviceGLES30, Cogs::GraphicsDeviceNull, Cogs::GraphicsDeviceGL20, Cogs::GraphicsDeviceVK, and Cogs::GraphicsDeviceWebGPU.

◆ initializeThread()

virtual bool Cogs::IGraphicsDevice::initializeThread ( )
inlinevirtual

Initialize the graphics device for operation on the current thread.

Definition at line 177 of file IGraphicsDevice.h.

◆ isInitializationFinished()

virtual bool Cogs::IGraphicsDevice::isInitializationFinished ( )
inlinevirtual

Check if async initialization is finished.

Reimplemented in Cogs::GraphicsDeviceWebGPU.

Definition at line 218 of file IGraphicsDevice.h.

◆ releaseResources()

virtual void Cogs::IGraphicsDevice::releaseResources ( )
pure virtual

◆ releaseSharedContext()

virtual void Cogs::IGraphicsDevice::releaseSharedContext ( SharedGraphicsContext )
inlinevirtual

Releases the given shared context.

Parameters
contextPointer to a shared graphics context.

Reimplemented in Cogs::GraphicsDeviceGL20.

Definition at line 208 of file IGraphicsDevice.h.

◆ setSettings()

virtual bool Cogs::IGraphicsDevice::setSettings ( const GraphicsDeviceSettings newSettings)
inlinevirtual

Updates the settings associated with this device.

The device must be recreated for the new settings to take effect.

Parameters
Graphicsdevice settings to use when initializing the device.

Reimplemented in Cogs::GraphicsDeviceGL20.

Definition at line 362 of file IGraphicsDevice.h.

Referenced by Cogs::GraphicsDeviceGL20::setSettings().

◆ setSize()

virtual void Cogs::IGraphicsDevice::setSize ( int  width,
int  height 
)
pure virtual

Set the size of the main drawing buffer used by the graphics device in pixels.

Parameters
widthWidth of the drawing buffer in pixels.
heightHeight of the drawing buffer in pixels.

Implemented in Cogs::GraphicsDeviceD3D11, Cogs::GraphicsDeviceD3D12, Cogs::GraphicsDeviceGL20, Cogs::GraphicsDeviceGLES30, Cogs::GraphicsDeviceVK, Cogs::GraphicsDeviceWebGPU, and Cogs::GraphicsDeviceNull.

◆ waitForCommandSync()

virtual void Cogs::IGraphicsDevice::waitForCommandSync ( )
inlinevirtual

Wait for any GPU commands on the current device to finish before returning.

After this command returns, any commands issued to the graphics device should be finished, and results from these ready to use.

Reimplemented in Cogs::GraphicsDeviceD3D12, Cogs::GraphicsDeviceNull, Cogs::GraphicsDeviceGL20, Cogs::GraphicsDeviceGLES30, Cogs::GraphicsDeviceVK, and Cogs::GraphicsDeviceWebGPU.

Definition at line 271 of file IGraphicsDevice.h.

Member Data Documentation

◆ settings

GraphicsDeviceSettings Cogs::IGraphicsDevice::settings
protected

Definition at line 373 of file IGraphicsDevice.h.

◆ swapChains

std::vector<ISwapChain*> Cogs::IGraphicsDevice::swapChains
protected

Definition at line 374 of file IGraphicsDevice.h.


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