Skip to content

Commit

Permalink
Workaround for SteamVR bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kwahoo2 committed Aug 23, 2021
1 parent f3f3215 commit 5517192
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Gui/CoinXRWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ void CoinXRWidget::paintGL()

swapchain.acquireSwapchainImage(xr::SwapchainImageAcquireInfo{}, &swapchainIndex);
swapchain.waitSwapchainImage(xr::SwapchainImageWaitInfo{ xr::Duration::infinite() });

#if defined XR_USE_PLATFORM_XLIB
glXMakeCurrent(xDisplay, glxDrawable, glxContext); //SteamVR bug workaround https://github.com/ValveSoftware/SteamVR-for-Linux/issues/421
#endif
glBindFramebuffer(GL_FRAMEBUFFER, fbo.id);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, swapchainImages[swapchainIndex].image, 0);

Expand Down Expand Up @@ -318,10 +320,14 @@ void CoinXRWidget::prepareXrSession()

uint32_t visualid = 0;
GLXFBConfig glxFBConfig = nullptr;
Display* xDisplay = XOpenDisplay(nullptr);
xDisplay = XOpenDisplay(nullptr);
//Display* xDisplay = XOpenDisplay(nullptr);
int xScreen = XDefaultScreen(xDisplay);
GLXContext glxContext = glXGetCurrentContext();
GLXDrawable glxDrawable = glXGetCurrentDrawable();
glxContext = glXGetCurrentContext();
//GLXContext glxContext = glXGetCurrentContext();
glxDrawable = glXGetCurrentDrawable();
//GLXDrawable glxDrawable = glXGetCurrentDrawable();


/*To render using OpenGL into a GLX drawable, you must determine the appropriate GLXFBConfig that supports the rendering features your application requires. glXChooseFBConfig returns a GLXFBConfig matching the required attributes or NULL if no match is found. A complete list of GLXFBConfigs supported by a server can be obtained by calling glXGetFBConfigs. Attributes of a particular GLXFBConfig can be queried by calling glXGetFBConfigAttrib. */
int fbConfigCount = 0;
Expand Down Expand Up @@ -413,7 +419,6 @@ void CoinXRWidget::prepareXrSwapchain()
swapchain = session.createSwapchain(swapchainCreateInfo);
swapchainImages = swapchain.enumerateSwapchainImages<xr::SwapchainImageOpenGLKHR>();


}
void CoinXRWidget::prepareXrCompositionLayers()
{
Expand Down
6 changes: 6 additions & 0 deletions src/Gui/CoinXRWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@
//QOpenGLWidget is a modern replacement for QGLWidget, it performs offscreen rendering
class CoinXRWidget : public QOpenGLWidget , protected QOpenGLFunctions_4_5_Core
{
#if defined XR_USE_PLATFORM_XLIB
Display* xDisplay;
GLXContext glxContext;
GLXDrawable glxDrawable;
#endif

SbViewportRegion vpReg;
SoSceneManager *m_sceneManager;
SoSeparator *rootScene[2];
Expand Down

0 comments on commit 5517192

Please sign in to comment.