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