Cogs.Rendering
Loading...
Searching...
No Matches
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>

Public Member Functions

virtual ~IGraphicsDevice ()=default
 Destructor.
 
virtual bool initializeThread ()
 Initialize the graphics device for operation on the current thread.
 
virtual SharedGraphicsContext * createSharedContext ()
 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.

Constructor & Destructor Documentation

◆ ~IGraphicsDevice()

virtual Cogs::IGraphicsDevice::~IGraphicsDevice ( )
virtualdefault

Destructor.

Referenced by Cogs::Factory::releaseDevice().

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.

◆ beginFrame()

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

Signal the beginning of a new frame to the graphics device.

◆ 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.

◆ 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.

◆ 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.

◆ 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

◆ 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.

◆ getBuffers()

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

Get a pointer to the buffer management interface.

Returns
A pointer to the buffer management interface.

◆ getCapabilities()

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

Get a pointer to the capability management interface used to query the graphics device capability flags.

Returns
A pointer to the capability management interface.

◆ 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.

◆ getEffects()

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

Get a pointer to the effect management interface.

Returns
A pointer to the effect management interface.

◆ 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.

◆ 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.

◆ getNativeDevice()

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

◆ 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.

◆ getRenderTargets()

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

Get a pointer to the render target management interface.

Returns
A pointer to the render target management interface.

◆ getResourceStatistics()

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

◆ getSettings()

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

References settings.

◆ getSize()

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

Retrieve the size previously set by setSize.

◆ 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.

◆ getTextures()

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

Get a pointer to the texture management interface.

Returns
A pointer to the texture management interface.

◆ getType()

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

Get the type of the graphics device.

Returns
The identifier of the graphics device.

References Cogs::Unknown.

Referenced by Cogs::Factory::releaseDevice().

◆ initialize()

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

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

◆ initializeThread()

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

Initialize the graphics device for operation on the current thread.

◆ isInitializationFinished()

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

Check if async initialization is finished.

◆ releaseResources()

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

Release all resources allocated.

◆ releaseSharedContext()

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

Releases the given shared context.

Parameters
contextPointer to a shared graphics context.

◆ 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.

References settings.

◆ 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.

◆ 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.

Member Data Documentation

◆ settings

GraphicsDeviceSettings Cogs::IGraphicsDevice::settings
protected

Referenced by getSettings(), and setSettings().

◆ swapChains

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

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