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. QGLWidget different behavior on windows and linux
Forum Updated to NodeBB v4.3 + New Features

QGLWidget different behavior on windows and linux

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.2k Views 1 Watching
  • 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
    matrem
    wrote on last edited by
    #1

    Hello,

    First of all I'm using qt 4.7.2 on my Linux kubuntu, and qt 4.7.4 on my Windows vista.
    I'm using a custom context class inheriting from QGLContext.

    The problem:
    When I use the QGLWidget constructor taking a QGLContext under Windows all works fine.
    But under Linux the GLWidget does not seems to take the good format from my context (it has a different visual configuration ), so I have to set the format and the context manually in my custom QGLWidget constructor.

    @ QGLContextAdapter * create_context()
    {
    return new QGLContextAdapter(
    vglc::GLContext::Config(
    vglc::GLContext::Config::MinVersion(4, 1),
    vglc::GLContext::Config::LIGHT_R8G8B8,
    #ifdef NDEBUG
    vglc::GLContext::Config::DEBUG_OFF,
    #else
    vglc::GLContext::Config::DEBUG_ON,
    #endif
    vglc::GLContext::Config::STRICT_CORE
    )
    );
    }

    GLWidget::GLWidget( QWidget * parent )
    : QGLWidget(
    #if defined( VIRTREV_WIN32 ) // under windows it's not possible to set context later
    create_context(),
    #endif
    parent
    ),
    ui(new Ui::GLWidget),
    log_dialog_(NULL)
    {
    ui->setupUi(this);

    #if defined( VIRTREV_LINUX ) // under linux if we pass the context to QGLWidget constructor, QGLWidget will not use the good format
    QGLContextAdapter * context = create_context();
    setFormat( context->format() );
    context->setDevice( this );
    setContext( context );
    #endif
    }@

    Is this a bug which has been solved in 4.7.4 or is this not a bug ?

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

      Reading qt source code (qgl_x11.cpp) I guess I understand why there is the problem.

      The visual used to create the window is only set in qglcontext::choosecontext and since this a private data of qglcontext (d->vi), my custom QGLContext (which redefined choosecontext) as no way to setup the visual. So it use a 0 visual which is CopyFromParent.

      The setformat; is a bit of a trick because it let a temporary QGLContext set the visual.

      I guess one solution would be to call choosevisual in qglcontext::create to initialize the visual instead of doing it in choosecontext.

      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