Use glad loader in Qt app

c++, glew, opengl, qt

Solution

gladLoadGL() returns 1 on success, but you are interpreting it as a failure.

Problem

I'm using Qt to write an OpenGL app. Until now, I was using QOpenGLFunctions_4_4_Core to get the OpenGL function pointers. However, I don't like to have to use inheritance in all the classes that call OpenGL functions. To avoid this I tried to use the glad loader instead: ``` void GLViewer::initializeGL() { qDebug() << "GL init"; makeCurrent(); if (gladLoadGL()) { // you need an OpenGL context before loading glad printf("I did load GL with no context!\n"); exit(1); } ... ``` However, it doesn't work, the loading fails telling me that there is no GL context. Do you know why? Can I use an external GL loader instead of the Qt one?

Original source