Revision a4d59c0b
Added by Leszek Koltunski over 5 years ago
src/main/java/org/distorted/examples/effectqueue/EffectQueueSurfaceView.java | ||
---|---|---|
26 | 26 |
import android.view.MotionEvent; |
27 | 27 |
import android.util.AttributeSet; |
28 | 28 |
|
29 |
import org.distorted.library.effect.Effect; |
|
29 | 30 |
import org.distorted.library.effect.FragmentEffectAlpha; |
30 | 31 |
import org.distorted.library.effect.FragmentEffectChroma; |
31 | 32 |
import org.distorted.library.effect.FragmentEffectSaturation; |
... | ... | |
47 | 48 |
private int mCurrentEffect; |
48 | 49 |
private int mScrW, mScrH; |
49 | 50 |
|
50 |
private Static4D mRegionV; |
|
51 | 51 |
private Dynamic1D mInterA, mInterB, mInterC, mInterS; |
52 | 52 |
private Dynamic3D mInterD; |
53 | 53 |
|
54 |
private final static Static3D mRED = new Static3D(1,0,0); |
|
55 |
private final static Static3D mREGION = new Static3D(RADIUS,RADIUS,RADIUS); |
|
54 |
private final static Static3D RED = new Static3D(1,0,0); |
|
55 |
private final static Static3D REGION_F = new Static3D(RADIUS,RADIUS,RADIUS); |
|
56 |
private final static Static4D REGION_V = new Static4D(0,0,0,RADIUS); |
|
56 | 57 |
|
57 | 58 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
58 | 59 |
|
... | ... | |
97 | 98 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
98 | 99 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
99 | 100 |
setRenderer(mRenderer); |
100 |
mRegionV= new Static4D(0,0,0,RADIUS); |
|
101 |
setEffect(0); |
|
101 |
setEffect(0); |
|
102 | 102 |
} |
103 | 103 |
} |
104 | 104 |
|
... | ... | |
126 | 126 |
|
127 | 127 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
128 | 128 |
|
129 |
@Override public boolean onTouchEvent(MotionEvent event) |
|
129 |
@Override |
|
130 |
public boolean onTouchEvent(MotionEvent event) |
|
130 | 131 |
{ |
131 | 132 |
int x,y,action = event.getAction(); |
133 |
Effect effect; |
|
132 | 134 |
boolean success; |
133 | 135 |
|
134 | 136 |
switch(action) |
135 | 137 |
{ |
136 |
case MotionEvent.ACTION_DOWN: x = (int)event.getX()* mRenderer.BWID/mScrW;
|
|
137 |
y = (int)event.getY()* mRenderer.BHEI/mScrH;
|
|
138 |
case MotionEvent.ACTION_DOWN: x = (int)event.getX()* EffectQueueRenderer.BWID/mScrW;
|
|
139 |
y = EffectQueueRenderer.BHEI-(int)event.getY()* EffectQueueRenderer.BHEI/mScrH;
|
|
138 | 140 |
EffectQueueActivity act = (EffectQueueActivity)getContext(); |
141 |
Static3D center = new Static3D(x,y,0); |
|
139 | 142 |
|
140 | 143 |
switch(mCurrentEffect) |
141 | 144 |
{ |
142 |
case 0: VertexEffectDistort distort = new VertexEffectDistort(mInterD, new Static3D(x,y,0), mRegionV);
|
|
143 |
success = mRenderer.getEffects().apply(distort);
|
|
144 |
act.effectAdded(success,distort);
|
|
145 |
case 0: effect = new VertexEffectDistort (mInterD, center, REGION_V);
|
|
146 |
success= mRenderer.getEffects().apply(effect);
|
|
147 |
act.effectAdded(success,effect);
|
|
145 | 148 |
break; |
146 |
case 1: VertexEffectSink sink = new VertexEffectSink(mInterS, new Static3D(x,y,0), mRegionV);
|
|
147 |
success = mRenderer.getEffects().apply(sink);
|
|
148 |
act.effectAdded(success,sink);
|
|
149 |
case 1: effect = new VertexEffectSink (mInterS, center, REGION_V);
|
|
150 |
success= mRenderer.getEffects().apply(effect);
|
|
151 |
act.effectAdded(success,effect);
|
|
149 | 152 |
break; |
150 |
case 2: FragmentEffectAlpha alpha = new FragmentEffectAlpha(mInterA, new Static3D(x,y,0), mREGION, true);
|
|
151 |
success = mRenderer.getEffects().apply(alpha);
|
|
152 |
act.effectAdded(success,alpha);
|
|
153 |
case 2: effect = new FragmentEffectAlpha (mInterA, center, REGION_F, true);
|
|
154 |
success= mRenderer.getEffects().apply(effect);
|
|
155 |
act.effectAdded(success,effect);
|
|
153 | 156 |
break; |
154 |
case 3: FragmentEffectSaturation saturation = new FragmentEffectSaturation(mInterB, new Static3D(x,y,0), mREGION, false);
|
|
155 |
success = mRenderer.getEffects().apply(saturation);
|
|
156 |
act.effectAdded(success,saturation);
|
|
157 |
case 3: effect = new FragmentEffectSaturation(mInterB, center, REGION_F, false);
|
|
158 |
success= mRenderer.getEffects().apply(effect);
|
|
159 |
act.effectAdded(success,effect);
|
|
157 | 160 |
break; |
158 |
case 4: FragmentEffectChroma chroma = new FragmentEffectChroma(mInterC, mRED, new Static3D(x,y,0), mREGION, true);
|
|
159 |
success = mRenderer.getEffects().apply(chroma);
|
|
160 |
act.effectAdded(success,chroma);
|
|
161 |
case 4: effect = new FragmentEffectChroma (mInterC, RED, center, REGION_F, true);
|
|
162 |
success= mRenderer.getEffects().apply(effect);
|
|
163 |
act.effectAdded(success,effect);
|
|
161 | 164 |
break; |
162 | 165 |
} |
163 | 166 |
|
Also available in: Unified diff
Massive: make the coordinate system agree with that of OpenGL (i.e. invert the Y axis).