2929#include " DebugUtilities.hpp"
3030#include " DataBlobImpl.hpp"
3131
32+ typedef unsigned int GLuint;
33+ typedef int GLint;
34+ typedef unsigned int GLenum;
35+
3236#if GL_SUPPORTED
3337
38+ # if PLATFORM_WIN32
39+
40+ # include " WinHPreface.h"
41+ # include < Windows.h>
42+ # include < Unknwn.h>
43+ # include " WinHPostface.h"
44+
45+ # include " ../../GraphicsEngineOpenGL/include/RenderDeviceGLImpl.hpp"
46+ # include " ../../GraphicsEngineOpenGL/include/GLContextWindows.hpp"
47+
48+ # define XR_USE_PLATFORM_WIN32
49+ # endif
50+
3451# define XR_USE_GRAPHICS_API_OPENGL
3552# include < openxr/openxr_platform.h>
3653
@@ -39,8 +56,6 @@ constexpr XrStructureType XR_TYPE_SWAPCHAIN_IMAGE_GL = XR_TYPE_SWAPCHAIN_IMAGE_O
3956
4057#elif GLES_SUPPORTED
4158
42- typedef unsigned int EGLenum;
43-
4459# define XR_USE_GRAPHICS_API_OPENGL_ES
4560# include < openxr/openxr_platform.h>
4661
@@ -60,7 +75,22 @@ void GetOpenXRGraphicsBindingGL(IRenderDevice* pDevice,
6075 IDeviceContext* pContext,
6176 IDataBlob** ppGraphicsBinding)
6277{
63- UNSUPPORTED (" Not yet implemented" );
78+ #if GL_SUPPORTED && PLATFORM_WIN32
79+ RefCntAutoPtr<DataBlobImpl> pDataBlob{DataBlobImpl::Create (sizeof (XrGraphicsBindingOpenGLWin32KHR))};
80+
81+ RefCntAutoPtr<RenderDeviceGLImpl> pDeviceGL{pDevice, RenderDeviceGLImpl::IID_RenderDeviceGLImpl};
82+ VERIFY_EXPR (pDeviceGL != nullptr );
83+
84+ XrGraphicsBindingOpenGLWin32KHR& Binding = *reinterpret_cast <XrGraphicsBindingOpenGLWin32KHR*>(pDataBlob->GetDataPtr ());
85+ Binding.type = XR_TYPE_GRAPHICS_BINDING_D3D11_KHR;
86+ Binding.next = nullptr ;
87+ Binding.hDC = pDeviceGL->GetContext ().GetWindowHandleToDeviceContext ();
88+ Binding.hGLRC = pDeviceGL->GetContext ().GetHandle ();
89+
90+ *ppGraphicsBinding = pDataBlob.Detach ();
91+ #else
92+ UNEXPECTED (" OpenXR GL bindings are not supported on this platform. The application should initialize the bindings manually." );
93+ #endif
6494}
6595
6696void AllocateOpenXRSwapchainImageDataGL (Uint32 ImageCount,
0 commit comments