Revision 392e16fd
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/listener/ListenerRenderer.java | ||
---|---|---|
29 | 29 |
import org.distorted.examples.R; |
30 | 30 |
|
31 | 31 |
import org.distorted.library.Distorted; |
32 |
import org.distorted.library.DistortedFramebuffer; |
|
32 | 33 |
import org.distorted.library.GridFlat; |
33 | 34 |
import org.distorted.library.DistortedTexture; |
34 | 35 |
import org.distorted.library.DistortedEffectQueues; |
... | ... | |
53 | 54 |
|
54 | 55 |
private GLSurfaceView mView; |
55 | 56 |
private DistortedTexture mTexture; |
56 |
private DistortedEffectQueues mQueues; |
|
57 |
private DistortedEffectQueues mEffects; |
|
58 |
private DistortedFramebuffer mScreen; |
|
57 | 59 |
private GridFlat mGrid; |
58 | 60 |
private int bmpHeight, bmpWidth; |
59 | 61 |
private Random mRnd; |
... | ... | |
64 | 66 |
{ |
65 | 67 |
Distorted.setMaxVertex(NUM_BUBBLES); |
66 | 68 |
mView = v; |
67 |
mQueues = new DistortedEffectQueues(); |
|
68 |
mQueues.registerForMessages(this); |
|
69 |
mEffects = new DistortedEffectQueues(); |
|
70 |
mEffects.registerForMessages(this); |
|
71 |
mScreen = new DistortedFramebuffer(0); |
|
69 | 72 |
mRnd = new Random(0); |
70 | 73 |
} |
71 | 74 |
|
... | ... | |
83 | 86 |
dDistort.add(new Static3D(0,0, 0)); |
84 | 87 |
dDistort.add(new Static3D(0,0,height)); |
85 | 88 |
|
86 |
return mQueues.distort(dDistort, new Static3D(pointx,pointy,0), new Static4D(0,0,radius,radius));
|
|
89 |
return mEffects.distort(dDistort, new Static3D(pointx,pointy,0), new Static4D(0,0,radius,radius));
|
|
87 | 90 |
} |
88 | 91 |
|
89 | 92 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
103 | 106 |
public void onDrawFrame(GL10 glUnused) |
104 | 107 |
{ |
105 | 108 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
106 |
mQueues.draw(System.currentTimeMillis(), mTexture,mGrid);
|
|
109 |
mEffects.draw(System.currentTimeMillis(), mTexture,mGrid,mScreen);
|
|
107 | 110 |
} |
108 | 111 |
|
109 | 112 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
110 | 113 |
|
111 | 114 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
112 | 115 |
{ |
113 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
116 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
114 | 117 |
|
115 | 118 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
116 | 119 |
{ |
117 | 120 |
int w = (height*bmpWidth)/bmpHeight; |
118 | 121 |
float factor = (float)height/bmpHeight; |
119 | 122 |
|
120 |
mQueues.move( new Static3D((width-w)/2,0,0) );
|
|
121 |
mQueues.scale(factor);
|
|
123 |
mEffects.move( new Static3D((width-w)/2,0,0) );
|
|
124 |
mEffects.scale(factor);
|
|
122 | 125 |
} |
123 | 126 |
else |
124 | 127 |
{ |
125 | 128 |
int h = (width*bmpHeight)/bmpWidth; |
126 | 129 |
float factor = (float)width/bmpWidth; |
127 | 130 |
|
128 |
mQueues.move( new Static3D(0,(height-h)/2,0) );
|
|
129 |
mQueues.scale(factor);
|
|
131 |
mEffects.move( new Static3D(0,(height-h)/2,0) );
|
|
132 |
mEffects.scale(factor);
|
|
130 | 133 |
} |
131 | 134 |
|
132 |
Distorted.onSurfaceChanged(width, height);
|
|
135 |
mScreen.resize(width, height);
|
|
133 | 136 |
} |
134 | 137 |
|
135 | 138 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Change in the API: we always have to create a DistortedFramebuffer to render to.