android - Clear screen with transparency in libgdx to draw a particle trail -


I am working on an Android app, I am using libgdx, and I use some types of wind particles I am trying to attract that which is behind, something like this:

I have been able to attract the particles, which are the lines that connect the previous state to the latest. However, if I clean the screen every time, it will only attract the current situation, which will be similar to expected small points.

I want to draw a mark behind those particles, which are far away, I tried to make a list of past particle positions and try to paint them with decreasing alpha. But many particles have to be attracted and it proved to be very slow. So I searched, and there is another way to achieve this, which is clearing the screen with some transparency, while I pull new particles. My solution is now using it: And when my desktop rendering works as expected, it has a dark background from white particles in Android which I can not understand. How can I solve it?

Code:

  Pixmap ScreenclairPixSmap = New Pixmap (480), 548, format. RGBA 8888); Screen Clear Paxmap. Setting (Color. Rgba8888 (0f, 0f, 0f, 0.1f)); ScreenClearPixmap.fill (); Screen-cleartexture = new texture (screen-clearPixmap); Screen clearpritata = new sprite (screen cutlet); Screen cleaner; light; set size (480, 548); screenClearPixmap.dispose (); Public Zero Render () {batch.begin (); screenClearSprite.draw (batch); Batch.end (); Chetan (); } Public Void Animate () {moveParticles (); DrawParticles (); } Public Zero Draw () {shapeRenderer.begin (ShapeType.Line); ShapeRenderer.setColor (Color.WHITE); ... Rangaroundline (particle.getOldX) (), (float) particle.getOldX (), particle.getOldY (), (float) particle.getX (), (float) particle.getY ()); Gdx.gl20.glLineWidth (Global.LINEWIDTH); ShapeRenderer.end (); }  "post-text" itemprop = "text"> 

I know that it has been late for many years, but as it works well for me, I am hoping that It helps anyone.

I have noticed that most Android devices (except emulators) need to call you Gdx.gl.glClear (GL20.GL_COLOR_BUFFER_BIT) or you get some strange results You can do this by allowing you to clear the screen, but still get trail effects to work your drawing in the frame buffer object (FBO), which is not cleared by glitchier, and then FBO on the screen Areas are.

Code> Spritebatch batch;

  • GetHeight (), false); Batch = new spritebatch ();

  • In the render (): Gdx.gl.glClearColor (0, 0, 0, 1); Gdx.gl.glClear (GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glEnable (GL20.GL_BLEND); Gdx.gl.glBlendFunc (GL20.GL_SRC_ALPHA, GL 20.GL_ONE_MINUS_SRC_ALPHA); fbo.begin (); // It should be said before the size of your drawing code Resenderer.begin (); ShapeRenderer.setColor (0, 0, 0, 0.2f); // You can change the length of the mark by changing the alpha shape. (0, 0, screenwidth, screenhit); // Make a translucent rectangle to FBo. ... your drawing code goes here ... sizeRenderer (); Fbo.end (); // Make sure it is called Resenderer.end () after resizing or resender.flush (); Batch.begin (); Batch Draw (fbo.getColorBufferTexture (), 0, 0); // FOO Batch.and Draw (Draw); Gdx.gl.glDisable (GL20.GL_BLEND);

  • Remember to call fbo.dispose () in your application's settlement () method;

  • Comments

    Popular posts from this blog

    Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

    multithreading - PhantomJS-Node in a for Loop -

    c++ - MATLAB .m file to .mex file using Matlab Compiler -