Diligent Engine API Reference
GraphicsEngineOpenGL

Implementation of Diligent Engine API using OpenGL/GLES

Initialization

The following code snippet shows how to initialize diligent engine in OpenGL/GLES mode.

#include "RenderDeviceFactoryOpenGL.h"
using namespace Diligent;
// ...
#ifdef ENGINE_DLL
GetEngineFactoryOpenGLType GetEngineFactoryOpenGL;
if( !LoadGraphicsEngineOpenGL(GetEngineFactoryOpenGL) )
return FALSE;
#endif
GetEngineFactoryOpenGL()->CreateDeviceAndSwapChainGL(
EngineCreationAttribs(), &pRenderDevice, &pImmediateContext, SwapChainDesc, hWnd, &pSwapChain );

Alternatively, the engine can be initialized by attaching to existing OpenGL context (see below).

Interoperability with OpenGL/GLES

Diligent Engine exposes methods to access internal OpenGL/GLES objects, is able to create diligent engine buffers and textures from existing GL buffer and texture handles, and can be initialized by attaching to existing GL context.

Accessing Native GL objects

Below are some of the methods that provide access to internal D3D11 objects:

Function Description
GLuint IBufferGL::GetGLBufferHandle() returns GL buffer handle
bool IDeviceContextGL::UpdateCurrentGLContext() attaches to the active GL context in the thread. Returns false if there is no active context, and true otherwise. If an application uses multiple GL contexts, this method must be called before any other command to let the engine update the active context.
GLuint ITextureGL::GetGLTextureHandle() returns GL texture handle
GLenum ITextureGL::GetBindTarget() returns GL texture bind target

Creating Diligent Engine Objects from OpenGL Handles

Initializing the Engine by Attaching to Existing GL Context

The code snippet below shows how diligent engine can be attached to existing GL context

auto *pFactoryGL = GetEngineFactoryOpenGL();
EngineCreationAttribs Attribs;
pFactoryGL->AttachToActiveGLContext(Attribs, &m_Device, &m_Context);

For more information about interoperability with OpenGL, please visit Diligent Engine web site

References

Diligent Engine

Interoperability with OpenGL/GLES

Release Notes

2.1

New features

API Changes

2.0

Reworked the API to follow D3D12 style

1.0

Initial release

Copyright 2015-2018 Egor Yusov

diligentgraphics.com