I need to initialize and show OpenGL window not while application starts but by GUI event like QPushButton::clicked().
I am trying to run the ‘openglwindow’ Qt 5.1.1 example on Android 4.0.4 Samsung Galaxy Tab 2. The original project builds and runs correctly. I can see a rotating triangle.
Then I try to do TriangleWindow.show() by event not in main() function but in 'CMainWindow::SelectSecondPage()' slot. Expose event passes successfully but the application crashes in OpenGLWindow::renderNow() function on initializeOpenGLFunctions().
How can I initialize and show OpenGLWindow on event correctly?
CMainWindow
::CMainWindow(QWidget *parent
){
QSurfaceFormat format;
format.setSamples(16);
m_pTriangleWindow = new TriangleWindow;
m_pTriangleWindow->setFormat(format);
m_pTriangleWindow->resize(640, 480);
m_pTriangleWindow->setPosition(5000, 5000);
connect(pPushButton, SIGNAL(clicked()), this, SLOT(SelectSecondPage()));
pLayout->addStretch();
pLayout->addWidget(pPushButton);
pLayout->addStretch();
pFirstPage->setLayout(pLayout);
m_pWidgetStack->addWidget(pFirstPage);
m_pSecondPage
= new QWidget(m_pWidgetStack
);
m_pWidgetStack->addWidget(m_pSecondPage);
setCentralWidget(m_pWidgetStack);
m_pWidgetStack->setCurrentIndex(0);
}
CMainWindow::~CMainWindow()
{
m_pTriangleWindow->deleteLater();
}
void CMainWindow::SelectSecondPage()
{
m_pWidgetStack->setCurrentIndex(1);
m_pTriangleWindow->show();
m_pTriangleWindow->setAnimating(true);
}
CMainWindow::CMainWindow(QWidget *parent)
: QMainWindow(parent)
{
QSurfaceFormat format;
format.setSamples(16);
m_pTriangleWindow = new TriangleWindow;
m_pTriangleWindow->setFormat(format);
m_pTriangleWindow->resize(640, 480);
m_pTriangleWindow->setPosition(5000, 5000);
m_pWidgetStack = new QStackedWidget(this);
QWidget* pFirstPage = new QWidget(m_pWidgetStack);
QPushButton* pPushButton = new QPushButton("Start Triangle window", m_pWidgetStack);
QVBoxLayout* pLayout = new QVBoxLayout;
connect(pPushButton, SIGNAL(clicked()), this, SLOT(SelectSecondPage()));
pLayout->addStretch();
pLayout->addWidget(pPushButton);
pLayout->addStretch();
pFirstPage->setLayout(pLayout);
m_pWidgetStack->addWidget(pFirstPage);
m_pSecondPage = new QWidget(m_pWidgetStack);
m_pWidgetStack->addWidget(m_pSecondPage);
setCentralWidget(m_pWidgetStack);
m_pWidgetStack->setCurrentIndex(0);
}
CMainWindow::~CMainWindow()
{
m_pTriangleWindow->deleteLater();
}
void CMainWindow::SelectSecondPage()
{
m_pWidgetStack->setCurrentIndex(1);
m_pTriangleWindow->show();
m_pTriangleWindow->setAnimating(true);
}
To copy to clipboard, switch view to plain text mode
Application output:
Debugging starts
Could not load shared library symbols for 71 libraries, e.g. /system/bin/linker.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?Unable to find dynamic linker breakpoint function.
GDB will retry eventurally. Meanwhile, it is likely
that GDB is unable to debug shared library initializers
or resolve pending breakpoints after dlopen().I/Qt JAVA (27127): DEBUGGER: waiting for pong at /data/local/tmp/qt/debug-pong-org.qtproject.example.OpenGLWindow, attempt 3
I/Qt JAVA (27127): DEBUGGER: got pong /data/local/tmp/qt/debug-pong-org.qtproject.example.OpenGLWindow
W/Qt (27127): ../src/androidjnimain.cpp:449 (jboolean startQtApplication(JNIEnv*, jobject, jstring, jstring)): Can't set environment ""
W/Qt (27127): kernel/qcoreapplication.cpp:412 (QCoreApplicationPrivate::QCoreApplicationPrivate(int&, char**, uint)): WARNING: QApplication was not created in the main() thread.
D/libEGL (27127): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
D/libEGL (27127): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
D/libEGL (27127): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
W/dalvikvm(27127): dvmFindClassByName rejecting 'org/qtproject/qt5/android/QtNativeInputConnection'
W/dalvikvm(27127): dvmFindClassByName rejecting 'org/qtproject/qt5/android/QtExtractedText'
D/Qt (27127): ../OpenGLWindow/openglwindow.cpp:118 (virtual void OpenGLWindow::exposeEvent(QExposeEvent*)): exposeEvent passed
E/libEGL (27127): eglMakeCurrent:674 error 3009 (EGL_BAD_MATCH)
W/Qt (27127): eglconvenience/qeglplatformcontext.cpp:111 (virtual bool QEGLPlatformContext::makeCurrent(QPlatformSurface*)): QEGLPlatformContext::makeCurrent: eglError: 3009, this: 0x2098190
W/Qt (27127):
Debugging has finished
Debugging starts
Could not load shared library symbols for 71 libraries, e.g. /system/bin/linker.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?Unable to find dynamic linker breakpoint function.
GDB will retry eventurally. Meanwhile, it is likely
that GDB is unable to debug shared library initializers
or resolve pending breakpoints after dlopen().I/Qt JAVA (27127): DEBUGGER: waiting for pong at /data/local/tmp/qt/debug-pong-org.qtproject.example.OpenGLWindow, attempt 3
I/Qt JAVA (27127): DEBUGGER: got pong /data/local/tmp/qt/debug-pong-org.qtproject.example.OpenGLWindow
W/Qt (27127): ../src/androidjnimain.cpp:449 (jboolean startQtApplication(JNIEnv*, jobject, jstring, jstring)): Can't set environment ""
W/Qt (27127): kernel/qcoreapplication.cpp:412 (QCoreApplicationPrivate::QCoreApplicationPrivate(int&, char**, uint)): WARNING: QApplication was not created in the main() thread.
D/libEGL (27127): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
D/libEGL (27127): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
D/libEGL (27127): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
W/dalvikvm(27127): dvmFindClassByName rejecting 'org/qtproject/qt5/android/QtNativeInputConnection'
W/dalvikvm(27127): dvmFindClassByName rejecting 'org/qtproject/qt5/android/QtExtractedText'
D/Qt (27127): ../OpenGLWindow/openglwindow.cpp:118 (virtual void OpenGLWindow::exposeEvent(QExposeEvent*)): exposeEvent passed
E/libEGL (27127): eglMakeCurrent:674 error 3009 (EGL_BAD_MATCH)
W/Qt (27127): eglconvenience/qeglplatformcontext.cpp:111 (virtual bool QEGLPlatformContext::makeCurrent(QPlatformSurface*)): QEGLPlatformContext::makeCurrent: eglError: 3009, this: 0x2098190
W/Qt (27127):
Debugging has finished
To copy to clipboard, switch view to plain text mode
Bookmarks