It's a little bit more complicated, you are not catching all possible cases
(for instance when the surface is resized.) You should look at the how we
did it for the standard live wallpapers:

http://android.git.kernel.org/?p=platform/packages/wallpapers/Basic.git;a=blob;f=src/com/android/wallpaper/RenderScriptWallpaper.java;h=5d6a497c4c774003d9285e216378df10bacac897;hb=refs/heads/gingerbread-release

On Mon, Aug 22, 2011 at 12:12 AM, newbyca <newb...@gmail.com> wrote:

> for those interested, i came up with the following and it seems to
> work.
> for those that know way more about this than me, it'd be great to know
> if there's a better way or if i'm doing anything truly awful :)
>
> tia//
>
> ------------------------------------------------------------
> class WallpaperServiceHelper extends WallpaperService{
>
>        @Override
>        public final Engine onCreateEngine(){
>                return new WallpaperEngineHelper(getApplicationContext());
>        }
>
>        protected class WallpaperEngineHelper extends Engine{
>
>            private Context mContext;
>            private RenderScriptGL mRs;
>            private MyRenderRs mRender;
>
>            public WallpaperEngineHelper(Context c){
>                super();
>                mContext = c;
>            }
>
>            @Override
>            public void onSurfaceChanged(SurfaceHolder holder, int format,
> int w, int h) {
>                super.onSurfaceChanged(holder, format, w, h);
>                if(mRs == null){
>                        RenderScriptGL.SurfaceConfig sc = new
> RenderScriptGL.SurfaceConfig();
>                        mRs = new RenderScriptGL(mContext, sc);
>                        mRs.setSurface(holder, w, h);
>                        mRender = new MyRenderRs();
>                        mRender.init(mRs, w, h);
>                }
>            }
>
>            @Override
>            public void onSurfaceDestroyed(SurfaceHolder holder) {
>                super.onSurfaceDestroyed(holder);
>                if(mRs != null){
>                        mRs.destroy();
>                }
>            }
>
>        }
>
> }
> ------------------------------------------------------------
>
>
>
>
> On Aug 22, 2:40 am, newbyca <newb...@gmail.com> wrote:
> > are there any tutorials or source code examples on incorporating
> > RenderScript into a live wallpaper?
> >
> > i've looked quite a bit and can't find anything ... or maybe i missed
> > something obvious?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Romain Guy
Android framework engineer
romain...@android.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to