The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
libSDL OpenGL ES 2.0 issue on Android
tsethcle


Joined: 29 Oct 2013
Posts: 6
Hi folks,

I am looking at three development platforms:
1) Windows 8.1, libSDL 2.0.1, OpenGL instead of ES
2) Nexus 5, Android 4.4.4, OpenGL ES 2.0, libSDL 2.0.1 and libSDL 2.0.4 from today's source (3d2c0f659ad3)
3) simValley 421 smartwatch, 240x240 display, Android 4.2.2, OpenGL ES 2.0, libSDL 2.0.1 and libSDL 2.0.4 from today's source (3d2c0f659ad3). the GPU supports ES 2.0 and the NDK ES 2.0 sample works fine.

I am creating a window (SDL_CreateWindow) at 240x240 with the SDL_WINDOW_OPENGL and SDL_WINDOW_FULLSCREEN flags.

On Android I also do:
Code:
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);



Then I call SDL_GL_CreateContext(). I clean the buffers.
Code:
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow();
glClear(GL_COLOR_BUFFER_BIT);



Platform 1: Everything works as I expect it.
Platform 2: The app opens. My text gets printed. But I see it 8 times and there are random colors around it. When I continue to render content, then later it will only update the left corner which seems like an okay behaviour for the 240x240 resolution. The rest gets black as I expect if from clearing the buffers. When I exit I sometimes see the random colors again for a frame before it quits.

Platform 3: The app opens, but everything stays black. it runs and reacts to some touches as I've seen in the debugger, but it will not display anything.

Questions:
* Why do I see my rendering in the beginning eight times?
* Why does it stop later and seems to work fine and is shown again in the last exit frame?
* Is it not able to clear the full buffer as it thinks it is only 240x240? Should I create a windows in full screen first, clear it, then destroy it and create my small 240x240 window?
* I've seen in SDL_Activity.java that usually there seems to be a default format of SDL_PIXELFORMAT_RGB565. Could that interfere?
* I've seen in src/video/android/SDL_androidwindow.c that some OpenGL ES surface is already created automatically through SDL_EGL_CreateSurface(). Could that conflict with mine at different resolution?
* In the Android Device Manager I see messages from SDL: surfaceCreated(), surfaceChanged(), pixel format RGB_565, Window size: 1794x1080 (which is the full phone res without soft buttons). Also getting I/Adreno-EGL(29084): <qeglDrvAPI_eglInitialize:320>: EGL 1.4 QUALCOMM Build: ... W/Adreno-ES20(29084): <process_gl_state_enables:511>: GL_INVALID_ENUM ; Any hints on that?
* Why is the smartwatch (platform 3) black?

Thanks for any help!
libSDL OpenGL ES 2.0 issue on Android
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
Quote:

* Is it not able to clear the full buffer as it thinks it is only 240x240? Should I create a windows in full screen first, clear it, then destroy it and create my small 240x240 window?




Only one window at the native resolution is supported on Android. You also don't need to create the EGL surface (in any of the platforms iirc).



--
Gabriel.
tsethcle


Joined: 29 Oct 2013
Posts: 6
Ah, didn't know that only native resolution is supported for Android. That should explain some of the issues. Thanks! Then I guess the question remains why on the smartwatch, where I am creating the native 240x240, it shows only black...


As for the EGL surface. If I don't create it, it crashes in Windows and Android. E/libEGL(31319): call to OpenGL ES API with no current context
tsethcle


Joined: 29 Oct 2013
Posts: 6
Output from Android Device Manager on the smartwatch. Don't see any warnings or errors.

V/SDL(24564): onCreate():null
V/SDL(24564): onResume()
V/PhoneWindow(24564): DecorView setVisiblity: visibility = 4
V/PhoneWindow(24564): DecorView setVisiblity: visibility = 0
V/InputMethodManager(24564): Not IME target window, ignoring
I/SurfaceView(24564): Changes: creating=true format=true size=true visible=true left=true top=true mUpdateWindowNeeded=false mReportDrawNeeded=false redrawNeeded=false forceSizeChanged=true mVisible=false mRequestedVisible=true
I/SurfaceView(24564): Cur surface: Surface(name=null, identity=-1)
V/SurfaceView(24564): org.libsdl.app.SDLSurface{4146a738 VFE..... .F....ID 0,0-240,240} got resized: w=240 h=240, cur w=-1 h=-1
I/SurfaceView(24564): New surface: Surface(name=null, identity=647), vis=true, frame=Rect(0, 0 - 240, 240)
I/SurfaceView(24564): visibleChanged -- surfaceCreated
V/SDL(24564): surfaceCreated()
I/SurfaceView(24564): surfaceChanged -- format=4 w=240 h=240
V/SDL(24564): surfaceChanged()
V/SDL(24564): pixel format RGB_565
V/SDL(24564): Window size:240x240
I/SDL(24564): SDL_Android_Init()
I/SDL(24564): SDL_Android_Init() finished!
I/SurfaceView(24564): surfaceRedrawNeeded
I/SurfaceView(24564): finishedDrawing
V/SurfaceView(24564): Layout: x=0 y=0 w=240 h=240, frame=Rect(0, 0 - 240, 240)
I/SurfaceView(24564): Changes: creating=false format=false size=false visible=false left=false top=false mUpdateWindowNeeded=true mReportDrawNeeded=true redrawNeeded=false forceSizeChanged=false mVisible=true mRequestedVisible=true
I/SurfaceView(24564): Cur surface: Surface(name=null, identity=647)
I/SurfaceView(24564): New surface: Surface(name=null, identity=647), vis=true, frame=Rect(0, 0 - 240, 240)
I/SurfaceView(24564): surfaceRedrawNeeded
I/SurfaceView(24564): finishedDrawing
V/SurfaceView(24564): Layout: x=0 y=0 w=240 h=240, frame=Rect(0, 0 - 240, 240)
D/libEGL(24564): loaded /system/lib/egl/libEGL_mali.so
V/SDL(24564): onWindowFocusChanged(): true
V/InputMethodManager(24564): onWindowFocus: org.libsdl.app.SDLSurface{4146a738 VFE..... .F....I. 0,0-240,240} softInputMode=32 first=true flags=#810500
V/InputMethodManager(24564): START INPUT: org.libsdl.app.SDLSurface{4146a738 VFE..... .F....I. 0,0-240,240} ic=null tba=android.view.inputmethod.EditorInfo@414b2c10 controlFlags=#105
D/libEGL(24564): loaded /system/lib/egl/libGLESv1_CM_mali.so
D/libEGL(24564): loaded /system/lib/egl/libGLESv2_mali.so
V/InputMethodManager(24564): Starting input: Bind result=InputBindResult{null com.android.inputmethod.latin/.LatinIME #369}
I/InputMethodManager(24564): handleMessage: MSG_SET_ACTIVE true, was false
libSDL OpenGL ES 2.0 issue on Android
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
To validate SDL is working as it's supposed to on that platform you can try one of the tests (use build-script/androidbuild.sh with testgles2.c or testrendercopyex.c)



2014-10-16 11:56 GMT-03:00 tsethcle:
Quote:
Output from Android Device Manager on the smartwatch. Don't see any warnings or errors.

V/SDL(24564): onCreate():null
V/SDL(24564): onResume()
V/PhoneWindow(24564): DecorView setVisiblity: visibility = 4
V/PhoneWindow(24564): DecorView setVisiblity: visibility = 0
V/InputMethodManager(24564): Not IME target window, ignoring
I/SurfaceView(24564): Changes: creating=true format=true size=true visible=true left=true top=true mUpdateWindowNeeded=false mReportDrawNeeded=false redrawNeeded=false forceSizeChanged=true mVisible=false mRequestedVisible=true
I/SurfaceView(24564): Cur surface: Surface(name=null, identity=-1)
V/SurfaceView(24564): org.libsdl.app.SDLSurface{4146a738 VFE..... .F....ID 0,0-240,240} got resized: w=240 h=240, cur w=-1 h=-1
I/SurfaceView(24564): New surface: Surface(name=null, identity=647), vis=true, frame=Rect(0, 0 - 240, 240)
I/SurfaceView(24564): visibleChanged -- surfaceCreated
V/SDL(24564): surfaceCreated()
I/SurfaceView(24564): surfaceChanged -- format=4 w=240 h=240
V/SDL(24564): surfaceChanged()
V/SDL(24564): pixel format RGB_565
V/SDL(24564): Window size:240x240
I/SDL(24564): SDL_Android_Init()
I/SDL(24564): SDL_Android_Init() finished!
I/SurfaceView(24564): surfaceRedrawNeeded
I/SurfaceView(24564): finishedDrawing
V/SurfaceView(24564): Layout: x=0 y=0 w=240 h=240, frame=Rect(0, 0 - 240, 240)
I/SurfaceView(24564): Changes: creating=false format=false size=false visible=false left=false top=false mUpdateWindowNeeded=true mReportDrawNeeded=true redrawNeeded=false forceSizeChanged=false mVisible=true mRequestedVisible=true
I/SurfaceView(24564): Cur surface: Surface(name=null, identity=647)
I/SurfaceView(24564): New surface: Surface(name=null, identity=647), vis=true, frame=Rect(0, 0 - 240, 240)
I/SurfaceView(24564): surfaceRedrawNeeded
I/SurfaceView(24564): finishedDrawing
V/SurfaceView(24564): Layout: x=0 y=0 w=240 h=240, frame=Rect(0, 0 - 240, 240)
D/libEGL(24564): loaded /system/lib/egl/libEGL_mali.so
V/SDL(24564): onWindowFocusChanged(): true
V/InputMethodManager(24564): onWindowFocus: org.libsdl.app.SDLSurface{4146a738 VFE..... .F....I. 0,0-240,240} softInputMode=32 first=true flags=#810500
V/InputMethodManager(24564): START INPUT: org.libsdl.app.SDLSurface{4146a738 VFE..... .F....I. 0,0-240,240} ic=null tba=android.view.inputmethod.EditorInfo@414b2c10 controlFlags=#105
D/libEGL(24564): loaded /system/lib/egl/libGLESv1_CM_mali.so
D/libEGL(24564): loaded /system/lib/egl/libGLESv2_mali.so
V/InputMethodManager(24564): Starting input: Bind result=InputBindResult{null com.android.inputmethod.latin/.LatinIME #369}
I/InputMethodManager(24564): handleMessage: MSG_SET_ACTIVE true, was false


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





--
Gabriel.