Search code examples
openglqtopengl

glGenTextures gives GL_INVALID_OPERATION despite valid OpenGL context


I get a GL_INVALID_OPERATION error when calling glGenTextures and I have no idea what could be responsible for it.

I am using QtOpenGLWidget to retrieve the context and it looks valid at the time I call glGenTextures() (at least I have one since glGetString(GL_VERSION) and glxGetCurrentContext() both return something which is not crap)

The faulty code is called from the QOpenGLWidget::resizeGL() method. In the QOpenGLWidget::initializeGL() I compile successfully some shader programs and I create / upload data to VAO / VBOs.

So my questions are :

  • What are the common faulty cases of glGenTextures() except not having an OpenGL context at all
  • Can an OpenGL context be invalid or messed up and, in such a case
  • How can I check that my OpenGL context is valid ?

EDIT: Since I strongly believe this is related to the fact my machine has no proper GPU, here is the return of glxinfo.


Solution

  • Ok found the problem. It appears a shader was silently not compiling properly (hardcoded shader not checked for proper compilation, with incorrect #version) and that was messing up the next OpenGL error check which was the glGenTextures().