110 |
110 |
private DistortedFramebuffer mFramebuffer;
|
111 |
111 |
private String mPath;
|
112 |
112 |
|
|
113 |
private int sW, sH;
|
|
114 |
|
113 |
115 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
114 |
116 |
|
115 |
117 |
BandagedCreatorRenderer(BandagedCreatorView v)
|
... | ... | |
231 |
233 |
if( done ) mResettingObject = false;
|
232 |
234 |
}
|
233 |
235 |
|
234 |
|
if( mSaveIcon>=0 ) mSaveIcon++;
|
235 |
|
if( mSaveIcon>=2 ) { saveIcon(time); mSaveIcon = -1; }
|
|
236 |
if( mSaveIcon>=0 )
|
|
237 |
{
|
|
238 |
if( mSaveIcon==0 ) renderIcon(time);
|
|
239 |
mSaveIcon++;
|
|
240 |
}
|
|
241 |
if( mSaveIcon>=2 )
|
|
242 |
{
|
|
243 |
saveIcon();
|
|
244 |
mSaveIcon = -1;
|
|
245 |
}
|
236 |
246 |
}
|
237 |
247 |
|
238 |
248 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
255 |
265 |
mScreen.attach(node);
|
256 |
266 |
}
|
257 |
267 |
|
|
268 |
sW = width;
|
|
269 |
sH = height;
|
|
270 |
|
258 |
271 |
mScale.set( mScaleValue,mScaleValue,mScaleValue );
|
259 |
272 |
mView.setScreenSize(width,height);
|
260 |
273 |
mScreen.resize(width,height);
|
... | ... | |
432 |
445 |
|
433 |
446 |
private void setupIconCreation(Activity act)
|
434 |
447 |
{
|
|
448 |
TwistyObject object = new TwistyBandagedGeneric(ShapeHexahedron.DEFAULT_ROT, 0.9f, TwistyObject.MODE_ICON);
|
|
449 |
DistortedEffects effects = object.getObjectEffects();
|
|
450 |
DistortedNode node = object.getNode();
|
|
451 |
|
435 |
452 |
if( mFramebuffer==null )
|
436 |
453 |
{
|
437 |
|
mFramebuffer = new DistortedFramebuffer(FBO_SIZE,FBO_SIZE,1, InternalOutputSurface.DEPTH_NO_STENCIL);
|
|
454 |
mFramebuffer = new DistortedFramebuffer(sW,sH,1, InternalOutputSurface.DEPTH_NO_STENCIL);
|
|
455 |
mFramebuffer.glClearColor(BRIGHTNESS, BRIGHTNESS, 0.0f, 1.0f);
|
438 |
456 |
}
|
439 |
457 |
|
440 |
|
TwistyObject object = new TwistyBandagedGeneric(ShapeHexahedron.DEFAULT_ROT, 1.15f, TwistyObject.MODE_ICON);
|
441 |
|
DistortedEffects effects = object.getObjectEffects();
|
442 |
|
DistortedNode node = object.getNode();
|
443 |
|
|
444 |
458 |
mFramebuffer.detachAll();
|
445 |
459 |
mFramebuffer.attach(node);
|
446 |
460 |
|
... | ... | |
460 |
474 |
|
461 |
475 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
462 |
476 |
|
463 |
|
private void saveIcon(long time)
|
464 |
|
{
|
465 |
|
mFramebuffer.render(time);
|
466 |
|
int fW = mFramebuffer.getWidth();
|
467 |
|
int fH = mFramebuffer.getHeight();
|
468 |
|
ByteBuffer buf = ByteBuffer.allocateDirect(fW*fH*4);
|
469 |
|
buf.order(ByteOrder.LITTLE_ENDIAN);
|
|
477 |
private void renderIcon(long time)
|
|
478 |
{
|
|
479 |
mFramebuffer.render(time);
|
|
480 |
}
|
470 |
481 |
|
471 |
|
int textureID = mFramebuffer.getTextureID();
|
|
482 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
472 |
483 |
|
473 |
|
if( textureID>=0 )
|
474 |
|
{
|
475 |
|
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, textureID);
|
476 |
|
GLES31.glReadPixels( 0, 0, fW, fH, GLES31.GL_RGBA, GLES31.GL_UNSIGNED_BYTE, buf);
|
477 |
|
BandagedCreatorWorkerThread.newBuffer(buf,fW,fH,6,mPath);
|
478 |
|
}
|
479 |
|
else
|
480 |
|
{
|
481 |
|
android.util.Log.e("Save", "Error trying to read from offscreen FBO, textureID="+textureID);
|
482 |
|
}
|
|
484 |
private void saveIcon()
|
|
485 |
{
|
|
486 |
int fW = mFramebuffer.getWidth();
|
|
487 |
int fH = mFramebuffer.getHeight();
|
483 |
488 |
|
484 |
|
mSaveIcon = -1;
|
485 |
|
}
|
|
489 |
ByteBuffer buf = ByteBuffer.allocateDirect(fW*fH*4);
|
|
490 |
buf.order(ByteOrder.LITTLE_ENDIAN);
|
|
491 |
|
|
492 |
mFramebuffer.setAsReadFramebuffer(0);
|
|
493 |
GLES31.glReadBuffer(GLES31.GL_COLOR_ATTACHMENT0);
|
|
494 |
GLES31.glReadPixels( 0, 0, fW, fH, GLES31.GL_RGBA, GLES31.GL_UNSIGNED_BYTE, buf);
|
|
495 |
BandagedCreatorWorkerThread.newBuffer(buf,fW,fH,6,mPath);
|
|
496 |
GLES31.glBindFramebuffer(GLES31.GL_READ_FRAMEBUFFER, 0);
|
|
497 |
|
|
498 |
mSaveIcon = -1;
|
|
499 |
}
|
486 |
500 |
|
487 |
501 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
488 |
502 |
|
Create the bandaged 3x3 icon: something works, the shape is drawn, but it's entirely black. Investigate.