Project

General

Profile

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

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

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 final DistortedEffects mEffects;
45
  private final InternalRenderState mState;
46
  private final InternalChildrenList mChildren;
47
  private InternalChildrenList.Parent mParent;
48
  private InternalSurface mSurface;
49
  private InternalNodeData mData;
50
  private MeshBase mMesh;
51

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

    
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58

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

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

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

    
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77

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

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

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

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

    
118
    return ret;
119
    }
120

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

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

    
148
    mData = newData;
149

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

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

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

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

    
171
    return 0;
172
    }
173

    
174
///////////////////////////////////////////////////////////////////////////////////////////////////
175
// Use the Order Independent Transparency method to draw a non-postprocessed child.
176

    
177
  int drawOIT(long currTime, InternalOutputSurface surface)
178
    {
179
    InternalSurface input = getSurface();
180

    
181
    if( input.setAsInput() )
182
      {
183
      mState.apply();
184
      if( mLastTime==0 ) mLastTime=currTime;
185
      DistortedLibrary.drawPrivOIT(mEffects, mMesh, surface, currTime, (currTime-mLastTime));
186
      mLastTime = currTime;
187
      return 1;
188
      }
189

    
190
    return 0;
191
    }
192

    
193
///////////////////////////////////////////////////////////////////////////////////////////////////
194
// return the total number of render calls issued
195

    
196
  int draw(long currTime, InternalOutputSurface surface)
197
    {
198
    InternalSurface input = getSurface();
199

    
200
    if( input.setAsInput() )
201
      {
202
      mState.apply();
203
      if( mLastTime==0 ) mLastTime=currTime;
204
      DistortedLibrary.drawPriv(mEffects, mMesh, surface, currTime, (currTime-mLastTime));
205
      mLastTime = currTime;
206
      return 1;
207
      }
208

    
209
    return 0;
210
    }
211

    
212
///////////////////////////////////////////////////////////////////////////////////////////////////
213
// return the total number of render calls issued
214

    
215
  int renderRecursive(long currTime)
216
    {
217
    int numRenders = 0;
218
    int numChildren = mChildren.getNumChildren();
219

    
220
    if( numChildren>0 && mData.notRenderedYetAtThisTime(currTime) )
221
      {
222
      DistortedNode node;
223
      long oldBucket=0, newBucket;
224

    
225
      for (int i=0; i<numChildren; i++)
226
        {
227
        node = mChildren.getChild(i);
228
        newBucket = node.getBucket();
229
        numRenders += node.renderRecursive(currTime);
230
        if( newBucket<oldBucket ) mChildren.rearrangeByBuckets(i,newBucket);
231
        else oldBucket=newBucket;
232
        }
233

    
234
      if( mData.mFBO==null ) mData.mFBO = allocateNewFBO();
235
      mData.mFBO.setAsOutput(currTime);
236

    
237
      if( mSurface.setAsInput() )
238
        {
239
        numRenders++;
240
        DistortedLibrary.blitPriv(mData.mFBO);
241
        }
242

    
243
      numRenders += mData.mFBO.renderChildren(currTime,numChildren,mChildren,0, mRenderWayOIT);
244
      }
245

    
246
    return numRenders;
247
    }
248

    
249
///////////////////////////////////////////////////////////////////////////////////////////////////
250

    
251
  private DistortedFramebuffer allocateNewFBO()
252
    {
253
    int width, height;
254

    
255
    if( mFboW>0 && mFboH>0 )
256
      {
257
      width = mFboW;
258
      height= mFboH;
259
      }
260
    else
261
      {
262
      if( mSurface instanceof DistortedFramebuffer )
263
        {
264
        DistortedFramebuffer fbo = (DistortedFramebuffer)mSurface;
265
        width = fbo.mWidth;
266
        height= fbo.mHeight;
267
        }
268
      else
269
        {
270
        width = DEFAULT_FBO_SIZE;
271
        height= DEFAULT_FBO_SIZE;
272
        }
273
      }
274

    
275
    DistortedFramebuffer fbo = new DistortedFramebuffer(1,mFboDepthStencil, InternalSurface.TYPE_TREE, width, height);
276

    
277
    if( mFOV!=InternalOutputSurface.DEFAULT_FOV || mNear!=InternalOutputSurface.DEFAULT_NEAR )
278
      {
279
      fbo.setProjection(mFOV,mNear);
280
      }
281

    
282
    return fbo;
283
    }
284

    
285
///////////////////////////////////////////////////////////////////////////////////////////////////
286

    
287
  void resetLastTime()
288
    {
289
    mLastTime = 0;
290
    }
291

    
292
///////////////////////////////////////////////////////////////////////////////////////////////////
293

    
294
  void setParent(InternalChildrenList.Parent parent)
295
    {
296
    mParent = parent;
297
    }
298

    
299
///////////////////////////////////////////////////////////////////////////////////////////////////
300
// PUBLIC API
301
///////////////////////////////////////////////////////////////////////////////////////////////////
302
/**
303
 * Constructs new Node.
304
 *     
305
 * @param surface InputSurface to put into the new Node.
306
 * @param effects DistortedEffects to put into the new Node.
307
 * @param mesh MeshBase to put into the new Node.
308
 */
309
  public DistortedNode(InternalSurface surface, DistortedEffects effects, MeshBase mesh)
310
    {
311
    mLastTime      = 0;
312
    mSurface       = surface;
313
    mEffects       = effects;
314
    mMesh          = mesh;
315
    mState         = new InternalRenderState();
316
    mChildren      = new InternalChildrenList(this);
317
    mParent        = null;
318
    mRenderWayOIT  = false;
319

    
320
    mFOV = InternalOutputSurface.DEFAULT_FOV;
321
    mNear= InternalOutputSurface.DEFAULT_NEAR;
322

    
323
    mFboW            = 0;  // i.e. take this from
324
    mFboH            = 0;  // mEffects's stretch{X,Y}
325
    mFboDepthStencil = DistortedFramebuffer.DEPTH_NO_STENCIL;
326

    
327
    mData = InternalNodeData.returnData(generateIDList());
328
    }
329

    
330
///////////////////////////////////////////////////////////////////////////////////////////////////  
331
/**
332
 * Copy-constructs new Node from another Node.
333
 *     
334
 * @param node The DistortedNode to copy data from.
335
 * @param flags bit field composed of a subset of the following:
336
 *        {@link DistortedLibrary#CLONE_SURFACE},  {@link DistortedLibrary#CLONE_MATRIX}, {@link DistortedLibrary#CLONE_VERTEX},
337
 *        {@link DistortedLibrary#CLONE_FRAGMENT} and {@link DistortedLibrary#CLONE_CHILDREN}.
338
 *        For example flags = CLONE_SURFACE | CLONE_CHILDREN.
339
 */
340
  public DistortedNode(DistortedNode node, int flags)
341
    {
342
    mLastTime     = 0;
343
    mEffects      = new DistortedEffects(node.mEffects,flags);
344
    mMesh         = node.mMesh;
345
    mState        = new InternalRenderState();
346
    mParent       = null;
347
    mRenderWayOIT = false;
348

    
349
    mFOV = InternalOutputSurface.DEFAULT_FOV;
350
    mNear= InternalOutputSurface.DEFAULT_NEAR;
351

    
352
    mFboW            = node.mFboW;
353
    mFboH            = node.mFboH;
354
    mFboDepthStencil = node.mFboDepthStencil;
355

    
356
    if( (flags & DistortedLibrary.CLONE_SURFACE) != 0 )
357
      {
358
      mSurface = node.mSurface;
359
      }
360
    else
361
      {
362
      if( node.mSurface instanceof DistortedTexture )
363
        {
364
        mSurface = new DistortedTexture(InternalSurface.TYPE_TREE);
365
        }
366
      else if( node.mSurface instanceof DistortedFramebuffer )
367
        {
368
        DistortedFramebuffer fbo = (DistortedFramebuffer)node.mSurface;
369

    
370
        int w = fbo.getWidth();
371
        int h = fbo.getHeight();
372
        int depthStencil = DistortedFramebuffer.NO_DEPTH_NO_STENCIL;
373

    
374
        if( fbo.hasDepth() )
375
          {
376
          boolean hasStencil = fbo.hasStencil();
377
          depthStencil = (hasStencil ? DistortedFramebuffer.BOTH_DEPTH_STENCIL:DistortedFramebuffer.DEPTH_NO_STENCIL);
378
          }
379

    
380
        mSurface = new DistortedFramebuffer(1,depthStencil, InternalSurface.TYPE_TREE,w,h);
381
        }
382
      }
383

    
384
    if( (flags & DistortedLibrary.CLONE_CHILDREN) != 0 )
385
      {
386
      mChildren = node.mChildren;
387
      }
388
    else
389
      {
390
      mChildren = new InternalChildrenList(this);
391
      }
392

    
393
    mData = InternalNodeData.returnData(generateIDList());
394
    }
395

    
396
///////////////////////////////////////////////////////////////////////////////////////////////////
397
  /**
398
   * Change the input surface while keeping everything else about the Node the same.
399
   *
400
   * @param surface The new input surface.
401
   */
402
  public void changeInputSurface(InternalSurface surface)
403
    {
404
    mSurface = surface;
405
    }
406

    
407
///////////////////////////////////////////////////////////////////////////////////////////////////
408

    
409
  /**
410
   * When rendering this Node, should we use the Order Independent Transparency render more?
411
   * <p>
412
   * There are two modes of rendering: the fast 'normal' way, which however renders transparent
413
   * fragments in different ways depending on which fragments get rendered first, or the slower
414
   * 'oit' way, which renders transparent fragments correctly regardless of their order.
415
   *
416
   * @param oit True if we want to render more slowly, but in a way which accounts for transparency.
417
   */
418
  public void setOrderIndependentTransparency(boolean oit)
419
    {
420
    mRenderWayOIT = oit;
421
    }
422

    
423
///////////////////////////////////////////////////////////////////////////////////////////////////
424
  /**
425
   * When rendering this Node, should we use the Order Independent Transparency render more?
426
   * <p>
427
   * There are two modes of rendering: the fast 'normal' way, which however renders transparent
428
   * fragments in different ways depending on which fragments get rendered first, or the slower
429
   * 'oit' way, which renders transparent fragments correctly regardless of their order.
430
   *
431
   * @param oit True if we want to render more slowly, but in a way which accounts for transparency.
432
   * @param initialSize Initial number of transparent fragments we expect, in screenfulls.
433
   *                    I.e '1.0' means 'the scene we are going to render contains dialog_about 1 screen
434
   *                    worth of transparent fragments'. Valid values: 0.0 &lt; initialSize &lt; 10.0
435
   *                    Even if you get this wrong, the library will detect that there are more
436
   *                    transparent fragments than it has space for and readjust its internal buffers,
437
   *                    but only after a few frames during which one will probably see missing objects.
438
   */
439
  public void setOrderIndependentTransparency(boolean oit, float initialSize)
440
    {
441
    mRenderWayOIT = oit;
442

    
443
    if( initialSize>0.0f && initialSize<10.0f )
444
      DistortedLibrary.setSSBOSize(initialSize);
445
    }
446

    
447
///////////////////////////////////////////////////////////////////////////////////////////////////
448
/**
449
 * Adds a new child to the last position in the list of our Node's children.
450
 * <p>
451
 * We cannot do this mid-render - actual attachment will be done just before the next render, by the
452
 * InternalMaster (by calling doWork())
453
 *
454
 * @param node The new Node to add.
455
 */
456
  public void attach(DistortedNode node)
457
    {
458
    mChildren.attach(node);
459
    }
460

    
461
///////////////////////////////////////////////////////////////////////////////////////////////////
462
/**
463
 * Adds a new child to the last position in the list of our Node's children.
464
 * <p>
465
 * We cannot do this mid-render - actual attachment will be done just before the next render, by the
466
 * InternalMaster (by calling doWork())
467
 *
468
 * @param surface InputSurface to initialize our child Node with.
469
 * @param effects DistortedEffects to initialize our child Node with.
470
 * @param mesh MeshBase to initialize our child Node with.
471
 * @return the newly constructed child Node, or null if we couldn't allocate resources.
472
 */
473
  public DistortedNode attach(InternalSurface surface, DistortedEffects effects, MeshBase mesh)
474
    {
475
    return mChildren.attach(surface,effects,mesh);
476
    }
477

    
478
///////////////////////////////////////////////////////////////////////////////////////////////////
479
/**
480
 * Removes the first occurrence of a specified child from the list of children of our Node.
481
 * <p>
482
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
483
 * InternalMaster (by calling doWork())
484
 *
485
 * @param node The Node to remove.
486
 */
487
  public void detach(DistortedNode node)
488
    {
489
    mChildren.detach(node);
490
    }
491

    
492
///////////////////////////////////////////////////////////////////////////////////////////////////
493
/**
494
 * Removes the first occurrence of a specified child from the list of children of our Node.
495
 * <p>
496
 * A bit questionable method as there can be many different Nodes attached as children, some
497
 * of them having the same Effects but - for instance - different Mesh. Use with care.
498
 * <p>
499
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
500
 * InternalMaster (by calling doWork())
501
 *
502
 * @param effects DistortedEffects to remove.
503
 */
504
  public void detach(DistortedEffects effects)
505
    {
506
    mChildren.detach(effects);
507
    }
508

    
509
///////////////////////////////////////////////////////////////////////////////////////////////////
510
/**
511
 * Removes all children Nodes.
512
 * <p>
513
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
514
 * InternalMaster (by calling doWork())
515
 */
516
  public void detachAll()
517
    {
518
    mChildren.detachAll();
519
    }
520

    
521
///////////////////////////////////////////////////////////////////////////////////////////////////
522
/**
523
 * Returns the DistortedEffects object that's in the Node.
524
 * 
525
 * @return The DistortedEffects contained in the Node.
526
 */
527
  public DistortedEffects getEffects()
528
    {
529
    return mEffects;
530
    }
531

    
532
///////////////////////////////////////////////////////////////////////////////////////////////////
533
  /**
534
   * Returns the surface this object gets rendered to.
535
   *
536
   * @return The InternalSurface contained in the Node (if a leaf), or the FBO (if an internal Node)
537
   */
538
  public InternalSurface getSurface()
539
    {
540
    return mChildren.getNumChildren()==0 ? mSurface : mData.mFBO;
541
    }
542

    
543
//////////////////////////////////////////////////////////////////////////////////////////////////
544
  /**
545
   * Returns the FBO contained in this object, even if it is a leaf.
546
   *
547
   * @return The DistortedFramebuffer.
548
   */
549
  public DistortedFramebuffer getFramebuffer()
550
    {
551
    return mData.mFBO;
552
    }
553

    
554
///////////////////////////////////////////////////////////////////////////////////////////////////
555
/**
556
 * Returns the Mesh object that's in the Node.
557
 *
558
 * @return Mesh contained in the Node.
559
 */
560
  public MeshBase getMesh()
561
    {
562
    return mMesh;
563
    }
564

    
565
///////////////////////////////////////////////////////////////////////////////////////////////////
566
/**
567
 * Set a new Mesh.
568
 */
569
  public void setMesh(MeshBase mesh)
570
    {
571
    mMesh = mesh;
572
    }
573

    
574
///////////////////////////////////////////////////////////////////////////////////////////////////
575
/**
576
 * Resizes the DistortedFramebuffer object that we render this Node to.
577
 */
578
  public void resizeFBO(int width, int height)
579
    {
580
    mFboW = width;
581
    mFboH = height;
582

    
583
    if ( mData.mFBO !=null )
584
      {
585
      // TODO: potentially allocate a new NodeData if we have to
586
      mData.mFBO.resize(width,height);
587
      }
588
    }
589

    
590
///////////////////////////////////////////////////////////////////////////////////////////////////
591
/**
592
 * Set Projection Matrix for the Framebuffer contained in this Node.
593
 * <p>
594
 * If this Node is a Leaf and has no Framebuffer in it, this call does nothing.
595
 *
596
 * @param fov Vertical 'field of view' of the Projection frustrum (in degrees).
597
 *            Valid values: 0<=fov<180. FOV==0 means 'parallel projection'.
598
 * @param near The Near plane.
599
 */
600
  public void setProjection(float fov, float near)
601
    {
602
    if( fov < 180.0f && fov >=0.0f )
603
      {
604
      mFOV = fov;
605
      }
606

    
607
    if( near<   1.0f && near> 0.0f )
608
      {
609
      mNear= near;
610
      }
611
    else if( near<=0.0f )
612
      {
613
      mNear = 0.01f;
614
      }
615
    else if( near>=1.0f )
616
      {
617
      mNear=0.99f;
618
      }
619

    
620
    if( mData.mFBO!=null )
621
      {
622
      mData.mFBO.setProjection(mFOV,mNear);
623
      }
624
    }
625

    
626
///////////////////////////////////////////////////////////////////////////////////////////////////
627
/**
628
 * Enables/disables DEPTH and STENCIL buffers in the Framebuffer object that we render this Node to.
629
 */
630
  public void enableDepthStencil(int depthStencil)
631
    {
632
    mFboDepthStencil = depthStencil;
633

    
634
    if ( mData.mFBO !=null )
635
      {
636
      // TODO: potentially allocate a new NodeData if we have to
637
      mData.mFBO.enableDepthStencil(depthStencil);
638
      }
639
    }
640

    
641
///////////////////////////////////////////////////////////////////////////////////////////////////
642
// APIs that control how to set the OpenGL state just before rendering this Node.
643
///////////////////////////////////////////////////////////////////////////////////////////////////
644
/**
645
 * When rendering this Node, use ColorMask (r,g,b,a).
646
 *
647
 * @param r Write to the RED color channel when rendering this Node?
648
 * @param g Write to the GREEN color channel when rendering this Node?
649
 * @param b Write to the BLUE color channel when rendering this Node?
650
 * @param a Write to the ALPHA channel when rendering this Node?
651
 */
652
  @SuppressWarnings("unused")
653
  public void glColorMask(boolean r, boolean g, boolean b, boolean a)
654
    {
655
    mState.glColorMask(r,g,b,a);
656
    }
657

    
658
///////////////////////////////////////////////////////////////////////////////////////////////////
659
/**
660
 * When rendering this Node, switch on writing to Depth buffer?
661
 *
662
 * @param mask Write to the Depth buffer when rendering this Node?
663
 */
664
  @SuppressWarnings("unused")
665
  public void glDepthMask(boolean mask)
666
    {
667
    mState.glDepthMask(mask);
668
    }
669

    
670
///////////////////////////////////////////////////////////////////////////////////////////////////
671
/**
672
 * When rendering this Node, which bits of the Stencil buffer to write to?
673
 *
674
 * @param mask Marks the bits of the Stencil buffer we will write to when rendering this Node.
675
 */
676
  @SuppressWarnings("unused")
677
  public void glStencilMask(int mask)
678
    {
679
    mState.glStencilMask(mask);
680
    }
681

    
682
///////////////////////////////////////////////////////////////////////////////////////////////////
683
/**
684
 * When rendering this Node, which Tests to enable?
685
 *
686
 * @param test Valid values: GL_DEPTH_TEST, GL_STENCIL_TEST, GL_BLEND
687
 */
688
  @SuppressWarnings("unused")
689
  public void glEnable(int test)
690
    {
691
    mState.glEnable(test);
692
    }
693

    
694
///////////////////////////////////////////////////////////////////////////////////////////////////
695
/**
696
 * When rendering this Node, which Tests to enable?
697
 *
698
 * @param test Valid values: GL_DEPTH_TEST, GL_STENCIL_TEST, GL_BLEND
699
 */
700
  @SuppressWarnings("unused")
701
  public void glDisable(int test)
702
    {
703
    mState.glDisable(test);
704
    }
705

    
706
///////////////////////////////////////////////////////////////////////////////////////////////////
707
/**
708
 * When rendering this Node, use the following StencilFunc.
709
 *
710
 * @param func Valid values: GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL
711
 * @param ref  Reference valut to compare our stencil with.
712
 * @param mask Mask used when comparing.
713
 */
714
  @SuppressWarnings("unused")
715
  public void glStencilFunc(int func, int ref, int mask)
716
    {
717
    mState.glStencilFunc(func,ref,mask);
718
    }
719

    
720
///////////////////////////////////////////////////////////////////////////////////////////////////
721
/**
722
 * When rendering this Node, use the following StencilOp.
723
 * <p>
724
 * Valid values of all 3 parameters: GL_KEEP, GL_ZERO, GL_REPLACE, GL_INCR, GL_DECR, GL_INVERT, GL_INCR_WRAP, GL_DECR_WRAP
725
 *
726
 * @param sfail  What to do when Stencil Test fails.
727
 * @param dpfail What to do when Depth Test fails.
728
 * @param dppass What to do when Depth Test passes.
729
 */
730
  @SuppressWarnings("unused")
731
  public void glStencilOp(int sfail, int dpfail, int dppass)
732
    {
733
    mState.glStencilOp(sfail,dpfail,dppass);
734
    }
735

    
736
///////////////////////////////////////////////////////////////////////////////////////////////////
737
/**
738
 * When rendering this Node, use the following DepthFunc.
739
 *
740
 * @param func Valid values: GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL
741
 */
742
  @SuppressWarnings("unused")
743
  public void glDepthFunc(int func)
744
    {
745
    mState.glDepthFunc(func);
746
    }
747

    
748
///////////////////////////////////////////////////////////////////////////////////////////////////
749
/**
750
 * When rendering this Node, use the following Blending mode.
751
 * <p>
752
 * Valid values: GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
753
 *               GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR,
754
 *               GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_SRC_ALPHA_SATURATE
755
 *
756
 * @param src Source Blend function
757
 * @param dst Destination Blend function
758
 */
759
  @SuppressWarnings("unused")
760
  public void glBlendFunc(int src, int dst)
761
    {
762
    mState.glBlendFunc(src,dst);
763
    }
764

    
765
///////////////////////////////////////////////////////////////////////////////////////////////////
766
/**
767
 * Before rendering this Node, clear the following buffers.
768
 * <p>
769
 * Valid values: 0, or bitwise OR of one or more values from the set GL_COLOR_BUFFER_BIT,
770
 *               GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT.
771
 * Default: 0
772
 *
773
 * @param mask bitwise OR of BUFFER_BITs to clear.
774
 */
775
  @SuppressWarnings("unused")
776
  public void glClear(int mask)
777
    {
778
    mState.glClear(mask);
779
    }
780
  }
(4-4/17)