Revision 392e16fd
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/bean/BeanRenderer.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
|
30 |
import org.distorted.library.DistortedFramebuffer; |
|
30 | 31 |
import org.distorted.library.EffectTypes; |
31 | 32 |
import org.distorted.library.Distorted; |
32 | 33 |
import org.distorted.library.DistortedTexture; |
... | ... | |
47 | 48 |
{ |
48 | 49 |
private GLSurfaceView mView; |
49 | 50 |
private DistortedTexture mTexture; |
50 |
private DistortedEffectQueues mQueues; |
|
51 |
private DistortedEffectQueues mEffects; |
|
52 |
private DistortedFramebuffer mScreen; |
|
51 | 53 |
private GridFlat mGrid; |
52 | 54 |
private int bmpHeight, bmpWidth; |
53 | 55 |
|
... | ... | |
83 | 85 |
dRight.add(p1); |
84 | 86 |
dRight.add(p1); |
85 | 87 |
|
86 |
mQueues = new DistortedEffectQueues(); |
|
87 |
mQueues.distort(dLeft , pLeft , rLeft ); |
|
88 |
mQueues.distort(dRight, pRight, rRight); |
|
88 |
mEffects = new DistortedEffectQueues(); |
|
89 |
mEffects.distort(dLeft , pLeft , rLeft ); |
|
90 |
mEffects.distort(dRight, pRight, rRight); |
|
91 |
|
|
92 |
mScreen = new DistortedFramebuffer(0); |
|
89 | 93 |
} |
90 | 94 |
|
91 | 95 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
93 | 97 |
public void onDrawFrame(GL10 glUnused) |
94 | 98 |
{ |
95 | 99 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
96 |
mQueues.draw(System.currentTimeMillis(), mTexture, mGrid);
|
|
100 |
mEffects.draw(System.currentTimeMillis(), mTexture, mGrid, mScreen);
|
|
97 | 101 |
} |
98 | 102 |
|
99 | 103 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
100 | 104 |
|
101 | 105 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
102 | 106 |
{ |
103 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
107 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
104 | 108 |
|
105 | 109 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
106 | 110 |
{ |
107 | 111 |
int w = (height*bmpWidth)/bmpHeight; |
108 | 112 |
float factor = (float)height/bmpHeight; |
109 | 113 |
|
110 |
mQueues.move( new Static3D((width-w)/2,0,0) );
|
|
111 |
mQueues.scale(factor);
|
|
114 |
mEffects.move( new Static3D((width-w)/2,0,0) );
|
|
115 |
mEffects.scale(factor);
|
|
112 | 116 |
} |
113 | 117 |
else |
114 | 118 |
{ |
115 | 119 |
int h = (width*bmpHeight)/bmpWidth; |
116 | 120 |
float factor = (float)width/bmpWidth; |
117 | 121 |
|
118 |
mQueues.move( new Static3D(0,(height-h)/2,0) );
|
|
119 |
mQueues.scale(factor);
|
|
122 |
mEffects.move( new Static3D(0,(height-h)/2,0) );
|
|
123 |
mEffects.scale(factor);
|
|
120 | 124 |
} |
121 | 125 |
|
122 |
Distorted.onSurfaceChanged(width, height);
|
|
126 |
mScreen.resize(width, height);
|
|
123 | 127 |
} |
124 | 128 |
|
125 | 129 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Change in the API: we always have to create a DistortedFramebuffer to render to.