Revision f6d884d5
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/sink/SinkRenderer.java | ||
---|---|---|
29 | 29 |
|
30 | 30 |
import org.distorted.library.Distorted; |
31 | 31 |
import org.distorted.library.GridFlat; |
32 |
import org.distorted.library.DistortedObject; |
|
32 |
import org.distorted.library.DistortedTexture; |
|
33 |
import org.distorted.library.DistortedEffectQueues; |
|
33 | 34 |
import org.distorted.library.EffectTypes; |
34 | 35 |
import org.distorted.library.type.Dynamic1D; |
35 | 36 |
import org.distorted.library.type.Static1D; |
... | ... | |
46 | 47 |
class SinkRenderer implements GLSurfaceView.Renderer |
47 | 48 |
{ |
48 | 49 |
private GLSurfaceView mView; |
49 |
private DistortedObject mObject; |
|
50 |
private DistortedTexture mTexture; |
|
51 |
private DistortedEffectQueues mQueues; |
|
50 | 52 |
private GridFlat mGrid; |
51 |
private Static3D pLeft, pRight; |
|
52 |
private Static4D Region; |
|
53 | 53 |
private int bmpHeight, bmpWidth; |
54 | 54 |
|
55 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
58 | 58 |
{ |
59 | 59 |
mView = v; |
60 | 60 |
|
61 |
pLeft = new Static3D(214, 206, 0); |
|
62 |
pRight= new Static3D(390, 212, 0); |
|
63 |
Region= new Static4D(0,0,60,60); |
|
61 |
Static3D pLeft = new Static3D(214, 206, 0); |
|
62 |
Static3D pRight= new Static3D(390, 212, 0); |
|
63 |
Static4D Region= new Static4D(0,0,60,60); |
|
64 |
|
|
65 |
Dynamic1D dSink = new Dynamic1D(2000,0.0f); |
|
66 |
dSink.add(new Static1D( 1)); |
|
67 |
dSink.add(new Static1D(10)); |
|
68 |
|
|
69 |
mQueues = new DistortedEffectQueues(); |
|
70 |
mQueues.sink( dSink, pLeft, Region); |
|
71 |
mQueues.sink( dSink, pRight,Region); |
|
64 | 72 |
} |
65 | 73 |
|
66 | 74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
68 | 76 |
public void onDrawFrame(GL10 glUnused) |
69 | 77 |
{ |
70 | 78 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
71 |
mObject.draw(System.currentTimeMillis(), mGrid);
|
|
79 |
mQueues.draw(System.currentTimeMillis(), mTexture,mGrid);
|
|
72 | 80 |
} |
73 | 81 |
|
74 | 82 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
75 | 83 |
|
76 | 84 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
77 | 85 |
{ |
78 |
mObject.abortEffects(EffectTypes.MATRIX);
|
|
86 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
79 | 87 |
|
80 | 88 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
81 | 89 |
{ |
82 | 90 |
int w = (height*bmpWidth)/bmpHeight; |
83 | 91 |
float factor = (float)height/bmpHeight; |
84 | 92 |
|
85 |
mObject.move( new Static3D((width-w)/2,0,0) );
|
|
86 |
mObject.scale( factor );
|
|
93 |
mQueues.move( new Static3D((width-w)/2,0,0) );
|
|
94 |
mQueues.scale( factor );
|
|
87 | 95 |
} |
88 | 96 |
else |
89 | 97 |
{ |
90 | 98 |
int h = (width*bmpHeight)/bmpWidth; |
91 | 99 |
float factor = (float)width/bmpWidth; |
92 | 100 |
|
93 |
mObject.move( new Static3D(0,(height-h)/2,0) );
|
|
94 |
mObject.scale( factor );
|
|
101 |
mQueues.move( new Static3D(0,(height-h)/2,0) );
|
|
102 |
mQueues.scale( factor );
|
|
95 | 103 |
} |
96 | 104 |
|
97 | 105 |
Distorted.onSurfaceChanged(width, height); |
... | ... | |
122 | 130 |
bmpHeight = bitmap.getHeight(); |
123 | 131 |
bmpWidth = bitmap.getWidth(); |
124 | 132 |
|
125 |
Dynamic1D dSink = new Dynamic1D(2000,0.0f);
|
|
126 |
dSink.add(new Static1D( 1));
|
|
127 |
dSink.add(new Static1D(10));
|
|
133 |
mGrid = new GridFlat(30,30*bmpHeight/bmpWidth);
|
|
134 |
mTexture = new DistortedTexture(bmpWidth,bmpHeight,0);
|
|
135 |
mTexture.setTexture(bitmap);
|
|
128 | 136 |
|
129 |
mGrid = new GridFlat(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); |
|
135 |
|
|
136 | 137 |
try |
137 | 138 |
{ |
138 | 139 |
Distorted.onSurfaceCreated(mView.getContext()); |
Also available in: Unified diff
Complete the split DistortedObject -> (DistortedTexture,DistortedEffectQueue)