XLE  v0.02.0
Public Member Functions | List of all members
RenderCore::IDevice Class Referenceabstract

Represents a hardware device capable of rendering More...

#include <IDevice.h>

Inheritance diagram for RenderCore::IDevice:
Inheritance graph
[legend]

Public Member Functions

virtual std::unique_ptr< IPresentationChainCreatePresentationChain (const void *platformWindowHandle, unsigned width, unsigned height)=0
 Initialised a window for rendering More...
 
virtual virtual void * QueryInterface (const GUID &guid)=0
 Looks for compatibility with another interface More...
 
virtual void BeginFrame (IPresentationChain *presentationChain)=0
 Begins rendering of a new frame More...
 
virtual std::shared_ptr< IThreadContextGetImmediateContext ()=0
 
virtual std::unique_ptr< IThreadContextCreateDeferredContext ()=0
 
virtual std::pair< const char *, const char * > GetVersionInformation ()=0
 Returns version information for this device More...
 

Detailed Description

Represents a hardware device capable of rendering

IDevice represents a single hardware device that can render. Usually it is the first rendering object created. Most rendering objects are associated with a single device (because the device defines the format and memory location of the object). So a device must be created and selected before anything else is created.

Normally there is only a single device. Multiple devices are only required in very special case situations (for example, if a PC has 2 graphics cards, and you want to render using both cards).

Call CreateDevice() to create a new default with the default parameters.

Normally clients should create a device first, and then create a presentation chain once an output window has been created.

To render a frame, call BeginFrame() on the device first, and then call PresentationChain::Present when the frame is finished.

You can use "QueryInterface" to get extended interfaces for the device. Some platforms might expose special case behaviour. To get access, use QueryInterface to check if the device supports the behaviour you want.

Note that there is no reference counting behaviour built into IDevice (or any RenderCore object). But you can use std::shared_ptr<> to get that behaviour. If necessary, we can add a CreateDeviceShared() that will use std::make_shared<> to create an efficient referenced counted object.

Member Function Documentation

virtual void RenderCore::IDevice::BeginFrame ( IPresentationChain presentationChain)
pure virtual

Begins rendering of a new frame

Starts rendering of a new frame. The frame is ended with a call to RenderCore::IPresentationChain::Present(); You must pass a presentationChain. This defines how the frame will be presented to the user. Note that rendering to offscreen surfaces can happen outside of the BeginFrame/Present boundaries.

See also
RenderCore::IPresentationChain::Present

Implemented in RenderCore::Device.

virtual std::unique_ptr<IPresentationChain> RenderCore::IDevice::CreatePresentationChain ( const void *  platformWindowHandle,
unsigned  width,
unsigned  height 
)
pure virtual

Initialised a window for rendering

To render to a window, we first need to create a presentation chain. This creates the buffers necessary to render to that window.

Parameters
platformWindowHandleA platform specific value representing a window. On windows, this is would be a HWND value
widthWidth of the presentation chain. RenderCore can't call GetClientRect() on the window directly, because that would require adding a linker reference to windows dlls. But normally, with and height are the same size as the window client area. If a different size is used, the behaviour might be different on different platforms (but on windows, the output is stretched.
heightsee width

Implemented in RenderCore::Device.

virtual std::pair<const char*, const char*> RenderCore::IDevice::GetVersionInformation ( )
pure virtual

Returns version information for this device

Queries build number and build date information. The build number is in a format such as:

vX.Y.Z-[commits]-[commit marker]-[configuration]

Here, X, Y, Z are major, minor and patch version.

  • [commits] is the number of extra commits past the version tag in git.
  • [commit marker] is the short name of the latest commit to git.
  • [configuration] is the build configuration

The build date format is determined by the OS and locale at compilation time.

Returns
The first returned string is the build number, the second is the build date

Implemented in RenderCore::Device.

virtual virtual void* RenderCore::IDevice::QueryInterface ( const GUID &  guid)
pure virtual

Looks for compatibility with another interface

Some implementations of IDevice might provide extension interfaces. to extensions.

Note that reference counting behaviour is not the same as DirectX/COM QueryInterface. RenderCore objects don't have reference counting built it. So we can't increase the reference count on return. So don't delete or deref the returned object. As a result, be careful that another thread doesn't delete the object as you're using it.

Example:

@code
RenderCore::IDeviceDX11* dx11Device =
(RenderCore::IDeviceDX11*)device->QueryInterface(__uuidof(RenderCore::IDeviceDX11));
if (dx11Device) {
...
}
\endcode
Parameters
guidA large random value that is unique to the interface. On the visual studio compiler, use the __uuidof() extension to get the correct guid for a class. For example, To query for the "IDeviceDX11" interface, use __uuid(RenderCore::IDeviceDX11).
Returns
Returns nullptr if the interface isn't supported
See also
RenderCore::IDeviceDX11, RenderCore::IDeviceOpenGLES

Implemented in RenderCore::DeviceDX11.


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