Project

General

Profile

« Previous | Next » 

Revision c4f5a8db

Added by Leszek Koltunski about 8 years ago

onPause(): fix StarWars

View differences:

src/main/java/org/distorted/examples/effectqueue/EffectQueueRenderer.java
73 73
    mTexture = new DistortedTexture(texWidth,texHeight);
74 74
    mQueues  = new DistortedEffectQueues();
75 75

  
76
    mQueues.addEventListener(this);
76
    mQueues.registerForMessages(this);
77 77
    }
78 78

  
79 79
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/listener/ListenerRenderer.java
65 65
      Distorted.setMaxVertex(NUM_BUBBLES);   
66 66
      mView = v;
67 67
      mQueues = new DistortedEffectQueues();
68
      mQueues.addEventListener(this);
68
      mQueues.registerForMessages(this);
69 69
      mRnd = new Random(0);
70 70
      }
71 71

  
src/main/java/org/distorted/examples/starwars/StarWarsActivity.java
45 45
  @Override
46 46
  protected void onPause() 
47 47
    {
48
    mView.onPause();  
48
    mView.onPause();
49
    mView.getRenderer().onPause();
49 50
    super.onPause();
50 51
    }
51 52

  
src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java
110 110
  private Random mRnd = new Random(0);
111 111
  private DistortedObjectTree mRoot, mBackground;
112 112
  private GridFlat mQuad;
113
  private int mWidth, mHeight;
113 114

  
114 115
///////////////////////////////////////////////////////////////////////////////////////////////////
115 116

  
......
133 134
    Distorted.setProjection(60.0f, 0.0f, 0.0f);
134 135
    }
135 136

  
137
///////////////////////////////////////////////////////////////////////////////////////////////////
138

  
139
  public void onPause()
140
    {
141
    mWidth = 0;
142
    mHeight= 0;
143
    }
144

  
136 145
///////////////////////////////////////////////////////////////////////////////////////////////////
137 146
   
138 147
  public void onDrawFrame(GL10 glUnused) 
......
145 154
    
146 155
  public void onSurfaceChanged(GL10 glUnused, int width, int height) 
147 156
    {
148
    mScreenQueue.abortAllEffects();
149
    mGFFAQueue.abortAllEffects();
150
    mLogoQueue.abortAllEffects();
151
    mCrawlQueue.abortAllEffects();
152
    mCrawlBackgroundQueue.abortAllEffects();
157
    if( mWidth!=width || mHeight!=height )  // after onPause() we get 2 calls here
158
      {
159
      mWidth = width;
160
      mHeight= height;
153 161

  
154
    for(int i=0; i<NUM_STARS; i++) mStarQueue[i].abortAllEffects();
162
      mScreenQueue.abortAllEffects();
163
      mGFFAQueue.abortAllEffects();
164
      mLogoQueue.abortAllEffects();
165
      mCrawlQueue.abortAllEffects();
166
      mCrawlBackgroundQueue.abortAllEffects();
155 167

  
156
    setupScreen(width,height);
168
      for(int i=0; i<NUM_STARS; i++) mStarQueue[i].abortAllEffects();
157 169

  
158
    Distorted.onSurfaceChanged(width, height);
170
      setupScreen(width,height);
171

  
172
      Distorted.onSurfaceChanged(width, height);
173
      }
159 174
    }
160 175

  
161 176
///////////////////////////////////////////////////////////////////////////////////////////////////
......
228 243
    mGFFAQueue.alpha(di);
229 244
      
230 245
    mRoot.attach(mGFFATexture, mGFFAQueue, mQuad);
231
    mGFFAQueue.addEventListener(this);
246
    mGFFAQueue.registerForMessages(this);
232 247
    }
233 248
    
234 249
///////////////////////////////////////////////////////////////////////////////////////////////////
......
377 392
        mLogoQueue.move( new Static3D(-logoW/2,-logoH/2,0) );
378 393
      
379 394
        mRoot.attach(mLogoTexture,mLogoQueue,mQuad);
380
        mLogoQueue.addEventListener(this);
395
        mLogoQueue.registerForMessages(this);
381 396
        }
382 397
      else if( objectID==logoID )
383 398
        {
......
409 424
        
410 425
        mBackground = mRoot.attach(mCrawlBackgroundTexture,mCrawlBackgroundQueue,mQuad);
411 426
        mBackground.attach(mCrawlTexture,mCrawlQueue,mQuad);
412
        mCrawlQueue.addEventListener(this);
427
        mCrawlQueue.registerForMessages(this);
413 428
        }
414 429
      else if( objectID==crawlID )
415 430
        {
src/main/java/org/distorted/examples/starwars/StarWarsSurfaceView.java
21 21

  
22 22
import android.content.Context;
23 23
import android.opengl.GLSurfaceView;
24
import android.os.Build;
25 24

  
26 25
///////////////////////////////////////////////////////////////////////////////////////////////////
27 26

  
28 27
class StarWarsSurfaceView extends GLSurfaceView 
29 28
  {
29
  private StarWarsRenderer mRenderer;
30

  
30 31
  public StarWarsSurfaceView(Context context) 
31 32
    {
32 33
    super(context);
33 34
    setEGLContextClientVersion(2);
34
    setRenderer(new StarWarsRenderer(this));
35
    mRenderer = new StarWarsRenderer(this);
36
    setRenderer(mRenderer);
37
    }
38

  
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

  
41
  StarWarsRenderer getRenderer()
42
    {
43
    return mRenderer;
35 44
    }
36 45
  }
37 46

  

Also available in: Unified diff