Revision 392e16fd
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/plainmonalisa/RenderThread.java | ||
---|---|---|
31 | 31 |
import android.view.SurfaceView; |
32 | 32 |
|
33 | 33 |
import org.distorted.library.Distorted; |
34 |
import org.distorted.library.DistortedFramebuffer; |
|
34 | 35 |
import org.distorted.library.GridFlat; |
35 | 36 |
import org.distorted.library.DistortedTexture; |
36 | 37 |
import org.distorted.library.DistortedEffectQueues; |
... | ... | |
62 | 63 |
private EGLSurface eglSurface; |
63 | 64 |
|
64 | 65 |
private DistortedTexture mTexture; |
65 |
private DistortedEffectQueues mQueues; |
|
66 |
private DistortedEffectQueues mEffects; |
|
67 |
private DistortedFramebuffer mScreen; |
|
66 | 68 |
private GridFlat mGrid; |
67 | 69 |
private int bmpHeight, bmpWidth; |
68 | 70 |
private SurfaceView mView; |
... | ... | |
89 | 91 |
dRight.add( new Static3D( 0, 0,0) ); |
90 | 92 |
dRight.add( new Static3D( 20,-10,0) ); |
91 | 93 |
|
92 |
mQueues = new DistortedEffectQueues(); |
|
93 |
mQueues.distort( dLeft, pLeft , rLeft ); |
|
94 |
mQueues.distort(dRight, pRight, rRight); |
|
94 |
mEffects = new DistortedEffectQueues(); |
|
95 |
mEffects.distort( dLeft, pLeft , rLeft ); |
|
96 |
mEffects.distort(dRight, pRight, rRight); |
|
97 |
|
|
98 |
mScreen = new DistortedFramebuffer(0); |
|
95 | 99 |
} |
96 | 100 |
|
97 | 101 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
228 | 232 |
{ |
229 | 233 |
Log.d(TAG, "surfaceChanged " + width + "x" + height); |
230 | 234 |
|
231 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
235 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
232 | 236 |
|
233 | 237 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
234 | 238 |
{ |
235 | 239 |
int w = (height*bmpWidth)/bmpHeight; |
236 | 240 |
float factor = (float)height/bmpHeight; |
237 | 241 |
|
238 |
mQueues.move( new Static3D((width-w)/2,0,0) );
|
|
239 |
mQueues.scale( factor );
|
|
242 |
mEffects.move( new Static3D((width-w)/2,0,0) );
|
|
243 |
mEffects.scale( factor );
|
|
240 | 244 |
} |
241 | 245 |
else |
242 | 246 |
{ |
243 | 247 |
int h = (width*bmpHeight)/bmpWidth; |
244 | 248 |
float factor = (float)width/bmpWidth; |
245 | 249 |
|
246 |
mQueues.move( new Static3D(0,(height-h)/2,0) );
|
|
247 |
mQueues.scale( factor );
|
|
250 |
mEffects.move( new Static3D(0,(height-h)/2,0) );
|
|
251 |
mEffects.scale( factor );
|
|
248 | 252 |
} |
249 | 253 |
|
250 |
Distorted.onSurfaceChanged(width, height);
|
|
254 |
mScreen.resize(width, height);
|
|
251 | 255 |
} |
252 | 256 |
|
253 | 257 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
263 | 267 |
eglCore.makeCurrent(eglSurface); |
264 | 268 |
|
265 | 269 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
266 |
mQueues.draw(System.currentTimeMillis(), mTexture,mGrid);
|
|
270 |
mEffects.draw(System.currentTimeMillis(), mTexture,mGrid,mScreen);
|
|
267 | 271 |
|
268 | 272 |
eglCore.swapBuffers(eglSurface); |
269 | 273 |
} |
Also available in: Unified diff
Change in the API: we always have to create a DistortedFramebuffer to render to.