Forum Discussion
tmason101
12 years agoHonored Guest
Unhandled Exception with QT but no Problems on GLFW
Hello,
I have the following code which 100% works with GLFW but with QT I get an error at the marked line.
I am not sure what I am doing wrong as the only difference would be that I am using a HWND and HDC handle from QT versus OpenGL.
Anyway, here is my code:
How I get the Window handle for the QWindow in QT:
This is the line that crashes:
Part of this code...
Constructor for QWindow of the QT Library:
QWindow's renderNow function, inherited from:
I have the following code which 100% works with GLFW but with QT I get an error at the marked line.
I am not sure what I am doing wrong as the only difference would be that I am using a HWND and HDC handle from QT versus OpenGL.
Anyway, here is my code:
How I get the Window handle for the QWindow in QT:
WId TestID = this->winId();
HWND WindowHandle = (HWND)(this->winId());
This is the line that crashes:
ovrHmd_ConfigureRendering((*MainRiftSupport->GetHmd()),
&MainRiftSupport->Get_Hmd_Cfg()->Config,
(*MainRiftSupport->GetHmd())->DistortionCaps & ~ovrDistortionCap_FlipInput,
//(*MainRiftSupport->GetHmd())->DistortionCaps,
(*MainRiftSupport->GetHmd())->DefaultEyeFov,
MainRiftSupport->GetEyeRenderDesc());
Part of this code...
glGenFramebuffers(1, &OculusRiftFrameBufferID);
glBindFramebuffer(GL_FRAMEBUFFER, OculusRiftFrameBufferID);
// The texture we're going to render to...
glGenTextures(1, &OculusRiftTextureID);
// "Bind" the newly created texture : all future texture functions will modify this texture...
glBindTexture(GL_TEXTURE_2D, OculusRiftTextureID);
// Give an empty image to OpenGL (the last "0")
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (*MainRiftSupport->GetWidth()), (*MainRiftSupport->GetHeight()), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
// Linear filtering...
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// Create Depth Buffer...
glGenRenderbuffers(1, &OculusRiftDepthBufferID);
glBindRenderbuffer(GL_RENDERBUFFER, OculusRiftDepthBufferID);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, (*MainRiftSupport->GetWidth()), (*MainRiftSupport->GetHeight()));
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, OculusRiftDepthBufferID);
// Set the texture as our colour attachment #0...
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, OculusRiftTextureID, 0);
// Set the list of draw buffers...
GLenum l_GLDrawBuffers[1] = { GL_COLOR_ATTACHMENT0 };
glDrawBuffers(1, l_GLDrawBuffers); // "1" is the size of DrawBuffers
// Check if everything is OK...
GLenum l_Check = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
if (l_Check != GL_FRAMEBUFFER_COMPLETE)
{
printf("There is a problem with the FBO.\n");
return false;
}
// Unbind...
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glBindTexture(GL_TEXTURE_2D, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
MainRiftSupport->Get_Hmd_Cfg()->OGL.Header.API = ovrRenderAPI_OpenGL;
MainRiftSupport->Get_Hmd_Cfg()->OGL.Header.RTSize.w = (GLint)(*MainRiftSupport->GetWidth());
MainRiftSupport->Get_Hmd_Cfg()->OGL.Header.RTSize.h = (GLint)(*MainRiftSupport->GetHeight());
MainRiftSupport->Get_Hmd_Cfg()->OGL.Header.Multisample = 1;
#if defined(_WIN32)
if (UsingQTWindowing) {
MainRiftSupport->Get_Hmd_Cfg()->OGL.Window = WindowHandle;
HDC MainHDC = GetDC(MainRiftSupport->Get_Hmd_Cfg()->OGL.Window);
MainRiftSupport->Get_Hmd_Cfg()->OGL.DC = MainHDC;
} else {
MainRiftSupport->Get_Hmd_Cfg()->OGL.Window = glfwGetWin32Window(MainRiftSupport->GetGLFWwindow());
HDC MainHDC = GetDC(MainRiftSupport->Get_Hmd_Cfg()->OGL.Window);
MainRiftSupport->Get_Hmd_Cfg()->OGL.DC = MainHDC;
}
#elif defined(__linux__)
MainRiftSupport->Get_Hmd_Cfg()->OGL.Win = glfwGetX11Window(MainGLFWWindow);
MainRiftSupport->Get_Hmd_Cfg()->OGL.Disp = glfwGetX11Display();
#endif
/*
This line crashes in QT, doesn't in GLFW.
*/
ovrHmd_ConfigureRendering((*MainRiftSupport->GetHmd()),
&MainRiftSupport->Get_Hmd_Cfg()->Config,
(*MainRiftSupport->GetHmd())->DistortionCaps & ~ovrDistortionCap_FlipInput,
//(*MainRiftSupport->GetHmd())->DistortionCaps,
(*MainRiftSupport->GetHmd())->DefaultEyeFov,
MainRiftSupport->GetEyeRenderDesc());
GLint WidthOfTexture = (*MainRiftSupport->GetWidth());
GLint HeightOfTexture = (*MainRiftSupport->GetHeight());
OculusRift_EyeTexture[0].Header.API = ovrRenderAPI_OpenGL;
OculusRift_EyeTexture[0].Header.TextureSize.w = WidthOfTexture;
OculusRift_EyeTexture[0].Header.TextureSize.h = HeightOfTexture;
OculusRift_EyeTexture[0].Header.RenderViewport.Pos.x = 0;
OculusRift_EyeTexture[0].Header.RenderViewport.Pos.y = 0;
OculusRift_EyeTexture[0].Header.RenderViewport.Size.w = WidthOfTexture / 2;
OculusRift_EyeTexture[0].Header.RenderViewport.Size.h = HeightOfTexture;
((ovrGLTexture*)(&OculusRift_EyeTexture[0]))->OGL.TexId = OculusRiftTextureID;
// Right eye the same, except for the x-position in the texture...
OculusRift_EyeTexture[1] = OculusRift_EyeTexture[0];
OculusRift_EyeTexture[1].Header.RenderViewport.Pos.x = (WidthOfTexture + 1) / 2;
Constructor for QWindow of the QT Library:
QWindow's renderNow function, inherited from:
if (!isExposed())
return;
bool needsInitialize = false;
if (!m_context) {
m_context = new QOpenGLContext(this);
m_context->setFormat(requestedFormat());
m_context->create();
needsInitialize = true;
}
m_context->makeCurrent(this);
if (needsInitialize) {
initializeOpenGLFunctions();
initialize(); //// ----->>>>>>>>> The above code get's called here.
ReadyForUse = true;
}
render();
if (!MainRiftSupport->IsInitialized()) {
m_context->swapBuffers(this);
}
if (m_animating)
renderLater();
1 Reply
- tmason101Honored GuestIf I haven't posted something you need to see please feel free to reply and ask.
It's part of a large project so I couldn't post everything...
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 7 months ago
- 2 years ago
- 12 months ago
- 2 months ago