Getting OpenGL to work with OpenXR

I have an existing OpenGL (4.6) system working under windows 10. I am looking for a path of least resistance to add VR to this system. I downloaded the BasicXrApp (https://github.com/microsoft/OpenXR-MixedReality/tree/master/samples/BasicXrApp) which works on my computer but it uses D3D11 instead of OpenGL. I have tried to update the code to link with OpenGL instead of D3D11 and have ran into problems.
The XrExtensions.h file used within xrUtility has an entry for xrGetD3D11GraphicsRequirementsKHR but not for xrGetOpenGLGraphicsRequirementsKHR. I simply tried replacing the one for D3D11 with the one for OpenGL but it doesn’t seem to find the address when populating the DispatchTable. I have also changed the pch.h file to define XR_USE_GRAPHICS_API_OPENGL instead of XR_USE_GRAPHICS_API_D3D11.
I also changed from XrGraphicsBindingD3D11KHR to XrGraphicsBindingOpenGLWin32KHR and put in my hDC and hGRLC but none of the OpenGL calls seem to work in getting addresses when populating the DispatchTable. It seems that either OpenGL is not supported even though it is documented or I am missing something basic in switching from D3D11 support to OpenGL support. I hope it is the latter. Can anybody help?
Thanks,
Jim

Runtimes can decide themselves whether to support each graphics API by supporting the respective extension.

In this example BasicXrApp/OpenXrProgram.cpp checks if the d3d11 extension is supported and if so, adds it to the list of extensions given to xrCreateInstance(): CHECK(EnableExtentionIfSupported(XR_KHR_D3D11_ENABLE_EXTENSION_NAME));

To my knowledge the Windows MR runtime does not support OpenGL (my knowledge might be out of date). Blender solved this by using a minimal directx wrapper: https://devtalk.blender.org/t/gsoc-2019-vr-support-through-openxr-weekly-reports/7665

Thanks, This is useful. One more question to make sure I fully understand…
Having a newer version of openxr_loader (which I assume comes from the OpenXR people) will not help and is unnecessary, but what I need is a newer version of what it loads (which I assume comes from MS (the “Runtime” you mention above)). Is this correct? The reason I ask is that the BasicXrProgram uses XrExtensions.h which has:

#define FOR_EACH_EXTENSION_FUNCTION(_)           \
    _(xrCreateSpatialAnchorMSFT)                 \
    _(xrCreateSpatialAnchorSpaceMSFT)            \
    _(xrDestroySpatialAnchorMSFT)                \
    _(xrCreateHandTrackerMSFT)                   \
    _(xrDestroyHandTrackerMSFT)                  \
    _(xrGetHandTrackerStateMSFT)                 \
    _(xrCreateHandJointSpaceMSFT)                \
    _(xrCreateHandMeshSpaceMSFT)                 \
    _(xrUpdateHandMeshMSFT)                      \
    _(xrConvertWin32PerformanceCounterToTimeKHR) \
    _(xrCreateSpatialGraphNodeSpaceMSFT)         \
    _(xrGetD3D11GraphicsRequirementsKHR)         \   <=====
    _(xrLoadControllerModelMSFT)                 \
    _(xrGetControllerModelPropertiesMSFT)        \
    _(xrGetControllerModelStateMSFT)             \
    _(xrGetVisibilityMaskKHR)

which has something for D3D11 but nothing for OpenGL.
Is this (XrExtensions.h) something that is made by the OpenXR-MixedReality-master package and needs to be rebuilt when Windows supports OpenGL access by OpenXR?
I guess what I want to know is where I need to look if and when OpenGL is supported (MS, OpenXR or both)?

@Jim127,
This XrUtility library is mean to help openxr developers when consuming openxr apis in C++ context. But it is not built from master package from Khronos. It is mostly hand crafted for the scenarios tested in all the samples in that repo.

If you have improvements to the header file and get them working for GL, please feel free to contribute back to the repo.

P.S. on the “if or when GL is supported” question, it is supported by the OpenXR spec and should be supported by these helper libraries as the dispatch table if necessary. The support can be dynamically inspected from the API to understand where the current runtime supports this or not, as @haagch indicated above.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.