Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ripple effect does not work with live wallpaper #659

Closed
winigma opened this issue May 3, 2013 · 58 comments
Closed

Ripple effect does not work with live wallpaper #659

winigma opened this issue May 3, 2013 · 58 comments
Labels

Comments

@winigma
Copy link

winigma commented May 3, 2013

I saw a doubt like what I have, but did not see the solution ...

I'm creating my live wallpaper based on the template. but the effect does not work in normal activity was as follows:

public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setGLBackgroundTransparent (true);
mRenderer RajawaliRipplesRenderer = new (this);
mRenderer.setSurfaceView (mSurfaceView);
super.setRenderer (mRenderer);

mSurfaceView.setOnTouchListener (this);

Display display = getWindowManager (). GetDefaultDisplay ();
mScreenSize = new Point ();
mScreenSize.x display.getWidth = ();
mScreenSize.y display.getHeight = ();

LinearLayout ll = new LinearLayout (this);
ll.setOrientation (LinearLayout.VERTICAL);
ll.setGravity (Gravity.BOTTOM);

TextView tv = new TextView (this);
tv.setText ("Touch Me");
tv.setTextColor (Color.BLACK);
ll.addView (tv);

initLoader ();
}

and livewallpaoer have this:

onCreateEngine public Engine () {
mRenderer RajawaliRipplesRenderer = new (this);

return new WallpaperEngine (this.getSharedPreferences (SHARED_PREFS_NAME,
Context.MODE_PRIVATE) getBaseContext (), mRenderer, false);
}
@winigma
Copy link
Author

winigma commented May 3, 2013

not have this option in Walpaper class:

mRenderer.setSurfaceView (mSurfaceView);
super.setRenderer (mRenderer);

@jwoolston
Copy link
Member

not have this option in Walpaper class:

mRenderer.setSurfaceView (mSurfaceView);
super.setRenderer (mRenderer);

I'm not sure what this means. Can you please explain more?

@AndrewJo
Copy link
Member

AndrewJo commented May 3, 2013

I'm sorry but I'm having a hard time understanding what your question is. Please read the guidelines for submitting issues.

@winigma
Copy link
Author

winigma commented May 3, 2013

I will explain better to inherit the class Wallpaper blilioteca Rajawali, I can not run the animation the same way as in the activity, understand?

in the activity RajawaliRipplesActivity, have methods:
mRenderer.setSurfaceView (mSurfaceView);
super.setRenderer (mRenderer);

mSurfaceView.setOnTouchListener (this);

@jwoolston
Copy link
Member

@winigma @Davhed asked previously but we never got an answer...what is your native language? Maybe someone here can help you natively.

@winigma
Copy link
Author

winigma commented May 3, 2013

my language is portuguese

@winigma
Copy link
Author

winigma commented May 3, 2013

ripple not work in livewallpaper?

@winigma
Copy link
Author

winigma commented May 3, 2013

I mean, the class inheriting wallpaper native library?

@jwoolston
Copy link
Member

It can work. The constructor for WallpaperEngine takes a RajawaliRenderer instance. It looks like you are passing one but your java code is a bit jumbled above. Did you look at the sample wallpaper project?

@jwoolston
Copy link
Member

@winigma
Copy link
Author

winigma commented May 3, 2013

yes i see,

I'm running it now and follow it to build my own, but I can not call the methods as:
mRenderer.setSurfaceView (mSurfaceView);
super.setRenderer (mRenderer);

mSurfaceView.setOnTouchListener (this);

@winigma
Copy link
Author

winigma commented May 3, 2013

render the image, but I can not simulate screen taps

@jwoolston
Copy link
Member

Are you receiving touch events? Have you registered to receive them? Are you certain you are handling them correctly?

@winigma
Copy link
Author

winigma commented May 3, 2013

I did the same as in normal activity, the renderer is the same, only modified the activity, which is now a service for wallpaper

@jwoolston
Copy link
Member

So what view are you registered to receive touch events for?

@winigma
Copy link
Author

winigma commented May 3, 2013

My Service:

public class ServiceWallpaper extends Wallpaper implements OnTouchListener {
    private RajawaliRipplesRenderer mRenderer;
    private Point mScreenSize;


    @Override
    public Engine onCreateEngine() {
        mRenderer = new RajawaliRipplesRenderer(this);


        return new WallpaperEngine(this.getSharedPreferences(SHARED_PREFS_NAME,
                Context.MODE_PRIVATE), getBaseContext(), mRenderer, false);
    }

    public boolean onTouch(View v, MotionEvent event) {

        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            Log.i("toqueX", event.getX() + "Y = " + event.getY());

            mRenderer.setTouch(event.getX() / mScreenSize.x,
                    1.f - (event.getY() / mScreenSize.y));
            return true;
        }
        if (event.getAction() == MotionEvent.ACTION_MOVE) {
            Log.i("toqueX", event.getX() + "Y = " + event.getY());

            mRenderer.setTouch(event.getX(), event.getY());

        }
        int action = MotionEventCompat.getActionMasked(event);
        return true;

        // return super.onTouchEvent(event);
    }

}

@winigma
Copy link
Author

winigma commented May 3, 2013

My Renderer:

public class RipplesRenderer extends RajawaliRenderer {
    private final int NUM_CUBES_H = 2;
    private final int NUM_CUBES_V = 2;
    private final int NUM_CUBES = NUM_CUBES_H * NUM_CUBES_V;
    private Animation3D[] mAnims;
    private TouchRippleFilter mFilter;
    private long frameCount;
    private final int QUAD_SEGMENTS = 10;

    public RipplesRenderer(Context context) {
        super(context);
        // MUDEI AKI PADRao e 60
        setFrameRate(10);
    }

    protected void initScene() {
        mAnims = new Animation3D[NUM_CUBES];

        mCamera.setPosition(0, 0, 5);

        DirectionalLight light = new DirectionalLight(0, 0, 1);
        light.setPower(1f);

        BaseObject3D group = new BaseObject3D();
        DiffuseMaterial material = new DiffuseMaterial();
        material.setUseColor(true);

        Random rnd = new Random();

        for (int y = 0; y < NUM_CUBES_V; ++y) {
            for (int x = 0; x < NUM_CUBES_H; ++x) {
                Cube cube = new Cube(.7f);
                cube.setPosition(x * 2, y * 2, 50);
                cube.addLight(light);
                cube.setMaterial(material);
                cube.setColor((int) (0xffffff * rnd.nextFloat()));
                group.addChild(cube);
                Number3D axis = new Number3D(rnd.nextFloat(), rnd.nextFloat(),
                        rnd.nextFloat());
                // mudei aki padrao 360
                Animation3D anim = new RotateAnimation3D(axis, 360, 360);
                anim.setRepeatMode(RepeatMode.RESTART);
                // mudei aki padrao 8000
                anim.setDuration(800);
                anim.setTransformable3D(cube);

                int index = x + (NUM_CUBES_H * y);
                mAnims[index] = anim;
            }
        }

        group.setX(((NUM_CUBES_H - 1) * 8) * -.1f);
        group.setY(((NUM_CUBES_V - 1) * 8) * -.1f);
        group.setZ(-1f);

        addChild(group);

        SimpleMaterial planeMat = new SimpleMaterial();
        // mudei aki padrao era streech
        Bitmap texture = BitmapFactory.decodeResource(mContext.getResources(),
                R.drawable.fundo);
        planeMat.addTexture(mTextureManager.addTexture(texture));
        Plane plane = new Plane(3, 1, 4, 4);
        plane.setRotZ(-90);
        plane.setScale(3.7f);
        plane.setMaterial(planeMat);
        addChild(plane);

        mFilter = new TouchRippleFilter();

        // mudei padrao 62
        mFilter.setRippleSize(50);
        mFilter.setRippleSpeed(5);
        mFilter.setTime(0);
        mFilter.setDuration(1);

        mPostProcessingRenderer.setQuadSegments(QUAD_SEGMENTS);
        mPostProcessingRenderer.setQuality(PostProcessingQuality.HIGH);
        addPostProcessingFilter(mFilter);
    }

    public void onSurfaceCreated(GL10 gl, EGLConfig config) {

        //((RajawaliExampleActivity) mContext).showLoader();
        super.onSurfaceCreated(gl, config);

        for (int i = 0; i < NUM_CUBES; ++i) {

            registerAnimation(mAnims[i]);

            mAnims[i].play();
        }
        mFilter.setScreenSize(mViewportWidth, mViewportHeight);
    //  ((RajawaliExampleActivity) mContext).hideLoader();
    }

    public void onDrawFrame(GL10 glUnused) {
        super.onDrawFrame(glUnused);

        mFilter.setTime((float) frameCount++ * .05f);
    }

    public void onSurfaceChanged(GL10 gl, int width, int height) {
        gl.glAlphaFunc(10, 10);
        gl.glBlendFunc(100, 100);
        super.onSurfaceChanged(gl, width, height);
        mFilter.setScreenSize(width, height);
    }

    public void setTouch(float x, float y) {
        mAnims = new Animation3D[NUM_CUBES];

        mFilter.addTouch(x, y, frameCount * .05f);
    }
}

@winigma
Copy link
Author

winigma commented May 3, 2013

mRenderer = RipplesRenderer();

@jwoolston
Copy link
Member

Yeah, you aren't registered to receive a touch event, thats why you aren't receiving touch events. Also, please read the GitHub markdown tutorial to see how to format your code samples. HTML tagging doesn't work.

@winigma
Copy link
Author

winigma commented May 3, 2013

but, this mSurfaceView.setOnTouchListener(this); is not available, it is only available for activities

@AndrewJo
Copy link
Member

AndrewJo commented May 3, 2013

You need to inherit the WallpaperEngine class and override the onTouchEvent.

@winigma
Copy link
Author

winigma commented May 3, 2013

and Class Rajawali Wallpaper not implement wallpaperEngine?

@jwoolston
Copy link
Member

WallpaperEngine is an instance returned from Wallpaper. In your ServiceWallpaper class you need to have onCreateEngine() return your specific implimentation, by subclassing WallpaperEngine and in that subclass override onTouchEvent()

@winigma
Copy link
Author

winigma commented May 3, 2013

you post link for format code in github???

@jwoolston
Copy link
Member

@winigma
Copy link
Author

winigma commented May 3, 2013

My solution was not permanent, is faulty, but is running, sometimes hangs while giving many screen taps.

public class ServiceWallpaper extends Wallpaper {
private RipplesRenderer mRipplesRenderer;
private Point mScreenSize;

@Override
public Engine onCreateEngine() {
    mRipplesRenderer = new RipplesRenderer(this);

    return new SimpleWaterEngine(this.getSharedPreferences(
            SHARED_PREFS_NAME, Context.MODE_PRIVATE), getBaseContext(),
            mRipplesRenderer, false);
}

public class SimpleWaterEngine extends WallpaperEngine {

    public SimpleWaterEngine(SharedPreferences preferences,
            Context context, RajawaliRenderer renderer,
            boolean useMultisampling) {
        super(preferences, context, renderer, useMultisampling);

        WindowManager mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
        Display display = mWindowManager.getDefaultDisplay();
        mScreenSize = new Point();
        mScreenSize.x = display.getWidth();
        mScreenSize.y = display.getHeight();
    }

    @Override
    public void onTouchEvent(MotionEvent event) {

        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            Log.i("toqueX", event.getX() + "Y = " + event.getY());

            mRipplesRenderer.setTouch(event.getX() / mScreenSize.x,
                    1.f - (event.getY() / mScreenSize.y));
        }
        if (event.getAction() == MotionEvent.ACTION_MOVE) {
            Log.i("toqueX", event.getX() + "Y = " + event.getY());

            mRipplesRenderer.setTouch(event.getX(), event.getY());

        }
    }

}

}

@jwoolston
Copy link
Member

So it seems like the issue is resolved. Hanging from too many taps is to be expected...devices can only process data so fast.

@winigma
Copy link
Author

winigma commented May 3, 2013

rajawali does not work with samsung galaxy tab 2??? wallpaper error: Called unimplemented OpenGL ES API?

@MasDennis
Copy link
Member

can you paste the complete stack trace here????????????????????

@winigma
Copy link
Author

winigma commented May 3, 2013

05-03 16:07:22.997: E/libEGL(14432): called unimplemented OpenGL ES API
05-03 16:07:22.997: E/libEGL(14432): called unimplemented OpenGL ES API

@MasDennis
Copy link
Member

@winigma Você poderia por favor ser mais descritivo quando você faz perguntas? Ele vai tornar as coisas muito mais fácil. Obrigado.

@winigma
Copy link
Author

winigma commented May 3, 2013

was only that, and not performed, no other Feedback

@winigma
Copy link
Author

winigma commented May 3, 2013

now this:
05-03 16:19:01.880: E/AndroidRuntime(14432): FATAL EXCEPTION: GLThread 1848
05-03 16:19:01.880: E/AndroidRuntime(14432): java.lang.NullPointerException
05-03 16:19:01.880: E/AndroidRuntime(14432): at com.monyetmabuk.rajawali.tutorials.RajawaliRipplesRenderer.onSurfaceCreated(RajawaliRipplesRenderer.java:115)
05-03 16:19:01.880: E/AndroidRuntime(14432): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1446)
05-03 16:19:01.880: E/AndroidRuntime(14432): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216)

@MasDennis
Copy link
Member

Have you installed the RajawaliExamples app? Does it run without problems? Or does it crash as well?

@winigma
Copy link
Author

winigma commented May 3, 2013

there in Rajawali Examples

@winigma
Copy link
Author

winigma commented May 3, 2013

in my wallpaper this:
05-03 16:20:54.990: E/libEGL(14736): called unimplemented OpenGL ES API

@MasDennis
Copy link
Member

Do you mean that RajawaliExamples crashes as well? Or does it run fine?

@winigma
Copy link
Author

winigma commented May 3, 2013

but in galaxy s3 gran duos and works perfectly

@winigma
Copy link
Author

winigma commented May 3, 2013

Do you mean that RajawaliExamples crashes as well? Or does it run fine?

In ripple effeect not

@MasDennis
Copy link
Member

But do the other examples run fine? Or do they all crash?

@winigma
Copy link
Author

winigma commented May 3, 2013

you test in tablets?

@jwoolston
Copy link
Member

you test in tablets?

Yes. We have quite a few devices that it is tested on to fully encompass the range of possibilities.

@MasDennis
Copy link
Member

But do the other examples run fine? Or do they all crash?

Mas os outros exemplos correr bem? Ou todos eles acidente?

@winigma
Copy link
Author

winigma commented May 3, 2013

only in 2000 textures and the ripple effect, others are fine

@jwoolston
Copy link
Member

What is the last commit message for Rajawali and Rajawali Examples that you have?

Qual é a última mensagem de commit para Rajawali e Rajawali exemplos que você tem?

@winigma
Copy link
Author

winigma commented May 3, 2013

last version...

@jwoolston
Copy link
Member

Are you certain? It has been under heavy development with near daily changes over the last week.

@winigma
Copy link
Author

winigma commented May 3, 2013

my version is 3 days ago

@jwoolston
Copy link
Member

I submitted 21422d8 yesterday which fixed the 2000 planes example.

@jwoolston
Copy link
Member

you need to update your repository

@winigma
Copy link
Author

winigma commented May 3, 2013

and rippples effects?

@MasDennis
Copy link
Member

Did you try it after updating it?

@jwoolston
Copy link
Member

Please read the cloning instructions. In your case I recommend using the tags as master is under HEAVY development and should not be considered bug free. That said, unless your support request involves the code in the TAG or is notifying us of a bug, we are not going to put much effort into it since the development is fluid. In the case of post processing effects, they are being removed in favor of something else on the master branch so we will no be supporting them.

@winigma
Copy link
Author

winigma commented May 3, 2013

but you know know if some devices have openGL version mismatch eat the Rajawali?

@winigma
Copy link
Author

winigma commented May 3, 2013

I followed these steps, as I said, the galaxy s3 works, but the galaxy tab does not work.

@jwoolston
Copy link
Member

If a device claims OpenGL 2.0 support, Rajawali supports it. Device specific bugs are to be expected though as you are dealing with a very low level interface. We do our best to eliminate them but particularly with Samsung devices, it is a constant battle we can never win so some acceptance of this situation must be present. You should not look at 3D graphics as being a one solution fits all problem.

@winigma
Copy link
Author

winigma commented May 3, 2013

ok, undesteand, I thought it might be my problem to implement the code

@jwoolston
Copy link
Member

ok, undesteand, I thought it might be my problem to implement the code

I apologize for any difficulty we have with the language barrier, we are doing our best. For future questions, following the GitHub markdown for code and stack traces and providing complete stack traces and error messages, as well as more complete code, or at least context for the code will help us understand the problem much more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants