Author Topic: LiveWallpaper Shader Problem  (Read 9565 times)

Offline MrM

  • byte
  • *
  • Posts: 36
    • View Profile
LiveWallpaper Shader Problem
« on: September 11, 2011, 01:06:33 am »
I've got JPCT-ae working with markguerra's LiveWallpaperService, and the only problem's I've had so far was the Texture inpus, since texturemanager is a singleton but that's bypassed with a few ifs.

My problem are the shaders, I can't get them working at all, it's as if they're not used, while logcat says they're loaded, and debugging shows no problems. If I blend them, the normal map is dominant, and it's like IT IS the face map. I'd appreciate it if somebody could take a look at what I'm doing wrong, I'm guessing it's where I instance the renderer or probably at the Engine. The complete Eclipse project, along with jpct and the wallpaperservice libraries are at this link:
http://www.mediafire.com/?yyfchd20h71jotj

Offline MrM

  • byte
  • *
  • Posts: 36
    • View Profile
Re: LiveWallpaper Shader Problem
« Reply #1 on: September 11, 2011, 05:45:43 pm »
These are shots from the device:

This is how the application looks like:


And this is how the LiveWallpaper looks like:


As you can see, the LiveWallpaper is flat, and it's more on the purple side, because of the normal map being blended. The texture settings are the same for both the application and the Live Wallpaper.

Would anybody take a look at the project? I'm at wits end :)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: LiveWallpaper Shader Problem
« Reply #2 on: September 11, 2011, 08:12:08 pm »
Do have a log output where jPCT initializes the renderer? Are you sure that ES 2.0 actually works in the context of a wall paper?

Offline MrM

  • byte
  • *
  • Posts: 36
    • View Profile
Re: LiveWallpaper Shader Problem
« Reply #3 on: September 11, 2011, 08:26:22 pm »
Code: [Select]
[2011-09-11 19:29:43 - Emulator] D/dalvikvm(  157): GC_FOR_MALLOC freed 4017 objects / 242192 bytes in 85ms
[2011-09-11 19:30:04 - Emulator] W/KeyCharacterMap(  126): No keyboard for id 0
[2011-09-11 19:30:04 - Emulator] W/KeyCharacterMap(  126): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
[2011-09-11 19:30:05 - Emulator] I/ActivityManager(   59): Starting activity: Intent { act=android.intent.action.CHOOSER cmp=android/com.android.internal.app.ChooserActivity (has extras) }
[2011-09-11 19:30:06 - Emulator] I/ActivityManager(   59): Displayed activity android/com.android.internal.app.ChooserActivity: 834 ms (total 834 ms)
[2011-09-11 19:30:07 - Emulator] I/ARMAssembler(   59): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x237ab8:0x237b74] in 508990 ns
[2011-09-11 19:30:08 - Emulator] I/ActivityManager(   59): Starting activity: Intent { act=android.intent.action.SET_WALLPAPER flg=0x3000000 cmp=com.android.wallpaper.livepicker/.LiveWallpaperListActivity }
[2011-09-11 19:30:08 - Emulator] I/ActivityManager(   59): Start proc com.android.wallpaper.livepicker for activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: pid=278 uid=10021 gids={}
[2011-09-11 19:30:09 - Emulator] I/ARMAssembler(   59): generated scanline__00000077:03545404_00000004_00000000 [ 47 ipp] (67 ins) at [0x34a290:0x34a39c] in 533736 ns
[2011-09-11 19:30:09 - Emulator] D/dalvikvm(  278): GC_EXTERNAL_ALLOC freed 873 objects / 62000 bytes in 64ms
[2011-09-11 19:30:09 - Emulator] I/ActivityManager(   59): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: 1446 ms (total 1446 ms)
[2011-09-11 19:30:15 - Emulator] I/ActivityManager(   59): Starting activity: Intent { cmp=com.android.wallpaper.livepicker/.LiveWallpaperPreview (has extras) }
[2011-09-11 19:30:15 - Emulator] I/ActivityManager(   59): Start proc net.markguerra.android.glwallpapertest for service net.markguerra.android.glwallpapertest/.MyWallpaperService: pid=290 uid=10044 gids={}
[2011-09-11 19:30:16 - Emulator] I/ActivityManager(   59): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperPreview: 707 ms (total 707 ms)
[2011-09-11 19:30:16 - Emulator] D/GLWallpaperService(  290): onSurfaceCreated()
[2011-09-11 19:30:16 - Emulator] D/libEGL  (  290): egl.cfg not found, using default config
[2011-09-11 19:30:16 - Emulator] D/libEGL  (  290): loaded /system/lib/egl/libGLES_android.so
[2011-09-11 19:30:16 - Emulator] I/jPCT-AE (  290): onSurfaceCreated
[2011-09-11 19:30:16 - Emulator] I/jPCT-AE (  290): onSurfaceChanged
[2011-09-11 19:30:17 - Emulator] D/dalvikvm(  290): GC_EXTERNAL_ALLOC freed 1080 objects / 75016 bytes in 98ms
[2011-09-11 19:30:17 - Emulator] I/jPCT-AE (  290): OpenGL vendor:     Android
[2011-09-11 19:30:17 - Emulator] I/jPCT-AE (  290): OpenGL renderer:   Android PixelFlinger 1.3
[2011-09-11 19:30:17 - Emulator] I/jPCT-AE (  290): OpenGL version:    OpenGL ES-CM 1.0
[2011-09-11 19:30:17 - Emulator] I/jPCT-AE (  290): OpenGL renderer initialized (using 2 texture stages)
[2011-09-11 19:30:17 - Emulator] I/jPCT-AE (  290): Loading Texture...
[2011-09-11 19:30:17 - Emulator] D/dalvikvm(  290): GC_FOR_MALLOC freed 325 objects / 16968 bytes in 54ms
[2011-09-11 19:30:17 - Emulator] I/dalvikvm-heap(  290): Grow heap (frag case) to 3.647MB for 1048592-byte allocation
[2011-09-11 19:30:17 - Emulator] D/dalvikvm(  290): GC_FOR_MALLOC freed 41 objects / 1592 bytes in 125ms
[2011-09-11 19:30:17 - Emulator] I/jPCT-AE (  290): Loading Texture...
[2011-09-11 19:30:17 - Emulator] D/dalvikvm(  290): GC_FOR_MALLOC freed 2 objects / 48 bytes in 58ms
[2011-09-11 19:30:17 - Emulator] I/dalvikvm-heap(  290): Grow heap (frag case) to 4.646MB for 1048592-byte allocation
[2011-09-11 19:30:17 - Emulator] D/dalvikvm(  290): GC_FOR_MALLOC freed 0 objects / 0 bytes in 143ms
[2011-09-11 19:30:18 - Emulator] I/jPCT-AE (  290): Loading Texture...
[2011-09-11 19:30:18 - Emulator] D/dalvikvm(  290): GC_FOR_MALLOC freed 4 objects / 128 bytes in 59ms
[2011-09-11 19:30:18 - Emulator] I/dalvikvm-heap(  290): Grow heap (frag case) to 5.646MB for 1048592-byte allocation
[2011-09-11 19:30:18 - Emulator] D/dalvikvm(  290): GC_FOR_MALLOC freed 0 objects / 0 bytes in 141ms
[2011-09-11 19:30:18 - Emulator] D/dalvikvm(  290): GC_FOR_MALLOC freed 40 objects / 2112 bytes in 52ms
[2011-09-11 19:30:18 - Emulator] I/dalvikvm-heap(  290): Grow heap (frag case) to 6.652MB for 1048592-byte allocation
[2011-09-11 19:30:18 - Emulator] D/dalvikvm(  290): GC_FOR_MALLOC freed 0 objects / 0 bytes in 139ms
[2011-09-11 19:30:19 - Emulator] D/dalvikvm(  290): GC_FOR_MALLOC freed 10 objects / 600 bytes in 64ms
[2011-09-11 19:30:19 - Emulator] I/jPCT-AE (  290): Loading Texture...
[2011-09-11 19:30:19 - Emulator] I/jPCT-AE (  290): Loading file from InputStream
[2011-09-11 19:30:19 - Emulator] I/jPCT-AE (  290): Text file from InputStream loaded...1438 bytes
[2011-09-11 19:30:19 - Emulator] I/jPCT-AE (  290): Loading file from InputStream
[2011-09-11 19:30:19 - Emulator] I/jPCT-AE (  290): Text file from InputStream loaded...1209 bytes
[2011-09-11 19:30:19 - Emulator] I/jPCT-AE (  290): Normal vectors calculated in 7ms!
[2011-09-11 19:30:19 - Emulator] I/jPCT-AE (  290): Tangent vectors calculated in 1ms!
[2011-09-11 19:30:19 - Emulator] I/jPCT-AE (  290): Adding Lightsource: 0
[2011-09-11 19:30:19 - Emulator] I/jPCT-AE (  290): Subobject of object 0/object2 compiled to flat fixed point data using 6 vertices in 4ms!
[2011-09-11 19:30:19 - Emulator] I/jPCT-AE (  290): Object 0/object2 compiled to 1 subobjects in 11ms!
[2011-09-11 19:30:19 - Emulator] I/jPCT-AE (  290): Object 'object2' uses one texture set!
[2011-09-11 19:30:19 - Emulator] D/dalvikvm(  290): GC_EXTERNAL_ALLOC freed 290 objects / 2144936 bytes in 58ms
[2011-09-11 19:30:20 - Emulator] D/dalvikvm(  290): GC_EXTERNAL_ALLOC freed 53 objects / 526304 bytes in 59ms
[2011-09-11 19:30:20 - Emulator] I/jPCT-AE (  290): VBO created for object 'object2'
[2011-09-11 19:30:20 - Emulator] I/ARMAssembler(  290): generated scanline__000000B7:03010144_00009506_00009507 [157 ipp] (254 ins) at [0x2487b8:0x248bb0] in 6688975 ns
[2011-09-11 19:30:21 - Emulator] I/ARMAssembler(  290): generated scanline__00000077:03141444_00009506_00000000 [ 71 ipp] (120 ins) at [0x24f9d0:0x24fbb0] in 1175839 ns
[2011-09-11 19:30:21 - Emulator] I/jPCT-AE (  290): 0fps
[2011-09-11 19:30:22 - Emulator] I/jPCT-AE (  290): 5fps
[2011-09-11 19:30:23 - Emulator] I/jPCT-AE (  290): 5fps
[2011-09-11 19:30:24 - Emulator] I/jPCT-AE (  290): 5fps
[2011-09-11 19:30:25 - Emulator] I/jPCT-AE (  290): 5fps
[2011-09-11 19:30:26 - Emulator] I/jPCT-AE (  290): 5fps
[2011-09-11 19:30:27 - Emulator] I/jPCT-AE (  290): 5fps

It says:
[2011-09-11 19:30:17 - Emulator] I/jPCT-AE (  290): OpenGL vendor:     Android
[2011-09-11 19:30:17 - Emulator] I/jPCT-AE (  290): OpenGL renderer:   Android PixelFlinger 1.3
[2011-09-11 19:30:17 - Emulator] I/jPCT-AE (  290): OpenGL version:    OpenGL ES-CM 1.0
[2011-09-11 19:30:17 - Emulator] I/jPCT-AE (  290): OpenGL renderer initialized (using 2 texture stages)


I might have made an oversight:
I haven't checked for ES 2.0 compatibility.

Offline MrM

  • byte
  • *
  • Posts: 36
    • View Profile
Re: LiveWallpaper Shader Problem
« Reply #4 on: September 11, 2011, 08:31:57 pm »
I could'n find anything better than this:
http://www.youtube.com/watch?v=k3SVtxNvk4E

I'd conclude ES 2.0 indeed works with Live Wallpapers.
I can't see however why this:
[2011-09-11 19:30:17 - Emulator] I/jPCT-AE (  290): OpenGL version:    OpenGL ES-CM 1.0
is initalized.
Maybe it's an oversight in the livewallpaper library?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: LiveWallpaper Shader Problem
« Reply #5 on: September 11, 2011, 08:46:56 pm »
This is even more disturbing: Android PixelFlinger 1.3

...that means that you are running your wallpaper on Android's software renderer implementation which (apart from the fact that it doesn't support ES 2.0 anyway), is slow and buggy and should be avoided at all costs...no idea why this happens. Most likely, it has to do something with your initialization code being faulty somehow...

Offline MrM

  • byte
  • *
  • Posts: 36
    • View Profile
Re: LiveWallpaper Shader Problem
« Reply #6 on: September 12, 2011, 07:45:28 am »
All Right, I got over my initialization issues, but now I have different problems:
Quote
09-12 07:38:48.931: INFO/KeyInputQueue(176): Enqueueing touch event0
09-12 07:38:48.931: INFO/WindowManager(176): Read next event 0
09-12 07:38:48.931: INFO/WindowManager(176): Delivering pointer 0 > Window{4a5c3df0 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperListActivity paused=false}
09-12 07:38:49.001: INFO/KeyInputQueue(176): Enqueueing touch event1
09-12 07:38:49.001: INFO/PowerManagerService(176): Ulight 1->3|0
09-12 07:38:49.001: INFO/PowerManagerService(176): Setting target 2: cur=20.0 target=203 delta=12.2 nominalCurrentValue=20
09-12 07:38:49.001: INFO/PowerManagerService(176): Scheduling light animator!
09-12 07:38:49.001: INFO/WindowManager(176): Read next event 1
09-12 07:38:49.001: INFO/WindowManager(176): Delivering pointer 1 > Window{4a5c3df0 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperListActivity paused=false}
09-12 07:38:49.141: INFO/ActivityManager(176): Starting activity: Intent { cmp=com.android.wallpaper.livepicker/.LiveWallpaperPreview (has extras) }
09-12 07:38:49.151: WARN/ActivityManager(176): Trying to launch com.android.wallpaper.livepicker/.LiveWallpaperPreview
09-12 07:38:49.221: INFO/ActivityManager(176): Start proc net.markguerra.android.glwallpapertest for service net.markguerra.android.glwallpapertest/.MyWallpaper: pid=15311 uid=10087 gids={}
09-12 07:38:49.261: INFO/PowerManagerService(176): Light Animator Finished curIntValue=203
09-12 07:38:49.281: INFO/ActivityManager(176): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperPreview: 128 ms (total 128 ms)
09-12 07:38:49.281: INFO/ActivityThread(848): queueIdle
09-12 07:38:49.281: VERBOSE/ActivityThread(848): Reporting idle of ActivityRecord{4a39d7c8 token=android.os.BinderProxy@4a3cc798 {com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview}} finished=false
09-12 07:38:49.291: WARN/ActivityNative(848): send ACTIVITY_IDLE_TRANSACTION
09-12 07:38:49.291: WARN/ActivityNative(176): RCV ACTIVITY_IDLE_TRANSACTION
09-12 07:38:49.421: DEBUG/GLWallpaperService(15311): onSurfaceCreated()
09-12 07:38:49.451: DEBUG/WALLPAPERTAG(15311): Creating OpenGL ES 2.0 context
09-12 07:38:49.481: INFO/jPCT-AE(15311): onSurfaceChanged
09-12 07:38:49.501: ERROR/libEGL(15311): called unimplemented OpenGL ES API
09-12 07:38:49.501: ERROR/libEGL(15311): called unimplemented OpenGL ES API
09-12 07:38:49.501: ERROR/libEGL(15311): called unimplemented OpenGL ES API
09-12 07:38:49.501: ERROR/libEGL(15311): called unimplemented OpenGL ES API
09-12 07:38:49.501: ERROR/libEGL(15311): called unimplemented OpenGL ES API
09-12 07:38:49.501: ERROR/libEGL(15311): called unimplemented OpenGL ES API

09-12 07:38:49.561: INFO/jPCT-AE(15311): OpenGL vendor:     Qualcomm
09-12 07:38:49.561: INFO/jPCT-AE(15311): OpenGL renderer:   Adreno 200
09-12 07:38:49.561: INFO/jPCT-AE(15311): OpenGL version:    OpenGL ES 2.0 1309647
09-12 07:38:49.561: INFO/jPCT-AE(15311): OpenGL renderer initialized (using 0 texture stages)

09-12 07:38:49.561: INFO/jPCT-AE(15311): Loading Texture...
09-12 07:38:49.841: INFO/jPCT-AE(15311): Loading Texture...
09-12 07:38:50.151: INFO/jPCT-AE(15311): Loading Texture...
09-12 07:38:50.631: INFO/jPCT-AE(15311): Loading Texture...
09-12 07:38:50.631: INFO/jPCT-AE(15311): Loading file from InputStream
09-12 07:38:50.631: INFO/jPCT-AE(15311): Text file from InputStream loaded...1438 bytes
09-12 07:38:50.641: INFO/jPCT-AE(15311): Loading file from InputStream
09-12 07:38:50.641: INFO/jPCT-AE(15311): Text file from InputStream loaded...1209 bytes
09-12 07:38:50.641: INFO/jPCT-AE(15311): Normal vectors calculated in 1ms!
09-12 07:38:50.641: INFO/jPCT-AE(15311): Tangent vectors calculated in 0ms!
09-12 07:38:50.641: INFO/jPCT-AE(15311): Adding Lightsource: 0
09-12 07:38:50.641: INFO/jPCT-AE(15311): Memory usage before compacting: 8631 KB used out of 9415 KB
09-12 07:38:50.911: INFO/jPCT-AE(15311): Memory usage after compacting: 8590 KB used out of 9415 KB
09-12 07:38:50.941: WARN/dalvikvm(15311): threadid=8: thread exiting with uncaught exception (group=0x400207d8)
09-12 07:38:50.951: ERROR/AndroidRuntime(15311): FATAL EXCEPTION: GLThread 9
09-12 07:38:50.951: ERROR/AndroidRuntime(15311): java.lang.ArrayIndexOutOfBoundsException
09-12 07:38:50.951: ERROR/AndroidRuntime(15311):     at com.threed.jpct.CompiledInstance.fill(CompiledInstance.java:1164)
09-12 07:38:50.951: ERROR/AndroidRuntime(15311):     at com.threed.jpct.Object3DCompiler.compile(Object3DCompiler.java:151)
09-12 07:38:50.951: ERROR/AndroidRuntime(15311):     at com.threed.jpct.World.compile(World.java:2050)
09-12 07:38:50.951: ERROR/AndroidRuntime(15311):     at com.threed.jpct.World.compileAllObjects(World.java:1000)
09-12 07:38:50.951: ERROR/AndroidRuntime(15311):     at net.markguerra.android.glwallpapertest.MyRenderer.onSurfaceChanged(MyRenderer.java:215)
09-12 07:38:50.951: ERROR/AndroidRuntime(15311):     at net.rbgrn.opengl.GLThread.guardedRun(GLThread.java:229)
09-12 07:38:50.951: ERROR/AndroidRuntime(15311):     at net.rbgrn.opengl.GLThread.run(GLThread.java:93)

09-12 07:38:52.451: INFO/KeyInputQueue(176): Enqueueing touch event0
09-12 07:38:52.451: INFO/WindowManager(176): Read next event 0
09-12 07:38:52.451: INFO/WindowManager(176): Delivering pointer 0 > Window{4a7b0a98 Sorry! paused=false}
09-12 07:38:52.461: INFO/KeyInputQueue(176): Enqueueing touch event1
09-12 07:38:52.461: INFO/WindowManager(176): Read next event 1
09-12 07:38:52.461: INFO/WindowManager(176): Delivering pointer 1 > Window{4a7b0a98 Sorry! paused=false}
09-12 07:38:52.481: WARN/InputManagerService(176): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4a4e49d8
09-12 07:38:52.511: INFO/ActivityManager(176): Process net.markguerra.android.glwallpapertest (pid 15311) has died.
09-12 07:38:52.511: WARN/ActivityManager(176): Scheduling restart of crashed service net.markguerra.android.glwallpapertest/.MyWallpaper in 5000ms
09-12 07:38:52.511: INFO/WindowManager(176): WIN DEATH: Window{4a81b370 net.markguerra.android.glwallpapertest.MyWallpaper paused=false}
09-12 07:38:52.521: WARN/LiveWallpaperPreview(848): Wallpaper service gone: ComponentInfo{net.markguerra.android.glwallpapertest/net.markguerra.android.glwallpapertest.MyWallpaper}
09-12 07:38:52.931: INFO/KeyInputQueue(176): Input keycode=4 event: 1
09-12 07:38:52.931: DEBUG/KeyInputQueue(176): screenCaptureKeyFlag setting 1
09-12 07:38:52.931: INFO/PowerManagerService(176): Ulight 3->7|0
09-12 07:38:52.941: INFO/WindowManager(176): Dispatching key to Window{4a595960 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false}
09-12 07:38:53.091: INFO/KeyInputQueue(176): Input keycode=4 event: 0
09-12 07:38:53.091: DEBUG/KeyInputQueue(176): screenCaptureKeyFlag setting 0
09-12 07:38:53.101: INFO/WindowManager(176): Dispatching key to Window{4a595960 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false}
09-12 07:38:54.001: INFO/ActivityThread(848): queueIdle
09-12 07:38:54.001: VERBOSE/ActivityThread(848): Reporting idle of ActivityRecord{4a3c91e0 token=android.os.BinderProxy@4a3da890 {com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperListActivity}} finished=false
09-12 07:38:54.001: WARN/ActivityNative(848): send ACTIVITY_IDLE_TRANSACTION
09-12 07:38:54.001: WARN/ActivityNative(176): RCV ACTIVITY_IDLE_TRANSACTION

It seeems to me that the problem arises when trying to compile to the framebuffer. The code in OnSurfaceChanged, where the objects are compiled, is the same as in the HelloShader example. Do you have any suggestions that could solve this? Or whatever pops in your mind?

Offline MrM

  • byte
  • *
  • Posts: 36
    • View Profile
Re: LiveWallpaper Shader Problem
« Reply #7 on: September 12, 2011, 08:00:18 am »
If I get rid of all the FrameBuffer lines (in on SurfaceCahnged and in onDrawFrame), it works! Of course it doesn't render anything, just a black screen, but my point is, it's probably the FB.
Any other way to compile and render stuff?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: LiveWallpaper Shader Problem
« Reply #8 on: September 12, 2011, 08:03:39 am »
How are you creating the FrameBuffer? Make sure that you are using the constructor without the gl context.

Offline MrM

  • byte
  • *
  • Posts: 36
    • View Profile
Re: LiveWallpaper Shader Problem
« Reply #9 on: September 12, 2011, 08:31:56 am »
That was it! I can't thank you enough, I'll post some images later, once I've got it set up, to show you how JPCT-ae looks using GL ES 2.0 with LiveWallpapers.  ;)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: LiveWallpaper Shader Problem
« Reply #10 on: September 12, 2011, 08:48:29 am »
Ok...i'll try to catch this case (gl context provided but ES 2.0 actually wanted) then, as it might be a common problem.

Offline MrM

  • byte
  • *
  • Posts: 36
    • View Profile
Re: LiveWallpaper Shader Problem
« Reply #11 on: September 12, 2011, 09:32:49 am »
Yeah, I can't believe I didn't check before doing anything... Didn't even cross my mind. And I've been trying to do it for DAYS now, tried a lot of different methods. I can't say which libraries actually work, because this one I've created on my own, sort of... It does contain a lot of other people's codes and snippets I've found lying about.

Nevertheless, JPCT works brilliantly, fps is off the mark, loading time is a bit long but that's probably in my code, a lot of sleeps (for testing), and stuff instanced where it shouldn't be.
If I can only find my camera charger to film a bit of it... I haven't found a good sreen capture application or program.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: LiveWallpaper Shader Problem
« Reply #12 on: September 12, 2011, 08:43:23 pm »
I looked into it and i'm asking myself how you were able to initialize ES 2.0 and still create a 1.1 gl context?

Offline MrM

  • byte
  • *
  • Posts: 36
    • View Profile
Re: LiveWallpaper Shader Problem
« Reply #13 on: September 13, 2011, 03:19:15 am »
I'm not very good at explaining so I'll do the best I can:
(By the way, the project I've uploaded above, has been totally rewritten, it's no longer valid)

I guess you could say that I have the Wallpaper Service (in a class different than the renderer) wrapped in a surfaceView.
I guess it's all about adding the ES 2.0 depth bits. Then I spawn the engine with the renderer from your example, and with a previously set ContextFactory, and ConfigChooser, in which you customize the rbga, depth and stencil. There is a config checker too in there somewhere too, which identifies if what you have chosen is valid.
These lines would interest you the most:

Code: [Select]

    private static class ContextFactory implements GLSurfaceView.EGLContextFactory {
    private static int EGL_CONTEXT_CLIENT_VERSION = 0x3098;       //This is where it all starts.
   
    public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
    int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };  //These are from an EGL attribute list I've found. Pretty standard, just called with custom strings so it would make it easier.
    EGLContext context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
   
    return context;
    }
   
    public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) {
    egl.eglDestroyContext(display, context);
    }
    }


protected class WallpaperEngine extends GLEngine {

public WallpaperEngine(Context context, MyRenderer renderer) {
super();

setEGLContextFactory(new ContextFactory());
setEGLConfigChooser(new ConfigChooser(5, 6, 5, 0, 16, 0));

renderer.setEngine(this);
setRenderer(renderer);
setRenderMode(RENDERMODE_CONTINUOUSLY);
}
}

public class MyWallpaper extends Wallpaper {  //This is a class which extends the GLWallpaperService which I've got from Robert Green, and modified it a bit. It only overrides the engine.
private MyRenderer mRenderer;              //It's mostly setters and overrides.

@Override
public Engine onCreateEngine() {
mRenderer = new MyRenderer(this);
return new WallpaperEngine(getBaseContext(), mRenderer);
}
}


This is from the config chooser class, which implements GLSurfaceView.EGLConfigChooser, and actually specifies the ES2.0:
Code: [Select]
        private static int EGL_OPENGL_ES2_BIT = 4;
        private static int[] s_configAttribs2 =
        {
            EGL10.EGL_RED_SIZE, 4,
            EGL10.EGL_GREEN_SIZE, 4,
            EGL10.EGL_BLUE_SIZE, 4,
            EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
            EGL10.EGL_NONE
        };

I've added comments to simplify. The device is Samsung Galaxy Mini with 2.2 (FROYO) by the way... All debugging and testing were done on it, I don't trust the Emulator when working with GL stuff.
Getters and Setters for the engine and surfaceView should be made in the Renderer class accordingly, if you'd like to use preferences for Activity.

I'm not sure if I've been very clear, but as I said, I'm not very good at explaining. Take a look at:
http://www.rbgrn.net/content/354-glsurfaceview-adapted-3d-live-wallpapers

Anyways, here's the video:
http://www.youtube.com/watch?v=BBx8yftg_bk
Sorry about the blank side on the Primitive, this is only a test.
And yes, one of my accounts is Nitrus015, I've been asking you about the Parallax mapping on your video, while I was still doing research on GL for android  ;D

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: LiveWallpaper Shader Problem
« Reply #14 on: September 13, 2011, 07:56:12 pm »
Well, that's no exactly what i meant... i don't get how you managed to create a FrameBuffer with a GL10 implementation. Where does it come from? GL10 is an interface for GL1.0. You can't implement it with GL 2.0 (well...you can. I'm doing it internally, but anyway....). On Android, you either have an implementation of GL10/GL11, which means that you are using a GL1.0/1.1 context or you have a GL2.0 context but then, you don't have any implementation of the GL10 interface. I'm just asking because i'm unsure what to check for to detect this case.