Revision 40122d03
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java | ||
---|---|---|
31 | 31 |
import org.distorted.library.effect.MatrixEffectMove; |
32 | 32 |
import org.distorted.library.effect.MatrixEffectScale; |
33 | 33 |
import org.distorted.library.effect.VertexEffectDistort; |
34 |
import org.distorted.library.effect.VertexEffectScale; |
|
34 | 35 |
import org.distorted.library.effect.VertexEffectSink; |
35 | 36 |
import org.distorted.library.main.DistortedLibrary; |
36 | 37 |
import org.distorted.library.main.DistortedEffects; |
... | ... | |
58 | 59 |
private DistortedTexture mTexture; |
59 | 60 |
private MeshRectangles mMesh; |
60 | 61 |
private DistortedScreen mScreen; |
61 |
private Static3D mScale; |
|
62 |
private Static3D mScale, mScaleBitmap;
|
|
62 | 63 |
private Static3D[] mMove; |
64 |
private int mBmpWidth, mBmpHeight; |
|
63 | 65 |
|
64 | 66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
65 | 67 |
|
... | ... | |
85 | 87 |
|
86 | 88 |
for(int i=0; i<NUM; i++) mEffects[i] = new DistortedEffects(); |
87 | 89 |
|
90 |
mScaleBitmap = new Static3D(1,1,1); |
|
91 |
VertexEffectScale scale = new VertexEffectScale(mScaleBitmap); |
|
92 |
|
|
93 |
mEffects[0].apply(scale); |
|
94 |
mEffects[1].apply(scale); |
|
95 |
mEffects[2].apply(scale); |
|
96 |
|
|
88 | 97 |
Dynamic1D sink = new Dynamic1D(2000,0.0f); |
89 | 98 |
sink.add(new Static1D( 1)); |
90 | 99 |
sink.add(new Static1D(10)); |
... | ... | |
131 | 140 |
|
132 | 141 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
133 | 142 |
{ |
134 |
float horiRatio = (float)width / (NUM*mMesh.getStretchX());
|
|
135 |
float vertRatio = (float)height/ ( mMesh.getStretchY());
|
|
136 |
float factor = horiRatio > vertRatio ? vertRatio : horiRatio;
|
|
143 |
float horiRatio = (float)width / (NUM*mBmpWidth);
|
|
144 |
float vertRatio = (float)height/ ( mBmpHeight);
|
|
145 |
float factor = Math.min(horiRatio, vertRatio);
|
|
137 | 146 |
|
138 | 147 |
mScale.set( factor,factor,factor ); |
139 | 148 |
|
... | ... | |
162 | 171 |
catch(IOException e) { } |
163 | 172 |
} |
164 | 173 |
|
165 |
int bmpHeight = bitmap.getHeight();
|
|
166 |
int bmpWidth = bitmap.getWidth();
|
|
174 |
mBmpHeight = bitmap.getHeight();
|
|
175 |
mBmpWidth = bitmap.getWidth();
|
|
167 | 176 |
|
168 |
if( mMesh==null ) |
|
169 |
{ |
|
170 |
mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
|
171 |
mMesh.setStretch(bmpWidth, bmpHeight, 0); |
|
172 |
} |
|
177 |
mScaleBitmap.set(mBmpWidth,mBmpHeight,0); |
|
173 | 178 |
|
179 |
if( mMesh ==null ) mMesh = new MeshRectangles(30,30*mBmpHeight/mBmpWidth); |
|
174 | 180 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
175 | 181 |
mTexture.setTexture(bitmap); |
176 | 182 |
|
177 | 183 |
mScreen.detachAll(); |
178 | 184 |
for(int i=NUM-1; i>=0; i--) mScreen.attach(mTexture, mEffects[i], mMesh); |
179 | 185 |
|
186 |
VertexEffectScale.enable(); |
|
180 | 187 |
VertexEffectSink.enable(); |
181 | 188 |
VertexEffectDistort.enable(); |
182 | 189 |
FragmentEffectChroma.enable(); |
Also available in: Unified diff
Convert DifferentEffects app to the stretch-less API.