2

I have the following Code written by a classmate of mine (we are working a project):

//inside cqtopencvviewergl.cpp
void CQtOpenCVViewerGl::resizeGL(int width, int height)
{
    makeCurrent();

    glViewport(0, 0, (GLint)(width), (GLint)(height));

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    glOrtho(0, width, -height, 0, 0, 1);

    glMatrixMode(GL_MODELVIEW);

    recalculatePosition();

    emit imageSizeChanged(mRenderWidth, mRenderHeight);

    updateScene();
}

The call of glLoadIdentity() leads to an Exception at 0x0, code: 0x0000005 according to the Debugger which is C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\cdb.exe in my case.

I know that the function is deprecated. But I am very confused about all information sources about what I should do about it. So I will work you through the disorientation in hope you can help me...

According to this answer the Exception occurs because the functions used are deprecated. But the question differs because I (or we) include openGL quite differently:

At the top of the cqtopencvviewergl.cpp we include the following:

#include "include/Gui/cqtopencvviewergl.h"
#include <QOpenGLFunctions>
#include <opencv2/opencv.hpp>
#include <QPalette>

And at the top of the cqtopencvviewergl.h we include:

#include <QOpenGLWidget>
#include <QOpenGLFunctions_2_0>
#include <opencv2/core/core.hpp>

So we are using Qt classes to call the openGL functions. I took a look at the Code and it seems Qt handles the deprecation itself.

Also according to this answer Qt supports all current Desktop OpenGL versions.

According to this answer of the asker to the question How to replace following (deprecated) OpenGL functions? the Windows offline installers are by default ANGLE based. I used the offline installer...

According to this entry in the qt wiki To compile Qt with ANGLE I have to have a Direct X SDK installed. However I am sceptical whether I really need this if I use QOpenGLFunctions and QOpenGLFunctions_2_0...

According to the wiki entry the Direct X SDK is part of the Windows SDK so I am also sceptical that I already have ANGLE due to the fact that I already have a few Windows SDKs:

enter image description here

Also according to this article I should use configure -opengl dynamicly and because I use Windows I tried to find out where to call configure and found configure.bat -opengl desktop in this article. So wanted to run configure.bat -opengl dynamic but I could not find the configure.bat anywhere in the C:\Qt\Qt5.9.1 directory...

I use the following Qt Kit:

enter image description here

I am the only one (of 6 people in the project) who has that problem. Normally my questions are more precisely but I am lost here. What should I do ?

goulashsoup
  • 2,639
  • 2
  • 34
  • 60
  • Shouldn't that be [`QOpenGLFunctions_2_0::glLoadIdentity()`](http://doc.qt.io/qt-5/qopenglfunctions-2-0.html#glLoadIdentity)? It looks like you're calling the opengl function directly. – Jorn Vernee Aug 12 '17 at 22:32
  • @JornVernee No, the call leads to `QOpenGLFunctions_2_0::glLoadIdentity()`... – goulashsoup Aug 12 '17 at 23:23
  • Stop using ANGLE with compatibility OpenGL stuff. If you want the old stuff, you have to use a *real* OpenGL implementation, not the ANGLE stuff. – Nicol Bolas Aug 13 '17 at 01:50

1 Answers1

0

Well, the solution was quite simple...

According to this article the The loading mechanism can be configured through the QT_OPENGL environment variable and the following application attributes...

So I added QT_OPENGL set to desktop as a systen environment variable:

Control Panel > System > Advanced system settings > Environment Variables

enter image description here

I am sure my computer hates me... Cheers!

goulashsoup
  • 2,639
  • 2
  • 34
  • 60