Revision e8b6aa95
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/sink/SinkRenderer.java | ||
---|---|---|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
|
30 | 30 |
import org.distorted.library.Distorted; |
31 |
import org.distorted.library.DistortedBitmap; |
|
31 |
import org.distorted.library.DistortedBitmapGrid; |
|
32 |
import org.distorted.library.DistortedObject; |
|
32 | 33 |
import org.distorted.library.EffectTypes; |
33 | 34 |
import org.distorted.library.type.Dynamic1D; |
34 | 35 |
import org.distorted.library.type.Static1D; |
35 |
import org.distorted.library.type.Static2D; |
|
36 | 36 |
import org.distorted.library.type.Static3D; |
37 | 37 |
import org.distorted.library.type.Static4D; |
38 | 38 |
|
... | ... | |
46 | 46 |
class SinkRenderer implements GLSurfaceView.Renderer |
47 | 47 |
{ |
48 | 48 |
private GLSurfaceView mView; |
49 |
private DistortedBitmap sinkBmp; |
|
49 |
private DistortedObject mObject; |
|
50 |
private DistortedBitmapGrid mGrid; |
|
50 | 51 |
private Static3D pLeft, pRight; |
51 | 52 |
private Static4D Region; |
52 | 53 |
private int bmpHeight, bmpWidth; |
... | ... | |
67 | 68 |
public void onDrawFrame(GL10 glUnused) |
68 | 69 |
{ |
69 | 70 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
70 |
sinkBmp.draw(System.currentTimeMillis());
|
|
71 |
mObject.draw(System.currentTimeMillis(), mGrid);
|
|
71 | 72 |
} |
72 | 73 |
|
73 | 74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
74 | 75 |
|
75 | 76 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
76 | 77 |
{ |
77 |
sinkBmp.abortEffects(EffectTypes.MATRIX);
|
|
78 |
mObject.abortEffects(EffectTypes.MATRIX);
|
|
78 | 79 |
|
79 | 80 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
80 | 81 |
{ |
81 | 82 |
int w = (height*bmpWidth)/bmpHeight; |
82 | 83 |
float factor = (float)height/bmpHeight; |
83 | 84 |
|
84 |
sinkBmp.move( new Static3D((width-w)/2,0,0) );
|
|
85 |
sinkBmp.scale( factor );
|
|
85 |
mObject.move( new Static3D((width-w)/2,0,0) );
|
|
86 |
mObject.scale( factor );
|
|
86 | 87 |
} |
87 | 88 |
else |
88 | 89 |
{ |
89 | 90 |
int h = (width*bmpHeight)/bmpWidth; |
90 | 91 |
float factor = (float)width/bmpWidth; |
91 | 92 |
|
92 |
sinkBmp.move( new Static3D(0,(height-h)/2,0) );
|
|
93 |
sinkBmp.scale( factor );
|
|
93 |
mObject.move( new Static3D(0,(height-h)/2,0) );
|
|
94 |
mObject.scale( factor );
|
|
94 | 95 |
} |
95 | 96 |
|
96 | 97 |
Distorted.onSurfaceChanged(width, height); |
... | ... | |
125 | 126 |
dSink.add(new Static1D( 1)); |
126 | 127 |
dSink.add(new Static1D(10)); |
127 | 128 |
|
128 |
sinkBmp = new DistortedBitmap(bitmap, 30); |
|
129 |
sinkBmp.sink( dSink, pLeft, Region); |
|
130 |
sinkBmp.sink( dSink, pRight,Region); |
|
129 |
mGrid = new DistortedBitmapGrid(30,30*bmpHeight/bmpWidth); |
|
130 |
mObject = new DistortedObject(bmpWidth,bmpHeight,1); |
|
131 |
mObject.setTexture(bitmap); |
|
132 |
|
|
133 |
mObject.sink( dSink, pLeft, Region); |
|
134 |
mObject.sink( dSink, pRight,Region); |
|
131 | 135 |
|
132 | 136 |
try |
133 | 137 |
{ |
Also available in: Unified diff
Major change in API: separate the GRID from DistortedObject; completely remove classes derived from DistortedObject.