Project

General

Profile

« Previous | Next » 

Revision 4b7152b6

Added by Leszek Koltunski over 1 year ago

simplify the crash app.

View differences:

src/main/java/org/distorted/examples/flatblur2/FlatBlur2Renderer.java
21 21

  
22 22
import android.opengl.GLSurfaceView;
23 23

  
24
import org.distorted.library.effect.EffectQuality;
25
import org.distorted.library.effect.PostprocessEffectGlow;
26
import org.distorted.library.effect.VertexEffectScale;
27
import org.distorted.library.main.DistortedEffects;
24 28
import org.distorted.library.main.DistortedLibrary;
29
import org.distorted.library.main.DistortedNode;
25 30
import org.distorted.library.main.DistortedScreen;
31
import org.distorted.library.main.DistortedTexture;
32
import org.distorted.library.mesh.MeshQuad;
33
import org.distorted.library.message.EffectListener;
34
import org.distorted.library.type.Dynamic2D;
35
import org.distorted.library.type.Dynamic4D;
36
import org.distorted.library.type.Static2D;
37
import org.distorted.library.type.Static4D;
26 38

  
27 39
import javax.microedition.khronos.egl.EGLConfig;
28 40
import javax.microedition.khronos.opengles.GL10;
29 41

  
30 42
///////////////////////////////////////////////////////////////////////////////////////////////////
31 43

  
32
class FlatBlur2Renderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
44
class FlatBlur2Renderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener, EffectListener
33 45
{
46
    private static final int DUR_GLO =  2000;
47

  
48
    private static final int[] colors = new int[] {0,0,1,  1,0,1,  1,0,0,  1,1,0,  0,1,0,  1,1,1}; // blue, pink, red, yellow, green, white
49
    private static final int INDEX = 5;
50

  
34 51
    private final GLSurfaceView mView;
35 52
    private final DistortedScreen mScreen;
36
    private OverlayStars mStars;
53

  
54
    private DistortedNode mNode1, mNode2;
55
    private long mGlowID;
37 56

  
38 57
///////////////////////////////////////////////////////////////////////////////////////////////////
39 58

  
......
61 80
    
62 81
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
63 82
      {
64
      OverlayStars.enableEffects();
83
      VertexEffectScale.enable();
84
      PostprocessEffectGlow.enable();
65 85
      DistortedLibrary.onSurfaceCreated( mView.getContext(), this);
66 86
      }
67 87

  
......
76 96

  
77 97
    public void button1()
78 98
      {
79
      mStars = new OverlayStars();
80
      mStars.startOverlay(mScreen);
99
      DistortedTexture texture1 = new DistortedTexture();
100
      texture1.setColorARGB(0xffff0000);
101
      MeshQuad mesh1 = new MeshQuad();
102
      DistortedEffects effects1 = new DistortedEffects();
103
      VertexEffectScale mainScale= new VertexEffectScale(200);
104
      effects1.apply(mainScale);
105
      mNode1 = new DistortedNode(texture1,effects1,mesh1);
106
      mScreen.attach(mNode1);
107

  
108
      DistortedTexture texture2 = new DistortedTexture();
109
      texture2.setColorARGB(0xffff0000);
110
      MeshQuad mesh2 = new MeshQuad();
111
      DistortedEffects effects2 = new DistortedEffects();
112
      mNode2 = new DistortedNode(texture2,effects2,mesh2);
113
      mScreen.attach(mNode2);
81 114
      }
82 115

  
83 116
///////////////////////////////////////////////////////////////////////////////////////////////////
84 117

  
85 118
    public void button2()
86 119
      {
87
      if( mStars!=null )
88
        {
89
        mStars.button2();
90
        }
120
      Dynamic2D haloRadius = new Dynamic2D(DUR_GLO,1.0f);
121
      haloRadius.add(new Static2D( 0, 0));
122
      haloRadius.add(new Static2D(15,50));
123
      haloRadius.add(new Static2D( 0, 0));
124

  
125
      Dynamic4D color= new Dynamic4D(DUR_GLO,1.0f);
126
      Static4D P1    = new Static4D(colors[3*INDEX],colors[3*INDEX+1], colors[3*INDEX+2], 0.0f);
127
      Static4D P2    = new Static4D(colors[3*INDEX],colors[3*INDEX+1], colors[3*INDEX+2], 0.5f);
128
      color.add(P1);
129
      color.add(P2);
130
      color.add(P1);
131

  
132
      PostprocessEffectGlow glow = new PostprocessEffectGlow(haloRadius,color);
133
      glow.setQuality(EffectQuality.MEDIUM);
134
      mGlowID = glow.getID();
135
      glow.notifyWhenFinished(this);
136
      DistortedEffects effects = mNode1.getEffects();
137
      effects.apply(glow);
138
      }
139

  
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141

  
142
   public void effectFinished(long id)
143
      {
144
      if( id==mGlowID )
145
         {
146
         mScreen.detach(mNode1);
147
         mNode1.markForDeletion();
148
         mNode1=null;
149
         mScreen.detach(mNode2);
150
         mNode2.markForDeletion();
151
         mNode2=null;
152
         }
91 153
      }
92 154
}

Also available in: Unified diff