Revision 15aa7d94
Added by Leszek Koltunski almost 7 years ago
src/main/java/org/distorted/library/main/EffectQueuePostprocess.java | ||
---|---|---|
32 | 32 |
import org.distorted.library.program.LinkingException; |
33 | 33 |
import org.distorted.library.program.VertexCompilationException; |
34 | 34 |
import org.distorted.library.program.VertexUniformsException; |
35 |
import org.distorted.library.type.Static; |
|
36 |
import org.distorted.library.type.Static1D; |
|
37 |
import org.distorted.library.type.Static2D; |
|
38 |
import org.distorted.library.type.Static3D; |
|
39 |
import org.distorted.library.type.Static4D; |
|
40 |
import org.distorted.library.type.Static5D; |
|
41 | 35 |
|
42 | 36 |
import java.io.InputStream; |
43 | 37 |
import java.nio.ByteBuffer; |
... | ... | |
53 | 47 |
private static final int POS_DATA_SIZE= 2; // Post Program: size of the position data in elements |
54 | 48 |
private static final int TEX_DATA_SIZE= 2; // Post Program: size of the texture coordinate data in elements. |
55 | 49 |
|
56 |
private static final int NUM_UNIFORMS = 5; |
|
57 |
private static final int NUM_CACHE = 0; |
|
50 |
private static final int NUM_UNIFORMS = PostprocessEffect.NUM_UNIFORMS; |
|
58 | 51 |
private static final int INDEX = Effect.POSTPROCESS; |
59 | 52 |
|
60 | 53 |
private static final FloatBuffer mQuadPositions, mQuadTexture, mQuadTextureInv; |
... | ... | |
118 | 111 |
|
119 | 112 |
EffectQueuePostprocess(long id) |
120 | 113 |
{ |
121 |
super(id,NUM_UNIFORMS,NUM_CACHE,INDEX );
|
|
114 |
super(id,NUM_UNIFORMS,INDEX ); |
|
122 | 115 |
|
123 | 116 |
mQualityLevel = 0; |
124 | 117 |
mQualityScale = 1.0f; |
... | ... | |
177 | 170 |
|
178 | 171 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
179 | 172 |
|
180 |
private boolean compute(long currTime)
|
|
173 |
private synchronized void compute(long currTime)
|
|
181 | 174 |
{ |
182 |
if( currTime==mTime ) return false;
|
|
175 |
if( currTime==mTime ) return; |
|
183 | 176 |
if( mTime==0 ) mTime = currTime; |
184 | 177 |
long step = (currTime-mTime); |
185 | 178 |
|
... | ... | |
190 | 183 |
{ |
191 | 184 |
mCurrentDuration[i] += step; |
192 | 185 |
|
193 |
if( mInter[0][i]!=null && mInter[0][i].interpolateMain(mUniforms ,NUM_UNIFORMS*i, mCurrentDuration[i], step) )
|
|
186 |
if( mEffects[i].compute(mUniforms, NUM_UNIFORMS*i, mCurrentDuration[i], step) )
|
|
194 | 187 |
{ |
195 | 188 |
for(int j=0; j<mNumListeners; j++) |
196 |
EffectMessageSender.newMessage( mListeners.elementAt(j), |
|
197 |
EffectMessage.EFFECT_FINISHED, |
|
198 |
(mID[i]<<Effect.LENGTH)+Effect.POSTPROCESS, |
|
199 |
mName[i], |
|
200 |
mObjectID); |
|
189 |
EffectMessageSender.newMessage( mListeners.elementAt(j), EffectMessage.EFFECT_FINISHED, mEffects[i].getID(), mID); |
|
201 | 190 |
|
202 |
if( PostprocessEffect.isUnity(mName[i], mUniforms, NUM_UNIFORMS*i) )
|
|
191 |
if( PostprocessEffect.isUnity( mEffects[i].getName(), mUniforms, NUM_UNIFORMS*i) )
|
|
203 | 192 |
{ |
204 |
remove(i); |
|
205 |
i--; |
|
193 |
remove(i--); |
|
206 | 194 |
continue; |
207 | 195 |
} |
208 |
else mInter[0][i] = null; |
|
209 | 196 |
} |
210 | 197 |
|
211 |
if( mInter[1][i]!=null ) mInter[1][i].interpolateMain( mUniforms, NUM_UNIFORMS*i+1, mCurrentDuration[i], step); |
|
212 |
|
|
213 | 198 |
halo = (int)mUniforms[NUM_UNIFORMS*i]; |
214 | 199 |
if( halo>mHalo ) mHalo = halo; |
215 | 200 |
} |
216 | 201 |
|
217 | 202 |
mTime = currTime; |
218 |
|
|
219 |
return true; |
|
220 |
} |
|
221 |
|
|
222 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
223 |
|
|
224 |
protected void moveEffect(int index) |
|
225 |
{ |
|
226 |
mUniforms[NUM_UNIFORMS*index ] = mUniforms[NUM_UNIFORMS*(index+1) ]; |
|
227 |
mUniforms[NUM_UNIFORMS*index+1] = mUniforms[NUM_UNIFORMS*(index+1)+1]; |
|
228 |
mUniforms[NUM_UNIFORMS*index+2] = mUniforms[NUM_UNIFORMS*(index+1)+2]; |
|
229 |
mUniforms[NUM_UNIFORMS*index+3] = mUniforms[NUM_UNIFORMS*(index+1)+3]; |
|
230 |
mUniforms[NUM_UNIFORMS*index+4] = mUniforms[NUM_UNIFORMS*(index+1)+4]; |
|
231 | 203 |
} |
232 | 204 |
|
233 | 205 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
383 | 355 |
{ |
384 | 356 |
|
385 | 357 |
} |
386 |
|
|
387 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
388 |
|
|
389 |
synchronized long add(PostprocessEffect pe) |
|
390 |
{ |
|
391 |
if( mMax[INDEX]>mNumEffects ) |
|
392 |
{ |
|
393 |
int dim0 = 0; |
|
394 |
|
|
395 |
if( pe.mDynamic0 != null ) |
|
396 |
{ |
|
397 |
mInter[0][mNumEffects] = pe.mDynamic0; |
|
398 |
dim0 = pe.mDynamic0.getDimension(); |
|
399 |
} |
|
400 |
else |
|
401 |
{ |
|
402 |
mInter[0][mNumEffects] = null; |
|
403 |
|
|
404 |
if( pe.mStatic0 != null ) |
|
405 |
{ |
|
406 |
Static s = pe.mStatic0; |
|
407 |
dim0 = s.getDimension(); |
|
408 |
|
|
409 |
switch( dim0 ) |
|
410 |
{ |
|
411 |
case 5 : mUniforms[NUM_UNIFORMS*mNumEffects + 4] = ((Static5D)s).getV(); |
|
412 |
case 4 : mUniforms[NUM_UNIFORMS*mNumEffects + 3] = ((Static4D)s).getW(); |
|
413 |
case 3 : mUniforms[NUM_UNIFORMS*mNumEffects + 2] = ((Static3D)s).getZ(); |
|
414 |
case 2 : mUniforms[NUM_UNIFORMS*mNumEffects + 1] = ((Static2D)s).getY(); |
|
415 |
case 1 : mUniforms[NUM_UNIFORMS*mNumEffects ] = ((Static1D)s).getX(); |
|
416 |
} |
|
417 |
} |
|
418 |
} |
|
419 |
|
|
420 |
mInter[1][mNumEffects] = null; |
|
421 |
|
|
422 |
if( pe.mStatic1 != null ) |
|
423 |
{ |
|
424 |
Static s = pe.mStatic1; |
|
425 |
int dim1 = s.getDimension(); |
|
426 |
|
|
427 |
switch( dim1 ) |
|
428 |
{ |
|
429 |
case 5 : mUniforms[NUM_UNIFORMS*mNumEffects + dim0 + 4] = ((Static5D)s).getV(); |
|
430 |
case 4 : mUniforms[NUM_UNIFORMS*mNumEffects + dim0 + 3] = ((Static4D)s).getW(); |
|
431 |
case 3 : mUniforms[NUM_UNIFORMS*mNumEffects + dim0 + 2] = ((Static3D)s).getZ(); |
|
432 |
case 2 : mUniforms[NUM_UNIFORMS*mNumEffects + dim0 + 1] = ((Static2D)s).getY(); |
|
433 |
case 1 : mUniforms[NUM_UNIFORMS*mNumEffects + dim0 ] = ((Static1D)s).getX(); |
|
434 |
} |
|
435 |
} |
|
436 |
|
|
437 |
return addBase(pe); |
|
438 |
} |
|
439 |
|
|
440 |
return -1; |
|
441 |
} |
|
442 | 358 |
} |
Also available in: Unified diff
Progress with support for Effect classes.