Strange OpenGL initialization error in Linux

  • I recently inherited a QT application for a project I'm working with that uses an OpenGL widget. The code worked as expected under Windows and Mac, but under Linux the OpenGL widget displayed nothing but garbage from the framebuffer. There were no errors from OpenGL, and nothing in the code looked like it should be causing such a problem. I tried adding calls to makeCurrent() in several places, and a few other things. Ultimately the only thing I could find that fixed the problem was adding this line of code at the beginning of the OpenGL widget's constructor:
    @ setContext( new QGLContext( QGLFormat(), this ) ); @

    With that line of code in place, everything worked under Linux just as under Windows or Mac. I assume this means there was some problem with initializing the OpenGL context under Linux, but I'm totally at a loss as to what could be causing it. Any thoughts would be appreciated.

    Here's the constructor in it's entirety:
    @OpenGLWidget::OpenGLWidget(MainWindow *main_window,
    QWidget *parent,
    const char *name) : QGLWidget(parent, 0, 0), main_window_(main_window) {

    setContext( new QGLContext( QGLFormat(), this ) );


    zoom = 2.0f;
    z_angle = 0.0f;

    // initialize camera
    camera_ = new OpenGLCamera();
    next_target_ = camera_->getTarget();
    FAHVector3 eye_dest;
    camera_->setEye(eye_dest.x, eye_dest.y, eye_dest.z);

    hasClicked = false;
    wireframeMode = true;

    connect(&advance_camera_timer_, SIGNAL(timeout()), this, SLOT(advanceCameraToTarget()));


  • I can't tell from what you have posted above. Could you extract a small compilable example that reproduces the problem please?

    What GPU card and drivers are you using?

    It's odd because creating a QGLContext with a default QGLFormat is essentially all that QGLWidget does anyway.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.