Revision 392e16fd
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java | ||
---|---|---|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
import org.distorted.library.Distorted; |
30 | 30 |
import org.distorted.library.DistortedEffectQueues; |
31 |
import org.distorted.library.DistortedFramebuffer; |
|
31 | 32 |
import org.distorted.library.DistortedTexture; |
32 | 33 |
import org.distorted.library.GridFlat; |
33 | 34 |
import org.distorted.library.EffectTypes; |
... | ... | |
47 | 48 |
class CatAndDogRenderer implements GLSurfaceView.Renderer |
48 | 49 |
{ |
49 | 50 |
private GLSurfaceView mView; |
50 |
private DistortedEffectQueues mQueues;
|
|
51 |
private DistortedEffectQueues mEffects;
|
|
51 | 52 |
private DistortedTexture mTexture; |
52 | 53 |
private GridFlat mGrid; |
54 |
private DistortedFramebuffer mScreen; |
|
53 | 55 |
private int bmpHeight, bmpWidth; |
54 | 56 |
|
55 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
59 | 61 |
mView = v; |
60 | 62 |
|
61 | 63 |
mGrid = new GridFlat(1,1); // no vertex effects, grid can be a (1x1) quad. |
62 |
mQueues = new DistortedEffectQueues();
|
|
64 |
mEffects = new DistortedEffectQueues();
|
|
63 | 65 |
|
64 | 66 |
Static4D chromaRegion= new Static4D( 530, 200,100,100); |
65 | 67 |
Static4D alphaRegion = new Static4D( 230, 200,100,100); |
... | ... | |
68 | 70 |
chromaDyn.add(new Static1D(1)); |
69 | 71 |
chromaDyn.add(new Static1D(0)); |
70 | 72 |
|
71 |
mQueues.chroma(chromaDyn, new Static3D(1,0,0), chromaRegion ,true);
|
|
73 |
mEffects.chroma(chromaDyn, new Static3D(1,0,0), chromaRegion ,true);
|
|
72 | 74 |
|
73 | 75 |
Dynamic1D alphaDyn = new Dynamic1D(3000,0.0f); |
74 | 76 |
alphaDyn.add(new Static1D(1)); |
75 | 77 |
alphaDyn.add(new Static1D(0)); |
76 | 78 |
|
77 |
mQueues.alpha( alphaDyn, alphaRegion, false ); |
|
79 |
mEffects.alpha( alphaDyn, alphaRegion, false ); |
|
80 |
|
|
81 |
mScreen = new DistortedFramebuffer(0); |
|
78 | 82 |
} |
79 | 83 |
|
80 | 84 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
82 | 86 |
public void onDrawFrame(GL10 glUnused) |
83 | 87 |
{ |
84 | 88 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
85 |
mQueues.draw(System.currentTimeMillis(), mTexture, mGrid);
|
|
89 |
mEffects.draw(System.currentTimeMillis(), mTexture, mGrid, mScreen);
|
|
86 | 90 |
} |
87 | 91 |
|
88 | 92 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
141 | 145 |
diRotate.add(new Static1D( 0)); |
142 | 146 |
diRotate.add(new Static1D(360)); |
143 | 147 |
|
144 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
148 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
145 | 149 |
|
146 |
mQueues.move(diMove);
|
|
147 |
mQueues.scale(diScale);
|
|
148 |
mQueues.rotate( diRotate, new Static3D(0,0,1), new Static3D(bmpWidth/2,bmpHeight/2,0) );
|
|
150 |
mEffects.move(diMove);
|
|
151 |
mEffects.scale(diScale);
|
|
152 |
mEffects.rotate( diRotate, new Static3D(0,0,1), new Static3D(bmpWidth/2,bmpHeight/2,0) );
|
|
149 | 153 |
|
150 |
Distorted.onSurfaceChanged(width, height);
|
|
154 |
mScreen.resize(width, height);
|
|
151 | 155 |
} |
152 | 156 |
} |
Also available in: Unified diff
Change in the API: we always have to create a DistortedFramebuffer to render to.