Revision 392e16fd
Added by Leszek Koltunski almost 9 years ago
| src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.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.GridFlat; |
| 30 | 31 |
import org.distorted.library.DistortedEffectQueues; |
| 31 | 32 |
import org.distorted.library.DistortedTexture; |
| ... | ... | |
| 43 | 44 |
class AroundTheWorldRenderer implements GLSurfaceView.Renderer |
| 44 | 45 |
{
|
| 45 | 46 |
private GLSurfaceView mView; |
| 46 |
private DistortedEffectQueues mQueues;
|
|
| 47 |
private DistortedEffectQueues mEffects;
|
|
| 47 | 48 |
private DistortedTexture mTexture; |
| 48 | 49 |
private GridFlat mGrid; |
| 49 |
private AroundTheWorldEffectsManager mEffects; |
|
| 50 |
private DistortedFramebuffer mScreen; |
|
| 51 |
private AroundTheWorldEffectsManager mManager; |
|
| 50 | 52 |
private int mObjWidth, mObjHeight; |
| 51 | 53 |
|
| 52 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 57 | 59 |
Distorted.setMaxFragment(9); |
| 58 | 60 |
|
| 59 | 61 |
mView = view; |
| 60 |
mEffects = new AroundTheWorldEffectsManager(); |
|
| 61 |
mQueues = new DistortedEffectQueues(); |
|
| 62 |
mEffects.apply(mQueues); |
|
| 62 |
mManager = new AroundTheWorldEffectsManager(); |
|
| 63 |
mEffects = new DistortedEffectQueues(); |
|
| 64 |
mManager.apply(mEffects); |
|
| 65 |
mScreen = new DistortedFramebuffer(0); |
|
| 63 | 66 |
} |
| 64 | 67 |
|
| 65 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 66 | 69 |
|
| 67 | 70 |
AroundTheWorldEffectsManager getManager() |
| 68 | 71 |
{
|
| 69 |
return mEffects;
|
|
| 72 |
return mManager;
|
|
| 70 | 73 |
} |
| 71 | 74 |
|
| 72 | 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 74 | 77 |
public void onDrawFrame(GL10 glUnused) |
| 75 | 78 |
{
|
| 76 | 79 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| 77 |
mQueues.draw(System.currentTimeMillis(), mTexture, mGrid);
|
|
| 80 |
mEffects.draw(System.currentTimeMillis(), mTexture, mGrid, mScreen);
|
|
| 78 | 81 |
} |
| 79 | 82 |
|
| 80 | 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 81 | 84 |
|
| 82 | 85 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 83 | 86 |
{
|
| 84 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
| 87 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
| 85 | 88 |
|
| 86 | 89 |
if( (float)mObjHeight/mObjWidth > (float)height/width ) |
| 87 | 90 |
{
|
| 88 | 91 |
int w = (height*mObjWidth)/mObjHeight; |
| 89 | 92 |
float factor = (float)height/mObjHeight; |
| 90 |
mQueues.move( new Static3D((width-w)/2,0,0) );
|
|
| 91 |
mQueues.scale(factor);
|
|
| 93 |
mEffects.move( new Static3D((width-w)/2,0,0) );
|
|
| 94 |
mEffects.scale(factor);
|
|
| 92 | 95 |
} |
| 93 | 96 |
else |
| 94 | 97 |
{
|
| 95 | 98 |
int h = (width*mObjHeight)/mObjWidth; |
| 96 | 99 |
float factor = (float)width/mObjWidth; |
| 97 |
mQueues.move( new Static3D(0,(height-h)/2,0) );
|
|
| 98 |
mQueues.scale(factor);
|
|
| 100 |
mEffects.move( new Static3D(0,(height-h)/2,0) );
|
|
| 101 |
mEffects.scale(factor);
|
|
| 99 | 102 |
} |
| 100 | 103 |
|
| 101 |
Distorted.onSurfaceChanged(width, height);
|
|
| 104 |
mScreen.resize(width,height);
|
|
| 102 | 105 |
} |
| 103 | 106 |
|
| 104 | 107 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/bean/BeanRenderer.java | ||
|---|---|---|
| 27 | 27 |
|
| 28 | 28 |
import org.distorted.examples.R; |
| 29 | 29 |
|
| 30 |
import org.distorted.library.DistortedFramebuffer; |
|
| 30 | 31 |
import org.distorted.library.EffectTypes; |
| 31 | 32 |
import org.distorted.library.Distorted; |
| 32 | 33 |
import org.distorted.library.DistortedTexture; |
| ... | ... | |
| 47 | 48 |
{
|
| 48 | 49 |
private GLSurfaceView mView; |
| 49 | 50 |
private DistortedTexture mTexture; |
| 50 |
private DistortedEffectQueues mQueues; |
|
| 51 |
private DistortedEffectQueues mEffects; |
|
| 52 |
private DistortedFramebuffer mScreen; |
|
| 51 | 53 |
private GridFlat mGrid; |
| 52 | 54 |
private int bmpHeight, bmpWidth; |
| 53 | 55 |
|
| ... | ... | |
| 83 | 85 |
dRight.add(p1); |
| 84 | 86 |
dRight.add(p1); |
| 85 | 87 |
|
| 86 |
mQueues = new DistortedEffectQueues(); |
|
| 87 |
mQueues.distort(dLeft , pLeft , rLeft ); |
|
| 88 |
mQueues.distort(dRight, pRight, rRight); |
|
| 88 |
mEffects = new DistortedEffectQueues(); |
|
| 89 |
mEffects.distort(dLeft , pLeft , rLeft ); |
|
| 90 |
mEffects.distort(dRight, pRight, rRight); |
|
| 91 |
|
|
| 92 |
mScreen = new DistortedFramebuffer(0); |
|
| 89 | 93 |
} |
| 90 | 94 |
|
| 91 | 95 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 93 | 97 |
public void onDrawFrame(GL10 glUnused) |
| 94 | 98 |
{
|
| 95 | 99 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| 96 |
mQueues.draw(System.currentTimeMillis(), mTexture, mGrid);
|
|
| 100 |
mEffects.draw(System.currentTimeMillis(), mTexture, mGrid, mScreen);
|
|
| 97 | 101 |
} |
| 98 | 102 |
|
| 99 | 103 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 100 | 104 |
|
| 101 | 105 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 102 | 106 |
{
|
| 103 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
| 107 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
| 104 | 108 |
|
| 105 | 109 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
| 106 | 110 |
{
|
| 107 | 111 |
int w = (height*bmpWidth)/bmpHeight; |
| 108 | 112 |
float factor = (float)height/bmpHeight; |
| 109 | 113 |
|
| 110 |
mQueues.move( new Static3D((width-w)/2,0,0) );
|
|
| 111 |
mQueues.scale(factor);
|
|
| 114 |
mEffects.move( new Static3D((width-w)/2,0,0) );
|
|
| 115 |
mEffects.scale(factor);
|
|
| 112 | 116 |
} |
| 113 | 117 |
else |
| 114 | 118 |
{
|
| 115 | 119 |
int h = (width*bmpHeight)/bmpWidth; |
| 116 | 120 |
float factor = (float)width/bmpWidth; |
| 117 | 121 |
|
| 118 |
mQueues.move( new Static3D(0,(height-h)/2,0) );
|
|
| 119 |
mQueues.scale(factor);
|
|
| 122 |
mEffects.move( new Static3D(0,(height-h)/2,0) );
|
|
| 123 |
mEffects.scale(factor);
|
|
| 120 | 124 |
} |
| 121 | 125 |
|
| 122 |
Distorted.onSurfaceChanged(width, height);
|
|
| 126 |
mScreen.resize(width, height);
|
|
| 123 | 127 |
} |
| 124 | 128 |
|
| 125 | 129 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 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 |
} |
| 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 |
{
|
| 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 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/deform/DeformRenderer.java | ||
|---|---|---|
| 23 | 23 |
import javax.microedition.khronos.opengles.GL10; |
| 24 | 24 |
|
| 25 | 25 |
import org.distorted.library.Distorted; |
| 26 |
import org.distorted.library.DistortedFramebuffer; |
|
| 26 | 27 |
import org.distorted.library.DistortedTexture; |
| 27 | 28 |
import org.distorted.library.DistortedEffectQueues; |
| 28 | 29 |
import org.distorted.library.GridObject; |
| ... | ... | |
| 51 | 52 |
|
| 52 | 53 |
private GLSurfaceView mView; |
| 53 | 54 |
private DistortedTexture fpsTexture, stretchTexture; |
| 54 |
private DistortedEffectQueues fpsQueues, stretchQueues;
|
|
| 55 |
private DistortedEffectQueues fpsEffects, stretchEffects;
|
|
| 55 | 56 |
private GridObject fpsGrid, stretchGrid; |
| 57 |
private DistortedFramebuffer mScreen; |
|
| 56 | 58 |
private Static3D touchPoint; |
| 57 | 59 |
|
| 58 | 60 |
private Dynamic3D mReleasedDistortDynamic; |
| ... | ... | |
| 90 | 92 |
mPaint.setAntiAlias(true); |
| 91 | 93 |
mPaint.setTextAlign(Paint.Align.CENTER); |
| 92 | 94 |
|
| 93 |
fpsQueues = new DistortedEffectQueues();
|
|
| 94 |
stretchQueues = new DistortedEffectQueues();
|
|
| 95 |
fpsEffects = new DistortedEffectQueues();
|
|
| 96 |
stretchEffects = new DistortedEffectQueues();
|
|
| 95 | 97 |
|
| 96 | 98 |
mRegion = new Static4D(0,0,50,50); |
| 97 | 99 |
|
| ... | ... | |
| 147 | 149 |
} |
| 148 | 150 |
|
| 149 | 151 |
mMovingShearDynamic.add(vShear[0]); |
| 152 |
|
|
| 153 |
mScreen = new DistortedFramebuffer(0); |
|
| 150 | 154 |
} |
| 151 | 155 |
|
| 152 | 156 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 178 | 182 |
|
| 179 | 183 |
long time = System.currentTimeMillis(); |
| 180 | 184 |
|
| 181 |
stretchQueues.draw(time,stretchTexture,stretchGrid);
|
|
| 185 |
stretchEffects.draw(time,stretchTexture,stretchGrid,mScreen);
|
|
| 182 | 186 |
|
| 183 | 187 |
mPaint.setColor(0xffffffff); |
| 184 | 188 |
fpsCanvas.drawRect(0, 0, fpsW, fpsH, mPaint); |
| ... | ... | |
| 186 | 190 |
fpsCanvas.drawText(fpsString, fpsW/2, 5*fpsH/6, mPaint); |
| 187 | 191 |
|
| 188 | 192 |
fpsTexture.setTexture(fpsBitmap); |
| 189 |
fpsQueues.draw(time,fpsTexture,fpsGrid);
|
|
| 193 |
fpsEffects.draw(time,fpsTexture,fpsGrid,mScreen);
|
|
| 190 | 194 |
|
| 191 | 195 |
computeFPS(time); |
| 192 | 196 |
} |
| ... | ... | |
| 198 | 202 |
scrHeight = height; |
| 199 | 203 |
scrWidth = width; |
| 200 | 204 |
|
| 201 |
Distorted.onSurfaceChanged(width, height); |
|
| 202 |
|
|
| 203 | 205 |
if( !bitmapCreated ) |
| 204 | 206 |
{
|
| 205 | 207 |
createBitmap(scrWidth/2,scrHeight/2); |
| 206 |
stretchQueues.abortAllEffects();
|
|
| 207 |
fpsQueues.abortAllEffects();
|
|
| 208 |
stretchQueues.move( new Static3D(scrWidth/4,scrHeight/4,0) );
|
|
| 209 |
fpsQueues.move( new Static3D(5,5,0) );
|
|
| 208 |
stretchEffects.abortAllEffects();
|
|
| 209 |
fpsEffects.abortAllEffects();
|
|
| 210 |
stretchEffects.move( new Static3D(scrWidth/4,scrHeight/4,0) );
|
|
| 211 |
fpsEffects.move( new Static3D(5,5,0) );
|
|
| 210 | 212 |
bitmapCreated=true; |
| 211 | 213 |
} |
| 212 | 214 |
else |
| 213 | 215 |
{
|
| 214 |
stretchQueues.abortEffects(EffectTypes.VERTEX);
|
|
| 215 |
stretchQueues.abortEffects(EffectTypes.FRAGMENT);
|
|
| 216 |
stretchQueues.abortEffects(EffectNames.SHEAR);
|
|
| 216 |
stretchEffects.abortEffects(EffectTypes.VERTEX);
|
|
| 217 |
stretchEffects.abortEffects(EffectTypes.FRAGMENT);
|
|
| 218 |
stretchEffects.abortEffects(EffectNames.SHEAR);
|
|
| 217 | 219 |
} |
| 220 |
|
|
| 221 |
mScreen.resize(width, height); |
|
| 218 | 222 |
} |
| 219 | 223 |
|
| 220 | 224 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 288 | 292 |
switch(mMode) |
| 289 | 293 |
{
|
| 290 | 294 |
case DISTORT: vDistort[0].set(0,0,0); |
| 291 |
mLastEffect = stretchQueues.distort( mMovingDistortDynamic, touchPoint, mRegion);
|
|
| 295 |
mLastEffect = stretchEffects.distort( mMovingDistortDynamic, touchPoint, mRegion);
|
|
| 292 | 296 |
break; |
| 293 | 297 |
case DEFORM : vDeform[0].set(0,0,0); |
| 294 |
mLastEffect = stretchQueues.deform( mMovingDeformDynamic, touchPoint, mRegion);
|
|
| 298 |
mLastEffect = stretchEffects.deform( mMovingDeformDynamic, touchPoint, mRegion);
|
|
| 295 | 299 |
break; |
| 296 | 300 |
case SHEAR : vShear[0].set(0,0,0); |
| 297 |
mLastEffect = stretchQueues.shear(mMovingShearDynamic, touchPoint);
|
|
| 301 |
mLastEffect = stretchEffects.shear(mMovingShearDynamic, touchPoint);
|
|
| 298 | 302 |
break; |
| 299 | 303 |
} |
| 300 | 304 |
} |
| ... | ... | |
| 318 | 322 |
|
| 319 | 323 |
void up() |
| 320 | 324 |
{
|
| 321 |
stretchQueues.abortEffect(mLastEffect);
|
|
| 325 |
stretchEffects.abortEffect(mLastEffect);
|
|
| 322 | 326 |
|
| 323 | 327 |
float damp = -0.65f; |
| 324 | 328 |
|
| ... | ... | |
| 329 | 333 |
vDistort[i].set( vDistort[i-1].getX()*damp, vDistort[i-1].getY()*damp ); |
| 330 | 334 |
} |
| 331 | 335 |
vDistort[NUM_VECTORS-1].set(0,0); |
| 332 |
stretchQueues.distort( mReleasedDistortDynamic, touchPoint, mRegion);
|
|
| 336 |
stretchEffects.distort( mReleasedDistortDynamic, touchPoint, mRegion);
|
|
| 333 | 337 |
break; |
| 334 | 338 |
case DEFORM : for(int i=1; i<NUM_VECTORS-1; i++) |
| 335 | 339 |
{
|
| 336 | 340 |
vDeform[i].set( vDeform[i-1].getX()*damp, vDeform[i-1].getY()*damp ); |
| 337 | 341 |
} |
| 338 | 342 |
vDeform[NUM_VECTORS-1].set(0,0); |
| 339 |
stretchQueues.deform( mReleasedDeformDynamic, touchPoint, mRegion);
|
|
| 343 |
stretchEffects.deform( mReleasedDeformDynamic, touchPoint, mRegion);
|
|
| 340 | 344 |
break; |
| 341 | 345 |
case SHEAR : for(int i=1; i<NUM_VECTORS-1; i++) |
| 342 | 346 |
{
|
| 343 | 347 |
vShear[i].set( vShear[i-1].getX()*damp, vShear[i-1].getY()*damp ); |
| 344 | 348 |
} |
| 345 | 349 |
vShear[NUM_VECTORS-1].set(0,0); |
| 346 |
stretchQueues.shear(mReleasedShearDynamic, touchPoint);
|
|
| 350 |
stretchEffects.shear(mReleasedShearDynamic, touchPoint);
|
|
| 347 | 351 |
break; |
| 348 | 352 |
} |
| 349 | 353 |
} |
| src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.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; |
| ... | ... | |
| 50 | 51 |
|
| 51 | 52 |
private GLSurfaceView mView; |
| 52 | 53 |
private DistortedTexture[] mTexture; |
| 53 |
private DistortedEffectQueues[] mQueues;
|
|
| 54 |
private DistortedEffectQueues[] mEffects;
|
|
| 54 | 55 |
private GridFlat mGrid; |
| 56 |
private DistortedFramebuffer mScreen; |
|
| 55 | 57 |
private int bmpHeight, bmpWidth; |
| 56 | 58 |
|
| 57 | 59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 65 | 67 |
dDistort.add(new Static3D(-25,0,0)); |
| 66 | 68 |
Static3D mPoint = new Static3D(305, 380, 0); |
| 67 | 69 |
|
| 68 |
mQueues = new DistortedEffectQueues[NUM];
|
|
| 69 |
mQueues[0] = new DistortedEffectQueues();
|
|
| 70 |
mEffects = new DistortedEffectQueues[NUM];
|
|
| 71 |
mEffects[0] = new DistortedEffectQueues();
|
|
| 70 | 72 |
for(int i=1; i<NUM; i++) |
| 71 |
mQueues[i] = new DistortedEffectQueues(mQueues[0], Distorted.CLONE_VERTEX|Distorted.CLONE_FRAGMENT);
|
|
| 73 |
mEffects[i] = new DistortedEffectQueues(mEffects[0], Distorted.CLONE_VERTEX|Distorted.CLONE_FRAGMENT);
|
|
| 72 | 74 |
|
| 73 | 75 |
// Add the effects only to the first queue - all VERTEX and FRAGMENT effects are shared! |
| 74 | 76 |
// (Matrix effect cannot be shared as we have to display each Texture in a different location) |
| 75 |
mQueues[0].sink( new Static1D(8), mPoint, new Static4D(0,0,80,80)); // enlarge the nose |
|
| 76 |
mQueues[0].distort(dDistort,mPoint); // keep moving the whole bitmap left and right. |
|
| 77 |
mEffects[0].sink( new Static1D(8), mPoint, new Static4D(0,0,80,80)); // enlarge the nose |
|
| 78 |
mEffects[0].distort(dDistort,mPoint); // keep moving the whole bitmap left and right. |
|
| 79 |
|
|
| 80 |
mScreen = new DistortedFramebuffer(0); |
|
| 77 | 81 |
} |
| 78 | 82 |
|
| 79 | 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 107 | 111 |
|
| 108 | 112 |
long time = System.currentTimeMillis(); |
| 109 | 113 |
|
| 110 |
for(int i=NUM-1; i>=0; i--) mQueues[i].draw(time, mTexture[i], mGrid);
|
|
| 114 |
for(int i=NUM-1; i>=0; i--) mEffects[i].draw(time, mTexture[i], mGrid, mScreen);
|
|
| 111 | 115 |
} |
| 112 | 116 |
|
| 113 | 117 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 116 | 120 |
{
|
| 117 | 121 |
for(int i=NUM-1; i>=0; i--) |
| 118 | 122 |
{
|
| 119 |
mQueues[i].abortEffects(EffectTypes.MATRIX);
|
|
| 123 |
mEffects[i].abortEffects(EffectTypes.MATRIX);
|
|
| 120 | 124 |
} |
| 121 | 125 |
|
| 122 | 126 |
if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width ) |
| ... | ... | |
| 126 | 130 |
|
| 127 | 131 |
for(int i=NUM-1; i>=0; i--) |
| 128 | 132 |
{
|
| 129 |
mQueues[i].move( new Static3D((width-NUM*w)/2 +i*w ,0,0) );
|
|
| 130 |
mQueues[i].scale(factor);
|
|
| 133 |
mEffects[i].move( new Static3D((width-NUM*w)/2 +i*w ,0,0) );
|
|
| 134 |
mEffects[i].scale(factor);
|
|
| 131 | 135 |
} |
| 132 | 136 |
} |
| 133 | 137 |
else |
| ... | ... | |
| 138 | 142 |
|
| 139 | 143 |
for(int i=NUM-1; i>=0; i--) |
| 140 | 144 |
{
|
| 141 |
mQueues[i].move( new Static3D(i*w,(height-h)/2,0) );
|
|
| 142 |
mQueues[i].scale(factor);
|
|
| 145 |
mEffects[i].move( new Static3D(i*w,(height-h)/2,0) );
|
|
| 146 |
mEffects[i].scale(factor);
|
|
| 143 | 147 |
} |
| 144 | 148 |
} |
| 145 | 149 |
|
| 146 |
Distorted.onSurfaceChanged(width, height);
|
|
| 150 |
mScreen.resize(width, height);
|
|
| 147 | 151 |
} |
| 148 | 152 |
|
| 149 | 153 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.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.GridFlat; |
| 32 | 33 |
import org.distorted.library.DistortedTexture; |
| 33 | 34 |
import org.distorted.library.DistortedEffectQueues; |
| ... | ... | |
| 50 | 51 |
private static final int NUM = 3; |
| 51 | 52 |
|
| 52 | 53 |
private GLSurfaceView mView; |
| 53 |
private DistortedEffectQueues[] mQueue;
|
|
| 54 |
private DistortedEffectQueues[] mEffects;
|
|
| 54 | 55 |
private DistortedTexture mTexture; |
| 55 | 56 |
private GridFlat mGrid; |
| 57 |
private DistortedFramebuffer mScreen; |
|
| 56 | 58 |
private int bmpHeight, bmpWidth; |
| 57 | 59 |
|
| 58 | 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 61 | 63 |
{
|
| 62 | 64 |
mView = v; |
| 63 | 65 |
|
| 64 |
// mQueue[0] effects
|
|
| 66 |
// mEffects[0] effects
|
|
| 65 | 67 |
Static3D pLeft = new Static3D(214, 206, 0); |
| 66 | 68 |
Static3D pRight= new Static3D(390, 212, 0); |
| 67 | 69 |
Static4D RegionEye = new Static4D(0,0,60,60); |
| 68 | 70 |
|
| 69 |
// mQueue[1] effects
|
|
| 71 |
// mEffects[1] effects
|
|
| 70 | 72 |
Dynamic3D dyn = new Dynamic3D(1000,0.0f); |
| 71 | 73 |
dyn.add(new Static3D( 50,0,0)); |
| 72 | 74 |
dyn.add(new Static3D(-50,0,0)); |
| 73 | 75 |
Static3D pNose1 = new Static3D(305, 340, 0); |
| 74 | 76 |
|
| 75 |
// we don't need to prepare anything for mQueue[2] effects
|
|
| 77 |
// we don't need to prepare anything for mEffects[2] effects
|
|
| 76 | 78 |
|
| 77 |
mQueue= new DistortedEffectQueues[NUM];
|
|
| 79 |
mEffects = new DistortedEffectQueues[NUM];
|
|
| 78 | 80 |
|
| 79 |
for(int i=0; i<NUM; i++) mQueue[i] = new DistortedEffectQueues();
|
|
| 81 |
for(int i=0; i<NUM; i++) mEffects[i] = new DistortedEffectQueues();
|
|
| 80 | 82 |
|
| 81 | 83 |
Dynamic1D sink = new Dynamic1D(2000,0.0f); |
| 82 | 84 |
sink.add(new Static1D( 1)); |
| 83 | 85 |
sink.add(new Static1D(10)); |
| 84 | 86 |
|
| 85 |
mQueue[0].sink(sink, pLeft, RegionEye);
|
|
| 86 |
mQueue[0].sink(sink, pRight,RegionEye);
|
|
| 87 |
mQueue[1].distort(dyn, pNose1);
|
|
| 87 |
mEffects[0].sink(sink, pLeft, RegionEye);
|
|
| 88 |
mEffects[0].sink(sink, pRight,RegionEye);
|
|
| 89 |
mEffects[1].distort(dyn, pNose1);
|
|
| 88 | 90 |
|
| 89 | 91 |
Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f); |
| 90 | 92 |
chromaDyn.add(new Static1D(0)); |
| 91 | 93 |
chromaDyn.add(new Static1D(1)); |
| 92 | 94 |
|
| 93 |
mQueue[2].chroma(chromaDyn, new Static3D(0,1,0) ); |
|
| 95 |
mEffects[2].chroma(chromaDyn, new Static3D(0,1,0) ); |
|
| 96 |
|
|
| 97 |
mScreen = new DistortedFramebuffer(0); |
|
| 94 | 98 |
} |
| 95 | 99 |
|
| 96 | 100 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 101 | 105 |
|
| 102 | 106 |
long time = System.currentTimeMillis(); |
| 103 | 107 |
|
| 104 |
for(int i=NUM-1; i>=0; i--) mQueue[i].draw(time, mTexture, mGrid);
|
|
| 108 |
for(int i=NUM-1; i>=0; i--) mEffects[i].draw(time, mTexture, mGrid, mScreen);
|
|
| 105 | 109 |
} |
| 106 | 110 |
|
| 107 | 111 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 110 | 114 |
{
|
| 111 | 115 |
for(int i=NUM-1; i>=0; i--) |
| 112 | 116 |
{
|
| 113 |
mQueue[i].abortEffects(EffectTypes.MATRIX);
|
|
| 117 |
mEffects[i].abortEffects(EffectTypes.MATRIX);
|
|
| 114 | 118 |
} |
| 115 | 119 |
|
| 116 | 120 |
if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width ) |
| ... | ... | |
| 120 | 124 |
|
| 121 | 125 |
for(int i=NUM-1; i>=0; i--) |
| 122 | 126 |
{
|
| 123 |
mQueue[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) );
|
|
| 124 |
mQueue[i].scale(factor);
|
|
| 127 |
mEffects[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) );
|
|
| 128 |
mEffects[i].scale(factor);
|
|
| 125 | 129 |
} |
| 126 | 130 |
} |
| 127 | 131 |
else |
| ... | ... | |
| 132 | 136 |
|
| 133 | 137 |
for(int i=NUM-1; i>=0; i--) |
| 134 | 138 |
{
|
| 135 |
mQueue[i].move( new Static3D(i*w, (height-h)/2, 0) );
|
|
| 136 |
mQueue[i].scale(factor);
|
|
| 139 |
mEffects[i].move( new Static3D(i*w, (height-h)/2, 0) );
|
|
| 140 |
mEffects[i].scale(factor);
|
|
| 137 | 141 |
} |
| 138 | 142 |
} |
| 139 | 143 |
|
| 140 |
Distorted.onSurfaceChanged(width, height);
|
|
| 144 |
mScreen.resize(width, height);
|
|
| 141 | 145 |
} |
| 142 | 146 |
|
| 143 | 147 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/dynamic/DynamicRenderer.java | ||
|---|---|---|
| 29 | 29 |
import android.opengl.GLES20; |
| 30 | 30 |
import android.opengl.GLSurfaceView; |
| 31 | 31 |
|
| 32 |
import org.distorted.library.DistortedFramebuffer; |
|
| 32 | 33 |
import org.distorted.library.GridFlat; |
| 33 | 34 |
import org.distorted.library.DistortedEffectQueues; |
| 34 | 35 |
import org.distorted.library.DistortedTexture; |
| ... | ... | |
| 40 | 41 |
{
|
| 41 | 42 |
private DynamicSurfaceView mView; |
| 42 | 43 |
private DistortedTexture mTexture; |
| 43 |
private DistortedEffectQueues mQueues; |
|
| 44 |
private DistortedEffectQueues mEffects; |
|
| 45 |
private DistortedFramebuffer mScreen; |
|
| 44 | 46 |
private GridFlat mGrid; |
| 45 | 47 |
private Canvas mCanvas; |
| 46 | 48 |
private Bitmap mBitmap; |
| ... | ... | |
| 60 | 62 |
|
| 61 | 63 |
mView = v; |
| 62 | 64 |
mGrid = new GridFlat(1,1); |
| 63 |
mQueues = new DistortedEffectQueues(); |
|
| 65 |
mEffects = new DistortedEffectQueues(); |
|
| 66 |
mScreen = new DistortedFramebuffer(0); |
|
| 64 | 67 |
} |
| 65 | 68 |
|
| 66 | 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 88 | 91 |
mBitmap = Bitmap.createBitmap(texW,texH, Bitmap.Config.ARGB_8888); |
| 89 | 92 |
mCanvas = new Canvas(mBitmap); |
| 90 | 93 |
|
| 91 |
Distorted.onSurfaceChanged(texW,texH);
|
|
| 94 |
mScreen.resize(texW,texH);
|
|
| 92 | 95 |
mView.onSurfaceChanged(texW,texH); |
| 93 | 96 |
} |
| 94 | 97 |
|
| ... | ... | |
| 103 | 106 |
mCanvas.drawRect(0, 0, texW, texH, mPaint); |
| 104 | 107 |
mView.drawCurve(mCanvas,time); |
| 105 | 108 |
mTexture.setTexture(mBitmap); |
| 106 |
mQueues.draw(time,mTexture,mGrid);
|
|
| 109 |
mEffects.draw(time,mTexture,mGrid,mScreen);
|
|
| 107 | 110 |
} |
| 108 | 111 |
|
| 109 | 112 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/effectqueue/EffectQueueActivity.java | ||
|---|---|---|
| 166 | 166 |
|
| 167 | 167 |
public void removeByID(View view) |
| 168 | 168 |
{
|
| 169 |
Long currID = (Long)mID.getItemAtPosition(mPosID); |
|
| 170 |
|
|
| 171 |
EffectQueueSurfaceView v = (EffectQueueSurfaceView) this.findViewById(R.id.effects2dSurfaceView); |
|
| 172 |
v.getRenderer().getQueues().abortEffect(currID); |
|
| 169 |
try |
|
| 170 |
{
|
|
| 171 |
Long currID = (Long)mID.getItemAtPosition(mPosID); |
|
| 172 |
EffectQueueSurfaceView v = (EffectQueueSurfaceView) this.findViewById(R.id.effects2dSurfaceView); |
|
| 173 |
v.getRenderer().getQueues().abortEffect(currID); |
|
| 174 |
} |
|
| 175 |
catch(IndexOutOfBoundsException ex) |
|
| 176 |
{
|
|
| 177 |
android.util.Log.e("effectQueue", "Failure trying to remove "+mPosID);
|
|
| 178 |
} |
|
| 173 | 179 |
} |
| 174 | 180 |
|
| 175 | 181 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/effectqueue/EffectQueueRenderer.java | ||
|---|---|---|
| 29 | 29 |
import android.opengl.GLES20; |
| 30 | 30 |
import android.opengl.GLSurfaceView; |
| 31 | 31 |
|
| 32 |
import org.distorted.library.DistortedFramebuffer; |
|
| 32 | 33 |
import org.distorted.library.GridFlat; |
| 33 | 34 |
import org.distorted.library.DistortedTexture; |
| 34 | 35 |
import org.distorted.library.DistortedEffectQueues; |
| ... | ... | |
| 53 | 54 |
|
| 54 | 55 |
private DistortedTexture mTexture; |
| 55 | 56 |
private GridFlat mGrid; |
| 56 |
private DistortedEffectQueues mQueues; |
|
| 57 |
private DistortedEffectQueues mEffects; |
|
| 58 |
private DistortedFramebuffer mScreen; |
|
| 57 | 59 |
|
| 58 | 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 59 | 61 |
|
| ... | ... | |
| 71 | 73 |
|
| 72 | 74 |
mGrid = new GridFlat(80,80*texHeight/texWidth); |
| 73 | 75 |
mTexture = new DistortedTexture(texWidth,texHeight); |
| 74 |
mQueues = new DistortedEffectQueues();
|
|
| 76 |
mEffects = new DistortedEffectQueues();
|
|
| 75 | 77 |
|
| 76 |
mQueues.registerForMessages(this); |
|
| 78 |
mEffects.registerForMessages(this); |
|
| 79 |
|
|
| 80 |
mScreen = new DistortedFramebuffer(0); |
|
| 77 | 81 |
} |
| 78 | 82 |
|
| 79 | 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 80 | 84 |
|
| 81 | 85 |
DistortedEffectQueues getQueues() |
| 82 | 86 |
{
|
| 83 |
return mQueues;
|
|
| 87 |
return mEffects;
|
|
| 84 | 88 |
} |
| 85 | 89 |
|
| 86 | 90 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 115 | 119 |
|
| 116 | 120 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 117 | 121 |
{
|
| 118 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
| 119 |
mQueues.scale( new Static3D((float)width/texWidth,(float)height/texHeight,1) );
|
|
| 120 |
Distorted.onSurfaceChanged(width,height);
|
|
| 122 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
| 123 |
mEffects.scale( new Static3D((float)width/texWidth,(float)height/texHeight,1) );
|
|
| 124 |
mScreen.resize(width,height);
|
|
| 121 | 125 |
mView.setScreenSize(width,height); |
| 122 | 126 |
} |
| 123 | 127 |
|
| ... | ... | |
| 126 | 130 |
public void onDrawFrame(GL10 glUnused) |
| 127 | 131 |
{
|
| 128 | 132 |
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); |
| 129 |
mQueues.draw(System.currentTimeMillis(), mTexture,mGrid);
|
|
| 133 |
mEffects.draw(System.currentTimeMillis(), mTexture,mGrid,mScreen);
|
|
| 130 | 134 |
} |
| 131 | 135 |
|
| 132 | 136 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.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.DistortedTexture; |
| 30 | 31 |
import org.distorted.library.GridFlat; |
| 31 | 32 |
import org.distorted.library.DistortedEffectQueues; |
| ... | ... | |
| 48 | 49 |
{
|
| 49 | 50 |
private GLSurfaceView mView; |
| 50 | 51 |
private DistortedTexture mObjectTexture, mBackgroundTexture, mCenterTexture, mRegionTexture; |
| 51 |
private DistortedEffectQueues mObjectQueues, mBackgroundQueues, mCenterQueues, mRegionQueues; |
|
| 52 |
private DistortedEffectQueues mObjectEffects, mBackgroundEffects, mCenterEffects, mRegionEffects; |
|
| 53 |
private DistortedFramebuffer mScreen; |
|
| 52 | 54 |
private GridFlat mQuad; |
| 53 | 55 |
private GridObject mObjectGrid; |
| 54 | 56 |
private int mObjWidth, mObjHeight, mObjDepth; |
| ... | ... | |
| 74 | 76 |
|
| 75 | 77 |
mObjectTexture = act.getTexture(); |
| 76 | 78 |
mObjectGrid = act.getGrid(); |
| 77 |
mObjectQueues = act.getQueues();
|
|
| 79 |
mObjectEffects = act.getQueues();
|
|
| 78 | 80 |
mBackgroundTexture = new DistortedTexture(100,100); |
| 79 | 81 |
mCenterTexture = new DistortedTexture(100,100); |
| 80 | 82 |
mRegionTexture = new DistortedTexture(100,100); |
| 81 | 83 |
mQuad = new GridFlat(1,1); |
| 82 |
mBackgroundQueues = new DistortedEffectQueues();
|
|
| 83 |
mCenterQueues = new DistortedEffectQueues();
|
|
| 84 |
mRegionQueues = new DistortedEffectQueues();
|
|
| 84 |
mBackgroundEffects = new DistortedEffectQueues();
|
|
| 85 |
mCenterEffects = new DistortedEffectQueues();
|
|
| 86 |
mRegionEffects = new DistortedEffectQueues();
|
|
| 85 | 87 |
|
| 86 | 88 |
mObjWidth = mObjectTexture.getWidth(); |
| 87 | 89 |
mObjHeight= mObjectTexture.getHeight(); |
| ... | ... | |
| 107 | 109 |
mRegionScaleInter = new Dynamic3D(); |
| 108 | 110 |
mRegionScalePoint = new Static3D(0,0,0); |
| 109 | 111 |
mRegionScaleInter.add(mRegionScalePoint); |
| 112 |
|
|
| 113 |
mScreen = new DistortedFramebuffer(0); |
|
| 110 | 114 |
} |
| 111 | 115 |
|
| 112 | 116 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 133 | 137 |
|
| 134 | 138 |
long time = System.currentTimeMillis(); |
| 135 | 139 |
|
| 136 |
mBackgroundQueues.draw(time,mBackgroundTexture,mQuad);
|
|
| 137 |
mObjectQueues.draw(time,mObjectTexture,mObjectGrid);
|
|
| 140 |
mBackgroundEffects.draw(time,mBackgroundTexture,mQuad,mScreen);
|
|
| 141 |
mObjectEffects.draw(time,mObjectTexture,mObjectGrid,mScreen);
|
|
| 138 | 142 |
|
| 139 | 143 |
if( Effects3DActivity.supportsCenter() ) |
| 140 | 144 |
{
|
| 141 |
mCenterQueues.draw(time, mCenterTexture,mQuad);
|
|
| 142 |
if( Effects3DActivity.supportsRegion() ) mRegionQueues.draw(time, mRegionTexture,mQuad);
|
|
| 145 |
mCenterEffects.draw(time, mCenterTexture,mQuad,mScreen);
|
|
| 146 |
if( Effects3DActivity.supportsRegion() ) mRegionEffects.draw(time, mRegionTexture,mQuad,mScreen);
|
|
| 143 | 147 |
} |
| 144 | 148 |
} |
| 145 | 149 |
|
| ... | ... | |
| 149 | 153 |
{
|
| 150 | 154 |
mScreenMin = width<height ? width:height; |
| 151 | 155 |
|
| 152 |
mObjectQueues.abortEffects(EffectTypes.MATRIX);
|
|
| 153 |
mBackgroundQueues.abortEffects(EffectTypes.MATRIX);
|
|
| 154 |
mCenterQueues.abortEffects(EffectTypes.MATRIX);
|
|
| 155 |
mRegionQueues.abortEffects(EffectTypes.MATRIX);
|
|
| 156 |
mObjectEffects.abortEffects(EffectTypes.MATRIX);
|
|
| 157 |
mBackgroundEffects.abortEffects(EffectTypes.MATRIX);
|
|
| 158 |
mCenterEffects.abortEffects(EffectTypes.MATRIX);
|
|
| 159 |
mRegionEffects.abortEffects(EffectTypes.MATRIX);
|
|
| 156 | 160 |
|
| 157 | 161 |
float factorCen; |
| 158 | 162 |
int centerSize = mCenterTexture.getWidth(); |
| ... | ... | |
| 178 | 182 |
|
| 179 | 183 |
Static3D rotateObj = new Static3D(mObjWidth/2,mObjHeight/2, 0); |
| 180 | 184 |
|
| 181 |
mObjectQueues.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) );
|
|
| 182 |
mObjectQueues.scale(mFactorObj);
|
|
| 183 |
mObjectQueues.quaternion(mQuatInt1, rotateObj);
|
|
| 184 |
mObjectQueues.quaternion(mQuatInt2, rotateObj);
|
|
| 185 |
mObjectEffects.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) );
|
|
| 186 |
mObjectEffects.scale(mFactorObj);
|
|
| 187 |
mObjectEffects.quaternion(mQuatInt1, rotateObj);
|
|
| 188 |
mObjectEffects.quaternion(mQuatInt2, rotateObj);
|
|
| 185 | 189 |
|
| 186 | 190 |
Static3D rotateCen = new Static3D(width/2,height/2, 0); |
| 187 | 191 |
|
| 188 |
mCenterQueues.quaternion(mQuatInt1, rotateCen);
|
|
| 189 |
mCenterQueues.quaternion(mQuatInt2, rotateCen);
|
|
| 192 |
mCenterEffects.quaternion(mQuatInt1, rotateCen);
|
|
| 193 |
mCenterEffects.quaternion(mQuatInt2, rotateCen);
|
|
| 190 | 194 |
|
| 191 |
mCenterQueues.move( new Static3D( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 ,
|
|
| 195 |
mCenterEffects.move( new Static3D( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 ,
|
|
| 192 | 196 |
(height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , mFactorObj*mObjDepth/2+10) ); |
| 193 |
mCenterQueues.move(mCenterInter);
|
|
| 194 |
mCenterQueues.scale(factorCen);
|
|
| 197 |
mCenterEffects.move(mCenterInter);
|
|
| 198 |
mCenterEffects.scale(factorCen);
|
|
| 195 | 199 |
|
| 196 |
mRegionQueues.quaternion(mQuatInt1, rotateCen);
|
|
| 197 |
mRegionQueues.quaternion(mQuatInt2, rotateCen);
|
|
| 200 |
mRegionEffects.quaternion(mQuatInt1, rotateCen);
|
|
| 201 |
mRegionEffects.quaternion(mQuatInt2, rotateCen);
|
|
| 198 | 202 |
|
| 199 |
mRegionQueues.move( new Static3D( (width -mFactorObj*mObjWidth )/2 ,
|
|
| 203 |
mRegionEffects.move( new Static3D( (width -mFactorObj*mObjWidth )/2 ,
|
|
| 200 | 204 |
(height-mFactorObj*mObjHeight)/2 , mFactorObj*mObjDepth/2+12) ); |
| 201 |
mRegionQueues.move(mCenterInter);
|
|
| 202 |
mRegionQueues.move(mRegionInter);
|
|
| 203 |
mRegionQueues.scale(mRegionScaleInter);
|
|
| 204 |
mRegionQueues.move( new Static3D( -regionSize/2 , -regionSize/2 , 0) );
|
|
| 205 |
mRegionEffects.move(mCenterInter);
|
|
| 206 |
mRegionEffects.move(mRegionInter);
|
|
| 207 |
mRegionEffects.scale(mRegionScaleInter);
|
|
| 208 |
mRegionEffects.move( new Static3D( -regionSize/2 , -regionSize/2 , 0) );
|
|
| 205 | 209 |
|
| 206 | 210 |
int backgroundSize = mBackgroundTexture.getWidth(); |
| 207 | 211 |
float factorBackX = ((float)width)/backgroundSize; |
| 208 | 212 |
float factorBackY = ((float)height)/backgroundSize; |
| 209 | 213 |
|
| 210 |
mBackgroundQueues.move(new Static3D( -width/2, -height/2,-mFactorObj*(mObjWidth+mObjHeight)/2) );
|
|
| 211 |
mBackgroundQueues.scale(new Static3D(2*factorBackX, 2*factorBackY, 1.0f) );
|
|
| 214 |
mBackgroundEffects.move(new Static3D( -width/2, -height/2,-mFactorObj*(mObjWidth+mObjHeight)/2) );
|
|
| 215 |
mBackgroundEffects.scale(new Static3D(2*factorBackX, 2*factorBackY, 1.0f) );
|
|
| 212 | 216 |
|
| 213 |
Distorted.onSurfaceChanged(width, height);
|
|
| 217 |
mScreen.resize(width, height);
|
|
| 214 | 218 |
} |
| 215 | 219 |
|
| 216 | 220 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/fbo/FBORenderer.java | ||
|---|---|---|
| 27 | 27 |
|
| 28 | 28 |
import org.distorted.examples.R; |
| 29 | 29 |
|
| 30 |
import org.distorted.library.DistortedFramebuffer; |
|
| 30 | 31 |
import org.distorted.library.DistortedObjectTree; |
| 31 | 32 |
import org.distorted.library.Distorted; |
| 32 | 33 |
import org.distorted.library.GridCubes; |
| ... | ... | |
| 49 | 50 |
class FBORenderer implements GLSurfaceView.Renderer |
| 50 | 51 |
{
|
| 51 | 52 |
private GLSurfaceView mView; |
| 52 |
private DistortedEffectQueues mQueues; |
|
| 53 |
private int lisaHeight, lisaWidth; |
|
| 54 |
|
|
| 53 |
private DistortedEffectQueues mEffects; |
|
| 54 |
private DistortedFramebuffer mScreen; |
|
| 55 | 55 |
private DistortedObjectTree mRoot; |
| 56 |
|
|
| 56 |
private int lisaHeight, lisaWidth; |
|
| 57 |
|
|
| 57 | 58 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 58 | 59 |
|
| 59 | 60 |
FBORenderer(GLSurfaceView v) |
| 60 | 61 |
{
|
| 61 |
mView = v; |
|
| 62 |
mQueues = new DistortedEffectQueues(); |
|
| 62 |
mView = v; |
|
| 63 |
mEffects= new DistortedEffectQueues(); |
|
| 64 |
mScreen = new DistortedFramebuffer(0); |
|
| 63 | 65 |
} |
| 64 | 66 |
|
| 65 | 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 67 | 69 |
public void onDrawFrame(GL10 glUnused) |
| 68 | 70 |
{
|
| 69 | 71 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| 70 |
mRoot.draw(System.currentTimeMillis()); |
|
| 72 |
mRoot.draw(System.currentTimeMillis(),mScreen);
|
|
| 71 | 73 |
} |
| 72 | 74 |
|
| 73 | 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 74 | 76 |
|
| 75 | 77 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 76 | 78 |
{
|
| 77 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
| 79 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
| 78 | 80 |
|
| 79 | 81 |
if( (float)lisaHeight/lisaWidth > (float)height/width ) |
| 80 | 82 |
{
|
| 81 | 83 |
int w = (height*lisaWidth)/lisaHeight; |
| 82 | 84 |
float factor = (float)height/lisaHeight; |
| 83 | 85 |
|
| 84 |
mQueues.move( new Static3D((width-w)/2,0,0) );
|
|
| 85 |
mQueues.scale(factor);
|
|
| 86 |
mEffects.move( new Static3D((width-w)/2,0,0) );
|
|
| 87 |
mEffects.scale(factor);
|
|
| 86 | 88 |
} |
| 87 | 89 |
else |
| 88 | 90 |
{
|
| 89 | 91 |
int h = (width*lisaHeight)/lisaWidth; |
| 90 | 92 |
float factor = (float)width/lisaWidth; |
| 91 | 93 |
|
| 92 |
mQueues.move( new Static3D(0,(height-h)/2,0) );
|
|
| 93 |
mQueues.scale(factor);
|
|
| 94 |
mEffects.move( new Static3D(0,(height-h)/2,0) );
|
|
| 95 |
mEffects.scale(factor);
|
|
| 94 | 96 |
} |
| 95 | 97 |
|
| 96 |
Distorted.onSurfaceChanged(width, height);
|
|
| 98 |
mScreen.resize(width, height);
|
|
| 97 | 99 |
} |
| 98 | 100 |
|
| 99 | 101 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 133 | 135 |
text.setTexture(bitmap2); |
| 134 | 136 |
DistortedEffectQueues textQueues = new DistortedEffectQueues(); |
| 135 | 137 |
|
| 136 |
mQueues.abortAllEffects();
|
|
| 138 |
mEffects.abortAllEffects();
|
|
| 137 | 139 |
|
| 138 |
mRoot = new DistortedObjectTree(lisa,mQueues,new GridFlat(1,1));
|
|
| 140 |
mRoot = new DistortedObjectTree(lisa, mEffects,new GridFlat(1,1));
|
|
| 139 | 141 |
mRoot.attach(text,textQueues,new GridCubes(20,5,false)); |
| 140 | 142 |
|
| 141 | 143 |
float factor = lisaWidth/(2.0f*textWidth); |
| ... | ... | |
| 160 | 162 |
chromaDyn.add(new Static1D(0.0f)); |
| 161 | 163 |
chromaDyn.add(new Static1D(1.0f)); |
| 162 | 164 |
|
| 163 |
mQueues.chroma(chromaDyn, new Static3D(0,0,1) );
|
|
| 165 |
mEffects.chroma(chromaDyn, new Static3D(0,0,1) );
|
|
| 164 | 166 |
|
| 165 | 167 |
try |
| 166 | 168 |
{
|
| src/main/java/org/distorted/examples/flag/FlagRenderer.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; |
| ... | ... | |
| 48 | 49 |
class FlagRenderer implements GLSurfaceView.Renderer |
| 49 | 50 |
{
|
| 50 | 51 |
private GLSurfaceView mView; |
| 51 |
private DistortedEffectQueues mQueues;
|
|
| 52 |
private DistortedEffectQueues mEffects;
|
|
| 52 | 53 |
private DistortedTexture mTexture; |
| 54 |
private DistortedFramebuffer mScreen; |
|
| 53 | 55 |
private GridCubes mGrid; |
| 54 |
private int mObjWidth, mObjHeight; |
|
| 55 | 56 |
private DynamicQuat mQuatInt1, mQuatInt2; |
| 56 | 57 |
private Dynamic5D mWaveDyn; |
| 57 | 58 |
private Static5D mWaveSta1, mWaveSta2; |
| 59 |
private int mObjWidth, mObjHeight; |
|
| 58 | 60 |
|
| 59 | 61 |
Static4D mQuat1, mQuat2; |
| 60 | 62 |
int mScreenMin; |
| ... | ... | |
| 65 | 67 |
{
|
| 66 | 68 |
mView = v; |
| 67 | 69 |
|
| 68 |
mQueues = new DistortedEffectQueues();
|
|
| 70 |
mEffects = new DistortedEffectQueues();
|
|
| 69 | 71 |
mGrid = new GridCubes(50,30,false); |
| 70 | 72 |
mTexture = new DistortedTexture(500,300); |
| 71 | 73 |
|
| ... | ... | |
| 92 | 94 |
Static3D waveCenter = new Static3D(mObjWidth, mObjHeight/2, 0); // middle of the right edge |
| 93 | 95 |
Static4D waveRegion = new Static4D(0,0,mObjWidth,mObjWidth); |
| 94 | 96 |
|
| 95 |
mQueues.wave(mWaveDyn, waveCenter, waveRegion); |
|
| 97 |
mEffects.wave(mWaveDyn, waveCenter, waveRegion); |
|
| 98 |
|
|
| 99 |
mScreen = new DistortedFramebuffer(0); |
|
| 96 | 100 |
} |
| 97 | 101 |
|
| 98 | 102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 139 | 143 |
public void onDrawFrame(GL10 glUnused) |
| 140 | 144 |
{
|
| 141 | 145 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| 142 |
mQueues.draw(System.currentTimeMillis(), mTexture, mGrid);
|
|
| 146 |
mEffects.draw(System.currentTimeMillis(), mTexture, mGrid, mScreen);
|
|
| 143 | 147 |
} |
| 144 | 148 |
|
| 145 | 149 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 148 | 152 |
{
|
| 149 | 153 |
mScreenMin = width<height ? width:height; |
| 150 | 154 |
|
| 151 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
| 155 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
| 152 | 156 |
float factor; |
| 153 | 157 |
|
| 154 | 158 |
if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object |
| ... | ... | |
| 160 | 164 |
factor = (0.8f*width)/mObjWidth; |
| 161 | 165 |
} |
| 162 | 166 |
|
| 163 |
mQueues.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
|
|
| 164 |
mQueues.scale(factor);
|
|
| 167 |
mEffects.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
|
|
| 168 |
mEffects.scale(factor);
|
|
| 165 | 169 |
Static3D center = new Static3D(mObjWidth/2,mObjHeight/2, 0); |
| 166 | 170 |
|
| 167 |
mQueues.quaternion(mQuatInt1, center);
|
|
| 168 |
mQueues.quaternion(mQuatInt2, center);
|
|
| 171 |
mEffects.quaternion(mQuatInt1, center);
|
|
| 172 |
mEffects.quaternion(mQuatInt2, center);
|
|
| 169 | 173 |
|
| 170 |
Distorted.onSurfaceChanged(width, height);
|
|
| 174 |
mScreen.resize(width, height);
|
|
| 171 | 175 |
} |
| 172 | 176 |
|
| 173 | 177 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/girl/GirlRenderer.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.GridFlat; |
| 32 | 33 |
import org.distorted.library.DistortedTexture; |
| 33 | 34 |
import org.distorted.library.DistortedEffectQueues; |
| ... | ... | |
| 49 | 50 |
{
|
| 50 | 51 |
private GLSurfaceView mView; |
| 51 | 52 |
private DistortedTexture mTexture; |
| 52 |
private DistortedEffectQueues mQueues; |
|
| 53 |
private DistortedEffectQueues mEffects; |
|
| 54 |
private DistortedFramebuffer mScreen; |
|
| 53 | 55 |
private GridFlat mGrid; |
| 54 | 56 |
private Static3D v0,v1,v2,v3; |
| 55 | 57 |
private Static1D dBegin, dMiddle, dEnd, s0; |
| ... | ... | |
| 109 | 111 |
diHips.add(dMiddle); |
| 110 | 112 |
diHips.add(dBegin); |
| 111 | 113 |
|
| 112 |
mQueues = new DistortedEffectQueues();
|
|
| 114 |
mEffects = new DistortedEffectQueues();
|
|
| 113 | 115 |
|
| 114 |
mQueues.sink( diSink, pLeft, sinkRegion );
|
|
| 115 |
mQueues.sink( diSink, pRight,sinkRegion );
|
|
| 116 |
mEffects.sink( diSink, pLeft, sinkRegion );
|
|
| 117 |
mEffects.sink( diSink, pRight,sinkRegion );
|
|
| 116 | 118 |
|
| 117 |
mQueues.distort(diL, pLeft , Region);
|
|
| 118 |
mQueues.distort(diR, pRight, Region);
|
|
| 119 |
mEffects.distort(diL, pLeft , Region);
|
|
| 120 |
mEffects.distort(diR, pRight, Region);
|
|
| 119 | 121 |
|
| 120 |
mQueues.swirl(diHips, pHips, HipsRegion ); |
|
| 122 |
mEffects.swirl(diHips, pHips, HipsRegion ); |
|
| 123 |
|
|
| 124 |
mScreen = new DistortedFramebuffer(0); |
|
| 121 | 125 |
} |
| 122 | 126 |
|
| 123 | 127 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 150 | 154 |
public void onDrawFrame(GL10 glUnused) |
| 151 | 155 |
{
|
| 152 | 156 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| 153 |
mQueues.draw(System.currentTimeMillis(),mTexture,mGrid);
|
|
| 157 |
mEffects.draw(System.currentTimeMillis(),mTexture,mGrid,mScreen);
|
|
| 154 | 158 |
} |
| 155 | 159 |
|
| 156 | 160 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 157 | 161 |
|
| 158 | 162 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 159 | 163 |
{
|
| 160 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
| 164 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
| 161 | 165 |
|
| 162 | 166 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
| 163 | 167 |
{
|
| 164 | 168 |
int w = (height*bmpWidth)/bmpHeight; |
| 165 | 169 |
float factor = (float)height/bmpHeight; |
| 166 | 170 |
|
| 167 |
mQueues.move( new Static3D((width-w)/2,0,0) );
|
|
| 168 |
mQueues.scale(factor);
|
|
| 171 |
mEffects.move( new Static3D((width-w)/2,0,0) );
|
|
| 172 |
mEffects.scale(factor);
|
|
| 169 | 173 |
} |
| 170 | 174 |
else |
| 171 | 175 |
{
|
| 172 | 176 |
int h = (width*bmpHeight)/bmpWidth; |
| 173 | 177 |
float factor = (float)width/bmpWidth; |
| 174 | 178 |
|
| 175 |
mQueues.move( new Static3D(0,(height-h)/2,0) );
|
|
| 176 |
mQueues.scale(factor);
|
|
| 179 |
mEffects.move( new Static3D(0,(height-h)/2,0) );
|
|
| 180 |
mEffects.scale(factor);
|
|
| 177 | 181 |
} |
| 178 | 182 |
|
| 179 |
Distorted.onSurfaceChanged(width, height);
|
|
| 183 |
mScreen.resize(width, height);
|
|
| 180 | 184 |
} |
| 181 | 185 |
|
| 182 | 186 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/listener/ListenerRenderer.java | ||
|---|---|---|
| 29 | 29 |
import org.distorted.examples.R; |
| 30 | 30 |
|
| 31 | 31 |
import org.distorted.library.Distorted; |
| 32 |
import org.distorted.library.DistortedFramebuffer; |
|
| 32 | 33 |
import org.distorted.library.GridFlat; |
| 33 | 34 |
import org.distorted.library.DistortedTexture; |
| 34 | 35 |
import org.distorted.library.DistortedEffectQueues; |
| ... | ... | |
| 53 | 54 |
|
| 54 | 55 |
private GLSurfaceView mView; |
| 55 | 56 |
private DistortedTexture mTexture; |
| 56 |
private DistortedEffectQueues mQueues; |
|
| 57 |
private DistortedEffectQueues mEffects; |
|
| 58 |
private DistortedFramebuffer mScreen; |
|
| 57 | 59 |
private GridFlat mGrid; |
| 58 | 60 |
private int bmpHeight, bmpWidth; |
| 59 | 61 |
private Random mRnd; |
| ... | ... | |
| 64 | 66 |
{
|
| 65 | 67 |
Distorted.setMaxVertex(NUM_BUBBLES); |
| 66 | 68 |
mView = v; |
| 67 |
mQueues = new DistortedEffectQueues(); |
|
| 68 |
mQueues.registerForMessages(this); |
|
| 69 |
mEffects = new DistortedEffectQueues(); |
|
| 70 |
mEffects.registerForMessages(this); |
|
| 71 |
mScreen = new DistortedFramebuffer(0); |
|
| 69 | 72 |
mRnd = new Random(0); |
| 70 | 73 |
} |
| 71 | 74 |
|
| ... | ... | |
| 83 | 86 |
dDistort.add(new Static3D(0,0, 0)); |
| 84 | 87 |
dDistort.add(new Static3D(0,0,height)); |
| 85 | 88 |
|
| 86 |
return mQueues.distort(dDistort, new Static3D(pointx,pointy,0), new Static4D(0,0,radius,radius));
|
|
| 89 |
return mEffects.distort(dDistort, new Static3D(pointx,pointy,0), new Static4D(0,0,radius,radius));
|
|
| 87 | 90 |
} |
| 88 | 91 |
|
| 89 | 92 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 103 | 106 |
public void onDrawFrame(GL10 glUnused) |
| 104 | 107 |
{
|
| 105 | 108 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| 106 |
mQueues.draw(System.currentTimeMillis(), mTexture,mGrid);
|
|
| 109 |
mEffects.draw(System.currentTimeMillis(), mTexture,mGrid,mScreen);
|
|
| 107 | 110 |
} |
| 108 | 111 |
|
| 109 | 112 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 110 | 113 |
|
| 111 | 114 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 112 | 115 |
{
|
| 113 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
| 116 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
| 114 | 117 |
|
| 115 | 118 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
| 116 | 119 |
{
|
| 117 | 120 |
int w = (height*bmpWidth)/bmpHeight; |
| 118 | 121 |
float factor = (float)height/bmpHeight; |
| 119 | 122 |
|
| 120 |
mQueues.move( new Static3D((width-w)/2,0,0) );
|
|
| 121 |
mQueues.scale(factor);
|
|
| 123 |
mEffects.move( new Static3D((width-w)/2,0,0) );
|
|
| 124 |
mEffects.scale(factor);
|
|
| 122 | 125 |
} |
| 123 | 126 |
else |
| 124 | 127 |
{
|
| 125 | 128 |
int h = (width*bmpHeight)/bmpWidth; |
| 126 | 129 |
float factor = (float)width/bmpWidth; |
| 127 | 130 |
|
| 128 |
mQueues.move( new Static3D(0,(height-h)/2,0) );
|
|
| 129 |
mQueues.scale(factor);
|
|
| 131 |
mEffects.move( new Static3D(0,(height-h)/2,0) );
|
|
| 132 |
mEffects.scale(factor);
|
|
| 130 | 133 |
} |
| 131 | 134 |
|
| 132 |
Distorted.onSurfaceChanged(width, height);
|
|
| 135 |
mScreen.resize(width, height);
|
|
| 133 | 136 |
} |
| 134 | 137 |
|
| 135 | 138 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/matrix3d/Matrix3DRenderer.java | ||
|---|---|---|
| 24 | 24 |
|
| 25 | 25 |
import org.distorted.library.Distorted; |
| 26 | 26 |
import org.distorted.library.DistortedEffectQueues; |
| 27 |
import org.distorted.library.DistortedFramebuffer; |
|
| 27 | 28 |
import org.distorted.library.GridObject; |
| 28 | 29 |
import org.distorted.library.DistortedTexture; |
| 29 |
import org.distorted.library.EffectTypes; |
|
| 30 | 30 |
|
| 31 | 31 |
import javax.microedition.khronos.egl.EGLConfig; |
| 32 | 32 |
import javax.microedition.khronos.opengles.GL10; |
| ... | ... | |
| 37 | 37 |
{
|
| 38 | 38 |
private GLSurfaceView mView; |
| 39 | 39 |
private DistortedTexture mTexture; |
| 40 |
private DistortedEffectQueues mQueues; |
|
| 40 |
private DistortedEffectQueues mEffects; |
|
| 41 |
private DistortedFramebuffer mScreen; |
|
| 41 | 42 |
private GridObject mGrid; |
| 42 | 43 |
|
| 43 | 44 |
private int mWidth, mHeight; |
| ... | ... | |
| 50 | 51 |
|
| 51 | 52 |
Matrix3DActivity act = (Matrix3DActivity)v.getContext(); |
| 52 | 53 |
|
| 53 |
mQueues = act.getQueues();
|
|
| 54 |
mEffects = act.getQueues();
|
|
| 54 | 55 |
mTexture= act.getTexture(); |
| 55 | 56 |
mGrid = act.getGrid(); |
| 57 |
mScreen = new DistortedFramebuffer(0); |
|
| 56 | 58 |
} |
| 57 | 59 |
|
| 58 | 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 60 | 62 |
public void onDrawFrame(GL10 glUnused) |
| 61 | 63 |
{
|
| 62 | 64 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| 63 |
mQueues.draw(System.currentTimeMillis(),mTexture,mGrid);
|
|
| 65 |
mEffects.draw(System.currentTimeMillis(),mTexture,mGrid,mScreen);
|
|
| 64 | 66 |
} |
| 65 | 67 |
|
| 66 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 84 | 86 |
mWidth = width; |
| 85 | 87 |
mHeight= height; |
| 86 | 88 |
|
| 87 |
Distorted.onSurfaceChanged(width, height);
|
|
| 89 |
mScreen.resize(width, height);
|
|
| 88 | 90 |
} |
| 89 | 91 |
|
| 90 | 92 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java | ||
|---|---|---|
| 27 | 27 |
|
| 28 | 28 |
import org.distorted.examples.R; |
| 29 | 29 |
import org.distorted.library.Distorted; |
| 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.GridFlat; |
| ... | ... | |
| 46 | 47 |
{
|
| 47 | 48 |
private GLSurfaceView mView; |
| 48 | 49 |
private DistortedTexture mTexture; |
| 49 |
private DistortedEffectQueues mQueues; |
|
| 50 |
private DistortedEffectQueues mEffects; |
|
Also available in: Unified diff
Change in the API: we always have to create a DistortedFramebuffer to render to.