Project

General

Profile

« Previous | Next » 

Revision 835cd7eb

Added by Leszek Koltunski about 2 years 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 24
import org.distorted.library.effect.PostprocessEffectGlow;
26 25
import org.distorted.library.effect.VertexEffectScale;
27 26
import org.distorted.library.main.DistortedEffects;
......
30 29
import org.distorted.library.main.DistortedScreen;
31 30
import org.distorted.library.main.DistortedTexture;
32 31
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 32
import org.distorted.library.type.Static2D;
37 33
import org.distorted.library.type.Static4D;
38 34

  
......
41 37

  
42 38
///////////////////////////////////////////////////////////////////////////////////////////////////
43 39

  
44
class FlatBlur2Renderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener, EffectListener
40
class FlatBlur2Renderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
45 41
{
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

  
51 42
    private final GLSurfaceView mView;
52 43
    private final DistortedScreen mScreen;
53
    private DistortedNode mNode1, mNode2;
44
    private final DistortedNode mNode;
54 45

  
55 46
///////////////////////////////////////////////////////////////////////////////////////////////////
56 47

  
......
65 56
      DistortedEffects effects1 = new DistortedEffects();
66 57
      VertexEffectScale mainScale= new VertexEffectScale(200);
67 58
      effects1.apply(mainScale);
68
      mNode1 = new DistortedNode(texture1,effects1,mesh1);
69
      mScreen.attach(mNode1);
59
      mNode = new DistortedNode(texture1,effects1,mesh1);
60
      mScreen.attach(mNode);
70 61

  
71 62
      DistortedTexture texture2 = new DistortedTexture();
72 63
      texture2.setColorARGB(0xffff0000);
73 64
      MeshQuad mesh2 = new MeshQuad();
74 65
      DistortedEffects effects2 = new DistortedEffects();
75
      mNode2 = new DistortedNode(texture2,effects2,mesh2);
76
      mScreen.attach(mNode2);
66
      DistortedNode node2 = new DistortedNode(texture2,effects2,mesh2);
67
      mScreen.attach(node2);
77 68
      }
78 69

  
79 70
///////////////////////////////////////////////////////////////////////////////////////////////////
......
110 101

  
111 102
    public void crash()
112 103
      {
113
      Dynamic2D haloRadius = new Dynamic2D(DUR_GLO,1.0f);
114
      haloRadius.add(new Static2D( 0, 0));
115
      haloRadius.add(new Static2D(15,50));
116
      haloRadius.add(new Static2D( 0, 0));
117

  
118
      Dynamic4D color= new Dynamic4D(DUR_GLO,1.0f);
119
      Static4D P1    = new Static4D(colors[3*INDEX],colors[3*INDEX+1], colors[3*INDEX+2], 0.0f);
120
      Static4D P2    = new Static4D(colors[3*INDEX],colors[3*INDEX+1], colors[3*INDEX+2], 0.5f);
121
      color.add(P1);
122
      color.add(P2);
123
      color.add(P1);
124

  
104
      Static2D haloRadius = new Static2D(15,50);
105
      Static4D color      = new Static4D(1,1,1,1);
125 106
      PostprocessEffectGlow glow = new PostprocessEffectGlow(haloRadius,color);
126
      glow.setQuality(EffectQuality.MEDIUM);
127
      glow.notifyWhenFinished(this);
128
      DistortedEffects effects = mNode1.getEffects();
107
      DistortedEffects effects = mNode.getEffects();
129 108
      effects.apply(glow);
130 109
      }
131

  
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133

  
134
   public void effectFinished(long id)
135
      {
136
      mScreen.detach(mNode1);
137
      mNode1.markForDeletion();
138
      mNode1=null;
139
      mScreen.detach(mNode2);
140
      mNode2.markForDeletion();
141
      mNode2=null;
142
      }
143 110
}

Also available in: Unified diff