Project

General

Profile

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

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

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;
21

    
22
import java.util.ArrayList;
23
import java.util.HashMap;
24

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

    
43
  private ArrayList<DistortedNode> mChildren;
44
  private int[] mNumChildren;  // ==mChildren.length(), but we only create mChildren if the first one gets added
45

    
46
  private class Job
47
    {
48
    int type;
49
    DistortedNode node;
50
    DistortedEffectsPostprocess dep;
51

    
52
    Job(int t, DistortedNode n, DistortedEffectsPostprocess d)
53
      {
54
      type = t;
55
      node = n;
56
      dep  = d;
57
      }
58
    }
59

    
60
  private ArrayList<Job> mJobs = new ArrayList<>();
61

    
62
  private static HashMap<ArrayList<Long>,NodeData> mMapNodeID = new HashMap<>();
63
  private static long mNextNodeID =0;
64

    
65
  private DistortedNode mParent;
66
  private DistortedOutputSurface mSurfaceParent;
67
  private MeshObject mMesh;
68
  private DistortedEffects mEffects;
69
  private DistortedEffectsPostprocess mPostprocess;
70
  private DistortedInputSurface mSurface;
71
  private DistortedRenderState mState;
72
  private NodeData mData;
73

    
74
  private class NodeData
75
    {
76
    long ID;
77
    int numPointingNodes;
78
    long currTime;
79
    ArrayList<Long> key;
80
    DistortedFramebuffer mFBO;
81

    
82
    NodeData(long id, ArrayList<Long> k)
83
      {
84
      ID              = id;
85
      key             = k;
86
      numPointingNodes= 1;
87
      currTime        =-1;
88
      mFBO            = null;
89
      }
90
    }
91
 
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

    
94
  static synchronized void onDestroy()
95
    {
96
    mNextNodeID = 0;
97
    mMapNodeID.clear();
98
    }
99

    
100
///////////////////////////////////////////////////////////////////////////////////////////////////
101

    
102
  private ArrayList<Long> generateIDList()
103
    {
104
    ArrayList<Long> ret = new ArrayList<>();
105
     
106
    ret.add( mSurface.getID() );
107

    
108
    if( mNumChildren[0]==0 )
109
      {
110
      ret.add(-mEffects.getID());
111
      }
112

    
113
    DistortedNode node;
114
   
115
    for(int i=0; i<mNumChildren[0]; i++)
116
      {
117
      node = mChildren.get(i);
118
      ret.add(node.mData.ID);
119
      }
120
   
121
    return ret;
122
    }
123

    
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125
// Debug - print all the Node IDs
126

    
127
  @SuppressWarnings("unused")
128
  void debug(int depth)
129
    {
130
    String tmp="";
131
    int i;
132

    
133
    for(i=0; i<depth; i++) tmp +="   ";
134
    tmp += ("NodeID="+mData.ID+" nodes pointing: "+mData.numPointingNodes+" surfaceID="+
135
            mSurface.getID()+" FBO="+(mData.mFBO==null ? "null":mData.mFBO.getID()))+
136
            " parent sID="+(mParent==null ? "null": (mParent.mSurface.getID()));
137

    
138
    android.util.Log.e("NODE", tmp);
139

    
140
    for(i=0; i<mNumChildren[0]; i++)
141
      mChildren.get(i).debug(depth+1);
142
    }
143

    
144
///////////////////////////////////////////////////////////////////////////////////////////////////
145
// Debug - print contents of the HashMap
146

    
147
  @SuppressWarnings("unused")
148
  static void debugMap()
149
    {
150
    NodeData tmp;
151

    
152
    for(ArrayList<Long> key: mMapNodeID.keySet())
153
      {
154
      tmp = mMapNodeID.get(key);
155
      android.util.Log.e("NODE", "NodeID: "+tmp.ID+" <-- "+key);
156
      }
157
    }
158

    
159
///////////////////////////////////////////////////////////////////////////////////////////////////
160
// tree isomorphism algorithm
161

    
162
  private void adjustIsomorphism()
163
    {
164
    ArrayList<Long> newList = generateIDList();
165
    NodeData newData = mMapNodeID.get(newList);
166

    
167
    if( newData!=null )
168
      {
169
      newData.numPointingNodes++;
170
      }
171
    else
172
      {
173
      newData = new NodeData(++mNextNodeID,newList);
174
      mMapNodeID.put(newList,newData);
175
      }
176

    
177
    boolean deleteOldFBO = false;
178
    boolean createNewFBO = false;
179

    
180
    if( --mData.numPointingNodes==0 )
181
      {
182
      mMapNodeID.remove(mData.key);
183
      if( mData.mFBO!=null ) deleteOldFBO=true;
184
      }
185
    if( mNumChildren[0]>0 && newData.mFBO==null )
186
      {
187
      createNewFBO = true;
188
      }
189
    if( mNumChildren[0]==0 && newData.mFBO!=null )
190
      {
191
      newData.mFBO.markForDeletion();
192
      android.util.Log.d("NODE", "ERROR!! this NodeData cannot possibly contain a non-null FBO!! "+newData.mFBO.getID() );
193
      newData.mFBO = null;
194
      }
195

    
196
    if( deleteOldFBO && createNewFBO )
197
      {
198
      newData.mFBO = mData.mFBO;  // just copy over
199
      //android.util.Log.d("NODE", "copying over FBOs "+mData.mFBO.getID() );
200
      }
201
    else if( deleteOldFBO )
202
      {
203
      mData.mFBO.markForDeletion();
204
      //android.util.Log.d("NODE", "deleting old FBO "+mData.mFBO.getID() );
205
      mData.mFBO = null;
206
      }
207
    else if( createNewFBO )
208
      {
209
      newData.mFBO = new DistortedFramebuffer(true, DistortedSurface.TYPE_TREE, mSurface.getWidth(),mSurface.getHeight());
210
      //android.util.Log.d("NODE", "creating new FBO "+newData.mFBO.getID() );
211
      }
212

    
213
    mData = newData;
214

    
215
    if( mParent!=null ) mParent.adjustIsomorphism();
216
    }
217

    
218
///////////////////////////////////////////////////////////////////////////////////////////////////
219
// return the total number of render calls issued
220

    
221
  int draw(long currTime, DistortedOutputSurface surface)
222
    {
223
    DistortedInputSurface input = mNumChildren[0]==0 ? mSurface : mData.mFBO;
224

    
225
    if( input.setAsInput() )
226
      {
227
      mState.apply();
228
      mEffects.drawPriv(mSurface.getWidth()/2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime);
229
      return 1;
230
      }
231

    
232
    return 0;
233
    }
234

    
235
///////////////////////////////////////////////////////////////////////////////////////////////////
236
// return the total number of render calls issued
237

    
238
  int renderRecursive(long currTime)
239
    {
240
    int numRenders = 0;
241

    
242
    if( mNumChildren[0]>0 && mData.currTime!=currTime )
243
      {
244
      mData.currTime = currTime;
245

    
246
      for (int i=0; i<mNumChildren[0]; i++)
247
        {
248
        numRenders += mChildren.get(i).renderRecursive(currTime);
249
        }
250

    
251
      mData.mFBO.setAsOutput(currTime);
252

    
253
      if( mSurface.setAsInput() )
254
        {
255
        numRenders++;
256
        DistortedEffects.blitPriv(mData.mFBO);
257
        }
258

    
259
      numRenders += mData.mFBO.renderChildren(currTime,mNumChildren[0],mChildren);
260
      }
261

    
262
    return numRenders;
263
    }
264

    
265
///////////////////////////////////////////////////////////////////////////////////////////////////
266

    
267
  private void newJob(int t, DistortedNode n, DistortedEffectsPostprocess d)
268
    {
269
    mJobs.add(new Job(t,n,d));
270
    }
271

    
272
///////////////////////////////////////////////////////////////////////////////////////////////////
273

    
274
  void setPost(DistortedEffectsPostprocess dep)
275
    {
276
    mPostprocess = dep;
277
    }
278

    
279
///////////////////////////////////////////////////////////////////////////////////////////////////
280

    
281
  void setSurfaceParent(DistortedOutputSurface dep)
282
    {
283
    mSurfaceParent = dep;
284
    mParent = null;
285
    }
286

    
287
///////////////////////////////////////////////////////////////////////////////////////////////////
288
// PUBLIC API
289
///////////////////////////////////////////////////////////////////////////////////////////////////
290
/**
291
 * Constructs new Node.
292
 *     
293
 * @param surface InputSurface to put into the new Node.
294
 * @param effects DistortedEffects to put into the new Node.
295
 * @param mesh MeshObject to put into the new Node.
296
 */
297
  public DistortedNode(DistortedInputSurface surface, DistortedEffects effects, MeshObject mesh)
298
    {
299
    mSurface       = surface;
300
    mEffects       = effects;
301
    mPostprocess   = null;
302
    mMesh          = mesh;
303
    mState         = new DistortedRenderState();
304
    mChildren      = null;
305
    mNumChildren   = new int[1];
306
    mNumChildren[0]= 0;
307
    mParent        = null;
308
    mSurfaceParent = null;
309

    
310
    ArrayList<Long> list = new ArrayList<>();
311
    list.add(mSurface.getID());
312
    list.add(-mEffects.getID());
313

    
314
    mData = mMapNodeID.get(list);
315
   
316
    if( mData!=null )
317
      {
318
      mData.numPointingNodes++;
319
      }
320
    else
321
      {
322
      mData = new NodeData(++mNextNodeID,list);
323
      mMapNodeID.put(list, mData);
324
      }
325
    }
326

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

    
346
    if( (flags & Distorted.CLONE_SURFACE) != 0 )
347
      {
348
      mSurface = node.mSurface;
349
      }
350
    else
351
      {
352
      int w = node.mSurface.getWidth();
353
      int h = node.mSurface.getHeight();
354

    
355
      if( node.mSurface instanceof DistortedTexture )
356
        {
357
        mSurface = new DistortedTexture(w,h, DistortedSurface.TYPE_TREE);
358
        }
359
      else if( node.mSurface instanceof DistortedFramebuffer )
360
        {
361
        boolean hasDepth = ((DistortedFramebuffer) node.mSurface).hasDepth();
362
        mSurface = new DistortedFramebuffer(hasDepth,DistortedSurface.TYPE_TREE,w,h);
363
        }
364
      }
365
    if( (flags & Distorted.CLONE_CHILDREN) != 0 )
366
      {
367
      if( node.mChildren==null )     // do NOT copy over the NULL!
368
        {
369
        node.mChildren = new ArrayList<>(2);
370
        }
371

    
372
      mChildren = node.mChildren;
373
      mNumChildren = node.mNumChildren;
374
      }
375
    else
376
      {
377
      mChildren = null;
378
      mNumChildren = new int[1];
379
      mNumChildren[0] = 0;
380
      }
381
   
382
    ArrayList<Long> list = generateIDList();
383
   
384
    mData = mMapNodeID.get(list);
385
   
386
    if( mData!=null )
387
      {
388
      mData.numPointingNodes++;
389
      }
390
    else
391
      {
392
      mData = new NodeData(++mNextNodeID,list);
393
      mMapNodeID.put(list, mData);
394
      }
395
    }
396

    
397
///////////////////////////////////////////////////////////////////////////////////////////////////
398
/**
399
 * Adds a new child to the last position in the list of our Node's children.
400
 * <p>
401
 * We cannot do this mid-render - actual attachment will be done just before the next render, by the
402
 * DistortedMaster (by calling doWork())
403
 *
404
 * @param node The new Node to add.
405
 */
406
  public void attach(DistortedNode node)
407
    {
408
    mJobs.add(new Job(ATTACH,node,null));
409
    DistortedMaster.newSlave(this);
410
    }
411

    
412
///////////////////////////////////////////////////////////////////////////////////////////////////
413
/**
414
 * Adds a new child to the last position in the list of our Node's children.
415
 * <p>
416
 * We cannot do this mid-render - actual attachment will be done just before the next render, by the
417
 * DistortedMaster (by calling doWork())
418
 *
419
 * @param surface InputSurface to initialize our child Node with.
420
 * @param effects DistortedEffects to initialize our child Node with.
421
 * @param mesh MeshObject to initialize our child Node with.
422
 * @return the newly constructed child Node, or null if we couldn't allocate resources.
423
 */
424
  public DistortedNode attach(DistortedInputSurface surface, DistortedEffects effects, MeshObject mesh)
425
    {
426
    DistortedNode node = new DistortedNode(surface,effects,mesh);
427
    mJobs.add(new Job(ATTACH,node,null));
428
    DistortedMaster.newSlave(this);
429
    return node;
430
    }
431

    
432
///////////////////////////////////////////////////////////////////////////////////////////////////
433
/**
434
 * Removes the first occurrence of a specified child from the list of children of our Node.
435
 * <p>
436
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
437
 * DistortedMaster (by calling doWork())
438
 *
439
 * @param node The Node to remove.
440
 */
441
  public void detach(DistortedNode node)
442
    {
443
    mJobs.add(new Job(DETACH,node,null));
444
    DistortedMaster.newSlave(this);
445
    }
446

    
447
///////////////////////////////////////////////////////////////////////////////////////////////////
448
/**
449
 * Removes the first occurrence of a specified child from the list of children of our Node.
450
 * <p>
451
 * A bit questionable method as there can be many different Nodes attached as children, some
452
 * of them having the same Effects but - for instance - different Mesh. Use with care.
453
 * <p>
454
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
455
 * DistortedMaster (by calling doWork())
456
 *
457
 * @param effects DistortedEffects to remove.
458
 */
459
  public void detach(DistortedEffects effects)
460
    {
461
    long id = effects.getID();
462
    DistortedNode node;
463
    boolean detached = false;
464

    
465
    for(int i=0; i<mNumChildren[0]; i++)
466
      {
467
      node = mChildren.get(i);
468

    
469
      if( node.getEffects().getID()==id )
470
        {
471
        detached = true;
472
        mJobs.add(new Job(DETACH,node,null));
473
        DistortedMaster.newSlave(this);
474
        break;
475
        }
476
      }
477

    
478
    if( !detached )
479
      {
480
      // if we failed to detach any, it still might be the case that
481
      // there's an ATTACH job that we need to cancel.
482
      int num = mJobs.size();
483
      Job job;
484

    
485
      for(int i=0; i<num; i++)
486
        {
487
        job = mJobs.get(i);
488

    
489
        if( job.type==ATTACH && job.node.getEffects()==effects )
490
          {
491
          mJobs.remove(i);
492
          break;
493
          }
494
        }
495
      }
496
    }
497

    
498
///////////////////////////////////////////////////////////////////////////////////////////////////
499
/**
500
 * Removes all children Nodes.
501
 * <p>
502
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
503
 * DistortedMaster (by calling doWork())
504
 */
505
  public void detachAll()
506
    {
507
    mJobs.add(new Job(DETALL,null,null));
508
    DistortedMaster.newSlave(this);
509
    }
510

    
511
///////////////////////////////////////////////////////////////////////////////////////////////////
512
/**
513
 * This is not really part of the public API. Has to be public only because it is a part of the
514
 * DistortedSlave interface, which should really be a class that we extend here instead but
515
 * Java has no multiple inheritance.
516
 *
517
 * @y.exclude
518
 */
519
  public void doWork()
520
    {
521
    int num = mJobs.size();
522
    Job job;
523

    
524
    int numChanges=0;
525

    
526
    for(int i=0; i<num; i++)
527
      {
528
      job = mJobs.remove(0);
529

    
530
      switch(job.type)
531
        {
532
        case ATTACH: numChanges++;
533
                     if( mChildren==null ) mChildren = new ArrayList<>(2);
534
                     job.node.mParent = this;
535
                     job.node.mSurfaceParent = null;
536
                     DistortedMaster.addSorted(mChildren,job.node);
537
                     mNumChildren[0]++;
538
                     break;
539
        case DETACH: numChanges++;
540
                     if( mNumChildren[0]>0 && mChildren.remove(job.node) )
541
                       {
542
                       job.node.mParent = null;
543
                       job.node.mSurfaceParent = null;
544
                       mNumChildren[0]--;
545
                       }
546
                     break;
547
        case DETALL: numChanges++;
548
                     if( mNumChildren[0]>0 )
549
                       {
550
                       DistortedNode tmp;
551

    
552
                       for(int j=mNumChildren[0]-1; j>=0; j--)
553
                         {
554
                         tmp = mChildren.remove(j);
555
                         tmp.mParent = null;
556
                         tmp.mSurfaceParent = null;
557
                         }
558

    
559
                       mNumChildren[0] = 0;
560
                       }
561
                     break;
562
        case SORT  : job.node.mPostprocess = job.dep;
563
                     mChildren.remove(job.node);
564
                     DistortedMaster.addSorted(mChildren,job.node);
565
                     break;
566
        }
567
      }
568

    
569
    if( numChanges>0 ) adjustIsomorphism();
570
    }
571
///////////////////////////////////////////////////////////////////////////////////////////////////
572
/**
573
 * Sets the Postprocessing Effects we will apply to the temporary buffer this Node - and fellow siblings
574
 * with the same Effects - will get rendered to.
575
 * <p>
576
 * For efficiency reasons, it is very important to assign the very same DistortedEffectsPostprocess
577
 * object to all the DistortedNode siblings that are supposed to be postprocessed in the same way,
578
 * because only then will the library assign all such siblings to the same 'Bucket' which gets rendered
579
 * to the same offscreen buffer which then gets postprocessed in one go and subsequently merged to the
580
 * target Surface.
581
 */
582
  public void setPostprocessEffects(DistortedEffectsPostprocess dep)
583
    {
584
    if( mParent!=null )
585
      {
586
      mParent.newJob(SORT, this, dep);
587
      DistortedMaster.newSlave(mParent);
588
      }
589
    else if( mSurfaceParent!=null )
590
      {
591
      mSurfaceParent.newJob(SORT, this, dep);
592
      DistortedMaster.newSlave(mSurfaceParent);
593
      }
594
    else
595
      {
596
      mPostprocess = dep;
597
      }
598
    }
599

    
600
///////////////////////////////////////////////////////////////////////////////////////////////////
601
/**
602
 * Returns the DistortedEffectsPostprocess object that's in the Node.
603
 *
604
 * @return The DistortedEffectsPostprocess contained in the Node.
605
 */
606
  public DistortedEffectsPostprocess getEffectsPostprocess()
607
    {
608
    return mPostprocess;
609
    }
610

    
611
///////////////////////////////////////////////////////////////////////////////////////////////////
612
/**
613
 * Returns the DistortedEffects object that's in the Node.
614
 * 
615
 * @return The DistortedEffects contained in the Node.
616
 */
617
  public DistortedEffects getEffects()
618
    {
619
    return mEffects;
620
    }
621

    
622
///////////////////////////////////////////////////////////////////////////////////////////////////
623
/**
624
 * Returns the DistortedInputSurface object that's in the Node.
625
 *
626
 * @return The DistortedInputSurface contained in the Node.
627
 */
628
  public DistortedInputSurface getSurface()
629
    {
630
    return mSurface;
631
    }
632

    
633
///////////////////////////////////////////////////////////////////////////////////////////////////
634
/**
635
 * Returns the DistortedFramebuffer object that's in the Node.
636
 *
637
 * @return The DistortedFramebuffer contained in the Node.
638
 */
639
  public DistortedFramebuffer getFramebuffer()
640
    {
641
    return mData.mFBO;
642
    }
643

    
644

    
645
///////////////////////////////////////////////////////////////////////////////////////////////////
646
/**
647
 * When rendering this Node, use ColorMask (r,g,b,a).
648
 *
649
 * @param r Write to the RED color channel when rendering this Node?
650
 * @param g Write to the GREEN color channel when rendering this Node?
651
 * @param b Write to the BLUE color channel when rendering this Node?
652
 * @param a Write to the ALPHA channel when rendering this Node?
653
 */
654
  @SuppressWarnings("unused")
655
  public void glColorMask(boolean r, boolean g, boolean b, boolean a)
656
    {
657
    mState.glColorMask(r,g,b,a);
658
    }
659

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

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

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

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

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

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

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

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