cmbruns / pyopenvr

Unofficial python bindings for Valve's OpenVR virtual reality SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trying to implement the same qt example as openvr ( qt app in the dashboard )

matEhickey opened this issue · comments

Hello,
I'm trying to figure out how to implement an example comparable to the one provided by cpp openvr (hellooverlaycontroller) that display a qt window to the steamvr dashboard.

I know we can use a opengl binded texture with "setOverlayTexture", and bind a framebufferobject (FBO) to a qt opengl context (see here for cpp example).

I'm trying my best to understand how to implement this using only pyqt5 and pyopenvr, and I'm confident that I'm not the only who would this kind of example.

So my question is : Do you already did something like that ? Or do you know anythong I might missed, or something that make this impossible ? Any kind of informations would be great.

Bye :)

My deconstruct CPP algorythm from the original example:

Create the opengl context :

m_pOpenGLContext = new QOpenGLContext();
m_pOpenGLContext->setFormat( format );
bSuccess = m_pOpenGLContext->create();

Create an offscreen surface to attach the context and FBO to

m_pOffscreenSurface = new QOffscreenSurface();
m_pOffscreenSurface->create();

Create FBO

m_pFbo = new QOpenGLFramebufferObject( pWidget->width(), pWidget->height(), GL_TEXTURE_2D );

Attach GLContext to offscreensurface and bind FBO:

m_pOpenGLContext->makeCurrent( m_pOffscreenSurface );
m_pFbo->bind();

Create a QGraphicScene that allow to render widgets with a painter of a QOpenGLPaintDevice (for example to take a screenshoot):

m_pScene = new QGraphicsScene();
QOpenGLPaintDevice device( m_pFbo->size() );
QPainter painter( &device );
m_pScene->render( &painter );

Set the texture to openvr overlay

GLuint unTexture = m_pFbo->texture();

if( unTexture != 0 )
{
      vr::Texture_t texture = {(void*)(uintptr_t)unTexture, vr::TextureType_OpenGL, vr::ColorSpace_Auto };
      vr::VROverlay()->SetOverlayTexture( m_ulOverlayHandle, &texture );
}