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
|
import android.opengl.GLES30;
|
26
|
|
27
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
28
|
/**
|
29
|
* Class which represents a Node in a Tree of (InputSurface,Mesh,Effects) triplets.
|
30
|
* <p>
|
31
|
* Having organized such sets into a Tree, we can then render any Node to any OutputSurface.
|
32
|
* That recursively renders the set held in the Node and all its children.
|
33
|
* <p>
|
34
|
* The class takes special care to only render identical sub-trees once. Each Node holds a reference
|
35
|
* to sub-class 'NodeData'. Two identical sub-trees attached at different points of the main tree
|
36
|
* will point to the same NodeData; only the first of this is rendered (mData.numRender!).
|
37
|
*/
|
38
|
public class DistortedNode implements DistortedAttacheable
|
39
|
{
|
40
|
private static HashMap<ArrayList<Long>,NodeData> mMapNodeID = new HashMap<>();
|
41
|
private static long mNextNodeID =0;
|
42
|
|
43
|
private DistortedNode mParent;
|
44
|
private MeshObject mMesh;
|
45
|
private DistortedEffects mEffects;
|
46
|
private DistortedEffectsPostprocess mPostprocess;
|
47
|
private DistortedInputSurface mSurface;
|
48
|
private DistortedRenderState mState;
|
49
|
private NodeData mData;
|
50
|
|
51
|
private ArrayList<DistortedNode> mChildren;
|
52
|
private int[] mNumChildren; // ==mChildren.length(), but we only create mChildren if the first one gets added
|
53
|
|
54
|
private class NodeData
|
55
|
{
|
56
|
long ID;
|
57
|
int numPointingNodes;
|
58
|
long currTime;
|
59
|
ArrayList<Long> key;
|
60
|
DistortedFramebuffer mFBO;
|
61
|
|
62
|
NodeData(long id, ArrayList<Long> k)
|
63
|
{
|
64
|
ID = id;
|
65
|
key = k;
|
66
|
numPointingNodes= 1;
|
67
|
currTime =-1;
|
68
|
mFBO = null;
|
69
|
}
|
70
|
}
|
71
|
|
72
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
73
|
|
74
|
static synchronized void onDestroy()
|
75
|
{
|
76
|
mNextNodeID = 0;
|
77
|
mMapNodeID.clear();
|
78
|
}
|
79
|
|
80
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
81
|
|
82
|
private ArrayList<Long> generateIDList()
|
83
|
{
|
84
|
ArrayList<Long> ret = new ArrayList<>();
|
85
|
|
86
|
ret.add( mSurface.getID() );
|
87
|
|
88
|
if( mNumChildren[0]==0 )
|
89
|
{
|
90
|
ret.add(-mEffects.getID());
|
91
|
}
|
92
|
|
93
|
DistortedNode node;
|
94
|
|
95
|
for(int i=0; i<mNumChildren[0]; i++)
|
96
|
{
|
97
|
node = mChildren.get(i);
|
98
|
ret.add(node.mData.ID);
|
99
|
}
|
100
|
|
101
|
return ret;
|
102
|
}
|
103
|
|
104
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
105
|
// Debug - print all the Node IDs
|
106
|
|
107
|
@SuppressWarnings("unused")
|
108
|
void debug(int depth)
|
109
|
{
|
110
|
String tmp="";
|
111
|
int i;
|
112
|
|
113
|
for(i=0; i<depth; i++) tmp +=" ";
|
114
|
tmp += ("NodeID="+mData.ID+" nodes pointing: "+mData.numPointingNodes+" surfaceID="+
|
115
|
mSurface.getID()+" FBO="+(mData.mFBO==null ? "null":mData.mFBO.getID()))+
|
116
|
" parent sID="+(mParent==null ? "null": (mParent.mSurface.getID()));
|
117
|
|
118
|
android.util.Log.e("NODE", tmp);
|
119
|
|
120
|
for(i=0; i<mNumChildren[0]; i++)
|
121
|
mChildren.get(i).debug(depth+1);
|
122
|
}
|
123
|
|
124
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
125
|
// Debug - print contents of the HashMap
|
126
|
|
127
|
@SuppressWarnings("unused")
|
128
|
static void debugMap()
|
129
|
{
|
130
|
NodeData tmp;
|
131
|
|
132
|
for(ArrayList<Long> key: mMapNodeID.keySet())
|
133
|
{
|
134
|
tmp = mMapNodeID.get(key);
|
135
|
android.util.Log.e("NODE", "NodeID: "+tmp.ID+" <-- "+key);
|
136
|
}
|
137
|
}
|
138
|
|
139
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
140
|
// tree isomorphism algorithm
|
141
|
|
142
|
private void adjustIsomorphism()
|
143
|
{
|
144
|
ArrayList<Long> newList = generateIDList();
|
145
|
NodeData newData = mMapNodeID.get(newList);
|
146
|
|
147
|
if( newData!=null )
|
148
|
{
|
149
|
newData.numPointingNodes++;
|
150
|
}
|
151
|
else
|
152
|
{
|
153
|
newData = new NodeData(++mNextNodeID,newList);
|
154
|
mMapNodeID.put(newList,newData);
|
155
|
}
|
156
|
|
157
|
boolean deleteOldFBO = false;
|
158
|
boolean createNewFBO = false;
|
159
|
|
160
|
if( --mData.numPointingNodes==0 )
|
161
|
{
|
162
|
mMapNodeID.remove(mData.key);
|
163
|
if( mData.mFBO!=null ) deleteOldFBO=true;
|
164
|
}
|
165
|
if( mNumChildren[0]>0 && newData.mFBO==null )
|
166
|
{
|
167
|
createNewFBO = true;
|
168
|
}
|
169
|
if( mNumChildren[0]==0 && newData.mFBO!=null )
|
170
|
{
|
171
|
newData.mFBO.markForDeletion();
|
172
|
android.util.Log.d("NODE", "ERROR!! this NodeData cannot possibly contain a non-null FBO!! "+newData.mFBO.getID() );
|
173
|
newData.mFBO = null;
|
174
|
}
|
175
|
|
176
|
if( deleteOldFBO && createNewFBO )
|
177
|
{
|
178
|
newData.mFBO = mData.mFBO; // just copy over
|
179
|
//android.util.Log.d("NODE", "copying over FBOs "+mData.mFBO.getID() );
|
180
|
}
|
181
|
else if( deleteOldFBO )
|
182
|
{
|
183
|
mData.mFBO.markForDeletion();
|
184
|
//android.util.Log.d("NODE", "deleting old FBO "+mData.mFBO.getID() );
|
185
|
mData.mFBO = null;
|
186
|
}
|
187
|
else if( createNewFBO )
|
188
|
{
|
189
|
newData.mFBO = new DistortedFramebuffer(true, DistortedSurface.TYPE_TREE, mSurface.getWidth(),mSurface.getHeight());
|
190
|
//android.util.Log.d("NODE", "creating new FBO "+newData.mFBO.getID() );
|
191
|
}
|
192
|
|
193
|
mData = newData;
|
194
|
|
195
|
if( mParent!=null ) mParent.adjustIsomorphism();
|
196
|
}
|
197
|
|
198
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
199
|
// return the total number of render calls issued
|
200
|
|
201
|
int draw(long currTime, DistortedOutputSurface surface)
|
202
|
{
|
203
|
DistortedInputSurface input = mNumChildren[0]==0 ? mSurface : mData.mFBO;
|
204
|
|
205
|
if( input.setAsInput() )
|
206
|
{
|
207
|
mState.apply();
|
208
|
mEffects.drawPriv(mSurface.getWidth()/2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime);
|
209
|
return 1;
|
210
|
}
|
211
|
|
212
|
return 0;
|
213
|
}
|
214
|
|
215
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
216
|
// return the total number of render calls issued
|
217
|
|
218
|
int renderRecursive(long currTime)
|
219
|
{
|
220
|
int numRenders = 0;
|
221
|
|
222
|
if( mNumChildren[0]>0 && mData.currTime!=currTime )
|
223
|
{
|
224
|
mData.currTime = currTime;
|
225
|
|
226
|
for (int i=0; i<mNumChildren[0]; i++)
|
227
|
{
|
228
|
numRenders += mChildren.get(i).renderRecursive(currTime);
|
229
|
}
|
230
|
|
231
|
mData.mFBO.setAsOutput(currTime);
|
232
|
|
233
|
if( mSurface.setAsInput() )
|
234
|
{
|
235
|
numRenders++;
|
236
|
DistortedEffects.blitPriv(mData.mFBO);
|
237
|
}
|
238
|
|
239
|
numRenders += mData.mFBO.renderChildren(currTime,mNumChildren[0],mChildren);
|
240
|
}
|
241
|
|
242
|
return numRenders;
|
243
|
}
|
244
|
|
245
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
246
|
// PUBLIC API
|
247
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
248
|
/**
|
249
|
* Constructs new Node.
|
250
|
*
|
251
|
* @param surface InputSurface to put into the new Node.
|
252
|
* @param effects DistortedEffects to put into the new Node.
|
253
|
* @param mesh MeshObject to put into the new Node.
|
254
|
*/
|
255
|
public DistortedNode(DistortedInputSurface surface, DistortedEffects effects, MeshObject mesh)
|
256
|
{
|
257
|
mSurface = surface;
|
258
|
mEffects = effects;
|
259
|
mPostprocess = null;
|
260
|
mMesh = mesh;
|
261
|
mState = new DistortedRenderState();
|
262
|
mChildren = null;
|
263
|
mNumChildren = new int[1];
|
264
|
mNumChildren[0]= 0;
|
265
|
mParent = null;
|
266
|
|
267
|
ArrayList<Long> list = new ArrayList<>();
|
268
|
list.add(mSurface.getID());
|
269
|
list.add(-mEffects.getID());
|
270
|
|
271
|
mData = mMapNodeID.get(list);
|
272
|
|
273
|
if( mData!=null )
|
274
|
{
|
275
|
mData.numPointingNodes++;
|
276
|
}
|
277
|
else
|
278
|
{
|
279
|
mData = new NodeData(++mNextNodeID,list);
|
280
|
mMapNodeID.put(list, mData);
|
281
|
}
|
282
|
}
|
283
|
|
284
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
285
|
/**
|
286
|
* Copy-constructs new Node from another Node.
|
287
|
*
|
288
|
* @param node The DistortedNode to copy data from.
|
289
|
* @param flags bit field composed of a subset of the following:
|
290
|
* {@link Distorted#CLONE_SURFACE}, {@link Distorted#CLONE_MATRIX}, {@link Distorted#CLONE_VERTEX},
|
291
|
* {@link Distorted#CLONE_FRAGMENT} and {@link Distorted#CLONE_CHILDREN}.
|
292
|
* For example flags = CLONE_SURFACE | CLONE_CHILDREN.
|
293
|
*/
|
294
|
public DistortedNode(DistortedNode node, int flags)
|
295
|
{
|
296
|
mEffects = new DistortedEffects(node.mEffects,flags);
|
297
|
mPostprocess = null;
|
298
|
mMesh = node.mMesh;
|
299
|
mState = new DistortedRenderState();
|
300
|
mParent = null;
|
301
|
|
302
|
if( (flags & Distorted.CLONE_SURFACE) != 0 )
|
303
|
{
|
304
|
mSurface = node.mSurface;
|
305
|
}
|
306
|
else
|
307
|
{
|
308
|
int w = node.mSurface.getWidth();
|
309
|
int h = node.mSurface.getHeight();
|
310
|
|
311
|
if( node.mSurface instanceof DistortedTexture )
|
312
|
{
|
313
|
mSurface = new DistortedTexture(w,h, DistortedSurface.TYPE_TREE);
|
314
|
}
|
315
|
else if( node.mSurface instanceof DistortedFramebuffer )
|
316
|
{
|
317
|
boolean hasDepth = ((DistortedFramebuffer) node.mSurface).hasDepth();
|
318
|
mSurface = new DistortedFramebuffer(hasDepth,DistortedSurface.TYPE_TREE,w,h);
|
319
|
}
|
320
|
}
|
321
|
if( (flags & Distorted.CLONE_CHILDREN) != 0 )
|
322
|
{
|
323
|
if( node.mChildren==null ) // do NOT copy over the NULL!
|
324
|
{
|
325
|
node.mChildren = new ArrayList<>(2);
|
326
|
}
|
327
|
|
328
|
mChildren = node.mChildren;
|
329
|
mNumChildren = node.mNumChildren;
|
330
|
}
|
331
|
else
|
332
|
{
|
333
|
mChildren = null;
|
334
|
mNumChildren = new int[1];
|
335
|
mNumChildren[0] = 0;
|
336
|
}
|
337
|
|
338
|
ArrayList<Long> list = generateIDList();
|
339
|
|
340
|
mData = mMapNodeID.get(list);
|
341
|
|
342
|
if( mData!=null )
|
343
|
{
|
344
|
mData.numPointingNodes++;
|
345
|
}
|
346
|
else
|
347
|
{
|
348
|
mData = new NodeData(++mNextNodeID,list);
|
349
|
mMapNodeID.put(list, mData);
|
350
|
}
|
351
|
}
|
352
|
|
353
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
354
|
/**
|
355
|
* Adds a new child to the last position in the list of our Node's children.
|
356
|
* <p>
|
357
|
* We cannot do this mid-render - actual attachment will be done just before the next render, by the
|
358
|
* DistortedAttachDeamon (by calling attachNow())
|
359
|
*
|
360
|
* @param node The new Node to add.
|
361
|
*/
|
362
|
public void attach(DistortedNode node)
|
363
|
{
|
364
|
DistortedAttachDaemon.attach(this,node);
|
365
|
}
|
366
|
|
367
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
368
|
/**
|
369
|
* Adds a new child to the last position in the list of our Node's children.
|
370
|
* <p>
|
371
|
* We cannot do this mid-render - actual attachment will be done just before the next render, by the
|
372
|
* DistortedAttachDeamon (by calling attachNow())
|
373
|
*
|
374
|
* @param surface InputSurface to initialize our child Node with.
|
375
|
* @param effects DistortedEffects to initialize our child Node with.
|
376
|
* @param mesh MeshObject to initialize our child Node with.
|
377
|
* @return the newly constructed child Node, or null if we couldn't allocate resources.
|
378
|
*/
|
379
|
public DistortedNode attach(DistortedInputSurface surface, DistortedEffects effects, MeshObject mesh)
|
380
|
{
|
381
|
DistortedNode node = new DistortedNode(surface,effects,mesh);
|
382
|
DistortedAttachDaemon.attach(this,node);
|
383
|
return node;
|
384
|
}
|
385
|
|
386
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
387
|
/**
|
388
|
* This is not really part of the public API. Has to be public only because it is a part of the
|
389
|
* DistortedAttacheable interface, which should really be a class that we extend here instead but
|
390
|
* Java has no multiple inheritance.
|
391
|
*
|
392
|
* @y.exclude
|
393
|
* @param node The new Node to add.
|
394
|
*/
|
395
|
public void attachNow(DistortedNode node)
|
396
|
{
|
397
|
if( mChildren==null ) mChildren = new ArrayList<>(2);
|
398
|
|
399
|
node.mParent = this;
|
400
|
mChildren.add(node);
|
401
|
mNumChildren[0]++;
|
402
|
adjustIsomorphism();
|
403
|
}
|
404
|
|
405
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
406
|
/**
|
407
|
* Removes the first occurrence of a specified child from the list of children of our Node.
|
408
|
* <p>
|
409
|
* We cannot do this mid-render - actual detachment will be done just before the next render, by the
|
410
|
* DistortedAttachDeamon (by calling detachNow())
|
411
|
*
|
412
|
* @param node The Node to remove.
|
413
|
*/
|
414
|
public void detach(DistortedNode node)
|
415
|
{
|
416
|
DistortedAttachDaemon.detach(this,node);
|
417
|
}
|
418
|
|
419
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
420
|
/**
|
421
|
* Removes the first occurrence of a specified child from the list of children of our Node.
|
422
|
* <p>
|
423
|
* A bit questionable method as there can be many different Nodes attached as children, some
|
424
|
* of them having the same Effects but - for instance - different Mesh. Use with care.
|
425
|
* <p>
|
426
|
* We cannot do this mid-render - actual detachment will be done just before the next render, by the
|
427
|
* DistortedAttachDeamon (by calling detachNow())
|
428
|
*
|
429
|
* @param effects DistortedEffects to remove.
|
430
|
*/
|
431
|
public void detach(DistortedEffects effects)
|
432
|
{
|
433
|
long id = effects.getID();
|
434
|
DistortedNode node;
|
435
|
boolean detached= false;
|
436
|
|
437
|
for(int i=0; i<mNumChildren[0]; i++)
|
438
|
{
|
439
|
node = mChildren.get(i);
|
440
|
|
441
|
if( node.mEffects.getID()==id )
|
442
|
{
|
443
|
detached=true;
|
444
|
DistortedAttachDaemon.detach(this,node);
|
445
|
break;
|
446
|
}
|
447
|
}
|
448
|
|
449
|
if( !detached )
|
450
|
{
|
451
|
// if we failed to detach any, it still might be the case that
|
452
|
// there's a job in Daemon's queue that we need to cancel.
|
453
|
DistortedAttachDaemon.cancelAttachJobs(this,effects);
|
454
|
}
|
455
|
}
|
456
|
|
457
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
458
|
/**
|
459
|
* This is not really part of the public API. Has to be public only because it is a part of the
|
460
|
* DistortedAttacheable interface, which should really be a class that we extend here instead but
|
461
|
* Java has no multiple inheritance.
|
462
|
*
|
463
|
* @y.exclude
|
464
|
* @param node The Node to remove.
|
465
|
*/
|
466
|
public void detachNow(DistortedNode node)
|
467
|
{
|
468
|
if( mNumChildren[0]>0 && mChildren.remove(node) )
|
469
|
{
|
470
|
node.mParent = null;
|
471
|
mNumChildren[0]--;
|
472
|
adjustIsomorphism();
|
473
|
}
|
474
|
}
|
475
|
|
476
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
477
|
/**
|
478
|
* Removes all children Nodes.
|
479
|
* <p>
|
480
|
* We cannot do this mid-render - actual detachment will be done just before the next render, by the
|
481
|
* DistortedAttachDeamon (by calling detachAllNow())
|
482
|
*/
|
483
|
public void detachAll()
|
484
|
{
|
485
|
DistortedAttachDaemon.detachAll(this);
|
486
|
}
|
487
|
|
488
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
489
|
/**
|
490
|
* This is not really part of the public API. Has to be public only because it is a part of the
|
491
|
* DistortedAttacheable interface, which should really be a class that we extend here instead but
|
492
|
* Java has no multiple inheritance.
|
493
|
*
|
494
|
* @y.exclude
|
495
|
*/
|
496
|
public void detachAllNow()
|
497
|
{
|
498
|
if( mNumChildren[0]>0 )
|
499
|
{
|
500
|
DistortedNode tmp;
|
501
|
|
502
|
for(int i=mNumChildren[0]-1; i>=0; i--)
|
503
|
{
|
504
|
tmp = mChildren.remove(i);
|
505
|
tmp.mParent = null;
|
506
|
}
|
507
|
|
508
|
mNumChildren[0] = 0;
|
509
|
adjustIsomorphism();
|
510
|
}
|
511
|
}
|
512
|
|
513
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
514
|
/**
|
515
|
* Sets the Postprocessing Effects we will apply to the temporary buffer this Node - and fellow siblings
|
516
|
* with the same Effects - will get rendered to.
|
517
|
* <p>
|
518
|
* For efficiency reasons, it is very important to assign the very same DistortedEffectsPostprocess
|
519
|
* object to all the DistortedNode siblings that are supposed to be postprocessed in the same way,
|
520
|
* because only then will the library assign all such siblings to the same 'Bucket' which gets rendered
|
521
|
* to the same offscreen buffer which then gets postprocessed in one go and subsequently merged to the
|
522
|
* target Surface.
|
523
|
*/
|
524
|
public void setPostprocessEffects(DistortedEffectsPostprocess dep)
|
525
|
{
|
526
|
mPostprocess = dep;
|
527
|
|
528
|
// TODO: rearrange all the siblings so that all are sorted by the DistortedEffectsPostprocess' ID.
|
529
|
}
|
530
|
|
531
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
532
|
/**
|
533
|
* Returns the DistortedEffectsPostprocess object that's in the Node.
|
534
|
*
|
535
|
* @return The DistortedEffectsPostprocess contained in the Node.
|
536
|
*/
|
537
|
public DistortedEffectsPostprocess getEffectsPostprocess()
|
538
|
{
|
539
|
return mPostprocess;
|
540
|
}
|
541
|
|
542
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
543
|
/**
|
544
|
* Returns the DistortedEffects object that's in the Node.
|
545
|
*
|
546
|
* @return The DistortedEffects contained in the Node.
|
547
|
*/
|
548
|
public DistortedEffects getEffects()
|
549
|
{
|
550
|
return mEffects;
|
551
|
}
|
552
|
|
553
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
554
|
/**
|
555
|
* Returns the DistortedInputSurface object that's in the Node.
|
556
|
*
|
557
|
* @return The DistortedInputSurface contained in the Node.
|
558
|
*/
|
559
|
public DistortedInputSurface getSurface()
|
560
|
{
|
561
|
return mSurface;
|
562
|
}
|
563
|
|
564
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
565
|
/**
|
566
|
* Returns the DistortedFramebuffer object that's in the Node.
|
567
|
*
|
568
|
* @return The DistortedFramebuffer contained in the Node.
|
569
|
*/
|
570
|
public DistortedFramebuffer getFramebuffer()
|
571
|
{
|
572
|
return mData.mFBO;
|
573
|
}
|
574
|
|
575
|
|
576
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
577
|
/**
|
578
|
* When rendering this Node, use ColorMask (r,g,b,a).
|
579
|
*
|
580
|
* @param r Write to the RED color channel when rendering this Node?
|
581
|
* @param g Write to the GREEN color channel when rendering this Node?
|
582
|
* @param b Write to the BLUE color channel when rendering this Node?
|
583
|
* @param a Write to the ALPHA channel when rendering this Node?
|
584
|
*/
|
585
|
@SuppressWarnings("unused")
|
586
|
public void glColorMask(boolean r, boolean g, boolean b, boolean a)
|
587
|
{
|
588
|
mState.glColorMask(r,g,b,a);
|
589
|
}
|
590
|
|
591
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
592
|
/**
|
593
|
* When rendering this Node, switch on writing to Depth buffer?
|
594
|
*
|
595
|
* @param mask Write to the Depth buffer when rendering this Node?
|
596
|
*/
|
597
|
@SuppressWarnings("unused")
|
598
|
public void glDepthMask(boolean mask)
|
599
|
{
|
600
|
mState.glDepthMask(mask);
|
601
|
}
|
602
|
|
603
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
604
|
/**
|
605
|
* When rendering this Node, which bits of the Stencil buffer to write to?
|
606
|
*
|
607
|
* @param mask Marks the bits of the Stencil buffer we will write to when rendering this Node.
|
608
|
*/
|
609
|
@SuppressWarnings("unused")
|
610
|
public void glStencilMask(int mask)
|
611
|
{
|
612
|
mState.glStencilMask(mask);
|
613
|
}
|
614
|
|
615
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
616
|
/**
|
617
|
* When rendering this Node, which Tests to enable?
|
618
|
*
|
619
|
* @param test Valid values: GL_DEPTH_TEST, GL_STENCIL_TEST, GL_BLEND
|
620
|
*/
|
621
|
@SuppressWarnings("unused")
|
622
|
public void glEnable(int test)
|
623
|
{
|
624
|
mState.glEnable(test);
|
625
|
}
|
626
|
|
627
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
628
|
/**
|
629
|
* When rendering this Node, which Tests to enable?
|
630
|
*
|
631
|
* @param test Valid values: GL_DEPTH_TEST, GL_STENCIL_TEST, GL_BLEND
|
632
|
*/
|
633
|
@SuppressWarnings("unused")
|
634
|
public void glDisable(int test)
|
635
|
{
|
636
|
mState.glDisable(test);
|
637
|
}
|
638
|
|
639
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
640
|
/**
|
641
|
* When rendering this Node, use the following StencilFunc.
|
642
|
*
|
643
|
* @param func Valid values: GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL
|
644
|
* @param ref Reference valut to compare our stencil with.
|
645
|
* @param mask Mask used when comparing.
|
646
|
*/
|
647
|
@SuppressWarnings("unused")
|
648
|
public void glStencilFunc(int func, int ref, int mask)
|
649
|
{
|
650
|
mState.glStencilFunc(func,ref,mask);
|
651
|
}
|
652
|
|
653
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
654
|
/**
|
655
|
* When rendering this Node, use the following StencilOp.
|
656
|
* <p>
|
657
|
* Valid values of all 3 parameters: GL_KEEP, GL_ZERO, GL_REPLACE, GL_INCR, GL_DECR, GL_INVERT, GL_INCR_WRAP, GL_DECR_WRAP
|
658
|
*
|
659
|
* @param sfail What to do when Stencil Test fails.
|
660
|
* @param dpfail What to do when Depth Test fails.
|
661
|
* @param dppass What to do when Depth Test passes.
|
662
|
*/
|
663
|
@SuppressWarnings("unused")
|
664
|
public void glStencilOp(int sfail, int dpfail, int dppass)
|
665
|
{
|
666
|
mState.glStencilOp(sfail,dpfail,dppass);
|
667
|
}
|
668
|
|
669
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
670
|
/**
|
671
|
* When rendering this Node, use the following DepthFunc.
|
672
|
*
|
673
|
* @param func Valid values: GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL
|
674
|
*/
|
675
|
@SuppressWarnings("unused")
|
676
|
public void glDepthFunc(int func)
|
677
|
{
|
678
|
mState.glDepthFunc(func);
|
679
|
}
|
680
|
|
681
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
682
|
/**
|
683
|
* When rendering this Node, use the following Blending mode.
|
684
|
* <p>
|
685
|
* Valid values: GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
|
686
|
* GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR,
|
687
|
* GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_SRC_ALPHA_SATURATE
|
688
|
*
|
689
|
* @param src Source Blend function
|
690
|
* @param dst Destination Blend function
|
691
|
*/
|
692
|
@SuppressWarnings("unused")
|
693
|
public void glBlendFunc(int src, int dst)
|
694
|
{
|
695
|
mState.glBlendFunc(src,dst);
|
696
|
}
|
697
|
}
|