Revision c9ff05c1
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/sink/SinkRenderer.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
|
30 |
import org.distorted.library.effect.EffectName; |
|
31 |
import org.distorted.library.effect.MatrixEffectMove; |
|
32 |
import org.distorted.library.effect.MatrixEffectScale; |
|
33 |
import org.distorted.library.effect.VertexEffectSink; |
|
30 | 34 |
import org.distorted.library.main.Distorted; |
31 | 35 |
import org.distorted.library.main.DistortedEffects; |
32 | 36 |
import org.distorted.library.main.DistortedScreen; |
33 |
import org.distorted.library.EffectNames; |
|
34 | 37 |
import org.distorted.library.main.MeshFlat; |
35 | 38 |
import org.distorted.library.main.DistortedTexture; |
36 |
import org.distorted.library.EffectTypes; |
|
37 | 39 |
import org.distorted.library.type.Dynamic1D; |
38 | 40 |
import org.distorted.library.type.Static1D; |
39 | 41 |
import org.distorted.library.type.Static3D; |
... | ... | |
52 | 54 |
private DistortedTexture mTexture; |
53 | 55 |
private MeshFlat mMesh; |
54 | 56 |
private int bmpHeight, bmpWidth; |
55 |
|
|
57 |
private Static3D mScale, mMove; |
|
58 |
|
|
56 | 59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
57 | 60 |
|
58 | 61 |
SinkRenderer(GLSurfaceView v) |
... | ... | |
64 | 67 |
sink.add(new Static1D(0.2f)); |
65 | 68 |
|
66 | 69 |
mEffects = new DistortedEffects(); |
67 |
mEffects.sink( sink, new Static3D(297, 320, 0), null); |
|
70 |
VertexEffectSink sinkEffect = new VertexEffectSink(sink, new Static3D(297, 320, 0), null); |
|
71 |
mEffects.apply(sinkEffect); |
|
72 |
|
|
73 |
mScale = new Static3D(1,1,1); |
|
74 |
mMove = new Static3D(0,0,0); |
|
75 |
mEffects.apply(new MatrixEffectMove(mMove)); |
|
76 |
mEffects.apply(new MatrixEffectScale(mScale)); |
|
68 | 77 |
|
69 | 78 |
mScreen = new DistortedScreen(mView); |
70 | 79 |
} |
... | ... | |
80 | 89 |
|
81 | 90 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
82 | 91 |
{ |
83 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
84 |
|
|
85 | 92 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
86 | 93 |
{ |
87 | 94 |
int w = (height*bmpWidth)/bmpHeight; |
88 | 95 |
float factor = (float)height/bmpHeight; |
89 |
|
|
90 |
mEffects.move( new Static3D((width-w)/2,0,0) ); |
|
91 |
mEffects.scale( factor ); |
|
96 |
mMove.set((width-w)/2,0,0); |
|
97 |
mScale.set(factor,factor,factor); |
|
92 | 98 |
} |
93 | 99 |
else |
94 | 100 |
{ |
95 | 101 |
int h = (width*bmpHeight)/bmpWidth; |
96 | 102 |
float factor = (float)width/bmpWidth; |
97 |
|
|
98 |
mEffects.move( new Static3D(0,(height-h)/2,0) ); |
|
99 |
mEffects.scale( factor ); |
|
103 |
mMove.set(0,(height-h)/2,0); |
|
104 |
mScale.set(factor,factor,factor); |
|
100 | 105 |
} |
101 | 106 |
|
102 | 107 |
mScreen.resize(width, height); |
... | ... | |
132 | 137 |
mScreen.detachAll(); |
133 | 138 |
mScreen.attach(mTexture,mEffects,mMesh); |
134 | 139 |
|
135 |
DistortedEffects.enableEffect(EffectNames.SINK);
|
|
140 |
DistortedEffects.enableEffect(EffectName.SINK); |
|
136 | 141 |
|
137 | 142 |
try |
138 | 143 |
{ |
Also available in: Unified diff
Some progress with Effect classes.
13 apps compile now.