Project

General

Profile

« Previous | Next » 

Revision ad16ed3b

Added by Leszek Koltunski over 7 years ago

Progress with Stencil App; should be working now AFAIK but doesn't.

View differences:

src/main/java/org/distorted/library/DistortedNode.java
685 685
    return mData.mFBO;
686 686
    }
687 687

  
688

  
688
///////////////////////////////////////////////////////////////////////////////////////////////////
689
// APIs that control how to set the OpenGL state just before rendering this Node.
689 690
///////////////////////////////////////////////////////////////////////////////////////////////////
690 691
/**
691 692
 * When rendering this Node, use ColorMask (r,g,b,a).
......
807 808
    {
808 809
    mState.glBlendFunc(src,dst);
809 810
    }
811

  
812
///////////////////////////////////////////////////////////////////////////////////////////////////
813
/**
814
 * Before rendering this Node, clear the following buffers.
815
 * <p>
816
 * Valid values: 0, or bitwise OR of one or more values from the set GL_COLOR_BUFFER_BIT,
817
 *               GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT.
818
 * Default: 0
819
 *
820
 * @param mask bitwise OR of BUFFER_BITs to clear.
821
 */
822
  @SuppressWarnings("unused")
823
  public void glClear(int mask)
824
    {
825
    mState.glClear(mask);
826
    }
810 827
  }
src/main/java/org/distorted/library/DistortedOutputSurface.java
64 64

  
65 65
  private float mClearR, mClearG, mClearB, mClearA;
66 66
  private float mClearDepth;
67
  private int mClear;
67 68

  
68 69
//private String sNew="", sOld="";
69 70

  
......
92 93
    mClearA = 0.0f;
93 94

  
94 95
    mClearDepth = 1.0f;
96
    mClear = GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT;
95 97

  
96 98
    mBuffer1 = new DistortedFramebuffer[EffectQuality.LENGTH];
97 99
    mBuffer2 = new DistortedFramebuffer[EffectQuality.LENGTH];
......
295 297
      DistortedRenderState.colorDepthOn();
296 298
      GLES30.glClearColor(mClearR, mClearG, mClearB, mClearA);
297 299
      GLES30.glClearDepthf(mClearDepth);
298
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
300
      GLES30.glClear(mClear);
299 301
      }
300 302
    }
301 303

  
......
326 328
///////////////////////////////////////////////////////////////////////////////////////////////////
327 329
/**
328 330
 * Set the (R,G,B,A) values of GLES30.glClearColor() to set up color with which to clear
329
 * this Surface before each render.
331
 * this Surface at the beginning of each frame.
330 332
 *
331 333
 * @param r the Red component. Default: 0.0f
332 334
 * @param g the Green component. Default: 0.0f
......
344 346
///////////////////////////////////////////////////////////////////////////////////////////////////
345 347
/**
346 348
 * Set the Depth value of GLES30.glClearDepthf() to set up depth with which to clear
347
 * the Depth buffer of Surface before each render.
349
 * the Depth buffer of Surface at the beginning of each frame.
348 350
 *
349 351
 * @param d the Depth. Default: 1.0f
350 352
 */
......
353 355
    mClearDepth = d;
354 356
    }
355 357

  
358
///////////////////////////////////////////////////////////////////////////////////////////////////
359
/**
360
 * Which buffers to Clear at the beginning of each frame?
361
 * <p>
362
 * Valid values: 0, or bitwise OR of one or more values from the set GL_COLOR_BUFFER_BIT,
363
 *               GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT.
364
 * Default: GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT.
365
 *
366
 * @param mask bitwise OR of BUFFER_BITs to clear.
367
 */
368
  public void glClear(int mask)
369
    {
370
    mClear = mask;
371
    }
372

  
356 373
///////////////////////////////////////////////////////////////////////////////////////////////////
357 374
/**
358 375
 * Create new Projection matrix.
src/main/java/org/distorted/library/DistortedRenderState.java
24 24
///////////////////////////////////////////////////////////////////////////////////////////////////
25 25
/**
26 26
 * Remember the OpenGL state.
27
 * <p>
28
 * This is a member of DistortedNode. Remembers the OpenGL state we want to set just before rendering
29
 * the Node.
27 30
 */
28 31
class DistortedRenderState
29 32
{
30
  private static int sColorMaskR, sColorMaskG, sColorMaskB, sColorMaskA;
31
  private static int sDepthMask;
32
  private static int sStencilMask;
33
  private static int sDepthTest;
34
  private static int sStencilTest;
35
  private static int sStencilFuncFunc, sStencilFuncRef, sStencilFuncMask;
36
  private static int sStencilOpSfail, sStencilOpDpfail, sStencilOpDppass;
37
  private static int sDepthFunc;
38
  private static int sBlend;
39
  private static int sBlendSrc, sBlendDst;
40

  
41
  private int mColorMaskR, mColorMaskG, mColorMaskB, mColorMaskA;
42
  private int mDepthMask;
43
  private int mStencilMask;
44
  private int mDepthTest;
45
  private int mStencilTest;
46
  private int mStencilFuncFunc, mStencilFuncRef, mStencilFuncMask;
47
  private int mStencilOpSfail, mStencilOpDpfail, mStencilOpDppass;
48
  private int mDepthFunc;
49
  private int mBlend;
50
  private int mBlendSrc, mBlendDst;
33
  private static int sColorMaskR, sColorMaskG, sColorMaskB, sColorMaskA;   //
34
  private static int sDepthMask;                                           //
35
  private static int sStencilMask;                                         //
36
  private static int sDepthTest;                                           //
37
  private static int sStencilTest;                                         //
38
  private static int sStencilFuncFunc, sStencilFuncRef, sStencilFuncMask;  // current OpenGL state
39
  private static int sStencilOpSfail, sStencilOpDpfail, sStencilOpDppass;  //
40
  private static int sDepthFunc;                                           //
41
  private static int sBlend;                                               //
42
  private static int sBlendSrc, sBlendDst;                                 //
43

  
44
  private int mColorMaskR, mColorMaskG, mColorMaskB, mColorMaskA;          //
45
  private int mDepthMask;                                                  //
46
  private int mStencilMask;                                                //
47
  private int mDepthTest;                                                  //
48
  private int mStencilTest;                                                //
49
  private int mStencilFuncFunc, mStencilFuncRef, mStencilFuncMask;         // The state we want to have
50
  private int mStencilOpSfail, mStencilOpDpfail, mStencilOpDppass;         //
51
  private int mDepthFunc;                                                  //
52
  private int mBlend;                                                      //
53
  private int mBlendSrc, mBlendDst;                                        //
54
  private int mClear;                                                      // This does not have a 'static' compatriot
51 55

  
52 56
///////////////////////////////////////////////////////////////////////////////////////////////////
53 57
// default: color writes on, depth test and writes on, blending on, stencil off.
......
75 79
    mStencilOpSfail  = GLES30.GL_KEEP;
76 80
    mStencilOpDpfail = GLES30.GL_KEEP;
77 81
    mStencilOpDppass = GLES30.GL_KEEP;
82

  
83
    mClear = 0;
78 84
    }
79 85

  
80 86
///////////////////////////////////////////////////////////////////////////////////////////////////
......
237 243
      sStencilMask = mStencilMask;
238 244
      GLES30.glStencilMask(sStencilMask);
239 245
      }
246

  
247
    // 7. Clear buffers?
248

  
249
    if( mClear!=0 )
250
      {
251
      GLES30.glClear(mClear);
252
      }
240 253
    }
241 254

  
242 255
///////////////////////////////////////////////////////////////////////////////////////////////////
......
314 327
    mBlendDst = dst;
315 328
    }
316 329

  
330
///////////////////////////////////////////////////////////////////////////////////////////////////
331

  
332
  void glClear(int mask)
333
    {
334
    mClear = mask;
335
    }
317 336
}

Also available in: Unified diff