Revision 88c7b603
Added by Leszek Koltunski almost 6 years ago
src/main/java/org/distorted/library/main/DistortedOutputSurface.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
public abstract class DistortedOutputSurface extends DistortedSurface implements DistortedMaster.Slave |
36 | 36 |
{ |
37 |
//////////// DEBUG FLAGS ///////////////////////////////////////////// |
|
38 |
/** |
|
39 |
* When rendering a Screen, show FPS in the upper-left corner? |
|
40 |
*/ |
|
41 |
public static final int DEBUG_FPS = 1; |
|
42 |
//////////// END DEBUG FLAGS ///////////////////////////////////////// |
|
43 |
|
|
44 | 37 |
/** |
45 | 38 |
* Do not create DEPTH or STENCIL attachment |
46 | 39 |
*/ |
... | ... | |
96 | 89 |
private int mClear; |
97 | 90 |
float mMipmap; |
98 | 91 |
|
99 |
private int mDebugLevel; |
|
100 |
|
|
101 | 92 |
int mRealWidth; // the Surface can be backed up with a texture that is |
102 | 93 |
int mRealHeight; // larger than the viewport we have to it. |
103 | 94 |
// mWidth,mHeight are the sizes of the Viewport, those - |
104 | 95 |
// sizes of the backing up texture. |
105 | 96 |
|
106 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
107 |
|
|
108 |
abstract void prepareDebug(long time); |
|
109 |
abstract void renderDebug(long time); |
|
110 |
|
|
111 | 97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
112 | 98 |
|
113 | 99 |
DistortedOutputSurface(int width, int height, int createColor, int numcolors, int depthStencil, int fbo, int type) |
... | ... | |
129 | 115 |
mDepthStencilH[0]= 0; |
130 | 116 |
|
131 | 117 |
mTime = 0; |
132 |
mDebugLevel = 0; |
|
133 | 118 |
|
134 | 119 |
mClearR = 0.0f; |
135 | 120 |
mClearG = 0.0f; |
... | ... | |
371 | 356 |
|
372 | 357 |
DistortedRenderState.enableStencil(); |
373 | 358 |
|
359 |
// we cannot compare DEPTH24_STENCIL8 format to DEPTH32 which oitRender's fragment shader expects. Remount! |
|
360 |
if( mDepthStencil==BOTH_DEPTH_STENCIL ) |
|
361 |
{ |
|
362 |
GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, mFBOH[0]); |
|
363 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_DEPTH_STENCIL_ATTACHMENT, GLES31.GL_TEXTURE_2D, 0, 0); |
|
364 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_DEPTH_ATTACHMENT, GLES31.GL_TEXTURE_2D, mDepthStencilH[0], 0); |
|
365 |
} |
|
366 |
|
|
374 | 367 |
DistortedEffects.oitRender(this, buffer.getWidthCorrection(), buffer.getHeightCorrection() ); |
368 |
|
|
369 |
if( mDepthStencil==BOTH_DEPTH_STENCIL ) |
|
370 |
{ |
|
371 |
GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, mFBOH[0]); |
|
372 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_DEPTH_ATTACHMENT, GLES31.GL_TEXTURE_2D, 0, 0); |
|
373 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_DEPTH_STENCIL_ATTACHMENT, GLES31.GL_TEXTURE_2D, mDepthStencilH[0], 0); |
|
374 |
} |
|
375 |
|
|
375 | 376 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE1); |
376 | 377 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0); |
377 | 378 |
|
... | ... | |
402 | 403 |
} |
403 | 404 |
} |
404 | 405 |
|
406 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
407 |
|
|
408 |
void clear() |
|
409 |
{ |
|
410 |
DistortedRenderState.colorDepthStencilOn(); |
|
411 |
GLES31.glClearColor(mClearR, mClearG, mClearB, mClearA); |
|
412 |
GLES31.glClearDepthf(mClearDepth); |
|
413 |
GLES31.glClearStencil(mClearStencil); |
|
414 |
GLES31.glClear(mClear); |
|
415 |
DistortedRenderState.colorDepthStencilRestore(); |
|
416 |
} |
|
417 |
|
|
405 | 418 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
406 | 419 |
// Render all children, one by one. If there are no postprocessing effects, just render to THIS. |
407 | 420 |
// Otherwise, render to a buffer and on each change of Postprocessing Bucket, apply the postprocessing |
... | ... | |
521 | 534 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
522 | 535 |
// PUBLIC API |
523 | 536 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
524 |
/** |
|
525 |
* Make the library show various debugging information. |
|
526 |
* <p> |
|
527 |
* Currently only DEBUG_FPS - show FPS in the upper-left corner of every Screen - is defined. |
|
528 |
* |
|
529 |
* @param bitmask 0, or a bitmask of DEBUG_** flags to enable (currently only DEBUG_FPS defined) |
|
530 |
*/ |
|
531 |
public void setDebug(int bitmask) |
|
532 |
{ |
|
533 |
if( this instanceof DistortedScreen ) |
|
534 |
mDebugLevel = bitmask; |
|
535 |
} |
|
536 |
|
|
537 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
538 |
|
|
539 | 537 |
/** |
540 | 538 |
* Draws all the attached children to this OutputSurface. |
541 | 539 |
* <p> |
... | ... | |
546 | 544 |
*/ |
547 | 545 |
public int render(long time) |
548 | 546 |
{ |
549 |
if( mDebugLevel!=0 ) prepareDebug(time); |
|
550 |
|
|
551 | 547 |
// change tree topology (attach and detach children) |
552 | 548 |
/* |
553 | 549 |
boolean changed1 = |
... | ... | |
592 | 588 |
setAsOutput(time); |
593 | 589 |
numRenders += renderChildren(time,mNumChildren,mChildren); |
594 | 590 |
|
595 |
if( mDebugLevel != 0 ) renderDebug(time); |
|
596 |
|
|
597 | 591 |
return numRenders; |
598 | 592 |
} |
599 | 593 |
|
... | ... | |
613 | 607 |
if( mTime!=time ) |
614 | 608 |
{ |
615 | 609 |
mTime = time; |
616 |
DistortedRenderState.colorDepthStencilOn(); |
|
617 |
GLES31.glClearColor(mClearR, mClearG, mClearB, mClearA); |
|
618 |
GLES31.glClearDepthf(mClearDepth); |
|
619 |
GLES31.glClearStencil(mClearStencil); |
|
620 |
GLES31.glClear(mClear); |
|
621 |
DistortedRenderState.colorDepthStencilRestore(); |
|
610 |
clear(); |
|
622 | 611 |
} |
623 | 612 |
} |
624 | 613 |
|
Also available in: Unified diff
Reengineer DistortedScreen