Revision 42d910b3
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/examples/movingeffects/MovingEffectsRenderer.java | ||
|---|---|---|
| 28 | 28 |
import android.graphics.Paint.Style; |
| 29 | 29 |
import android.opengl.GLSurfaceView; |
| 30 | 30 |
|
| 31 |
import org.distorted.library.effect.Effect; |
|
| 32 |
import org.distorted.library.effect.EffectType; |
|
| 31 | 33 |
import org.distorted.library.effect.FragmentEffectAlpha; |
| 32 | 34 |
import org.distorted.library.effect.FragmentEffectChroma; |
| 33 | 35 |
import org.distorted.library.effect.MatrixEffectScale; |
| 34 | 36 |
import org.distorted.library.effect.VertexEffectDeform; |
| 37 |
import org.distorted.library.effect.VertexEffectScale; |
|
| 35 | 38 |
import org.distorted.library.effect.VertexEffectSink; |
| 36 | 39 |
import org.distorted.library.effect.VertexEffectSwirl; |
| 37 | 40 |
import org.distorted.library.main.DistortedLibrary; |
| ... | ... | |
| 56 | 59 |
private DistortedScreen mScreen; |
| 57 | 60 |
private MeshRectangles mMesh; |
| 58 | 61 |
private boolean mRefresh; |
| 59 |
private Static3D mScale; |
|
| 62 |
private Static3D mScaleMatrix, mScaleVertex;
|
|
| 60 | 63 |
|
| 61 | 64 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 62 | 65 |
|
| ... | ... | |
| 73 | 76 |
mTexture= new DistortedTexture(); |
| 74 | 77 |
mRefresh= true; |
| 75 | 78 |
|
| 76 |
mScale = new Static3D(1,1,1); |
|
| 77 |
mEffects.apply( new MatrixEffectScale(mScale)); |
|
| 79 |
mScaleMatrix = new Static3D(1,1,1); |
|
| 80 |
mScaleVertex = new Static3D(1,1,1); |
|
| 81 |
mEffects.apply( new MatrixEffectScale(mScaleMatrix)); |
|
| 82 |
mEffects.apply( new VertexEffectScale(mScaleVertex)); |
|
| 78 | 83 |
} |
| 79 | 84 |
|
| 80 | 85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 104 | 109 |
|
| 105 | 110 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 106 | 111 |
|
| 107 |
DistortedEffects getEffects()
|
|
| 112 |
void apply(Effect effect)
|
|
| 108 | 113 |
{
|
| 109 |
return mEffects; |
|
| 114 |
mEffects.abortByType(EffectType.VERTEX); |
|
| 115 |
mEffects.abortByType(EffectType.FRAGMENT); |
|
| 116 |
|
|
| 117 |
mEffects.apply( new VertexEffectScale(mScaleVertex)); |
|
| 118 |
|
|
| 119 |
if( effect!=null ) mEffects.apply(effect); |
|
| 110 | 120 |
} |
| 111 | 121 |
|
| 112 | 122 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 120 | 130 |
|
| 121 | 131 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
| 122 | 132 |
{
|
| 133 |
VertexEffectScale.enable(); |
|
| 123 | 134 |
VertexEffectSwirl.enable(); |
| 124 | 135 |
VertexEffectDeform.enable(); |
| 125 | 136 |
VertexEffectSink.enable(); |
| ... | ... | |
| 143 | 154 |
texW = width; |
| 144 | 155 |
texH = height; |
| 145 | 156 |
|
| 146 |
mScale.set(width,width,width); |
|
| 157 |
mScaleMatrix.set(width,width,width); |
|
| 158 |
mScaleVertex.set(1.0f, (float)texH/texW, 1.0f); |
|
| 147 | 159 |
|
| 148 | 160 |
mBitmap = Bitmap.createBitmap(texW,texH, Bitmap.Config.ARGB_8888); |
| 149 | 161 |
mCanvas = new Canvas(mBitmap); |
| 150 | 162 |
|
| 151 | 163 |
if( mMesh!=null ) mMesh.markForDeletion(); |
| 152 | 164 |
mMesh = new MeshRectangles(80,80*texH/texW); |
| 153 |
mMesh.setStretch(1.0f, (float)texH/texW, 1.0f); |
|
| 154 | 165 |
|
| 155 | 166 |
mScreen.detachAll(); |
| 156 | 167 |
mScreen.attach(mTexture,mEffects,mMesh); |
| src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java | ||
|---|---|---|
| 29 | 29 |
import android.view.MotionEvent; |
| 30 | 30 |
import android.util.AttributeSet; |
| 31 | 31 |
|
| 32 |
import org.distorted.library.effect.EffectType; |
|
| 33 | 32 |
import org.distorted.library.effect.FragmentEffectAlpha; |
| 34 | 33 |
import org.distorted.library.effect.FragmentEffectChroma; |
| 35 | 34 |
import org.distorted.library.effect.VertexEffectDeform; |
| 36 | 35 |
import org.distorted.library.effect.VertexEffectSink; |
| 37 | 36 |
import org.distorted.library.effect.VertexEffectSwirl; |
| 38 |
import org.distorted.library.main.DistortedEffects; |
|
| 39 | 37 |
import org.distorted.library.type.Dynamic3D; |
| 40 | 38 |
import org.distorted.library.type.Static1D; |
| 41 | 39 |
import org.distorted.library.type.Static3D; |
| ... | ... | |
| 117 | 115 |
|
| 118 | 116 |
public void onSurfaceChanged(int width,int height) |
| 119 | 117 |
{
|
| 120 |
int max = width>height ? width:height;
|
|
| 118 |
int max = Math.max(width, height);
|
|
| 121 | 119 |
|
| 122 | 120 |
mScrWidth = width; |
| 123 | 121 |
mScrHeight = height; |
| ... | ... | |
| 143 | 141 |
|
| 144 | 142 |
synchronized(lock) |
| 145 | 143 |
{
|
| 146 |
DistortedEffects q = mRenderer.getEffects(); |
|
| 147 |
q.abortByType(EffectType.VERTEX); |
|
| 148 |
q.abortByType(EffectType.FRAGMENT); |
|
| 149 |
q.apply(mEffectDeform); |
|
| 144 |
mRenderer.apply(mEffectDeform); |
|
| 150 | 145 |
mCurrEffect = EFFECT_BUBBLE; |
| 151 | 146 |
} |
| 152 | 147 |
} |
| ... | ... | |
| 159 | 154 |
|
| 160 | 155 |
synchronized(lock) |
| 161 | 156 |
{
|
| 162 |
DistortedEffects q = mRenderer.getEffects(); |
|
| 163 |
q.abortByType(EffectType.VERTEX); |
|
| 164 |
q.abortByType(EffectType.FRAGMENT); |
|
| 165 |
q.apply(mEffectSink); |
|
| 157 |
mRenderer.apply(mEffectSink); |
|
| 166 | 158 |
mCurrEffect = EFFECT_SINK; |
| 167 | 159 |
} |
| 168 | 160 |
} |
| ... | ... | |
| 175 | 167 |
|
| 176 | 168 |
synchronized(lock) |
| 177 | 169 |
{
|
| 178 |
DistortedEffects q = mRenderer.getEffects(); |
|
| 179 |
q.abortByType(EffectType.VERTEX); |
|
| 180 |
q.abortByType(EffectType.FRAGMENT); |
|
| 181 |
q.apply(mEffectChroma); |
|
| 170 |
mRenderer.apply(mEffectChroma); |
|
| 182 | 171 |
mCurrEffect = EFFECT_CHROMA; |
| 183 | 172 |
} |
| 184 | 173 |
} |
| ... | ... | |
| 191 | 180 |
|
| 192 | 181 |
synchronized(lock) |
| 193 | 182 |
{
|
| 194 |
DistortedEffects q = mRenderer.getEffects(); |
|
| 195 |
q.abortByType(EffectType.VERTEX); |
|
| 196 |
q.abortByType(EffectType.FRAGMENT); |
|
| 197 |
q.apply(mEffectAlpha); |
|
| 183 |
mRenderer.apply(mEffectAlpha); |
|
| 198 | 184 |
mCurrEffect = EFFECT_TRANS; |
| 199 | 185 |
} |
| 200 | 186 |
} |
| ... | ... | |
| 207 | 193 |
|
| 208 | 194 |
synchronized(lock) |
| 209 | 195 |
{
|
| 210 |
DistortedEffects q = mRenderer.getEffects(); |
|
| 211 |
q.abortByType(EffectType.VERTEX); |
|
| 212 |
q.abortByType(EffectType.FRAGMENT); |
|
| 213 |
q.apply(mEffectSwirl); |
|
| 196 |
mRenderer.apply(mEffectSwirl); |
|
| 214 | 197 |
mCurrEffect = EFFECT_SWIRL; |
| 215 | 198 |
} |
| 216 | 199 |
} |
| ... | ... | |
| 221 | 204 |
{
|
| 222 | 205 |
synchronized(lock) |
| 223 | 206 |
{
|
| 224 |
DistortedEffects q = mRenderer.getEffects(); |
|
| 225 |
q.abortByType(EffectType.VERTEX); |
|
| 226 |
q.abortByType(EffectType.FRAGMENT); |
|
| 207 |
mRenderer.apply(null); |
|
| 227 | 208 |
mCenter.removeAll(); |
| 228 | 209 |
mCurrEffect = EFFECT_POINTS; |
| 229 | 210 |
mRenderer.setRefresh(); |
Also available in: Unified diff
Convert AroundTheWorld to stretchless API.