Project

General

Profile

« Previous | Next » 

Revision 5f2a53b6

Added by Leszek Koltunski about 7 years ago

Progress with VBOs - this time abstract out a new class, DistortedObject - i.e. everything that uploads something to GPU and thus needs to be auto re-created upon loss of the context.

View differences:

src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java
48 48
    private GLSurfaceView mView;
49 49
    private DistortedEffects mEffects;
50 50
    private DistortedTexture mTexture;
51
    private MeshFlat mMesh;
51 52
    private DistortedScreen mScreen;
52 53
    private int bmpHeight, bmpWidth;
53 54

  
......
135 136
      // Do not leak memory by creating it the second time around.
136 137
      if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
137 138

  
139
      // likewise the Mesh
140
      if( mMesh==null ) mMesh = new MeshFlat(9,9*bmpHeight/bmpWidth);
141

  
138 142
      // even if mTexture wasn't null, we still need to call setTexture() on it
139 143
      // because every time activity goes to background, its OpenGL resources
140 144
      // - including Textures - get deleted. We always need to call setTexture()
......
142 146
      mTexture.setTexture(bitmap);
143 147

  
144 148
      mScreen.detachAll();
145
      mScreen.attach(mTexture,mEffects,new MeshFlat(9,9*bmpHeight/bmpWidth));
149
      mScreen.attach(mTexture,mEffects,mMesh);
146 150

  
147 151
      DistortedEffects.enableEffect(EffectNames.DISTORT);
148 152

  

Also available in: Unified diff