Cogs.Rendering
Loading...
Searching...
No Matches
Creating and Initializing a Graphics Device

Creating a default device

#include <Factory.h>
{
// Create a graphics device with the default type.
auto device = Cogs::Factory::createDevice();
if (!device) {
// Error creating a device of the default type.
}
...
}
static class IGraphicsDevice * createDevice(RenderingAllocatorInfo *allocatorInfo=nullptr)
Creates a graphics device.
Definition: Factory.cpp:46

Creating a device of a specific type

Since the rendering abstraction library might be built with support for multiple graphics device types it might be necessary to specify the desired type.

Valid types are:

  • OpenGL20
  • OpenGLES30
  • Direct3D11
#include <Factory.h>
{
// Create an OpenGL20 graphics device.
if (!device) {
// Error creating a device of the given type.
}
...
}
@ OpenGL20
Graphics device using OpenGL, supporting at least OpenGL 2.0.

Initializing the graphics device

When you have created a valid graphics device it can be initialized in the current application context.

Initializing a graphics device on Windows systems:

#include <Factory.h>
{
...
if (!device->initialize(hWnd)) {
// Error initializing the device.
}
...
}