Project

General

Profile

« Previous | Next » 

Revision fd0f1dd8

Added by Leszek Koltunski almost 2 years ago

Stars: introductory dialog explaining the concept of stars.

View differences:

src/main/java/org/distorted/examples/flatblur2/FlatBlur2Renderer.java
20 20
package org.distorted.examples.flatblur2;
21 21

  
22 22
import android.content.res.Resources;
23
import android.graphics.Bitmap;
24
import android.graphics.BitmapFactory;
23 25
import android.opengl.GLSurfaceView;
24 26

  
27
import org.distorted.examples.R;
25 28
import org.distorted.library.effect.EffectQuality;
26 29
import org.distorted.library.effect.EffectType;
30
import org.distorted.library.effect.MatrixEffectMove;
27 31
import org.distorted.library.effect.MatrixEffectRotate;
28 32
import org.distorted.library.effect.MatrixEffectScale;
29 33
import org.distorted.library.effect.PostprocessEffectGlow;
......
43 47
import org.distorted.library.type.Static3D;
44 48
import org.distorted.library.type.Static4D;
45 49

  
50
import java.io.IOException;
51
import java.io.InputStream;
52

  
46 53
import javax.microedition.khronos.egl.EGLConfig;
47 54
import javax.microedition.khronos.opengles.GL10;
48 55

  
......
52 59
{
53 60
    private final GLSurfaceView mView;
54 61
    private final DistortedScreen mScreen;
55
    private Static3D mScale1, mScale2;
62
    private Static3D mScale1, mScale2, mMove;
56 63
    private DistortedNode mNode;
64
    private float mHeight;
57 65

  
58 66
///////////////////////////////////////////////////////////////////////////////////////////////////
59 67

  
......
74 82

  
75 83
    public void onSurfaceChanged(GL10 glUnused, int width, int height)
76 84
      {
85
      mHeight = height;
77 86
      float s = width*0.05f;
78 87
      mScale1.set(width,width,0);
79 88
      mScale2.set(s,s,s);
......
112 121
      DistortedNode node2 = new DistortedNode(surface2,effects2,mesh2);
113 122
      mNode.attach(node2);
114 123

  
124
      InputStream is = mView.getContext().getResources().openRawResource(R.raw.leaf);
125
      Bitmap bitmap;
126

  
127
      try
128
        {
129
        bitmap = BitmapFactory.decodeStream(is);
130
        }
131
      finally
132
        {
133
        try
134
          {
135
          is.close();
136
          }
137
        catch(IOException ignored) { }
138
        }
139

  
140
      DistortedTexture tex = new DistortedTexture();
141
      tex.setTexture(bitmap);
142
      DistortedEffects effects = new DistortedEffects();
143
      MeshQuad mesh = new MeshQuad();
144
      DistortedNode leaf = new DistortedNode(tex,effects,mesh);
145
      mScreen.attach(leaf);
146

  
147
      MatrixEffectScale sc = new MatrixEffectScale(new Static3D(50,50,50));
148
      effects.apply(sc);
149
      mMove = new Static3D(0,0,0);
150
      MatrixEffectMove mv = new MatrixEffectMove(mMove);
151
      effects.apply((mv));
152

  
115 153
      OverlayStars.enableEffects();
116 154
      DistortedLibrary.onSurfaceCreated( mView.getContext(), this);
117 155
      }
......
127 165

  
128 166
    public void button1()
129 167
      {
168
      /*
130 169
      OverlayStars stars = new OverlayStars();
131 170
      Resources res = mView.getResources();
132 171
      DataStars data  = new DataStars(10,5,res);
133 172
      stars.startOverlay(mScreen,this,data);
173
       */
174

  
175
      mMove.set(0,mHeight*0.5f,0);
134 176
      }
135 177

  
136 178
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff