@kognifai/cogsengine
    Preparing search index...

    Creating and Initializing a Graphics Device {#initialization}

    #include 
    
    {
        // Create a graphics device with the default type.
        auto device = Cogs::Factory::createDevice();
    
        if (!device) {
            // Error creating a device of the default 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 
    
    {
        // Create an OpenGL20 graphics device.
        auto device = Cogs::Factory::createDevice(Cogs::GraphicsDeviceType::OpenGL20);
    
        if (!device) {
            // Error creating a device of the given type.
        }
        
        ...
    }
    

    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 
    
    {
        ...
        
        if (!device->initialize(hWnd)) {
            // Error initializing the device.
        }
    
        ...
    }