Revision 392e16fd
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
import org.distorted.examples.R; |
28 | 28 |
import org.distorted.library.Distorted; |
29 |
import org.distorted.library.DistortedFramebuffer; |
|
29 | 30 |
import org.distorted.library.GridFlat; |
30 | 31 |
import org.distorted.library.DistortedEffectQueues; |
31 | 32 |
import org.distorted.library.DistortedTexture; |
... | ... | |
43 | 44 |
class AroundTheWorldRenderer implements GLSurfaceView.Renderer |
44 | 45 |
{ |
45 | 46 |
private GLSurfaceView mView; |
46 |
private DistortedEffectQueues mQueues;
|
|
47 |
private DistortedEffectQueues mEffects;
|
|
47 | 48 |
private DistortedTexture mTexture; |
48 | 49 |
private GridFlat mGrid; |
49 |
private AroundTheWorldEffectsManager mEffects; |
|
50 |
private DistortedFramebuffer mScreen; |
|
51 |
private AroundTheWorldEffectsManager mManager; |
|
50 | 52 |
private int mObjWidth, mObjHeight; |
51 | 53 |
|
52 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
57 | 59 |
Distorted.setMaxFragment(9); |
58 | 60 |
|
59 | 61 |
mView = view; |
60 |
mEffects = new AroundTheWorldEffectsManager(); |
|
61 |
mQueues = new DistortedEffectQueues(); |
|
62 |
mEffects.apply(mQueues); |
|
62 |
mManager = new AroundTheWorldEffectsManager(); |
|
63 |
mEffects = new DistortedEffectQueues(); |
|
64 |
mManager.apply(mEffects); |
|
65 |
mScreen = new DistortedFramebuffer(0); |
|
63 | 66 |
} |
64 | 67 |
|
65 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
66 | 69 |
|
67 | 70 |
AroundTheWorldEffectsManager getManager() |
68 | 71 |
{ |
69 |
return mEffects;
|
|
72 |
return mManager;
|
|
70 | 73 |
} |
71 | 74 |
|
72 | 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
74 | 77 |
public void onDrawFrame(GL10 glUnused) |
75 | 78 |
{ |
76 | 79 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
77 |
mQueues.draw(System.currentTimeMillis(), mTexture, mGrid);
|
|
80 |
mEffects.draw(System.currentTimeMillis(), mTexture, mGrid, mScreen);
|
|
78 | 81 |
} |
79 | 82 |
|
80 | 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
81 | 84 |
|
82 | 85 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
83 | 86 |
{ |
84 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
87 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
85 | 88 |
|
86 | 89 |
if( (float)mObjHeight/mObjWidth > (float)height/width ) |
87 | 90 |
{ |
88 | 91 |
int w = (height*mObjWidth)/mObjHeight; |
89 | 92 |
float factor = (float)height/mObjHeight; |
90 |
mQueues.move( new Static3D((width-w)/2,0,0) );
|
|
91 |
mQueues.scale(factor);
|
|
93 |
mEffects.move( new Static3D((width-w)/2,0,0) );
|
|
94 |
mEffects.scale(factor);
|
|
92 | 95 |
} |
93 | 96 |
else |
94 | 97 |
{ |
95 | 98 |
int h = (width*mObjHeight)/mObjWidth; |
96 | 99 |
float factor = (float)width/mObjWidth; |
97 |
mQueues.move( new Static3D(0,(height-h)/2,0) );
|
|
98 |
mQueues.scale(factor);
|
|
100 |
mEffects.move( new Static3D(0,(height-h)/2,0) );
|
|
101 |
mEffects.scale(factor);
|
|
99 | 102 |
} |
100 | 103 |
|
101 |
Distorted.onSurfaceChanged(width, height);
|
|
104 |
mScreen.resize(width,height);
|
|
102 | 105 |
} |
103 | 106 |
|
104 | 107 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Change in the API: we always have to create a DistortedFramebuffer to render to.