Revision 392e16fd
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/wind/WindRenderer.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
import org.distorted.examples.R; |
28 | 28 |
import org.distorted.library.Distorted; |
29 |
import org.distorted.library.DistortedFramebuffer; |
|
29 | 30 |
import org.distorted.library.GridCubes; |
30 | 31 |
import org.distorted.library.DistortedEffectQueues; |
31 | 32 |
import org.distorted.library.DistortedTexture; |
... | ... | |
43 | 44 |
class WindRenderer implements GLSurfaceView.Renderer |
44 | 45 |
{ |
45 | 46 |
private GLSurfaceView mView; |
46 |
private DistortedEffectQueues mQueues;
|
|
47 |
private DistortedEffectQueues mEffects;
|
|
47 | 48 |
private DistortedTexture mTexture; |
49 |
private DistortedFramebuffer mScreen; |
|
48 | 50 |
private GridCubes mGrid; |
49 |
private WindEffectsManager mEffects;
|
|
51 |
private WindEffectsManager mManager;
|
|
50 | 52 |
private int mObjWidth, mObjHeight; |
51 | 53 |
private int mWind; |
52 | 54 |
|
... | ... | |
57 | 59 |
mView = view; |
58 | 60 |
|
59 | 61 |
mGrid = new GridCubes(50,30,false); |
60 |
mQueues = new DistortedEffectQueues();
|
|
62 |
mEffects = new DistortedEffectQueues();
|
|
61 | 63 |
mTexture = new DistortedTexture(50,30); |
62 |
mEffects = new WindEffectsManager(mTexture); |
|
64 |
mManager = new WindEffectsManager(mTexture); |
|
65 |
mScreen = new DistortedFramebuffer(0); |
|
63 | 66 |
|
64 | 67 |
mObjWidth = mTexture.getWidth(); |
65 | 68 |
mObjHeight= mTexture.getHeight(); |
... | ... | |
70 | 73 |
void setWind(int wind) |
71 | 74 |
{ |
72 | 75 |
mWind = wind; |
73 |
mEffects.setWind(mWind);
|
|
76 |
mManager.setWind(mWind);
|
|
74 | 77 |
} |
75 | 78 |
|
76 | 79 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
78 | 81 |
public void onDrawFrame(GL10 glUnused) |
79 | 82 |
{ |
80 | 83 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
81 |
mQueues.draw(System.currentTimeMillis(),mTexture, mGrid);
|
|
84 |
mEffects.draw(System.currentTimeMillis(),mTexture, mGrid,mScreen);
|
|
82 | 85 |
} |
83 | 86 |
|
84 | 87 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
85 | 88 |
|
86 | 89 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
87 | 90 |
{ |
88 |
mQueues.abortAllEffects();
|
|
91 |
mEffects.abortAllEffects();
|
|
89 | 92 |
|
90 | 93 |
float factor = ( (float)(width<height? width:height) )/(mObjHeight + 1.4f*mObjWidth); |
91 | 94 |
|
92 |
mQueues.move( new Static3D( factor*mObjHeight*0.58f , factor*mObjHeight*0.08f , 0) );
|
|
93 |
mQueues.scale(factor);
|
|
95 |
mEffects.move( new Static3D( factor*mObjHeight*0.58f , factor*mObjHeight*0.08f , 0) );
|
|
96 |
mEffects.scale(factor);
|
|
94 | 97 |
|
95 | 98 |
Static1D angle = new Static1D(-45); |
96 | 99 |
Static3D axis = new Static3D(0,0,1); |
97 | 100 |
Static3D center= new Static3D(0,mObjHeight/2,0); |
98 | 101 |
|
99 |
mQueues.rotate(angle, axis, center); |
|
100 |
|
|
101 |
mEffects.apply(mQueues,mWind); |
|
102 |
|
|
103 |
Distorted.onSurfaceChanged(width, height); |
|
102 |
mEffects.rotate(angle, axis, center); |
|
103 |
mManager.apply(mEffects,mWind); |
|
104 |
mScreen.resize(width, height); |
|
104 | 105 |
} |
105 | 106 |
|
106 | 107 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Change in the API: we always have to create a DistortedFramebuffer to render to.