Revision 1f218177
Added by Leszek Koltunski almost 7 years ago
src/main/java/org/distorted/examples/plainmonalisa/RenderThread.java | ||
---|---|---|
30 | 30 |
import android.view.SurfaceHolder; |
31 | 31 |
import android.view.SurfaceView; |
32 | 32 |
|
33 |
import org.distorted.library.effect.EffectName; |
|
34 |
import org.distorted.library.effect.MatrixEffectMove; |
|
35 |
import org.distorted.library.effect.MatrixEffectScale; |
|
36 |
import org.distorted.library.effect.VertexEffectDistort; |
|
33 | 37 |
import org.distorted.library.main.Distorted; |
34 | 38 |
import org.distorted.library.main.DistortedEffects; |
35 | 39 |
import org.distorted.library.main.DistortedScreen; |
36 |
import org.distorted.library.EffectNames; |
|
37 | 40 |
import org.distorted.library.main.MeshFlat; |
38 | 41 |
import org.distorted.library.main.DistortedTexture; |
39 |
import org.distorted.library.EffectTypes; |
|
40 | 42 |
import org.distorted.library.type.Dynamic3D; |
41 | 43 |
import org.distorted.library.type.Static3D; |
42 | 44 |
import org.distorted.library.type.Static4D; |
... | ... | |
70 | 72 |
private int bmpHeight, bmpWidth; |
71 | 73 |
private SurfaceView mView; |
72 | 74 |
private static boolean resourcesCreated = false; |
75 |
private Static3D mMove, mScale; |
|
73 | 76 |
|
74 | 77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
75 | 78 |
|
... | ... | |
94 | 97 |
dRight.add( new Static3D( 20,-10,0) ); |
95 | 98 |
|
96 | 99 |
mEffects = new DistortedEffects(); |
97 |
mEffects.distort( dLeft, pLeft , rLeft ); |
|
98 |
mEffects.distort(dRight, pRight, rRight); |
|
100 |
mEffects.apply( new VertexEffectDistort(dLeft , pLeft , rLeft ) ); |
|
101 |
mEffects.apply( new VertexEffectDistort(dRight, pRight, rRight) ); |
|
102 |
|
|
103 |
mMove = new Static3D(0,0,0); |
|
104 |
mScale= new Static3D(1,1,1); |
|
105 |
mEffects.apply(new MatrixEffectMove(mMove)); |
|
106 |
mEffects.apply(new MatrixEffectScale(mScale)); |
|
99 | 107 |
|
100 | 108 |
mScreen = new DistortedScreen(null); |
101 | 109 |
} |
... | ... | |
117 | 125 |
{ |
118 | 126 |
String msg = op + ": glError 0x" + Integer.toHexString(error); |
119 | 127 |
Log.e(TAG, msg); |
120 |
// throw new RuntimeException(msg);
|
|
128 |
// throw new RuntimeException(msg); |
|
121 | 129 |
} |
122 | 130 |
} |
123 | 131 |
|
... | ... | |
210 | 218 |
{ |
211 | 219 |
Log.d(TAG, "surfaceChanged " + width + "x" + height); |
212 | 220 |
|
213 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
214 |
|
|
215 | 221 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
216 | 222 |
{ |
217 | 223 |
int w = (height*bmpWidth)/bmpHeight; |
218 | 224 |
float factor = (float)height/bmpHeight; |
219 | 225 |
|
220 |
mEffects.move( new Static3D((width-w)/2,0,0) );
|
|
221 |
mEffects.scale( factor );
|
|
226 |
mMove.set((width-w)/2,0,0);
|
|
227 |
mScale.set( factor,factor,factor );
|
|
222 | 228 |
} |
223 | 229 |
else |
224 | 230 |
{ |
225 | 231 |
int h = (width*bmpHeight)/bmpWidth; |
226 | 232 |
float factor = (float)width/bmpWidth; |
227 | 233 |
|
228 |
mEffects.move( new Static3D(0,(height-h)/2,0) );
|
|
229 |
mEffects.scale( factor );
|
|
234 |
mMove.set(0,(height-h)/2,0);
|
|
235 |
mScale.set( factor,factor,factor );
|
|
230 | 236 |
} |
231 | 237 |
|
232 | 238 |
mScreen.resize(width, height); |
... | ... | |
234 | 240 |
|
235 | 241 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
236 | 242 |
|
237 |
void createResources() |
|
243 |
private void createResources()
|
|
238 | 244 |
{ |
239 | 245 |
resourcesCreated = true; |
240 | 246 |
|
... | ... | |
265 | 271 |
mScreen.detachAll(); |
266 | 272 |
mScreen.attach(mTexture,mEffects,mMesh); |
267 | 273 |
|
268 |
DistortedEffects.enableEffect(EffectNames.DISTORT);
|
|
274 |
DistortedEffects.enableEffect(EffectName.DISTORT); |
|
269 | 275 |
|
270 | 276 |
try |
271 | 277 |
{ |
Also available in: Unified diff
Further progress with Apps: 18 (out of 30) compile now.