Revision ba95a70b
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java | ||
|---|---|---|
| 30 | 30 |
import org.distorted.library.effect.MatrixEffectScale; |
| 31 | 31 |
import org.distorted.library.effect.VertexEffectDistort; |
| 32 | 32 |
import org.distorted.library.effect.VertexEffectPinch; |
| 33 |
import org.distorted.library.effect.VertexEffectScale; |
|
| 33 | 34 |
import org.distorted.library.effect.VertexEffectSink; |
| 34 | 35 |
import org.distorted.library.effect.VertexEffectSwirl; |
| 35 | 36 |
import org.distorted.library.main.DistortedLibrary; |
| ... | ... | |
| 55 | 56 |
private DistortedScreen mScreen; |
| 56 | 57 |
private MeshRectangles mMesh; |
| 57 | 58 |
private AroundTheWorldEffectsManager mManager; |
| 58 |
private Static3D mScale; |
|
| 59 |
private Static3D mScaleMatrix, mScaleVertex;
|
|
| 59 | 60 |
|
| 60 | 61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 61 | 62 |
|
| 62 | 63 |
AroundTheWorldRenderer(GLSurfaceView view) |
| 63 | 64 |
{
|
| 64 |
mScale= new Static3D(1,1,1); |
|
| 65 |
mScaleMatrix= new Static3D(1,1,1); |
|
| 66 |
mScaleVertex= new Static3D(1,1,1); |
|
| 65 | 67 |
|
| 66 | 68 |
mView = view; |
| 67 | 69 |
mManager = new AroundTheWorldEffectsManager(); |
| 68 | 70 |
mEffects = new DistortedEffects(); |
| 69 |
mEffects.apply(new MatrixEffectScale(mScale)); |
|
| 71 |
mEffects.apply(new MatrixEffectScale(mScaleMatrix)); |
|
| 72 |
mEffects.apply(new VertexEffectScale(mScaleVertex)); |
|
| 70 | 73 |
|
| 71 | 74 |
mManager.apply(mEffects); |
| 72 | 75 |
mScreen = new DistortedScreen(); |
| ... | ... | |
| 91 | 94 |
|
| 92 | 95 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 93 | 96 |
{
|
| 94 |
float horiRatio = (float)width / mMesh.getStretchX();
|
|
| 95 |
float vertRatio = (float)height/ mMesh.getStretchY();
|
|
| 96 |
float factor = horiRatio > vertRatio ? vertRatio : horiRatio;
|
|
| 97 |
float horiRatio = (float)width / mScaleVertex.get0();
|
|
| 98 |
float vertRatio = (float)height/ mScaleVertex.get1();
|
|
| 99 |
float factor = Math.min(horiRatio,vertRatio);
|
|
| 97 | 100 |
|
| 98 |
mScale.set( factor,factor,factor ); |
|
| 101 |
mScaleMatrix.set( factor,factor,factor );
|
|
| 99 | 102 |
mScreen.resize(width,height); |
| 100 | 103 |
} |
| 101 | 104 |
|
| ... | ... | |
| 122 | 125 |
int objWidth = bitmap.getWidth(); |
| 123 | 126 |
int objHeight= bitmap.getHeight(); |
| 124 | 127 |
|
| 128 |
mScaleVertex.set(objWidth,objHeight,1); |
|
| 129 |
|
|
| 125 | 130 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
| 126 | 131 |
mTexture.setTexture(bitmap); |
| 127 | 132 |
|
| 128 |
if( mMesh==null ) |
|
| 129 |
{
|
|
| 130 |
mMesh = new MeshRectangles(30,30*objHeight/objWidth); |
|
| 131 |
mMesh.setStretch(objWidth,objHeight,0); |
|
| 132 |
} |
|
| 133 |
if( mMesh==null ) mMesh = new MeshRectangles(30,30*objHeight/objWidth); |
|
| 133 | 134 |
|
| 134 | 135 |
mScreen.detachAll(); |
| 135 | 136 |
mScreen.attach(mTexture, mEffects, mMesh); |
| ... | ... | |
| 137 | 138 |
DistortedLibrary.setMax(EffectType.VERTEX ,12); |
| 138 | 139 |
DistortedLibrary.setMax(EffectType.FRAGMENT, 9); |
| 139 | 140 |
|
| 141 |
VertexEffectScale.enable(); |
|
| 140 | 142 |
VertexEffectDistort.enable(); |
| 141 | 143 |
VertexEffectSink.enable(); |
| 142 | 144 |
VertexEffectPinch.enable(); |
Also available in: Unified diff
Convert AroundTheWorld to stretchless API.