Revision 392e16fd
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/cubes/CubesRenderer.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
|
30 |
import org.distorted.library.DistortedFramebuffer; |
|
30 | 31 |
import org.distorted.library.DistortedTexture; |
31 | 32 |
import org.distorted.library.DistortedEffectQueues; |
32 | 33 |
import org.distorted.library.GridObject; |
... | ... | |
47 | 48 |
{ |
48 | 49 |
private GLSurfaceView mView; |
49 | 50 |
private DistortedTexture mTexture; |
50 |
private DistortedEffectQueues mQueues;
|
|
51 |
private DistortedEffectQueues mEffects;
|
|
51 | 52 |
private GridObject mGrid; |
53 |
private DistortedFramebuffer mScreen; |
|
52 | 54 |
private DynamicQuat mQuatInt1, mQuatInt2; |
53 | 55 |
private int mObjWidth, mObjHeight; |
54 | 56 |
|
... | ... | |
63 | 65 |
|
64 | 66 |
CubesActivity act = (CubesActivity)v.getContext(); |
65 | 67 |
|
66 |
mQueues = new DistortedEffectQueues();
|
|
68 |
mEffects = new DistortedEffectQueues();
|
|
67 | 69 |
mTexture = act.getTexture(); |
68 | 70 |
mGrid = act.getGrid(); |
69 | 71 |
|
... | ... | |
78 | 80 |
|
79 | 81 |
mQuatInt1.add(mQuat1); |
80 | 82 |
mQuatInt2.add(mQuat2); |
83 |
|
|
84 |
mScreen = new DistortedFramebuffer(0); |
|
81 | 85 |
} |
82 | 86 |
|
83 | 87 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
85 | 89 |
public void onDrawFrame(GL10 glUnused) |
86 | 90 |
{ |
87 | 91 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
88 |
mQueues.draw(System.currentTimeMillis(),mTexture,mGrid);
|
|
92 |
mEffects.draw(System.currentTimeMillis(),mTexture,mGrid, mScreen);
|
|
89 | 93 |
} |
90 | 94 |
|
91 | 95 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
94 | 98 |
{ |
95 | 99 |
mScreenMin = width<height ? width:height; |
96 | 100 |
|
97 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
101 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
98 | 102 |
float factor; |
99 | 103 |
|
100 | 104 |
if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object |
... | ... | |
106 | 110 |
factor = (0.8f*width)/mObjWidth; |
107 | 111 |
} |
108 | 112 |
|
109 |
mQueues.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
|
|
110 |
mQueues.scale(factor);
|
|
113 |
mEffects.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
|
|
114 |
mEffects.scale(factor);
|
|
111 | 115 |
Static3D center = new Static3D(mObjWidth/2,mObjHeight/2, 0); |
112 | 116 |
|
113 |
mQueues.quaternion(mQuatInt1, center);
|
|
114 |
mQueues.quaternion(mQuatInt2, center);
|
|
117 |
mEffects.quaternion(mQuatInt1, center);
|
|
118 |
mEffects.quaternion(mQuatInt2, center);
|
|
115 | 119 |
|
116 |
Distorted.onSurfaceChanged(width, height);
|
|
120 |
mScreen.resize(width, height);
|
|
117 | 121 |
} |
118 | 122 |
|
119 | 123 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Change in the API: we always have to create a DistortedFramebuffer to render to.