Project

General

Profile

Download (25 KB) Statistics
| Branch: | Revision:

library / src / main / java / org / distorted / library / main / DistortedNode.java @ b7074bc6

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Distorted is distributed in the hope that it will be useful,                                  //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.library.main;
21

    
22
import android.opengl.GLES30;
23

    
24
import org.distorted.library.mesh.MeshBase;
25

    
26
import java.util.ArrayList;
27
import java.util.Collections;
28

    
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30
/**
31
 * Class which represents a Node in a Tree of (InputSurface,Mesh,Effects) triplets.
32
 * <p>
33
 * Having organized such sets into a Tree, we can then render any Node to any OutputSurface.
34
 * That recursively renders the set held in the Node and all its children.
35
 * <p>
36
 * The class takes special care to only render identical sub-trees once. Each Node holds a reference
37
 * to sub-class 'NodeData'. Two identical sub-trees attached at different points of the main tree
38
 * will point to the same NodeData; only the first of this is rendered (mData.numRender!).
39
 */
40
public class DistortedNode implements InternalChildrenList.Parent
41
  {
42
  private static final int DEFAULT_FBO_SIZE = 100;
43

    
44
  private MeshBase mMesh;
45
  private DistortedEffects mEffects;
46
  private InternalSurface mSurface;
47
  private InternalRenderState mState;
48
  private InternalNodeData mData;
49
  private InternalChildrenList mChildren;
50
  private InternalChildrenList.Parent mParent;
51

    
52
  private int mFboW, mFboH, mFboDepthStencil;
53
  private boolean mRenderWayOIT;
54
  private float mFOV, mNear;
55

    
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

    
58
  public void markForDeletion()
59
    {
60
    if( mData.removeData() )
61
      {
62
      mData.mFBO.markForDeletion();
63
      mData.mFBO = null;
64
      }
65
    }
66

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68
// [3] --> the postprocessing queue. See EffectType.
69

    
70
  long getBucket()
71
    {
72
    return mEffects.getQueues()[3].getID();
73
    }
74

    
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

    
77
  private ArrayList<Long> generateIDList()
78
    {
79
    ArrayList<Long> ret = new ArrayList<>();
80
    int numChildren = mChildren.getNumChildren();
81

    
82
    if( numChildren==0 )
83
      {
84
      // add a negative number so this leaf never gets confused with a internal node
85
      // with a single child that happens to have ID identical to some leaf's Effects ID.
86
      ret.add(-mEffects.getID());
87
      }
88
    else
89
      {
90
      DistortedNode node;
91
   
92
      for(int i=0; i<numChildren; i++)
93
        {
94
        node = mChildren.getChild(i);
95
        ret.add(node.mData.ID);
96
        }
97

    
98
      // A bit questionable decision here - we are sorting the children IDs, which means
99
      // that order in which we draw the children is going to be undefined (well, this is not
100
      // strictly speaking true - when rendering, if no postprocessing and isomorphism are
101
      // involved, we *DO* render the children in order they were added; if however there
102
      // are two internal nodes with the same list of identical children, just added in a
103
      // different order each time, then we consider them isomorphic, i.e. identical and only
104
      // render the first one. If then two children of such 'pseudo-isomorphic' nodes are at
105
      // exactly the same Z-height this might result in some unexpected sights).
106
      //
107
      // Reason: with the children being sorted by postprocessing buckets, the order is
108
      // undefined anyway (although only when postprocessing is applied).
109
      //
110
      // See the consequences in the 'Olympic' app - remove a few leaves and add them back in
111
      // different order. You will see the number of renders go back to the original 15.
112
      Collections.sort(ret);
113
      }
114

    
115
    ret.add( 0, mSurface.getID() );
116

    
117
    return ret;
118
    }
119

    
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121
/**
122
 * This is not really part of the public API. Has to be public only because it is a part of the
123
 * InternalChildrenList.Parent interface.
124
 *
125
 * @y.exclude
126
 */
127
  public void adjustIsomorphism()
128
    {
129
    InternalNodeData newData = InternalNodeData.returnData(generateIDList());
130
    boolean deleteOldFBO = mData.removeData();
131
    boolean createNewFBO = (mChildren.getNumChildren()>0 && newData.mFBO==null);
132

    
133
    if( deleteOldFBO && createNewFBO )
134
      {
135
      newData.mFBO = mData.mFBO;
136
      }
137
    else if( deleteOldFBO )
138
      {
139
      mData.mFBO.markForDeletion();
140
      mData.mFBO = null;
141
      }
142
    else if( createNewFBO )
143
      {
144
      newData.mFBO = allocateNewFBO();
145
      }
146

    
147
    mData = newData;
148

    
149
    if( mParent!=null ) mParent.adjustIsomorphism();
150
    }
151

    
152
///////////////////////////////////////////////////////////////////////////////////////////////////
153
// return the total number of render calls issued
154

    
155
  int drawNoBlend(long currTime, InternalOutputSurface surface)
156
    {
157
    InternalSurface input = getSurface();
158

    
159
    if( input.setAsInput() )
160
      {
161
      mState.apply();
162
      GLES30.glDisable(GLES30.GL_BLEND);
163
      DistortedLibrary.drawPriv(mEffects, mMesh, surface, currTime);
164
      GLES30.glEnable(GLES30.GL_BLEND);
165
      return 1;
166
      }
167

    
168
    return 0;
169
    }
170

    
171
///////////////////////////////////////////////////////////////////////////////////////////////////
172
// Use the Order Independent Transparency method to draw a non-postprocessed child.
173

    
174
  int drawOIT(long currTime, InternalOutputSurface surface)
175
    {
176
    InternalSurface input = getSurface();
177

    
178
    if( input.setAsInput() )
179
      {
180
      mState.apply();
181
      DistortedLibrary.drawPrivOIT(mEffects, mMesh, surface, currTime);
182
      return 1;
183
      }
184

    
185
    return 0;
186
    }
187

    
188
///////////////////////////////////////////////////////////////////////////////////////////////////
189
// return the total number of render calls issued
190

    
191
  int draw(long currTime, InternalOutputSurface surface)
192
    {
193
    InternalSurface input = getSurface();
194

    
195
    if( input.setAsInput() )
196
      {
197
      mState.apply();
198
      DistortedLibrary.drawPriv(mEffects, mMesh, surface, currTime);
199
      return 1;
200
      }
201

    
202
    return 0;
203
    }
204

    
205
///////////////////////////////////////////////////////////////////////////////////////////////////
206
// return the total number of render calls issued
207

    
208
  int renderRecursive(long currTime)
209
    {
210
    int numRenders = 0;
211
    int numChildren = mChildren.getNumChildren();
212

    
213
    if( numChildren>0 && mData.notRenderedYetAtThisTime(currTime) )
214
      {
215
      DistortedNode node;
216
      long oldBucket=0, newBucket;
217

    
218
      for (int i=0; i<numChildren; i++)
219
        {
220
        node = mChildren.getChild(i);
221
        newBucket = node.getBucket();
222
        numRenders += node.renderRecursive(currTime);
223
        if( newBucket<oldBucket ) mChildren.rearrangeByBuckets(i,newBucket);
224
        else oldBucket=newBucket;
225
        }
226

    
227
      if( mData.mFBO==null ) mData.mFBO = allocateNewFBO();
228
      mData.mFBO.setAsOutput(currTime);
229

    
230
      if( mSurface.setAsInput() )
231
        {
232
        numRenders++;
233
        DistortedLibrary.blitPriv(mData.mFBO);
234
        }
235

    
236
      numRenders += mData.mFBO.renderChildren(currTime,numChildren,mChildren,0, mRenderWayOIT);
237
      }
238

    
239
    return numRenders;
240
    }
241

    
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243

    
244
  private DistortedFramebuffer allocateNewFBO()
245
    {
246
    int width, height;
247

    
248
    if( mFboW>0 && mFboH>0 )
249
      {
250
      width = mFboW;
251
      height= mFboH;
252
      }
253
    else
254
      {
255
      if( mSurface instanceof DistortedFramebuffer )
256
        {
257
        DistortedFramebuffer fbo = (DistortedFramebuffer)mSurface;
258
        width = fbo.mWidth;
259
        height= fbo.mHeight;
260
        }
261
      else
262
        {
263
        width = DEFAULT_FBO_SIZE;
264
        height= DEFAULT_FBO_SIZE;
265
        }
266
      }
267

    
268
    DistortedFramebuffer fbo = new DistortedFramebuffer(1,mFboDepthStencil, InternalSurface.TYPE_TREE, width, height);
269

    
270
    if( mFOV!=InternalOutputSurface.DEFAULT_FOV || mNear!=InternalOutputSurface.DEFAULT_NEAR )
271
      {
272
      fbo.setProjection(mFOV,mNear);
273
      }
274

    
275
    return fbo;
276
    }
277

    
278
///////////////////////////////////////////////////////////////////////////////////////////////////
279

    
280
  void setParent(InternalChildrenList.Parent parent)
281
    {
282
    mParent = parent;
283
    }
284

    
285
///////////////////////////////////////////////////////////////////////////////////////////////////
286
// PUBLIC API
287
///////////////////////////////////////////////////////////////////////////////////////////////////
288
/**
289
 * Constructs new Node.
290
 *     
291
 * @param surface InputSurface to put into the new Node.
292
 * @param effects DistortedEffects to put into the new Node.
293
 * @param mesh MeshBase to put into the new Node.
294
 */
295
  public DistortedNode(InternalSurface surface, DistortedEffects effects, MeshBase mesh)
296
    {
297
    mSurface       = surface;
298
    mEffects       = effects;
299
    mMesh          = mesh;
300
    mState         = new InternalRenderState();
301
    mChildren      = new InternalChildrenList(this);
302
    mParent        = null;
303
    mRenderWayOIT  = false;
304

    
305
    mFOV = InternalOutputSurface.DEFAULT_FOV;
306
    mNear= InternalOutputSurface.DEFAULT_NEAR;
307

    
308
    mFboW            = 0;  // i.e. take this from
309
    mFboH            = 0;  // mEffects's stretch{X,Y}
310
    mFboDepthStencil = DistortedFramebuffer.DEPTH_NO_STENCIL;
311

    
312
    mData = InternalNodeData.returnData(generateIDList());
313
    }
314

    
315
///////////////////////////////////////////////////////////////////////////////////////////////////  
316
/**
317
 * Copy-constructs new Node from another Node.
318
 *     
319
 * @param node The DistortedNode to copy data from.
320
 * @param flags bit field composed of a subset of the following:
321
 *        {@link DistortedLibrary#CLONE_SURFACE},  {@link DistortedLibrary#CLONE_MATRIX}, {@link DistortedLibrary#CLONE_VERTEX},
322
 *        {@link DistortedLibrary#CLONE_FRAGMENT} and {@link DistortedLibrary#CLONE_CHILDREN}.
323
 *        For example flags = CLONE_SURFACE | CLONE_CHILDREN.
324
 */
325
  public DistortedNode(DistortedNode node, int flags)
326
    {
327
    mEffects      = new DistortedEffects(node.mEffects,flags);
328
    mMesh         = node.mMesh;
329
    mState        = new InternalRenderState();
330
    mParent       = null;
331
    mRenderWayOIT = false;
332

    
333
    mFOV = InternalOutputSurface.DEFAULT_FOV;
334
    mNear= InternalOutputSurface.DEFAULT_NEAR;
335

    
336
    mFboW            = node.mFboW;
337
    mFboH            = node.mFboH;
338
    mFboDepthStencil = node.mFboDepthStencil;
339

    
340
    if( (flags & DistortedLibrary.CLONE_SURFACE) != 0 )
341
      {
342
      mSurface = node.mSurface;
343
      }
344
    else
345
      {
346
      if( node.mSurface instanceof DistortedTexture )
347
        {
348
        mSurface = new DistortedTexture(InternalSurface.TYPE_TREE);
349
        }
350
      else if( node.mSurface instanceof DistortedFramebuffer )
351
        {
352
        DistortedFramebuffer fbo = (DistortedFramebuffer)node.mSurface;
353

    
354
        int w = fbo.getWidth();
355
        int h = fbo.getHeight();
356
        int depthStencil = DistortedFramebuffer.NO_DEPTH_NO_STENCIL;
357

    
358
        if( fbo.hasDepth() )
359
          {
360
          boolean hasStencil = fbo.hasStencil();
361
          depthStencil = (hasStencil ? DistortedFramebuffer.BOTH_DEPTH_STENCIL:DistortedFramebuffer.DEPTH_NO_STENCIL);
362
          }
363

    
364
        mSurface = new DistortedFramebuffer(1,depthStencil, InternalSurface.TYPE_TREE,w,h);
365
        }
366
      }
367

    
368
    if( (flags & DistortedLibrary.CLONE_CHILDREN) != 0 )
369
      {
370
      mChildren = node.mChildren;
371
      }
372
    else
373
      {
374
      mChildren = new InternalChildrenList(this);
375
      }
376

    
377
    mData = InternalNodeData.returnData(generateIDList());
378
    }
379

    
380
///////////////////////////////////////////////////////////////////////////////////////////////////
381
  /**
382
   * When rendering this Node, should we use the Order Independent Transparency render more?
383
   * <p>
384
   * There are two modes of rendering: the fast 'normal' way, which however renders transparent
385
   * fragments in different ways depending on which fragments get rendered first, or the slower
386
   * 'oit' way, which renders transparent fragments correctly regardless of their order.
387
   *
388
   * @param oit True if we want to render more slowly, but in a way which accounts for transparency.
389
   */
390
  public void setOrderIndependentTransparency(boolean oit)
391
    {
392
    mRenderWayOIT = oit;
393
    }
394

    
395
///////////////////////////////////////////////////////////////////////////////////////////////////
396
  /**
397
   * When rendering this Node, should we use the Order Independent Transparency render more?
398
   * <p>
399
   * There are two modes of rendering: the fast 'normal' way, which however renders transparent
400
   * fragments in different ways depending on which fragments get rendered first, or the slower
401
   * 'oit' way, which renders transparent fragments correctly regardless of their order.
402
   *
403
   * @param oit True if we want to render more slowly, but in a way which accounts for transparency.
404
   * @param initialSize Initial number of transparent fragments we expect, in screenfulls.
405
   *                    I.e '1.0' means 'the scene we are going to render contains dialog_about 1 screen
406
   *                    worth of transparent fragments'. Valid values: 0.0 &lt; initialSize &lt; 10.0
407
   *                    Even if you get this wrong, the library will detect that there are more
408
   *                    transparent fragments than it has space for and readjust its internal buffers,
409
   *                    but only after a few frames during which one will probably see missing objects.
410
   */
411
  public void setOrderIndependentTransparency(boolean oit, float initialSize)
412
    {
413
    mRenderWayOIT = oit;
414

    
415
    if( initialSize>0.0f && initialSize<10.0f )
416
      DistortedLibrary.setSSBOSize(initialSize);
417
    }
418

    
419
///////////////////////////////////////////////////////////////////////////////////////////////////
420
/**
421
 * Adds a new child to the last position in the list of our Node's children.
422
 * <p>
423
 * We cannot do this mid-render - actual attachment will be done just before the next render, by the
424
 * InternalMaster (by calling doWork())
425
 *
426
 * @param node The new Node to add.
427
 */
428
  public void attach(DistortedNode node)
429
    {
430
    mChildren.attach(node);
431
    }
432

    
433
///////////////////////////////////////////////////////////////////////////////////////////////////
434
/**
435
 * Adds a new child to the last position in the list of our Node's children.
436
 * <p>
437
 * We cannot do this mid-render - actual attachment will be done just before the next render, by the
438
 * InternalMaster (by calling doWork())
439
 *
440
 * @param surface InputSurface to initialize our child Node with.
441
 * @param effects DistortedEffects to initialize our child Node with.
442
 * @param mesh MeshBase to initialize our child Node with.
443
 * @return the newly constructed child Node, or null if we couldn't allocate resources.
444
 */
445
  public DistortedNode attach(InternalSurface surface, DistortedEffects effects, MeshBase mesh)
446
    {
447
    return mChildren.attach(surface,effects,mesh);
448
    }
449

    
450
///////////////////////////////////////////////////////////////////////////////////////////////////
451
/**
452
 * Removes the first occurrence of a specified child from the list of children of our Node.
453
 * <p>
454
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
455
 * InternalMaster (by calling doWork())
456
 *
457
 * @param node The Node to remove.
458
 */
459
  public void detach(DistortedNode node)
460
    {
461
    mChildren.detach(node);
462
    }
463

    
464
///////////////////////////////////////////////////////////////////////////////////////////////////
465
/**
466
 * Removes the first occurrence of a specified child from the list of children of our Node.
467
 * <p>
468
 * A bit questionable method as there can be many different Nodes attached as children, some
469
 * of them having the same Effects but - for instance - different Mesh. Use with care.
470
 * <p>
471
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
472
 * InternalMaster (by calling doWork())
473
 *
474
 * @param effects DistortedEffects to remove.
475
 */
476
  public void detach(DistortedEffects effects)
477
    {
478
    mChildren.detach(effects);
479
    }
480

    
481
///////////////////////////////////////////////////////////////////////////////////////////////////
482
/**
483
 * Removes all children Nodes.
484
 * <p>
485
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
486
 * InternalMaster (by calling doWork())
487
 */
488
  public void detachAll()
489
    {
490
    mChildren.detachAll();
491
    }
492

    
493
///////////////////////////////////////////////////////////////////////////////////////////////////
494
/**
495
 * Returns the DistortedEffects object that's in the Node.
496
 * 
497
 * @return The DistortedEffects contained in the Node.
498
 */
499
  public DistortedEffects getEffects()
500
    {
501
    return mEffects;
502
    }
503

    
504
///////////////////////////////////////////////////////////////////////////////////////////////////
505
  /**
506
   * Returns the surface this object gets rendered to.
507
   *
508
   * @return The InternalSurface contained in the Node (if a leaf), or the FBO (if an internal Node)
509
   */
510
  public InternalSurface getSurface()
511
    {
512
    return mChildren.getNumChildren()==0 ? mSurface : mData.mFBO;
513
    }
514

    
515
///////////////////////////////////////////////////////////////////////////////////////////////////
516
/**
517
 * Returns the Mesh object that's in the Node.
518
 *
519
 * @return Mesh contained in the Node.
520
 */
521
  public MeshBase getMesh()
522
    {
523
    return mMesh;
524
    }
525

    
526
///////////////////////////////////////////////////////////////////////////////////////////////////
527
/**
528
 * Resizes the DistortedFramebuffer object that we render this Node to.
529
 */
530
  public void resizeFBO(int width, int height)
531
    {
532
    mFboW = width;
533
    mFboH = height;
534

    
535
    if ( mData.mFBO !=null )
536
      {
537
      // TODO: potentially allocate a new NodeData if we have to
538
      mData.mFBO.resize(width,height);
539
      }
540
    }
541

    
542
///////////////////////////////////////////////////////////////////////////////////////////////////
543
/**
544
 * Set Projection Matrix for the Framebuffer contained in this Node.
545
 * <p>
546
 * If this Node is a Leaf and has no Framebuffer in it, this call does nothing.
547
 *
548
 * @param fov Vertical 'field of view' of the Projection frustrum (in degrees).
549
 *            Valid values: 0<=fov<180. FOV==0 means 'parallel projection'.
550
 * @param near The Near plane.
551
 */
552
  public void setProjection(float fov, float near)
553
    {
554
    if( fov < 180.0f && fov >=0.0f )
555
      {
556
      mFOV = fov;
557
      }
558

    
559
    if( near<   1.0f && near> 0.0f )
560
      {
561
      mNear= near;
562
      }
563
    else if( near<=0.0f )
564
      {
565
      mNear = 0.01f;
566
      }
567
    else if( near>=1.0f )
568
      {
569
      mNear=0.99f;
570
      }
571

    
572
    if( mData.mFBO!=null )
573
      {
574
      mData.mFBO.setProjection(mFOV,mNear);
575
      }
576
    }
577

    
578
///////////////////////////////////////////////////////////////////////////////////////////////////
579
/**
580
 * Enables/disables DEPTH and STENCIL buffers in the Framebuffer object that we render this Node to.
581
 */
582
  public void enableDepthStencil(int depthStencil)
583
    {
584
    mFboDepthStencil = depthStencil;
585

    
586
    if ( mData.mFBO !=null )
587
      {
588
      // TODO: potentially allocate a new NodeData if we have to
589
      mData.mFBO.enableDepthStencil(depthStencil);
590
      }
591
    }
592

    
593
///////////////////////////////////////////////////////////////////////////////////////////////////
594
// APIs that control how to set the OpenGL state just before rendering this Node.
595
///////////////////////////////////////////////////////////////////////////////////////////////////
596
/**
597
 * When rendering this Node, use ColorMask (r,g,b,a).
598
 *
599
 * @param r Write to the RED color channel when rendering this Node?
600
 * @param g Write to the GREEN color channel when rendering this Node?
601
 * @param b Write to the BLUE color channel when rendering this Node?
602
 * @param a Write to the ALPHA channel when rendering this Node?
603
 */
604
  @SuppressWarnings("unused")
605
  public void glColorMask(boolean r, boolean g, boolean b, boolean a)
606
    {
607
    mState.glColorMask(r,g,b,a);
608
    }
609

    
610
///////////////////////////////////////////////////////////////////////////////////////////////////
611
/**
612
 * When rendering this Node, switch on writing to Depth buffer?
613
 *
614
 * @param mask Write to the Depth buffer when rendering this Node?
615
 */
616
  @SuppressWarnings("unused")
617
  public void glDepthMask(boolean mask)
618
    {
619
    mState.glDepthMask(mask);
620
    }
621

    
622
///////////////////////////////////////////////////////////////////////////////////////////////////
623
/**
624
 * When rendering this Node, which bits of the Stencil buffer to write to?
625
 *
626
 * @param mask Marks the bits of the Stencil buffer we will write to when rendering this Node.
627
 */
628
  @SuppressWarnings("unused")
629
  public void glStencilMask(int mask)
630
    {
631
    mState.glStencilMask(mask);
632
    }
633

    
634
///////////////////////////////////////////////////////////////////////////////////////////////////
635
/**
636
 * When rendering this Node, which Tests to enable?
637
 *
638
 * @param test Valid values: GL_DEPTH_TEST, GL_STENCIL_TEST, GL_BLEND
639
 */
640
  @SuppressWarnings("unused")
641
  public void glEnable(int test)
642
    {
643
    mState.glEnable(test);
644
    }
645

    
646
///////////////////////////////////////////////////////////////////////////////////////////////////
647
/**
648
 * When rendering this Node, which Tests to enable?
649
 *
650
 * @param test Valid values: GL_DEPTH_TEST, GL_STENCIL_TEST, GL_BLEND
651
 */
652
  @SuppressWarnings("unused")
653
  public void glDisable(int test)
654
    {
655
    mState.glDisable(test);
656
    }
657

    
658
///////////////////////////////////////////////////////////////////////////////////////////////////
659
/**
660
 * When rendering this Node, use the following StencilFunc.
661
 *
662
 * @param func Valid values: GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL
663
 * @param ref  Reference valut to compare our stencil with.
664
 * @param mask Mask used when comparing.
665
 */
666
  @SuppressWarnings("unused")
667
  public void glStencilFunc(int func, int ref, int mask)
668
    {
669
    mState.glStencilFunc(func,ref,mask);
670
    }
671

    
672
///////////////////////////////////////////////////////////////////////////////////////////////////
673
/**
674
 * When rendering this Node, use the following StencilOp.
675
 * <p>
676
 * Valid values of all 3 parameters: GL_KEEP, GL_ZERO, GL_REPLACE, GL_INCR, GL_DECR, GL_INVERT, GL_INCR_WRAP, GL_DECR_WRAP
677
 *
678
 * @param sfail  What to do when Stencil Test fails.
679
 * @param dpfail What to do when Depth Test fails.
680
 * @param dppass What to do when Depth Test passes.
681
 */
682
  @SuppressWarnings("unused")
683
  public void glStencilOp(int sfail, int dpfail, int dppass)
684
    {
685
    mState.glStencilOp(sfail,dpfail,dppass);
686
    }
687

    
688
///////////////////////////////////////////////////////////////////////////////////////////////////
689
/**
690
 * When rendering this Node, use the following DepthFunc.
691
 *
692
 * @param func Valid values: GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL
693
 */
694
  @SuppressWarnings("unused")
695
  public void glDepthFunc(int func)
696
    {
697
    mState.glDepthFunc(func);
698
    }
699

    
700
///////////////////////////////////////////////////////////////////////////////////////////////////
701
/**
702
 * When rendering this Node, use the following Blending mode.
703
 * <p>
704
 * Valid values: GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
705
 *               GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR,
706
 *               GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_SRC_ALPHA_SATURATE
707
 *
708
 * @param src Source Blend function
709
 * @param dst Destination Blend function
710
 */
711
  @SuppressWarnings("unused")
712
  public void glBlendFunc(int src, int dst)
713
    {
714
    mState.glBlendFunc(src,dst);
715
    }
716

    
717
///////////////////////////////////////////////////////////////////////////////////////////////////
718
/**
719
 * Before rendering this Node, clear the following buffers.
720
 * <p>
721
 * Valid values: 0, or bitwise OR of one or more values from the set GL_COLOR_BUFFER_BIT,
722
 *               GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT.
723
 * Default: 0
724
 *
725
 * @param mask bitwise OR of BUFFER_BITs to clear.
726
 */
727
  @SuppressWarnings("unused")
728
  public void glClear(int mask)
729
    {
730
    mState.glClear(mask);
731
    }
732
  }
(4-4/14)