Revision f6d884d5
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/effectqueue/EffectQueueRenderer.java | ||
---|---|---|
30 | 30 |
import android.opengl.GLSurfaceView; |
31 | 31 |
|
32 | 32 |
import org.distorted.library.GridFlat; |
33 |
import org.distorted.library.DistortedObject; |
|
33 |
import org.distorted.library.DistortedTexture; |
|
34 |
import org.distorted.library.DistortedEffectQueues; |
|
34 | 35 |
import org.distorted.library.Distorted; |
35 | 36 |
import org.distorted.library.EffectNames; |
36 | 37 |
import org.distorted.library.EffectTypes; |
... | ... | |
40 | 41 |
|
41 | 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
42 | 43 |
|
43 |
public class EffectQueueRenderer implements GLSurfaceView.Renderer, EffectListener
|
|
44 |
class EffectQueueRenderer implements GLSurfaceView.Renderer, EffectListener |
|
44 | 45 |
{ |
45 | 46 |
private static final int NUMLINES = 10; |
46 | 47 |
static final int BWID = 300; |
... | ... | |
50 | 51 |
private Paint mPaint; |
51 | 52 |
private int texWidth, texHeight; |
52 | 53 |
|
53 |
DistortedObject mBackground; |
|
54 |
GridFlat mGrid; |
|
54 |
private DistortedTexture mTexture; |
|
55 |
private GridFlat mGrid; |
|
56 |
private DistortedEffectQueues mQueues; |
|
55 | 57 |
|
56 | 58 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
57 | 59 |
|
... | ... | |
67 | 69 |
texWidth = BWID; |
68 | 70 |
texHeight= BHEI; |
69 | 71 |
|
70 |
mGrid = new GridFlat(80,80*texHeight/texWidth); |
|
71 |
mBackground= new DistortedObject(texWidth,texHeight,1); |
|
72 |
mGrid = new GridFlat(80,80*texHeight/texWidth); |
|
73 |
mTexture = new DistortedTexture(texWidth,texHeight,0); |
|
74 |
mQueues = new DistortedEffectQueues(); |
|
72 | 75 |
|
73 |
mBackground.addEventListener(this);
|
|
76 |
mQueues.addEventListener(this);
|
|
74 | 77 |
} |
75 | 78 |
|
76 | 79 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
77 |
|
|
80 |
|
|
81 |
DistortedEffectQueues getQueues() |
|
82 |
{ |
|
83 |
return mQueues; |
|
84 |
} |
|
85 |
|
|
86 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
87 |
|
|
78 | 88 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
79 | 89 |
{ |
80 | 90 |
Bitmap bitmap = Bitmap.createBitmap(texWidth,texHeight, Bitmap.Config.ARGB_8888); |
... | ... | |
89 | 99 |
canvas.drawRect(texWidth*i/NUMLINES - 1, 0, texWidth*i/NUMLINES + 1, texHeight , mPaint); |
90 | 100 |
canvas.drawRect( 0, texHeight*i/NUMLINES -1, texWidth , texHeight*i/NUMLINES + 1, mPaint); |
91 | 101 |
} |
92 |
mBackground.setTexture(bitmap);
|
|
102 |
mTexture.setTexture(bitmap);
|
|
93 | 103 |
|
94 | 104 |
try |
95 | 105 |
{ |
... | ... | |
105 | 115 |
|
106 | 116 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
107 | 117 |
{ |
108 |
mBackground.abortEffects(EffectTypes.MATRIX);
|
|
109 |
mBackground.scale( new Static3D((float)width/texWidth,(float)height/texHeight,1) );
|
|
118 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
119 |
mQueues.scale( new Static3D((float)width/texWidth,(float)height/texHeight,1) );
|
|
110 | 120 |
Distorted.onSurfaceChanged(width,height); |
111 | 121 |
mView.setScreenSize(width,height); |
112 | 122 |
} |
... | ... | |
116 | 126 |
public void onDrawFrame(GL10 glUnused) |
117 | 127 |
{ |
118 | 128 |
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); |
119 |
mBackground.draw(System.currentTimeMillis(), mGrid);
|
|
129 |
mQueues.draw(System.currentTimeMillis(), mTexture,mGrid);
|
|
120 | 130 |
} |
121 | 131 |
|
122 | 132 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Complete the split DistortedObject -> (DistortedTexture,DistortedEffectQueue)