Revision 392e16fd
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/check/CheckRenderer.java | ||
---|---|---|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
|
30 | 30 |
import org.distorted.library.Distorted; |
31 |
import org.distorted.library.DistortedFramebuffer; |
|
31 | 32 |
import org.distorted.library.DistortedTexture; |
32 | 33 |
import org.distorted.library.DistortedEffectQueues; |
33 | 34 |
import org.distorted.library.GridFlat; |
... | ... | |
56 | 57 |
|
57 | 58 |
private GLSurfaceView mView; |
58 | 59 |
private DistortedTexture mTexture; |
59 |
private DistortedEffectQueues mQueues;
|
|
60 |
private DistortedEffectQueues mEffects;
|
|
60 | 61 |
private GridFlat mGrid; |
62 |
private DistortedFramebuffer mScreen; |
|
61 | 63 |
private int bmpHeight, bmpWidth; |
62 | 64 |
|
63 | 65 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
65 | 67 |
CheckRenderer(GLSurfaceView view) |
66 | 68 |
{ |
67 | 69 |
mView = view; |
68 |
mQueues = new DistortedEffectQueues();
|
|
70 |
mEffects = new DistortedEffectQueues();
|
|
69 | 71 |
|
70 | 72 |
CheckActivity act = (CheckActivity)mView.getContext(); |
71 | 73 |
|
72 | 74 |
Distorted.setMaxVertex(act.getMaxV()); |
73 | 75 |
Distorted.setMaxFragment(act.getMaxF()); |
76 |
|
|
77 |
mScreen = new DistortedFramebuffer(0); |
|
74 | 78 |
} |
75 | 79 |
|
76 | 80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
78 | 82 |
public void onDrawFrame(GL10 glUnused) |
79 | 83 |
{ |
80 | 84 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
81 |
mQueues.draw(System.currentTimeMillis(), mTexture, mGrid);
|
|
85 |
mEffects.draw(System.currentTimeMillis(), mTexture, mGrid, mScreen);
|
|
82 | 86 |
} |
83 | 87 |
|
84 | 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
85 | 89 |
|
86 | 90 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
87 | 91 |
{ |
88 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
92 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
89 | 93 |
|
90 | 94 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
91 | 95 |
{ |
92 | 96 |
int w = (height*bmpWidth)/bmpHeight; |
93 | 97 |
float factor = (float)height/bmpHeight; |
94 | 98 |
|
95 |
mQueues.move( new Static3D((width-w)/2,0,0) );
|
|
96 |
mQueues.scale(factor);
|
|
99 |
mEffects.move( new Static3D((width-w)/2,0,0) );
|
|
100 |
mEffects.scale(factor);
|
|
97 | 101 |
} |
98 | 102 |
else |
99 | 103 |
{ |
100 | 104 |
int h = (width*bmpHeight)/bmpWidth; |
101 | 105 |
float factor = (float)width/bmpWidth; |
102 | 106 |
|
103 |
mQueues.move( new Static3D(0,(height-h)/2,0) );
|
|
104 |
mQueues.scale(factor);
|
|
107 |
mEffects.move( new Static3D(0,(height-h)/2,0) );
|
|
108 |
mEffects.scale(factor);
|
|
105 | 109 |
} |
106 | 110 |
|
107 |
Distorted.onSurfaceChanged(width, height);
|
|
111 |
mScreen.resize(width, height);
|
|
108 | 112 |
} |
109 | 113 |
|
110 | 114 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
146 | 150 |
dSwirl.add(new Static3D( 0, bmpHeight/2, 0)); |
147 | 151 |
dSwirl.add(new Static3D( bmpWidth, bmpHeight/2, 0)); |
148 | 152 |
|
149 |
long swirlEffectID = mQueues.swirl( new Static1D(30), dSwirl, new Static4D( 0,0,40,40) );
|
|
153 |
long swirlEffectID = mEffects.swirl( new Static1D(30), dSwirl, new Static4D( 0,0,40,40) );
|
|
150 | 154 |
|
151 | 155 |
if( swirlEffectID<0 ) |
152 | 156 |
{ |
... | ... | |
157 | 161 |
dDeform.add(new Static3D( 0, 0,0)); |
158 | 162 |
dDeform.add(new Static3D( 0,-bmpHeight,0)); |
159 | 163 |
|
160 |
long deformEffectID = mQueues.deform(dDeform, new Static3D(bmpWidth/2,0,0) );
|
|
164 |
long deformEffectID = mEffects.deform(dDeform, new Static3D(bmpWidth/2,0,0) );
|
|
161 | 165 |
|
162 | 166 |
if( deformEffectID<0 ) |
163 | 167 |
{ |
... | ... | |
170 | 174 |
inter.add(new Static1D(0)); |
171 | 175 |
inter.add(new Static1D(1)); |
172 | 176 |
|
173 |
long chromaEffectID = mQueues.chroma(inter, color);
|
|
177 |
long chromaEffectID = mEffects.chroma(inter, color);
|
|
174 | 178 |
|
175 | 179 |
if( chromaEffectID<0 ) |
176 | 180 |
{ |
Also available in: Unified diff
Change in the API: we always have to create a DistortedFramebuffer to render to.