Author Topic: jPCT and Android LiveWallpaper  (Read 1714 times)

Offline Andrey8000

  • byte
  • *
  • Posts: 13
    • View Profile
jPCT and Android LiveWallpaper
« on: April 16, 2013, 04:56:08 pm »
Hi all, I like jPCT, but now I was faced with how to make live wallpaper using jPCT?  For example, I tried to combine the example of Robert Green and the standard example of a working code android, jPCT and so far I do not have enough understanding of the problem. For example now I get an error nullpointer in the method  onSurfaceCreated() (class myEngine extends GLEngine)... Can anyone share the sample code of jpct livewallpaper? p.s. Sorry by my english.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: jPCT and Android LiveWallpaper
« Reply #1 on: April 16, 2013, 10:49:51 pm »
Maybe you can post the exception and the code that causes it!?

Offline Andrey8000

  • byte
  • *
  • Posts: 13
    • View Profile
Re: jPCT and Android LiveWallpaper
« Reply #2 on: April 17, 2013, 12:50:41 pm »
Ok, I learned how to do it. I took this solution http://www.rbgrn.net/content/354-glsurfaceview-adapted-3d-live-wallpapers  and combined it with jPCT-ae code, replacing the "renderer" and some small details.
p.s. Thank you for jPCT-ae
« Last Edit: April 17, 2013, 12:52:13 pm by Andrey8000 »

Offline Andrey8000

  • byte
  • *
  • Posts: 13
    • View Profile
Re: jPCT and Android LiveWallpaper
« Reply #3 on: April 27, 2013, 07:05:15 am »
Hi. I have a new question.
When the live Wallpapers have 2 copies of the renderer (for example the one on the desktop, and the second - in the menu select the Wallpaper), then there is a little bug, as if to shake and at the moment shows a scene from the other instance Wallpaper (other positions 3D objects).
I tried to do renderer a static class, but in this case, when you try to create the 2nd copy is that it turns out incorrect, with the curves of objects and without textures.
I tried to do engine a static class - but it is not good too.
Does anyone else have thoughts on this? Or can code examples?

Offline Andrey8000

  • byte
  • *
  • Posts: 13
    • View Profile
Re: jPCT and Android LiveWallpaper
« Reply #4 on: April 27, 2013, 07:59:24 am »
And one more question. On the emulator, I get this error when I install after watching the live wallpaper on the screen. What could this mean?

04-27 05:55:35.044: E/SurfaceTextureClient(724): queueBuffer: error queuing buffer to SurfaceTexture, -19
04-27 05:55:35.064: E/EGL_emulation(724): tid 824: swapBuffers(322): error 0x3003 (EGL_BAD_ALLOC)
04-27 05:55:35.144: A/libc(724): Fatal signal 11 (SIGSEGV) at 0x0000003c (code=1), thread 824 (Thread-96)
04-27 05:55:43.134: E/Trace(829): error opening trace file: No such file or directory (2)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: jPCT and Android LiveWallpaper
« Reply #5 on: April 27, 2013, 08:45:30 pm »
To be honest, i'm not sure what you are talking about. What exactly is a 'renderer' in this case? Have you tried to synchronize you renderers....whatever they are...!?

Offline Andrey8000

  • byte
  • *
  • Posts: 13
    • View Profile
Re: jPCT and Android LiveWallpaper
« Reply #6 on: April 28, 2013, 10:14:50 am »
renderer is:

...
public class WallpaperService extends GLWallpaperService {
...
...
   public void onCreate(){
      Log.d(LOGTAG, "Load textures here");
      myTex mTex = new myTex(getResources());
   }
...
...
   public Engine onCreateEngine() {
      MyEngine engine = new MyEngine();
      return engine;
   }

class MyEngine extends GLEngine  {
      
      MyRenderer renderer;

      public MyEngine() {
         super();
         renderer = new MyRenderer();
         setRenderer(renderer);
      }
...
...

and:

class MyRenderer implements GLSurfaceView.Renderer {
       
       private FrameBuffer fb = null;
       private RGBColor back = new RGBColor(0, 0, 0);
      
      public MyRenderer() {
         Log.d(LOGTAG,"Create scene here");
         createWorld();
      }
      
      public void onSurfaceChanged(GL10 gl, int w, int h) {
         Log.d(LOGTAG,"SurfaseChanged()");
         if (fb != null) {
            fb.dispose();
         }
         fb = new FrameBuffer( gl, w, h);
                       //  no need to rebuild world, it cost a lot of time
      }
...
...

How i understand Wallpaper Service is designed so that if the wallpaper is already installed - then we get new renderer in preview (for example, when we want to change the settings)... and some bugs

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: jPCT and Android LiveWallpaper
« Reply #7 on: April 28, 2013, 05:36:42 pm »
I think we had this issue before. Somehow, both wallpapers are running in parallel. The solution should be somewhere in the forum, but i can't really search for it, because i'm on a very slow mobile connection for this week.

Offline Andrey8000

  • byte
  • *
  • Posts: 13
    • View Profile
Re: jPCT and Android LiveWallpaper
« Reply #8 on: April 29, 2013, 08:24:09 am »
A little more about the problem: the bug looks like a short-term (may be 1-2 frames) collapsing objects, short-term movement of objects in other places and back, short-term change in the scale of objects.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: jPCT and Android LiveWallpaper
« Reply #9 on: April 29, 2013, 12:23:49 pm »
As said: There should be a thread dealing with this problem. IIRC, the solution was to not let the preview renderer render anything as long as the normal one hasn't really stopped.