Revision fa9b6494
Added by Leszek Koltunski almost 7 years ago
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java | ||
---|---|---|
24 | 24 |
import android.opengl.GLSurfaceView; |
25 | 25 |
|
26 | 26 |
import org.distorted.examples.R; |
27 |
import org.distorted.library.effect.EffectName; |
|
28 |
import org.distorted.library.effect.MatrixEffectMove; |
|
29 |
import org.distorted.library.effect.MatrixEffectScale; |
|
27 | 30 |
import org.distorted.library.main.Distorted; |
28 | 31 |
import org.distorted.library.main.DistortedEffects; |
29 | 32 |
import org.distorted.library.main.DistortedScreen; |
30 |
import org.distorted.library.EffectNames; |
|
31 | 33 |
import org.distorted.library.main.MeshFlat; |
32 | 34 |
import org.distorted.library.main.DistortedTexture; |
33 |
import org.distorted.library.EffectTypes; |
|
34 | 35 |
import org.distorted.library.type.Static3D; |
35 | 36 |
|
36 | 37 |
import java.io.IOException; |
... | ... | |
51 | 52 |
private AroundTheWorldEffectsManager mManager; |
52 | 53 |
private int mObjWidth, mObjHeight; |
53 | 54 |
|
55 |
private Static3D mMove, mScale; |
|
56 |
|
|
54 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
55 | 58 |
|
56 | 59 |
AroundTheWorldRenderer(GLSurfaceView view) |
... | ... | |
58 | 61 |
DistortedEffects.setMaxVertex(12); |
59 | 62 |
DistortedEffects.setMaxFragment(9); |
60 | 63 |
|
64 |
mMove = new Static3D(0,0,0); |
|
65 |
mScale= new Static3D(1,1,1); |
|
66 |
|
|
61 | 67 |
mView = view; |
62 | 68 |
mManager = new AroundTheWorldEffectsManager(); |
63 | 69 |
mEffects = new DistortedEffects(); |
70 |
mEffects.apply(new MatrixEffectMove(mMove)); |
|
71 |
mEffects.apply(new MatrixEffectScale(mScale)); |
|
72 |
|
|
64 | 73 |
mManager.apply(mEffects); |
65 | 74 |
mScreen = new DistortedScreen(mView); |
66 | 75 |
mScreen.glClearColor(0.5f, 0.5f, 0.5f, 1.0f); |
... | ... | |
84 | 93 |
|
85 | 94 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
86 | 95 |
{ |
87 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
88 |
|
|
89 | 96 |
if( (float)mObjHeight/mObjWidth > (float)height/width ) |
90 | 97 |
{ |
91 | 98 |
int w = (height*mObjWidth)/mObjHeight; |
92 | 99 |
float factor = (float)height/mObjHeight; |
93 |
mEffects.move( new Static3D((width-w)/2,0,0) );
|
|
94 |
mEffects.scale(factor);
|
|
100 |
mMove.set((width-w)/2,0,0);
|
|
101 |
mScale.set(factor,factor,factor);
|
|
95 | 102 |
} |
96 | 103 |
else |
97 | 104 |
{ |
98 | 105 |
int h = (width*mObjHeight)/mObjWidth; |
99 | 106 |
float factor = (float)width/mObjWidth; |
100 |
mEffects.move( new Static3D(0,(height-h)/2,0) );
|
|
101 |
mEffects.scale(factor);
|
|
107 |
mMove.set(0,(height-h)/2,0);
|
|
108 |
mScale.set(factor,factor,factor);
|
|
102 | 109 |
} |
103 | 110 |
|
104 | 111 |
mScreen.resize(width,height); |
... | ... | |
135 | 142 |
mScreen.detachAll(); |
136 | 143 |
mScreen.attach(mTexture, mEffects, mMesh); |
137 | 144 |
|
138 |
DistortedEffects.enableEffect(EffectNames.DISTORT);
|
|
139 |
DistortedEffects.enableEffect(EffectNames.SINK);
|
|
140 |
DistortedEffects.enableEffect(EffectNames.PINCH);
|
|
141 |
DistortedEffects.enableEffect(EffectNames.SWIRL);
|
|
142 |
DistortedEffects.enableEffect(EffectNames.CHROMA);
|
|
143 |
DistortedEffects.enableEffect(EffectNames.SMOOTH_CHROMA);
|
|
144 |
DistortedEffects.enableEffect(EffectNames.CONTRAST);
|
|
145 |
DistortedEffects.enableEffect(EffectName.DISTORT); |
|
146 |
DistortedEffects.enableEffect(EffectName.SINK); |
|
147 |
DistortedEffects.enableEffect(EffectName.PINCH); |
|
148 |
DistortedEffects.enableEffect(EffectName.SWIRL); |
|
149 |
DistortedEffects.enableEffect(EffectName.CHROMA); |
|
150 |
DistortedEffects.enableEffect(EffectName.SMOOTH_CHROMA); |
|
151 |
DistortedEffects.enableEffect(EffectName.CONTRAST); |
|
145 | 152 |
|
146 | 153 |
try |
147 | 154 |
{ |
Also available in: Unified diff
Convert the first few Apps to the new Effect API.