Project

General

Profile

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

library / src / main / java / org / distorted / library / DistortedNode.java @ 0c303a2c

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 onPause()
95
    {
96
    NodeData data;
97

    
98
    for (HashMap.Entry<ArrayList<Long>,NodeData> entry : mMapNodeID.entrySet())
99
      {
100
      data = entry.getValue();
101

    
102
      if( data.mFBO != null )
103
        {
104
        data.mFBO.markForDeletion();
105
        data.mFBO = null;
106
        }
107
      }
108
    }
109

    
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

    
112
  static synchronized void onDestroy()
113
    {
114
    mNextNodeID = 0;
115
    mMapNodeID.clear();
116
    }
117

    
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119

    
120
  private ArrayList<Long> generateIDList()
121
    {
122
    ArrayList<Long> ret = new ArrayList<>();
123
     
124
    ret.add( mSurface.getID() );
125

    
126
    if( mNumChildren[0]==0 )
127
      {
128
      ret.add(-mEffects.getID());
129
      }
130

    
131
    DistortedNode node;
132
   
133
    for(int i=0; i<mNumChildren[0]; i++)
134
      {
135
      node = mChildren.get(i);
136
      ret.add(node.mData.ID);
137
      }
138
   
139
    return ret;
140
    }
141

    
142
///////////////////////////////////////////////////////////////////////////////////////////////////
143
// Debug - print all the Node IDs
144

    
145
  @SuppressWarnings("unused")
146
  void debug(int depth)
147
    {
148
    String tmp="";
149
    int i;
150

    
151
    for(i=0; i<depth; i++) tmp +="   ";
152
    tmp += ("NodeID="+mData.ID+" nodes pointing: "+mData.numPointingNodes+" surfaceID="+
153
            mSurface.getID()+" FBO="+(mData.mFBO==null ? "null":mData.mFBO.getID()))+
154
            " parent sID="+(mParent==null ? "null": (mParent.mSurface.getID()));
155

    
156
    android.util.Log.e("NODE", tmp);
157

    
158
    for(i=0; i<mNumChildren[0]; i++)
159
      mChildren.get(i).debug(depth+1);
160
    }
161

    
162
///////////////////////////////////////////////////////////////////////////////////////////////////
163
// Debug - print contents of the HashMap
164

    
165
  @SuppressWarnings("unused")
166
  static void debugMap()
167
    {
168
    NodeData tmp;
169

    
170
    for(ArrayList<Long> key: mMapNodeID.keySet())
171
      {
172
      tmp = mMapNodeID.get(key);
173
      android.util.Log.e("NODE", "NodeID: "+tmp.ID+" <-- "+key);
174
      }
175
    }
176

    
177
///////////////////////////////////////////////////////////////////////////////////////////////////
178
// tree isomorphism algorithm
179

    
180
  private void adjustIsomorphism()
181
    {
182
    ArrayList<Long> newList = generateIDList();
183
    NodeData newData = mMapNodeID.get(newList);
184

    
185
    if( newData!=null )
186
      {
187
      newData.numPointingNodes++;
188
      }
189
    else
190
      {
191
      newData = new NodeData(++mNextNodeID,newList);
192
      mMapNodeID.put(newList,newData);
193
      }
194

    
195
    boolean deleteOldFBO = false;
196
    boolean createNewFBO = false;
197

    
198
    if( --mData.numPointingNodes==0 )
199
      {
200
      mMapNodeID.remove(mData.key);
201
      if( mData.mFBO!=null ) deleteOldFBO=true;
202
      }
203
    if( mNumChildren[0]>0 && newData.mFBO==null )
204
      {
205
      createNewFBO = true;
206
      }
207
    if( mNumChildren[0]==0 && newData.mFBO!=null )
208
      {
209
      newData.mFBO.markForDeletion();
210
      android.util.Log.d("NODE", "ERROR!! this NodeData cannot possibly contain a non-null FBO!! "+newData.mFBO.getID() );
211
      newData.mFBO = null;
212
      }
213

    
214
    if( deleteOldFBO && createNewFBO )
215
      {
216
      newData.mFBO = mData.mFBO;  // just copy over
217
      //android.util.Log.d("NODE", "copying over FBOs "+mData.mFBO.getID() );
218
      }
219
    else if( deleteOldFBO )
220
      {
221
      mData.mFBO.markForDeletion();
222
      //android.util.Log.d("NODE", "deleting old FBO "+mData.mFBO.getID() );
223
      mData.mFBO = null;
224
      }
225
    else if( createNewFBO )
226
      {
227
      newData.mFBO = new DistortedFramebuffer(true, DistortedSurface.TYPE_TREE, mSurface.getWidth(),mSurface.getHeight());
228
      //android.util.Log.d("NODE", "creating new FBO "+newData.mFBO.getID() );
229
      }
230

    
231
    mData = newData;
232

    
233
    if( mParent!=null ) mParent.adjustIsomorphism();
234
    }
235

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

    
239
  int draw(long currTime, DistortedOutputSurface surface)
240
    {
241
    DistortedInputSurface input = mNumChildren[0]==0 ? mSurface : mData.mFBO;
242

    
243
    if( input.setAsInput() )
244
      {
245
      mState.apply();
246
      mEffects.drawPriv(mSurface.getWidth()/2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime);
247
      return 1;
248
      }
249

    
250
    return 0;
251
    }
252

    
253
///////////////////////////////////////////////////////////////////////////////////////////////////
254
// return the total number of render calls issued
255

    
256
  int renderRecursive(long currTime)
257
    {
258
    int numRenders = 0;
259

    
260
    if( mNumChildren[0]>0 && mData.currTime!=currTime )
261
      {
262
      mData.currTime = currTime;
263

    
264
      for (int i=0; i<mNumChildren[0]; i++)
265
        {
266
        numRenders += mChildren.get(i).renderRecursive(currTime);
267
        }
268

    
269
      if( mData.mFBO==null )
270
        {
271
        mData.mFBO = new DistortedFramebuffer(true, DistortedSurface.TYPE_TREE, mSurface.getWidth(),mSurface.getHeight());
272
        }
273

    
274
      mData.mFBO.setAsOutput(currTime);
275

    
276
      if( mSurface.setAsInput() )
277
        {
278
        numRenders++;
279
        DistortedEffects.blitPriv(mData.mFBO);
280
        }
281

    
282
      numRenders += mData.mFBO.renderChildren(currTime,mNumChildren[0],mChildren);
283
      }
284

    
285
    return numRenders;
286
    }
287

    
288
///////////////////////////////////////////////////////////////////////////////////////////////////
289

    
290
  private void newJob(int t, DistortedNode n, DistortedEffectsPostprocess d)
291
    {
292
    mJobs.add(new Job(t,n,d));
293
    }
294

    
295
///////////////////////////////////////////////////////////////////////////////////////////////////
296

    
297
  void setPost(DistortedEffectsPostprocess dep)
298
    {
299
    mPostprocess = dep;
300
    }
301

    
302
///////////////////////////////////////////////////////////////////////////////////////////////////
303

    
304
  void setSurfaceParent(DistortedOutputSurface dep)
305
    {
306
    mSurfaceParent = dep;
307
    mParent = null;
308
    }
309

    
310
///////////////////////////////////////////////////////////////////////////////////////////////////
311
// PUBLIC API
312
///////////////////////////////////////////////////////////////////////////////////////////////////
313
/**
314
 * Constructs new Node.
315
 *     
316
 * @param surface InputSurface to put into the new Node.
317
 * @param effects DistortedEffects to put into the new Node.
318
 * @param mesh MeshObject to put into the new Node.
319
 */
320
  public DistortedNode(DistortedInputSurface surface, DistortedEffects effects, MeshObject mesh)
321
    {
322
    mSurface       = surface;
323
    mEffects       = effects;
324
    mPostprocess   = null;
325
    mMesh          = mesh;
326
    mState         = new DistortedRenderState();
327
    mChildren      = null;
328
    mNumChildren   = new int[1];
329
    mNumChildren[0]= 0;
330
    mParent        = null;
331
    mSurfaceParent = null;
332

    
333
    ArrayList<Long> list = new ArrayList<>();
334
    list.add(mSurface.getID());
335
    list.add(-mEffects.getID());
336

    
337
    mData = mMapNodeID.get(list);
338
   
339
    if( mData!=null )
340
      {
341
      mData.numPointingNodes++;
342
      }
343
    else
344
      {
345
      mData = new NodeData(++mNextNodeID,list);
346
      mMapNodeID.put(list, mData);
347
      }
348
    }
349

    
350
///////////////////////////////////////////////////////////////////////////////////////////////////  
351
/**
352
 * Copy-constructs new Node from another Node.
353
 *     
354
 * @param node The DistortedNode to copy data from.
355
 * @param flags bit field composed of a subset of the following:
356
 *        {@link Distorted#CLONE_SURFACE},  {@link Distorted#CLONE_MATRIX}, {@link Distorted#CLONE_VERTEX},
357
 *        {@link Distorted#CLONE_FRAGMENT} and {@link Distorted#CLONE_CHILDREN}.
358
 *        For example flags = CLONE_SURFACE | CLONE_CHILDREN.
359
 */
360
  public DistortedNode(DistortedNode node, int flags)
361
    {
362
    mEffects      = new DistortedEffects(node.mEffects,flags);
363
    mPostprocess  = null;
364
    mMesh         = node.mMesh;
365
    mState        = new DistortedRenderState();
366
    mParent       = null;
367
    mSurfaceParent= null;
368

    
369
    if( (flags & Distorted.CLONE_SURFACE) != 0 )
370
      {
371
      mSurface = node.mSurface;
372
      }
373
    else
374
      {
375
      int w = node.mSurface.getWidth();
376
      int h = node.mSurface.getHeight();
377

    
378
      if( node.mSurface instanceof DistortedTexture )
379
        {
380
        mSurface = new DistortedTexture(w,h, DistortedSurface.TYPE_TREE);
381
        }
382
      else if( node.mSurface instanceof DistortedFramebuffer )
383
        {
384
        boolean hasDepth = ((DistortedFramebuffer) node.mSurface).hasDepth();
385
        mSurface = new DistortedFramebuffer(hasDepth,DistortedSurface.TYPE_TREE,w,h);
386
        }
387
      }
388
    if( (flags & Distorted.CLONE_CHILDREN) != 0 )
389
      {
390
      if( node.mChildren==null )     // do NOT copy over the NULL!
391
        {
392
        node.mChildren = new ArrayList<>(2);
393
        }
394

    
395
      mChildren = node.mChildren;
396
      mNumChildren = node.mNumChildren;
397
      }
398
    else
399
      {
400
      mChildren = null;
401
      mNumChildren = new int[1];
402
      mNumChildren[0] = 0;
403
      }
404
   
405
    ArrayList<Long> list = generateIDList();
406
   
407
    mData = mMapNodeID.get(list);
408
   
409
    if( mData!=null )
410
      {
411
      mData.numPointingNodes++;
412
      }
413
    else
414
      {
415
      mData = new NodeData(++mNextNodeID,list);
416
      mMapNodeID.put(list, mData);
417
      }
418
    }
419

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

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

    
455
///////////////////////////////////////////////////////////////////////////////////////////////////
456
/**
457
 * Removes the first occurrence of a specified child from the list of children of our Node.
458
 * <p>
459
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
460
 * DistortedMaster (by calling doWork())
461
 *
462
 * @param node The Node to remove.
463
 */
464
  public void detach(DistortedNode node)
465
    {
466
    mJobs.add(new Job(DETACH,node,null));
467
    DistortedMaster.newSlave(this);
468
    }
469

    
470
///////////////////////////////////////////////////////////////////////////////////////////////////
471
/**
472
 * Removes the first occurrence of a specified child from the list of children of our Node.
473
 * <p>
474
 * A bit questionable method as there can be many different Nodes attached as children, some
475
 * of them having the same Effects but - for instance - different Mesh. Use with care.
476
 * <p>
477
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
478
 * DistortedMaster (by calling doWork())
479
 *
480
 * @param effects DistortedEffects to remove.
481
 */
482
  public void detach(DistortedEffects effects)
483
    {
484
    long id = effects.getID();
485
    DistortedNode node;
486
    boolean detached = false;
487

    
488
    for(int i=0; i<mNumChildren[0]; i++)
489
      {
490
      node = mChildren.get(i);
491

    
492
      if( node.getEffects().getID()==id )
493
        {
494
        detached = true;
495
        mJobs.add(new Job(DETACH,node,null));
496
        DistortedMaster.newSlave(this);
497
        break;
498
        }
499
      }
500

    
501
    if( !detached )
502
      {
503
      // if we failed to detach any, it still might be the case that
504
      // there's an ATTACH job that we need to cancel.
505
      int num = mJobs.size();
506
      Job job;
507

    
508
      for(int i=0; i<num; i++)
509
        {
510
        job = mJobs.get(i);
511

    
512
        if( job.type==ATTACH && job.node.getEffects()==effects )
513
          {
514
          mJobs.remove(i);
515
          break;
516
          }
517
        }
518
      }
519
    }
520

    
521
///////////////////////////////////////////////////////////////////////////////////////////////////
522
/**
523
 * Removes all children Nodes.
524
 * <p>
525
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
526
 * DistortedMaster (by calling doWork())
527
 */
528
  public void detachAll()
529
    {
530
    mJobs.add(new Job(DETALL,null,null));
531
    DistortedMaster.newSlave(this);
532
    }
533

    
534
///////////////////////////////////////////////////////////////////////////////////////////////////
535
/**
536
 * This is not really part of the public API. Has to be public only because it is a part of the
537
 * DistortedSlave interface, which should really be a class that we extend here instead but
538
 * Java has no multiple inheritance.
539
 *
540
 * @y.exclude
541
 */
542
  public void doWork()
543
    {
544
    int num = mJobs.size();
545
    Job job;
546

    
547
    int numChanges=0;
548

    
549
    for(int i=0; i<num; i++)
550
      {
551
      job = mJobs.remove(0);
552

    
553
      switch(job.type)
554
        {
555
        case ATTACH: numChanges++;
556
                     if( mChildren==null ) mChildren = new ArrayList<>(2);
557
                     job.node.mParent = this;
558
                     job.node.mSurfaceParent = null;
559
                     DistortedMaster.addSorted(mChildren,job.node);
560
                     mNumChildren[0]++;
561
                     break;
562
        case DETACH: numChanges++;
563
                     if( mNumChildren[0]>0 && mChildren.remove(job.node) )
564
                       {
565
                       job.node.mParent = null;
566
                       job.node.mSurfaceParent = null;
567
                       mNumChildren[0]--;
568
                       }
569
                     break;
570
        case DETALL: numChanges++;
571
                     if( mNumChildren[0]>0 )
572
                       {
573
                       DistortedNode tmp;
574

    
575
                       for(int j=mNumChildren[0]-1; j>=0; j--)
576
                         {
577
                         tmp = mChildren.remove(j);
578
                         tmp.mParent = null;
579
                         tmp.mSurfaceParent = null;
580
                         }
581

    
582
                       mNumChildren[0] = 0;
583
                       }
584
                     break;
585
        case SORT  : job.node.mPostprocess = job.dep;
586
                     mChildren.remove(job.node);
587
                     DistortedMaster.addSorted(mChildren,job.node);
588
                     break;
589
        }
590
      }
591

    
592
    if( numChanges>0 ) adjustIsomorphism();
593
    }
594
///////////////////////////////////////////////////////////////////////////////////////////////////
595
/**
596
 * Sets the Postprocessing Effects we will apply to the temporary buffer this Node - and fellow siblings
597
 * with the same Effects - will get rendered to.
598
 * <p>
599
 * For efficiency reasons, it is very important to assign the very same DistortedEffectsPostprocess
600
 * object to all the DistortedNode siblings that are supposed to be postprocessed in the same way,
601
 * because only then will the library assign all such siblings to the same 'Bucket' which gets rendered
602
 * to the same offscreen buffer which then gets postprocessed in one go and subsequently merged to the
603
 * target Surface.
604
 */
605
  public void setPostprocessEffects(DistortedEffectsPostprocess dep)
606
    {
607
    if( mParent!=null )
608
      {
609
      mParent.newJob(SORT, this, dep);
610
      DistortedMaster.newSlave(mParent);
611
      }
612
    else if( mSurfaceParent!=null )
613
      {
614
      mSurfaceParent.newJob(SORT, this, dep);
615
      DistortedMaster.newSlave(mSurfaceParent);
616
      }
617
    else
618
      {
619
      mPostprocess = dep;
620
      }
621
    }
622

    
623
///////////////////////////////////////////////////////////////////////////////////////////////////
624
/**
625
 * Returns the DistortedEffectsPostprocess object that's in the Node.
626
 *
627
 * @return The DistortedEffectsPostprocess contained in the Node.
628
 */
629
  public DistortedEffectsPostprocess getEffectsPostprocess()
630
    {
631
    return mPostprocess;
632
    }
633

    
634
///////////////////////////////////////////////////////////////////////////////////////////////////
635
/**
636
 * Returns the DistortedEffects object that's in the Node.
637
 * 
638
 * @return The DistortedEffects contained in the Node.
639
 */
640
  public DistortedEffects getEffects()
641
    {
642
    return mEffects;
643
    }
644

    
645
///////////////////////////////////////////////////////////////////////////////////////////////////
646
/**
647
 * Returns the DistortedInputSurface object that's in the Node.
648
 *
649
 * @return The DistortedInputSurface contained in the Node.
650
 */
651
  public DistortedInputSurface getSurface()
652
    {
653
    return mSurface;
654
    }
655

    
656
///////////////////////////////////////////////////////////////////////////////////////////////////
657
/**
658
 * Returns the DistortedFramebuffer object that's in the Node.
659
 *
660
 * @return The DistortedFramebuffer contained in the Node.
661
 */
662
  public DistortedFramebuffer getFramebuffer()
663
    {
664
    return mData.mFBO;
665
    }
666

    
667

    
668
///////////////////////////////////////////////////////////////////////////////////////////////////
669
/**
670
 * When rendering this Node, use ColorMask (r,g,b,a).
671
 *
672
 * @param r Write to the RED color channel when rendering this Node?
673
 * @param g Write to the GREEN color channel when rendering this Node?
674
 * @param b Write to the BLUE color channel when rendering this Node?
675
 * @param a Write to the ALPHA channel when rendering this Node?
676
 */
677
  @SuppressWarnings("unused")
678
  public void glColorMask(boolean r, boolean g, boolean b, boolean a)
679
    {
680
    mState.glColorMask(r,g,b,a);
681
    }
682

    
683
///////////////////////////////////////////////////////////////////////////////////////////////////
684
/**
685
 * When rendering this Node, switch on writing to Depth buffer?
686
 *
687
 * @param mask Write to the Depth buffer when rendering this Node?
688
 */
689
  @SuppressWarnings("unused")
690
  public void glDepthMask(boolean mask)
691
    {
692
    mState.glDepthMask(mask);
693
    }
694

    
695
///////////////////////////////////////////////////////////////////////////////////////////////////
696
/**
697
 * When rendering this Node, which bits of the Stencil buffer to write to?
698
 *
699
 * @param mask Marks the bits of the Stencil buffer we will write to when rendering this Node.
700
 */
701
  @SuppressWarnings("unused")
702
  public void glStencilMask(int mask)
703
    {
704
    mState.glStencilMask(mask);
705
    }
706

    
707
///////////////////////////////////////////////////////////////////////////////////////////////////
708
/**
709
 * When rendering this Node, which Tests to enable?
710
 *
711
 * @param test Valid values: GL_DEPTH_TEST, GL_STENCIL_TEST, GL_BLEND
712
 */
713
  @SuppressWarnings("unused")
714
  public void glEnable(int test)
715
    {
716
    mState.glEnable(test);
717
    }
718

    
719
///////////////////////////////////////////////////////////////////////////////////////////////////
720
/**
721
 * When rendering this Node, which Tests to enable?
722
 *
723
 * @param test Valid values: GL_DEPTH_TEST, GL_STENCIL_TEST, GL_BLEND
724
 */
725
  @SuppressWarnings("unused")
726
  public void glDisable(int test)
727
    {
728
    mState.glDisable(test);
729
    }
730

    
731
///////////////////////////////////////////////////////////////////////////////////////////////////
732
/**
733
 * When rendering this Node, use the following StencilFunc.
734
 *
735
 * @param func Valid values: GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL
736
 * @param ref  Reference valut to compare our stencil with.
737
 * @param mask Mask used when comparing.
738
 */
739
  @SuppressWarnings("unused")
740
  public void glStencilFunc(int func, int ref, int mask)
741
    {
742
    mState.glStencilFunc(func,ref,mask);
743
    }
744

    
745
///////////////////////////////////////////////////////////////////////////////////////////////////
746
/**
747
 * When rendering this Node, use the following StencilOp.
748
 * <p>
749
 * Valid values of all 3 parameters: GL_KEEP, GL_ZERO, GL_REPLACE, GL_INCR, GL_DECR, GL_INVERT, GL_INCR_WRAP, GL_DECR_WRAP
750
 *
751
 * @param sfail  What to do when Stencil Test fails.
752
 * @param dpfail What to do when Depth Test fails.
753
 * @param dppass What to do when Depth Test passes.
754
 */
755
  @SuppressWarnings("unused")
756
  public void glStencilOp(int sfail, int dpfail, int dppass)
757
    {
758
    mState.glStencilOp(sfail,dpfail,dppass);
759
    }
760

    
761
///////////////////////////////////////////////////////////////////////////////////////////////////
762
/**
763
 * When rendering this Node, use the following DepthFunc.
764
 *
765
 * @param func Valid values: GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL
766
 */
767
  @SuppressWarnings("unused")
768
  public void glDepthFunc(int func)
769
    {
770
    mState.glDepthFunc(func);
771
    }
772

    
773
///////////////////////////////////////////////////////////////////////////////////////////////////
774
/**
775
 * When rendering this Node, use the following Blending mode.
776
 * <p>
777
 * Valid values: GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
778
 *               GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR,
779
 *               GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_SRC_ALPHA_SATURATE
780
 *
781
 * @param src Source Blend function
782
 * @param dst Destination Blend function
783
 */
784
  @SuppressWarnings("unused")
785
  public void glBlendFunc(int src, int dst)
786
    {
787
    mState.glBlendFunc(src,dst);
788
    }
789
  }
(7-7/24)