Revision c7a31368
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/examples/bean/BeanRenderer.java | ||
---|---|---|
108 | 108 |
|
109 | 109 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
110 | 110 |
{ |
111 |
float min= width>height ? height : width; |
|
111 |
if( width<height ) mScale.set( width, width*mBmpRatio, 1 ); |
|
112 |
else mScale.set( height/mBmpRatio, height, 1 ); |
|
112 | 113 |
|
113 |
mScale.set( min, min*mBmpRatio, 1 ); |
|
114 | 114 |
mScreen.resize(width, height); |
115 | 115 |
} |
116 | 116 |
|
src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java | ||
---|---|---|
124 | 124 |
|
125 | 125 |
mScreen.resize(width, height); |
126 | 126 |
} |
127 |
|
|
127 | 128 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
128 | 129 |
|
129 | 130 |
public void onDrawFrame(GL10 glUnused) |
src/main/java/org/distorted/examples/girl/GirlRenderer.java | ||
---|---|---|
166 | 166 |
|
167 | 167 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
168 | 168 |
{ |
169 |
float min= width>height ? height : width; |
|
169 |
if( width<height ) mScale.set( width, width*mBmpRatio, width ); |
|
170 |
else mScale.set( height/mBmpRatio, height, height ); |
|
170 | 171 |
|
171 |
mScale.set( min, min*mBmpRatio, min ); |
|
172 | 172 |
mScreen.resize(width, height); |
173 | 173 |
} |
174 | 174 |
|
src/main/java/org/distorted/examples/listener/ListenerRenderer.java | ||
---|---|---|
139 | 139 |
|
140 | 140 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
141 | 141 |
{ |
142 |
float min= width>height ? height : width; |
|
142 |
if( width<height ) mScale.set( width, width*mBmpRatio, width ); |
|
143 |
else mScale.set( height/mBmpRatio, height, height ); |
|
143 | 144 |
|
144 |
mScale.set( min, min*mBmpRatio, min ); |
|
145 | 145 |
mScreen.resize(width, height); |
146 | 146 |
} |
147 | 147 |
|
src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java | ||
---|---|---|
114 | 114 |
|
115 | 115 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
116 | 116 |
{ |
117 |
float min= width>height ? height : width; |
|
117 |
if( width<height ) mScale.set( width, width*mBmpRatio, 1 ); |
|
118 |
else mScale.set( height/mBmpRatio, height, 1 ); |
|
118 | 119 |
|
119 |
mScale.set( min, min*mBmpRatio, 1 ); |
|
120 | 120 |
mScreen.resize(width, height); |
121 | 121 |
} |
122 | 122 |
|
src/main/java/org/distorted/examples/movingeffects/MovingEffectsRenderer.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
import org.distorted.library.effect.FragmentEffectAlpha; |
32 | 32 |
import org.distorted.library.effect.FragmentEffectChroma; |
33 |
import org.distorted.library.effect.MatrixEffectScale; |
|
33 | 34 |
import org.distorted.library.effect.VertexEffectDeform; |
34 | 35 |
import org.distorted.library.effect.VertexEffectSink; |
35 | 36 |
import org.distorted.library.effect.VertexEffectSwirl; |
... | ... | |
38 | 39 |
import org.distorted.library.main.DistortedTexture; |
39 | 40 |
import org.distorted.library.main.DistortedEffects; |
40 | 41 |
import org.distorted.library.mesh.MeshRectangles; |
42 |
import org.distorted.library.type.Static3D; |
|
41 | 43 |
|
42 | 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
43 | 45 |
|
... | ... | |
54 | 56 |
private DistortedScreen mScreen; |
55 | 57 |
private MeshRectangles mMesh; |
56 | 58 |
private boolean mRefresh; |
59 |
private Static3D mScale; |
|
57 | 60 |
|
58 | 61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
59 | 62 |
|
... | ... | |
67 | 70 |
mView = v; |
68 | 71 |
mEffects= new DistortedEffects(); |
69 | 72 |
mScreen = new DistortedScreen(); |
73 |
mTexture= new DistortedTexture(); |
|
70 | 74 |
mRefresh= true; |
75 |
|
|
76 |
mScale = new Static3D(1,1,1); |
|
77 |
mEffects.apply( new MatrixEffectScale(mScale)); |
|
71 | 78 |
} |
72 | 79 |
|
73 | 80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
136 | 143 |
texW = width; |
137 | 144 |
texH = height; |
138 | 145 |
|
139 |
if( mTexture!=null ) mTexture.markForDeletion();
|
|
140 |
mTexture = new DistortedTexture(); |
|
146 |
mScale.set(width,height,width);
|
|
147 |
|
|
141 | 148 |
mBitmap = Bitmap.createBitmap(texW,texH, Bitmap.Config.ARGB_8888); |
142 | 149 |
mCanvas = new Canvas(mBitmap); |
143 | 150 |
|
144 | 151 |
if( mMesh!=null ) mMesh.markForDeletion(); |
145 | 152 |
mMesh = new MeshRectangles(80,80*texH/texW); |
146 |
mMesh.setStretch(texW,texH,0); |
|
147 | 153 |
|
148 | 154 |
mScreen.detachAll(); |
149 | 155 |
mScreen.attach(mTexture,mEffects,mMesh); |
src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java | ||
---|---|---|
58 | 58 |
private static final Object lock = new Object(); |
59 | 59 |
|
60 | 60 |
private Dynamic3D mCenter; |
61 |
private Static4D mRegionVertex; |
|
62 |
private Static3D mRegionFragment; |
|
63 |
|
|
64 | 61 |
private Paint mPaint; |
65 | 62 |
private int moving; |
66 | 63 |
private int mScrWidth, mScrHeight; |
... | ... | |
89 | 86 |
mPaint.setStyle(Style.FILL); |
90 | 87 |
moving = -1; |
91 | 88 |
|
92 |
mCenter = new Dynamic3D(LOOP_TIME,0.0f); |
|
93 |
mRegionFragment = new Static3D(0,0,0); |
|
94 |
mRegionVertex = new Static4D(0,0,0,0); |
|
95 |
mDeform = new Static3D(0,0,0); |
|
89 |
mCenter = new Dynamic3D(LOOP_TIME,0.0f); |
|
90 |
mDeform = new Static3D(0,0,0.15f); |
|
96 | 91 |
|
97 | 92 |
if(!isInEditMode()) |
98 | 93 |
{ |
... | ... | |
105 | 100 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
106 | 101 |
setRenderer(mRenderer); |
107 | 102 |
|
108 |
mEffectDeform = new VertexEffectDeform ( mDeform , mCenter, mRegionVertex); |
|
109 |
mEffectSink = new VertexEffectSink (new Static1D(10) , mCenter, mRegionVertex); |
|
110 |
mEffectSwirl = new VertexEffectSwirl (new Static1D(30) , mCenter, mRegionVertex); |
|
111 |
mEffectAlpha = new FragmentEffectAlpha (new Static1D(0.5f), mCenter, mRegionFragment, true); |
|
112 |
mEffectChroma = new FragmentEffectChroma(new Static1D(0.5f), new Static3D(1,0,0), mCenter, mRegionFragment, true); |
|
103 |
Static3D regionFrag = new Static3D(0.15f,0.15f,0.15f); |
|
104 |
Static4D regionVert = new Static4D(0,0,0,0.15f); |
|
105 |
|
|
106 |
mEffectDeform = new VertexEffectDeform ( mDeform , mCenter, regionVert); |
|
107 |
mEffectSink = new VertexEffectSink (new Static1D(10) , mCenter, regionVert); |
|
108 |
mEffectSwirl = new VertexEffectSwirl (new Static1D(30) , mCenter, regionVert); |
|
109 |
mEffectAlpha = new FragmentEffectAlpha (new Static1D(0.5f), mCenter, regionFrag, true); |
|
110 |
mEffectChroma = new FragmentEffectChroma(new Static1D(0.5f), new Static3D(1,0,0), mCenter, regionFrag, true); |
|
113 | 111 |
} |
114 | 112 |
} |
115 | 113 |
|
... | ... | |
124 | 122 |
|
125 | 123 |
mSize1 = max/200; |
126 | 124 |
mSize2 = max/80; |
127 |
int rad= max/6; |
|
128 |
|
|
129 |
mRegionVertex.set(0,0,0,rad); |
|
130 |
mRegionFragment.set(rad,rad,rad); |
|
131 |
mDeform.set2(max/7); |
|
132 | 125 |
} |
133 | 126 |
|
134 | 127 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
246 | 239 |
|
247 | 240 |
if( len>=2 ) |
248 | 241 |
{ |
249 |
float step = (float)LOOP_TIME/(NUM_POINTS+1); |
|
242 |
final float step = (float)LOOP_TIME/(NUM_POINTS+1);
|
|
250 | 243 |
|
251 | 244 |
for(int i=0; i<NUM_POINTS; i++) |
252 | 245 |
{ |
253 | 246 |
mPaint.setColor( 0xffffffff ); |
254 | 247 |
mCenter.get( drawCoord, 0, (long)(i*step) ); |
255 |
c.drawCircle(drawCoord[0] + mScrWidth*0.5f, mScrHeight*0.5f - drawCoord[1], mSize1, mPaint );
|
|
248 |
c.drawCircle( (drawCoord[0]+0.5f)*mScrWidth, mScrHeight*(0.5f-drawCoord[1]), mSize1, mPaint );
|
|
256 | 249 |
} |
257 | 250 |
} |
258 | 251 |
|
... | ... | |
261 | 254 |
for(int curr=0; curr<len; curr++) |
262 | 255 |
{ |
263 | 256 |
cu = mCenter.getPoint(curr); |
264 |
c.drawCircle(cu.get0() + mScrWidth*0.5f, mScrHeight*0.5f - cu.get1(), mSize2, mPaint);
|
|
257 |
c.drawCircle( (cu.get0()+0.5f)*mScrWidth, mScrHeight*(0.5f-cu.get1()), mSize2, mPaint);
|
|
265 | 258 |
} |
266 | 259 |
|
267 | 260 |
if( time-mTime > LOOP_TIME ) mTime = time; |
... | ... | |
275 | 268 |
{ |
276 | 269 |
if( mCurrEffect!=EFFECT_POINTS ) return true; |
277 | 270 |
|
278 |
int xDown = (int)event.getX() - mScrWidth/2;
|
|
279 |
int yDown = mScrHeight/2 - (int)event.getY();
|
|
271 |
float xDown = event.getX()/mScrWidth - 0.5f;
|
|
272 |
float yDown = 0.5f - event.getY()/mScrHeight;
|
|
280 | 273 |
|
281 | 274 |
switch(event.getAction()) |
282 | 275 |
{ |
src/main/java/org/distorted/examples/projection/ProjectionRenderer.java | ||
---|---|---|
125 | 125 |
bmpCanvas.drawRect( 0, height*i/NUMLINES-1, width , height*i/NUMLINES+1, paint); |
126 | 126 |
} |
127 | 127 |
|
128 |
mScale.set(width,height,width); // TODO - width in the third scale??
|
|
128 |
mScale.set(width,height,width); |
|
129 | 129 |
|
130 | 130 |
mTexture.setTexture(bmp); |
131 | 131 |
|
src/main/java/org/distorted/examples/sink/SinkRenderer.java | ||
---|---|---|
88 | 88 |
|
89 | 89 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
90 | 90 |
{ |
91 |
float min= width>height ? height : width; |
|
91 |
if( width<height ) mScale.set( width, width*mBmpRatio, 1 ); |
|
92 |
else mScale.set( height/mBmpRatio, height, 1 ); |
|
92 | 93 |
|
93 |
mScale.set( min, min*mBmpRatio, 1 ); |
|
94 | 94 |
mScreen.resize(width, height); |
95 | 95 |
} |
96 | 96 |
|
Also available in: Unified diff
Further corrections for the first apps.