Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Initializing GLEW: "Missing GL Version"

Initializing GLEW: "Missing GL Version"

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 3.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Morange
    wrote on last edited by
    #1

    While initializing glew in a class that inherits QWindow I get the error "Missing GL Version" after creating a QOpenGLContext, and glGetString(GL_VERSION) returns an empty string. Is this the correct way to initialize glew? Here is my code:
    @#include "gl/glew.h"
    #include "glviewwindow.h"
    #include <QSurfaceFormat>
    #include <QOpenGLContext>
    #include <QDebug>
    #include "qopengl.h"

    GLViewWindow::GLViewWindow(QWindow* parent)
    : QWindow(parent),
    context(new QOpenGLContext)
    {
    setSurfaceType(OpenGLSurface);
    }

    GLViewWindow::~GLViewWindow()
    {
    delete context;
    delete format;
    }

    void GLViewWindow::initWindowOpengl()
    {
    #ifdef QT_DEBUG
    format = new QSurfaceFormat(QSurfaceFormat::DebugContext);
    #else
    format = QSurfaceFormat();
    #endif
    format->setMajorVersion(3);
    format->setMinorVersion(3);
    format->setProfile(QSurfaceFormat::CoreProfile);
    format->setSwapBehavior(QSurfaceFormat::DoubleBuffer);
    format->setRenderableType(QSurfaceFormat::OpenGL);
    setFormat(*format);
    context->setFormat(requestedFormat());
    if(!context->create())
    qDebug() << "context creation failed";
    if(!context->isValid())
    qDebug("Opengl context invalid!");
    context->makeCurrent(this);
    qDebug() << this->format->majorVersion() << "." << this->format->minorVersion();
    qDebug() << context->format().majorVersion()<< "." << context->format().minorVersion();

    glewExperimental = GL_TRUE;
    GLenum err = glewInit();
    if(err != GLEW_OK)
    {
        QString s = reinterpret_cast<const char*>(glewGetErrorString(err));
        qDebug() << s;
    
        qDebug() << reinterpret_cast<const char*>(glGetString(GL_VERSION));
    }
    

    }@

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Morange
      wrote on last edited by
      #2

      I just realized that Qt has an class that contains all the opengl functions for a specified version, which gets rid of the need for glew, however, when I call initializeGLFunctions I get an assert at line 257 of qopenglfunctions_3_3_core.cpp. Looking at this section of the source code it seems like initializeGLFunctions is getting the currently bound context, and this is invalid. When I create my context it is valid and I call makeCurrent, but when I call QOpenGLContext::currentContext immediately afterwards I get 0.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved