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. Why are there two contexts instead of one?

Why are there two contexts instead of one?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 152 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.
  • D Offline
    D Offline
    Dosemnai
    wrote on last edited by
    #1

    I've been fighting a bug for some amount of time. I singled it out eventually, it was OpenGLContext related, but I still don't understand why this is happening.

    I was going to load my OpenGL textures later with a QAction trigger, instead of during initGL, but there was a context change in the middle for a reason unknown to me. I suppose I can set current context manually, but there's only a single OpenGLWidget instance in the entire program and I don't know why this is happening.

    Custom signal that fires at InitGL:

    ui.textureWidget->view()->sig_Start.connect([&]() {
        cout << "start" << endl;
        cout << QOpenGLContext::currentContext() << endl;
        cout << ui.textureWidget->view()->context() << endl;
    });
    

    QAction that is triggered later (much after initGL) on a key press:

    connect(action, &QAction::triggered, [&](bool) {
        cout << "trigger" << endl;
        cout << QOpenGLContext::currentContext() << endl;
        cout << ui.textureWidget->view()->context() << endl;
    });
    

    Output:

    start
    000002571DA62C00
    000002571DA62C00
    trigger
    000002571EA88700 <- ??
    000002571DA62C00
    

    Why does this happen? The only OpenGLWidget I use is one wrapped in another widget added to a QMainWindow. Why is there a context change in the middle and what is that other context?

    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