InitializeOpenGLFunctions crashes in QQuickView



  • So I made a QuickView with nothing really in it, in its ctor I placed a initializeOpenGLFunctions(); call. This class inherits from QQuickView, QOpenGLFunctions_3_0. this was my attempt at making a test case to wonder wtf is happening. i was trying to switch from glew to qopenglfunctions stuff but this crashes for some odd reason. my driver is fully capable (nvidia, modern hw).
    @

    #include "mainwindow.h"
    #include <QApplication>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    // w.show();

    return a.exec&#40;&#41;;
    

    }

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QQuickView>
    #include <QOpenGLFunctions_3_0>

    class MainWindow : public QQuickView, protected QOpenGLFunctions_3_0
    {
    Q_OBJECT

    public:
    MainWindow();
    ~MainWindow();
    };

    #endif // MAINWINDOW_H
    #include "mainwindow.h"

    MainWindow::MainWindow()
    : QQuickView()
    {
    initializeOpenGLFunctions();
    }

    MainWindow::~MainWindow()
    {

    }
    @
    bt:

    Thread 3 (Thread 0x7fffe3c36700 (LWP 603)):
    #0 0x00007ffff59e481d in poll () from /usr/lib/libc.so.6
    No symbol table info available.
    #1 0x00007ffff4218d64 in ?? () from /usr/lib/libglib-2.0.so.0
    No symbol table info available.
    #2 0x00007ffff4218e6c in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
    No symbol table info available.
    #3 0x00007ffff64b7edc in QEventDispatcherGlib::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/libQt5Core.so.5
    No symbol table info available.
    #4 0x00007ffff645e512 in QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/libQt5Core.so.5
    No symbol table info available.
    #5 0x00007ffff626f504 in QThread::exec() () from /usr/lib/libQt5Core.so.5
    No symbol table info available.
    #6 0x00007ffff62744fe in ?? () from /usr/lib/libQt5Core.so.5
    No symbol table info available.
    #7 0x00007ffff472f124 in start_thread () from /usr/lib/libpthread.so.0
    No symbol table info available.
    #8 0x00007ffff59ed4bd in clone () from /usr/lib/libc.so.6
    No symbol table info available.

    Thread 2 (Thread 0x7fffe8f2e700 (LWP 602)):
    #0 0x00007ffff59e481d in poll () from /usr/lib/libc.so.6
    No symbol table info available.
    #1 0x00007fffeeca19b2 in ?? () from /usr/lib/libxcb.so.1
    No symbol table info available.
    #2 0x00007fffeeca352f in xcb_wait_for_event () from /usr/lib/libxcb.so.1
    No symbol table info available.
    #3 0x00007fffebf88b19 in ?? () from /usr/lib/qt/plugins/platforms/libqxcb.so
    No symbol table info available.
    #4 0x00007ffff62744fe in ?? () from /usr/lib/libQt5Core.so.5
    No symbol table info available.
    #5 0x00007ffff472f124 in start_thread () from /usr/lib/libpthread.so.0
    No symbol table info available.
    #6 0x00007ffff59ed4bd in clone () from /usr/lib/libc.so.6
    No symbol table info available.

    Thread 1 (Thread 0x7ffff7fc27c0 (LWP 598)):
    #0 0x00007ffff69c5811 in QOpenGLContext::format() const () from /usr/lib/libQt5Gui.so.5
    No symbol table info available.
    #1 0x00007ffff6cddbc8 in QOpenGLFunctions_3_0::isContextCompatible(QOpenGLContext*) () from /usr/lib/libQt5Gui.so.5
    No symbol table info available.
    #2 0x00007ffff6cddce0 in QOpenGLFunctions_3_0::initializeOpenGLFunctions() () from /usr/lib/libQt5Gui.so.5
    No symbol table info available.
    #3 0x0000000000401e98 in MainWindow::MainWindow (this=0x7fffffffe120) at ../untitled/mainwindow.cpp:6
    No locals.
    #4 0x0000000000401dbd in main (argc=1, argv=0x7fffffffe2e8) at ../untitled/main.cpp:7
    a = <incomplete type>
    w = {<QQuickView> = {<No data fields>}, <QOpenGLFunctions_3_0> = {<No data fields>}, static staticMetaObject = {d = {superdata = 0x7ffff7dd2380 QQuickView::staticMetaObject, stringdata = 0x402300 <qt_meta_stringdata_MainWindow>, data = 0x402340 <qt_meta_data_MainWindow>, static_metacall = 0x401fba <MainWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, relatedMetaObjects = 0x0, extradata = 0x0}}}



  • I'm not an expert on the subject, but I believe you should use QQuickView's beforeRendering() or afterRendering() signals to call your render function and initialize OpenGL (the OpenGL context might not be created yet).
    Also, unless you are planning on drawing a UI over/under your OpenGL scene, you should probably inherit from QWindow instead of QQuickView.



  • hm, perhaps you're right.

    Also, unless you are planning on drawing a UI over/under your OpenGL scene, you should probably inherit from QWindow instead of QQuickView.

    well, i am doing exactly that. but i don't see how using qwindow would prevent me from doing it.



  • There are several ways, and I am myself struggling a bit with them, but here is a [url=https://www.youtube.com/watch?v=BfIaTccy6HQ&list=UUsyT1C1M-QoHQREjsixgayQ]talk by Sean Hammer[/url] that should help you. It gives several ways to have OpenGL and QtQuick working together.



  • it seems i can eg create a quickview in main, call setformat and then initializeopenglfunctions just fine..not sure why what i was doing wasn't working..i guess it was happening before it init'd or sth


Log in to reply
 

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