Project

General

Profile

« Previous | Next » 

Revision 89de975c

Added by Leszek Koltunski almost 7 years ago

Add possibility to create FBOs with combined DEPTH/STENCIL.

View differences:

src/main/java/org/distorted/library/DistortedOutputSurface.java
27 27

  
28 28
abstract class DistortedOutputSurface extends DistortedSurface implements DistortedSlave
29 29
{
30
/**
31
 * Do not create DEPTH or STENCIL attachment
32
 */
33
  public static final int NO_DEPTH_STENCIL = 0;
34
/**
35
 * Create DEPTH, but not STENCIL
36
 */
37
  public static final int DEPTH_NO_STENCIL = 1;
38
/**
39
 * Create both DEPTH and STENCIL
40
 */
41
  public static final int BOTH_DEPTH_STENCIL= 2;
42

  
30 43
  private static final int ATTACH = 0;
31 44
  private static final int DETACH = 1;
32 45
  private static final int DETALL = 2;
......
58 71
  float mDistance, mNear;
59 72
  float[] mProjectionMatrix;
60 73

  
61
  int mDepthCreated;
62
  int[] mDepthH = new int[1];
63
  int[] mFBOH   = new int[1];
74
  int mDepthStencilCreated;
75
  int mDepthStencil;
76
  int[] mDepthStencilH = new int[1];
77
  int[] mFBOH          = new int[1];
64 78

  
65 79
  private float mClearR, mClearG, mClearB, mClearA;
66 80
  private float mClearDepth;
......
72 86

  
73 87
///////////////////////////////////////////////////////////////////////////////////////////////////
74 88

  
75
  DistortedOutputSurface(int width, int height, int createColor, int createDepth, int fbo, int type)
89
  DistortedOutputSurface(int width, int height, int createColor, int depthStencil, int fbo, int type)
76 90
    {
77 91
    super(width,height,createColor,type);
78 92

  
......
81 95
    mFOV = 60.0f;
82 96
    mNear=  0.5f;
83 97

  
84
    mDepthCreated= createDepth;
85
    mFBOH[0]     = fbo;
86
    mDepthH[0]   = 0;
98
    mDepthStencilCreated= (depthStencil==NO_DEPTH_STENCIL ? DONT_CREATE:NOT_CREATED_YET);
99
    mDepthStencil = depthStencil;
100

  
101
    mFBOH[0]         = fbo;
102
    mDepthStencilH[0]= 0;
87 103

  
88 104
    mTime = 0;
89 105

  
......
180 196

  
181 197
          for(int j=0; j<EffectQuality.LENGTH; j++)
182 198
            {
183
            mBuffer1[j] = new DistortedFramebuffer( mDepthCreated!=DONT_CREATE, DistortedObject.TYPE_SYST,
199
            mBuffer1[j] = new DistortedFramebuffer( mDepthStencil   , DistortedObject.TYPE_SYST,
184 200
                                                    (int)(mWidth*mipmap), (int)(mHeight*mipmap) );
185
            mBuffer2[j] = new DistortedFramebuffer( false                     , DistortedObject.TYPE_SYST,
201
            mBuffer2[j] = new DistortedFramebuffer( NO_DEPTH_STENCIL, DistortedObject.TYPE_SYST,
186 202
                                                    (int)(mWidth*mipmap), (int)(mHeight*mipmap) );
187 203
            mBuffer1[j].mMipmap = mipmap;
188 204
            mipmap *= EffectQuality.MULTIPLIER;
......
431 447

  
432 448
///////////////////////////////////////////////////////////////////////////////////////////////////
433 449
/**
434
 * Create a new DEPTH buffer and attach it or (param=false) detach an existing DEPTH attachment and recreate it.
450
 * Return true if the Surface contains a DEPTH attachment.
435 451
 *
436
 * @param enable <bold>true</bold> if we want to attach a new DEPTH buffer to the FBO.<br>
437
 *               <bold>false</bold> if we want to detach the DEPTH attachment.
452
 * @return <bold>true</bold> if the Surface contains a DEPTH attachment.
438 453
 */
439
  public void enableDepth(boolean enable)
454
  public boolean hasDepth()
440 455
    {
441
    if( enable && mDepthCreated==DONT_CREATE )
442
      {
443
      mDepthCreated = NOT_CREATED_YET;
444
      markForCreation();
445
      }
446
    if( !enable && mDepthCreated!=DONT_CREATE )
447
      {
448
      mDepthCreated = DONT_CREATE;
449
      markForCreation();
450
      }
456
    return mDepthStencilCreated==CREATED;
451 457
    }
452 458

  
453 459
///////////////////////////////////////////////////////////////////////////////////////////////////
454 460
/**
455
 * Return true if the Surface contains a DEPTH attachment.
461
 * Return true if the Surface contains a STENCIL attachment.
456 462
 *
457
 * @return <bold>true</bold> if the FBO contains a DEPTH attachment.
463
 * @return <bold>true</bold> if the Surface contains a STENCIL attachment.
458 464
 */
459
  public boolean hasDepth()
465
  public boolean hasStencil()
460 466
    {
461
    return mDepthCreated==CREATED;
467
    return (mDepthStencilCreated==CREATED && mDepthStencil==BOTH_DEPTH_STENCIL);
462 468
    }
463 469

  
464 470
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff