Revision 392e16fd
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/flag/FlagRenderer.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.GridCubes; |
30 | 31 |
import org.distorted.library.DistortedEffectQueues; |
31 | 32 |
import org.distorted.library.DistortedTexture; |
... | ... | |
48 | 49 |
class FlagRenderer implements GLSurfaceView.Renderer |
49 | 50 |
{ |
50 | 51 |
private GLSurfaceView mView; |
51 |
private DistortedEffectQueues mQueues;
|
|
52 |
private DistortedEffectQueues mEffects;
|
|
52 | 53 |
private DistortedTexture mTexture; |
54 |
private DistortedFramebuffer mScreen; |
|
53 | 55 |
private GridCubes mGrid; |
54 |
private int mObjWidth, mObjHeight; |
|
55 | 56 |
private DynamicQuat mQuatInt1, mQuatInt2; |
56 | 57 |
private Dynamic5D mWaveDyn; |
57 | 58 |
private Static5D mWaveSta1, mWaveSta2; |
59 |
private int mObjWidth, mObjHeight; |
|
58 | 60 |
|
59 | 61 |
Static4D mQuat1, mQuat2; |
60 | 62 |
int mScreenMin; |
... | ... | |
65 | 67 |
{ |
66 | 68 |
mView = v; |
67 | 69 |
|
68 |
mQueues = new DistortedEffectQueues();
|
|
70 |
mEffects = new DistortedEffectQueues();
|
|
69 | 71 |
mGrid = new GridCubes(50,30,false); |
70 | 72 |
mTexture = new DistortedTexture(500,300); |
71 | 73 |
|
... | ... | |
92 | 94 |
Static3D waveCenter = new Static3D(mObjWidth, mObjHeight/2, 0); // middle of the right edge |
93 | 95 |
Static4D waveRegion = new Static4D(0,0,mObjWidth,mObjWidth); |
94 | 96 |
|
95 |
mQueues.wave(mWaveDyn, waveCenter, waveRegion); |
|
97 |
mEffects.wave(mWaveDyn, waveCenter, waveRegion); |
|
98 |
|
|
99 |
mScreen = new DistortedFramebuffer(0); |
|
96 | 100 |
} |
97 | 101 |
|
98 | 102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
139 | 143 |
public void onDrawFrame(GL10 glUnused) |
140 | 144 |
{ |
141 | 145 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
142 |
mQueues.draw(System.currentTimeMillis(), mTexture, mGrid);
|
|
146 |
mEffects.draw(System.currentTimeMillis(), mTexture, mGrid, mScreen);
|
|
143 | 147 |
} |
144 | 148 |
|
145 | 149 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
148 | 152 |
{ |
149 | 153 |
mScreenMin = width<height ? width:height; |
150 | 154 |
|
151 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
155 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
152 | 156 |
float factor; |
153 | 157 |
|
154 | 158 |
if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object |
... | ... | |
160 | 164 |
factor = (0.8f*width)/mObjWidth; |
161 | 165 |
} |
162 | 166 |
|
163 |
mQueues.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
|
|
164 |
mQueues.scale(factor);
|
|
167 |
mEffects.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
|
|
168 |
mEffects.scale(factor);
|
|
165 | 169 |
Static3D center = new Static3D(mObjWidth/2,mObjHeight/2, 0); |
166 | 170 |
|
167 |
mQueues.quaternion(mQuatInt1, center);
|
|
168 |
mQueues.quaternion(mQuatInt2, center);
|
|
171 |
mEffects.quaternion(mQuatInt1, center);
|
|
172 |
mEffects.quaternion(mQuatInt2, center);
|
|
169 | 173 |
|
170 |
Distorted.onSurfaceChanged(width, height);
|
|
174 |
mScreen.resize(width, height);
|
|
171 | 175 |
} |
172 | 176 |
|
173 | 177 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Change in the API: we always have to create a DistortedFramebuffer to render to.