Revision 392e16fd
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.java | ||
---|---|---|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
|
30 | 30 |
import org.distorted.library.Distorted; |
31 |
import org.distorted.library.DistortedFramebuffer; |
|
31 | 32 |
import org.distorted.library.DistortedTexture; |
32 | 33 |
import org.distorted.library.DistortedEffectQueues; |
33 | 34 |
import org.distorted.library.GridFlat; |
... | ... | |
50 | 51 |
|
51 | 52 |
private GLSurfaceView mView; |
52 | 53 |
private DistortedTexture[] mTexture; |
53 |
private DistortedEffectQueues[] mQueues;
|
|
54 |
private DistortedEffectQueues[] mEffects;
|
|
54 | 55 |
private GridFlat mGrid; |
56 |
private DistortedFramebuffer mScreen; |
|
55 | 57 |
private int bmpHeight, bmpWidth; |
56 | 58 |
|
57 | 59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
65 | 67 |
dDistort.add(new Static3D(-25,0,0)); |
66 | 68 |
Static3D mPoint = new Static3D(305, 380, 0); |
67 | 69 |
|
68 |
mQueues = new DistortedEffectQueues[NUM];
|
|
69 |
mQueues[0] = new DistortedEffectQueues();
|
|
70 |
mEffects = new DistortedEffectQueues[NUM];
|
|
71 |
mEffects[0] = new DistortedEffectQueues();
|
|
70 | 72 |
for(int i=1; i<NUM; i++) |
71 |
mQueues[i] = new DistortedEffectQueues(mQueues[0], Distorted.CLONE_VERTEX|Distorted.CLONE_FRAGMENT);
|
|
73 |
mEffects[i] = new DistortedEffectQueues(mEffects[0], Distorted.CLONE_VERTEX|Distorted.CLONE_FRAGMENT);
|
|
72 | 74 |
|
73 | 75 |
// Add the effects only to the first queue - all VERTEX and FRAGMENT effects are shared! |
74 | 76 |
// (Matrix effect cannot be shared as we have to display each Texture in a different location) |
75 |
mQueues[0].sink( new Static1D(8), mPoint, new Static4D(0,0,80,80)); // enlarge the nose |
|
76 |
mQueues[0].distort(dDistort,mPoint); // keep moving the whole bitmap left and right. |
|
77 |
mEffects[0].sink( new Static1D(8), mPoint, new Static4D(0,0,80,80)); // enlarge the nose |
|
78 |
mEffects[0].distort(dDistort,mPoint); // keep moving the whole bitmap left and right. |
|
79 |
|
|
80 |
mScreen = new DistortedFramebuffer(0); |
|
77 | 81 |
} |
78 | 82 |
|
79 | 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
107 | 111 |
|
108 | 112 |
long time = System.currentTimeMillis(); |
109 | 113 |
|
110 |
for(int i=NUM-1; i>=0; i--) mQueues[i].draw(time, mTexture[i], mGrid);
|
|
114 |
for(int i=NUM-1; i>=0; i--) mEffects[i].draw(time, mTexture[i], mGrid, mScreen);
|
|
111 | 115 |
} |
112 | 116 |
|
113 | 117 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
116 | 120 |
{ |
117 | 121 |
for(int i=NUM-1; i>=0; i--) |
118 | 122 |
{ |
119 |
mQueues[i].abortEffects(EffectTypes.MATRIX);
|
|
123 |
mEffects[i].abortEffects(EffectTypes.MATRIX);
|
|
120 | 124 |
} |
121 | 125 |
|
122 | 126 |
if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width ) |
... | ... | |
126 | 130 |
|
127 | 131 |
for(int i=NUM-1; i>=0; i--) |
128 | 132 |
{ |
129 |
mQueues[i].move( new Static3D((width-NUM*w)/2 +i*w ,0,0) );
|
|
130 |
mQueues[i].scale(factor);
|
|
133 |
mEffects[i].move( new Static3D((width-NUM*w)/2 +i*w ,0,0) );
|
|
134 |
mEffects[i].scale(factor);
|
|
131 | 135 |
} |
132 | 136 |
} |
133 | 137 |
else |
... | ... | |
138 | 142 |
|
139 | 143 |
for(int i=NUM-1; i>=0; i--) |
140 | 144 |
{ |
141 |
mQueues[i].move( new Static3D(i*w,(height-h)/2,0) );
|
|
142 |
mQueues[i].scale(factor);
|
|
145 |
mEffects[i].move( new Static3D(i*w,(height-h)/2,0) );
|
|
146 |
mEffects[i].scale(factor);
|
|
143 | 147 |
} |
144 | 148 |
} |
145 | 149 |
|
146 |
Distorted.onSurfaceChanged(width, height);
|
|
150 |
mScreen.resize(width, height);
|
|
147 | 151 |
} |
148 | 152 |
|
149 | 153 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Change in the API: we always have to create a DistortedFramebuffer to render to.