Revision 3c8b1903
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/examples/dynamic/DynamicRenderer.java | ||
---|---|---|
68 | 68 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
69 | 69 |
{ |
70 | 70 |
try |
71 |
{
|
|
72 |
Distorted.onSurfaceCreated(mView.getContext());
|
|
73 |
}
|
|
74 |
catch(Exception ex)
|
|
75 |
{
|
|
76 |
android.util.Log.e("Renderer", ex.getMessage() );
|
|
77 |
}
|
|
71 |
{ |
|
72 |
Distorted.onSurfaceCreated(mView.getContext()); |
|
73 |
} |
|
74 |
catch(Exception ex) |
|
75 |
{ |
|
76 |
android.util.Log.e("Renderer", ex.getMessage() ); |
|
77 |
} |
|
78 | 78 |
} |
79 | 79 |
|
80 | 80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/movingeffects/MovingEffectsRenderer.java | ||
---|---|---|
47 | 47 |
private GridFlat mGrid; |
48 | 48 |
private DistortedEffectQueues mQueues; |
49 | 49 |
private DistortedTexture mTexture; |
50 |
private boolean mRefresh; |
|
50 | 51 |
|
51 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
52 | 53 |
|
... | ... | |
60 | 61 |
mView = v; |
61 | 62 |
|
62 | 63 |
mQueues = new DistortedEffectQueues(); |
64 |
mRefresh = true; |
|
63 | 65 |
} |
64 | 66 |
|
65 | 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
94 | 96 |
return mQueues; |
95 | 97 |
} |
96 | 98 |
|
99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
100 |
|
|
101 |
void setRefresh() |
|
102 |
{ |
|
103 |
mRefresh = true; |
|
104 |
} |
|
105 |
|
|
97 | 106 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
98 | 107 |
|
99 | 108 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
... | ... | |
132 | 141 |
|
133 | 142 |
long time = System.currentTimeMillis(); |
134 | 143 |
|
135 |
if (mView.getCurrentEffect() == MovingEffectsSurfaceView.EFFECT_POINTS ) |
|
144 |
if (mView.getCurrentEffect() == MovingEffectsSurfaceView.EFFECT_POINTS && mRefresh )
|
|
136 | 145 |
{ |
137 | 146 |
drawBackground(); |
138 | 147 |
mView.drawCurve(mCanvas,time); |
139 | 148 |
mTexture.setTexture(mBitmap); |
149 |
mRefresh = false; |
|
140 | 150 |
} |
141 | 151 |
|
142 | 152 |
mQueues.draw(time,mTexture,mGrid); |
src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java | ||
---|---|---|
203 | 203 |
di3D.removeAll(); |
204 | 204 |
mRegion.removeAll(); |
205 | 205 |
mCurrEffect = EFFECT_POINTS; |
206 |
mRenderer.setRefresh(); |
|
206 | 207 |
} |
207 | 208 |
} |
208 | 209 |
|
... | ... | |
216 | 217 |
|
217 | 218 |
float[] drawCoord = new float[3]; |
218 | 219 |
Static3D cu; |
219 |
int lit = mTime> 0 ? (int)((float)(time-mTime)*NUM_POINTS/LOOP_TIME) : 0; |
|
220 |
|
|
220 |
|
|
221 | 221 |
if( len>=2 ) |
222 | 222 |
{ |
223 | 223 |
float step = (float)LOOP_TIME/(NUM_POINTS+1); |
224 | 224 |
|
225 | 225 |
for(int i=0; i<NUM_POINTS; i++) |
226 | 226 |
{ |
227 |
int color = i<=lit ? 0xff - (lit -i)*0xff/(NUM_POINTS-1) |
|
228 |
: 0xff - (lit+NUM_POINTS-i)*0xff/(NUM_POINTS-1); |
|
229 |
|
|
230 |
mPaint.setColor( 0xffffff + ((color&0xff)<<24) ); |
|
227 |
mPaint.setColor( 0xffffffff ); |
|
231 | 228 |
di3D.interpolateMain( drawCoord, 0, (long)(i*step) ); |
232 | 229 |
c.drawCircle(drawCoord[0], drawCoord[1], mSize1, mPaint ); |
233 | 230 |
} |
... | ... | |
281 | 278 |
di3D.add(new Static3D(xDown,yDown,0)); |
282 | 279 |
mRegion.add(new Static4D(xDown,yDown,mSizeR,mSizeR)); |
283 | 280 |
} |
284 |
} |
|
281 |
} |
|
282 |
mRenderer.setRefresh(); |
|
285 | 283 |
break; |
286 | 284 |
case MotionEvent.ACTION_MOVE: if( moving>=0 ) |
287 | 285 |
{ |
... | ... | |
290 | 288 |
|
291 | 289 |
di3D.setPoint(moving, xDown, yDown, 0); |
292 | 290 |
mRegion.setPoint(moving, xDown, yDown, mSizeR, mSizeR); |
293 |
} |
|
291 |
} |
|
292 |
mRenderer.setRefresh(); |
|
294 | 293 |
break; |
295 | 294 |
case MotionEvent.ACTION_UP : moving = -1; |
296 | 295 |
break; |
src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java | ||
---|---|---|
68 | 68 |
|
69 | 69 |
mScreenW = 9*LEAF_SIZE; |
70 | 70 |
mScreenH = 9*LEAF_SIZE; |
71 |
|
|
72 | 71 |
mScreen = new DistortedObjectTree(new DistortedTexture(mScreenW,mScreenH), queue, grid); |
73 | 72 |
|
74 | 73 |
Dynamic1D rot = new Dynamic1D(5000,0.0f); |
... | ... | |
87 | 86 |
|
88 | 87 |
for(int i=0; i<NUM_CIRCLES; i++) |
89 | 88 |
{ |
90 |
if( i==0 )
|
|
89 |
if( i<=1 )
|
|
91 | 90 |
{ |
92 | 91 |
queue = new DistortedEffectQueues(); |
93 | 92 |
mCircleNode[i] = new DistortedObjectTree(new DistortedTexture(3*LEAF_SIZE,3*LEAF_SIZE), queue, grid); |
94 | 93 |
|
95 |
for(int j=0; j<NUM_LEAVES; j++) |
|
94 |
for(int j=0; j<NUM_LEAVES-i; j++)
|
|
96 | 95 |
{ |
97 | 96 |
queue = new DistortedEffectQueues(); |
98 | 97 |
mCircleNode[i].attach(mLeaf, queue, grid); |
... | ... | |
104 | 103 |
{ |
105 | 104 |
mCircleNode[i] = new DistortedObjectTree(mCircleNode[0], Distorted.CLONE_BITMAP|Distorted.CLONE_CHILDREN); |
106 | 105 |
} |
107 |
|
|
106 |
|
|
108 | 107 |
mScreen.attach(mCircleNode[i]); |
109 | 108 |
queue = mCircleNode[i].getQueues(); |
110 | 109 |
queue.move( new Static3D(positions[2*i], positions[2*i+1], 0) ); |
src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java | ||
---|---|---|
348 | 348 |
{ |
349 | 349 |
mRoot.detach(mGFFAQueue); |
350 | 350 |
mGFFAQueue.delete(); |
351 |
mGFFATexture.delete();
|
|
351 |
mGFFATexture.markForDeletion();
|
|
352 | 352 |
|
353 | 353 |
int screenW=mScreenTexture.getWidth(); |
354 | 354 |
int screenH=mScreenTexture.getHeight(); |
... | ... | |
374 | 374 |
{ |
375 | 375 |
mRoot.detach(mLogoQueue); |
376 | 376 |
mLogoQueue.delete(); |
377 |
mLogoTexture.delete();
|
|
377 |
mLogoTexture.markForDeletion();
|
|
378 | 378 |
|
379 | 379 |
int crawlW = mCrawlTexture.getWidth(); |
380 | 380 |
int crawlH = mCrawlTexture.getHeight(); |
... | ... | |
407 | 407 |
mRoot.detach(mBackground); |
408 | 408 |
mBackground.detach(mCrawlQueue); |
409 | 409 |
mCrawlQueue.delete(); |
410 |
mCrawlTexture.delete();
|
|
410 |
mCrawlTexture.markForDeletion();
|
|
411 | 411 |
mCrawlBackgroundQueue.delete(); |
412 |
mCrawlBackgroundTexture.delete();
|
|
412 |
mCrawlBackgroundTexture.markForDeletion();
|
|
413 | 413 |
} |
414 | 414 |
} |
415 | 415 |
} |
Also available in: Unified diff
Major restructuring with DistortedTexture. One now is able to create Textures anywhere, even from a thread which does not hold the OpenGL context. Same for DistortedFramebuffers.