Android application with OpenGL ES 2.0 (EGL_BAD_CONTEXT?)



  • Hello,

    I'm having problems trying to run a Desktop application on Android.
    It was originally developed for desktop using Desktop Opengl. I switched to OpenGL ES 2.0.

    I've tested on a real Samsung Galaxy S3 under Windows 7 and Ubuntu. I get a similar problem in both. On the device I get "/data/app-lib/org.qtproject.example.A_RoboSol-1/libRobosol.so". I press OK once, then I have a blank screen, I press ok again and the application dies. Sometimes I see the splashscreen before the first message. This is the Application output:
    @
    Starting remote process.D/dalvikvm(32358): Added shared lib /data/data/org.qtproject.example.A_RoboSol/lib/libQt5Widgets.so 0x4245e138
    D/dalvikvm(32358): No JNI_OnLoad found in /data/data/org.qtproject.example.A_RoboSol/lib/libQt5Widgets.so 0x4245e138, skipping init
    D/dalvikvm(32358): Trying to load lib /data/data/org.qtproject.example.A_RoboSol/lib/libQt5OpenGL.so 0x4245e138
    D/dalvikvm(32358): Added shared lib /data/data/org.qtproject.example.A_RoboSol/lib/libQt5OpenGL.so 0x4245e138
    D/dalvikvm(32358): No JNI_OnLoad found in /data/data/org.qtproject.example.A_RoboSol/lib/libQt5OpenGL.so 0x4245e138, skipping init
    D/dalvikvm(32358): Trying to load lib /data/data/org.qtproject.example.A_RoboSol/plugins/platforms/android/libqtforandroidGL.so 0x4245e138
    D/dalvikvm(32358): Added shared lib /data/data/org.qtproject.example.A_RoboSol/plugins/platforms/android/libqtforandroidGL.so 0x4245e138
    I/Qt (32358): qt start
    D/dalvikvm(32358): Trying to load lib /data/app-lib/org.qtproject.example.A_RoboSol-1/libRoboDK.so 0x4245e138
    D/dalvikvm(32358): Added shared lib /data/app-lib/org.qtproject.example.A_RoboSol-1/libRoboDK.so 0x4245e138
    D/dalvikvm(32358): No JNI_OnLoad found in /data/app-lib/org.qtproject.example.A_RoboSol-1/libRoboDK.so 0x4245e138, skipping init
    W/Qt (32358): ..\src\androidjnimain.cpp:449 (jboolean startQtApplication(JNIEnv*, jobject, jstring, jstring)): Can't set environment ""
    W/Qt (32358): kernel\qcoreapplication.cpp:412 (QCoreApplicationPrivate::QCoreApplicationPrivate(int&, char**, uint)): WARNING: QApplication was not created in the main() thread.
    D/libEGL (32358): loaded /system/lib/egl/libEGL_adreno200.so
    D/libEGL (32358): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
    D/libEGL (32358): loaded /system/lib/egl/libGLESv2_adreno200.so
    I/Adreno200-EGL(32358): <qeglDrvAPI_eglInitialize:265>: EGL 1.4 QUALCOMM build: HAREESHG_Nondeterministic_AU+PATCH[ES]_msm8960_JB_1.9.6_MR2_CL3219408_release_ENGG (CL3219408)
    I/Adreno200-EGL(32358): Build Date: 09/28/13 Sat
    I/Adreno200-EGL(32358): Local Branch: hhh
    I/Adreno200-EGL(32358): Remote Branch: quic/jb_1.9.6_1
    I/Adreno200-EGL(32358): Local Patches: 8d50ec23e42ef52b570aa6ff1650afac0b503d78 CL3219408: Fix in the Glreadpixels for negative offsets and larger dimensions.
    I/Adreno200-EGL(32358): 801859126f6ca69482b39a34ca61447e3f7cded8 rb: fix panel settings to clear undrawn/undefined buffers
    I/Adreno200-EGL(32358): Reconstruct Branch: LOCAL_PATCH[ES]
    W/Adreno200-EGL(32358): <qeglDrvAPI_eglSwapInterval:3688>: EGL_BAD_CONTEXT
    W/dalvikvm(32358): dvmFindClassByName rejecting 'org/qtproject/qt5/android/QtNativeInputConnection'
    W/dalvikvm(32358): dvmFindClassByName rejecting 'org/qtproject/qt5/android/QtExtractedText'
    W/Qt (32358): kernel\qplatformwindow.cpp:300 (virtual void QPlatformWindow::propagateSizeHints()): This plugin does not support propagateSizeHints()
    W/Qt (32358): kernel\qplatformwindow.cpp:300 (virtual void QPlatformWindow::propagateSizeHints()): This plugin does not support propagateSizeHints()
    W/Qt (32358): kernel\qplatformwindow.cpp:261 (virtual void QPlatformWindow::setParent(const QPlatformWindow*)): This plugin does not support setParent!
    E/libEGL (32358): call to OpenGL ES API with no current context (logged once per thread)

    'org.qtproject.example.A_RoboSol' died.
    @

    My application uses a QGraphicsScene to display widgets in the OpenGL window, a QMainWindow, QSplashscreen, ... Is all this supposed to work under android also?

    I don't know what is the real source of my problem. Could anyone help?

    Thank you very much.



  • Could someone please point me to the right direction?

    When I debug it, it says segmentation fault and I get a huge call stack (>300) it seems it is a problem with Qt5Widgets.

    Maybe what I'm trying to do is not possible with the Qt 5.2 version?

    Thank you for your help,



  • Since you are mixing OpenGL and widgets, it could be that 5.2 is not good enough: 5.3 received numerous changes in this area so it might be a good idea to test on 5.3, once available.



  • Ok thanks for this info! this is very helpful. I'll wait for the Qt 5.3 version.



  • I've got this too, mostly because I was using UpdateGL();
    Instead of it, I started to use paintGL(); and swapBuffers();

    Also I must ask: Are you instancing an QApplication BEFORE call any widget creation?

    eg.
    @
    MyGLWidget glWidget;
    void main()
    {
    ...
    ...
    ...
    };
    @
    If so, that may cause problems because you really NEED to instance QApplication in main before instance any other widget.

    I'm still waiting for the 5.3 too...
    got some strange situations and I really hope that 5.3 sort some of them!



  • Thanks for your suggestions, but that did not help.

    Now I've tested the new Qt 5.3 version on a real Samsung Galaxy S3 and it works really well! I'm quite impressed to see such good results in these early developments of Qt in Android.

    With the new version I realised that my OpenGL shader program did not compile under android as I was using floating points without the ".0". Eg:
    @ vec3 light_Position = vec3(0,0,0); // wrong
    vec3 light_Position = vec3(0.0,0.0,0.0); // right@
    Before I was not getting any complaints about my shader program from the android device.

    I found a couple problems:
    1- The virtual android devices do not work with OpenGL (OpenGL cannot be initialised). I had to test with the real device. Every compile test also takes quite a while...

    2- If I use a toolbar located at the top, the OpenGL screen is not shifted accordingly: the top screen is blocked and I have a dark spot at the bottom. However, a quick fix is to place the toolbar is at the bottom. My program uses OpenGL mixed with Widgets as in "THIS EXAMPLE":http://doc.qt.digia.com/qq/qq26-openglcanvas.html I do not know if this can have an effect. Also the toolbar does not work very well when a drop down button is pressed.

    Still... I'm quite impressed with the new version :)


Log in to reply
 

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