Project

General

Profile

« Previous | Next » 

Revision 7602a827

Added by Leszek Koltunski about 5 years ago

Rename all the classes that are not exported to application to 'Internal'

View differences:

src/main/java/org/distorted/library/main/DistortedNode.java
1 1
///////////////////////////////////////////////////////////////////////////////////////////////////
2 2
// Copyright 2016 Leszek Koltunski                                                               //
3 3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
4
// This file is part of DistortedLibrary.                                                               //
5 5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
6
// DistortedLibrary is free software: you can redistribute it and/or modify                             //
7 7
// it under the terms of the GNU General Public License as published by                          //
8 8
// the Free Software Foundation, either version 2 of the License, or                             //
9 9
// (at your option) any later version.                                                           //
10 10
//                                                                                               //
11
// Distorted is distributed in the hope that it will be useful,                                  //
11
// DistortedLibrary is distributed in the hope that it will be useful,                                  //
12 12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13 13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14 14
// GNU General Public License for more details.                                                  //
15 15
//                                                                                               //
16 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/>.                            //
17
// along with DistortedLibrary.  If not, see <http://www.gnu.org/licenses/>.                            //
18 18
///////////////////////////////////////////////////////////////////////////////////////////////////
19 19

  
20 20
package org.distorted.library.main;
......
37 37
 * to sub-class 'NodeData'. Two identical sub-trees attached at different points of the main tree
38 38
 * will point to the same NodeData; only the first of this is rendered (mData.numRender!).
39 39
 */
40
public class DistortedNode implements DistortedChildrenList.Parent
40
public class DistortedNode implements InternalChildrenList.Parent
41 41
  {
42 42
  private MeshBase mMesh;
43 43
  private DistortedEffects mEffects;
44
  private DistortedSurface mSurface;
45
  private DistortedRenderState mState;
46
  private DistortedNodeData mData;
47
  private DistortedChildrenList mChildren;
48
  private DistortedChildrenList.Parent mParent;
44
  private InternalSurface mSurface;
45
  private InternalRenderState mState;
46
  private InternalNodeData mData;
47
  private InternalChildrenList mChildren;
48
  private InternalChildrenList.Parent mParent;
49 49

  
50 50
  private int mFboW, mFboH, mFboDepthStencil;
51 51
  private boolean mRenderWayOIT;
......
116 116
///////////////////////////////////////////////////////////////////////////////////////////////////
117 117
/**
118 118
 * This is not really part of the public API. Has to be public only because it is a part of the
119
 * DistortedChildrenList.Parent interface.
119
 * InternalChildrenList.Parent interface.
120 120
 *
121 121
 * @y.exclude
122 122
 */
123 123
  public void adjustIsomorphism()
124 124
    {
125
    DistortedNodeData newData = DistortedNodeData.returnData(generateIDList());
125
    InternalNodeData newData = InternalNodeData.returnData(generateIDList());
126 126
    boolean deleteOldFBO = mData.removeData();
127 127
    boolean createNewFBO = (mChildren.getNumChildren()>0 && newData.mFBO==null);
128 128

  
......
148 148
///////////////////////////////////////////////////////////////////////////////////////////////////
149 149
// return the total number of render calls issued
150 150

  
151
  int drawNoBlend(long currTime, DistortedOutputSurface surface)
151
  int drawNoBlend(long currTime, InternalOutputSurface surface)
152 152
    {
153
    DistortedSurface input = getInternalSurface();
153
    InternalSurface input = getInternalSurface();
154 154

  
155 155
    if( input.setAsInput() )
156 156
      {
157 157
      mState.apply();
158 158
      GLES31.glDisable(GLES31.GL_BLEND);
159
      Distorted.drawPriv(mEffects.getQueues(), mSurface.getWidth()/2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime);
159
      DistortedLibrary.drawPriv(mEffects.getQueues(), mSurface.getWidth()/2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime);
160 160
      GLES31.glEnable(GLES31.GL_BLEND);
161 161
      return 1;
162 162
      }
......
167 167
///////////////////////////////////////////////////////////////////////////////////////////////////
168 168
// Use the Order Independent Transparency method to draw a non-postprocessed child.
169 169

  
170
  int drawOIT(long currTime, DistortedOutputSurface surface)
170
  int drawOIT(long currTime, InternalOutputSurface surface)
171 171
    {
172
    DistortedSurface input = getInternalSurface();
172
    InternalSurface input = getInternalSurface();
173 173

  
174 174
    if( input.setAsInput() )
175 175
      {
176 176
      mState.apply();
177
      Distorted.drawPrivOIT(mEffects.getQueues(), mSurface.getWidth()/2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime);
177
      DistortedLibrary.drawPrivOIT(mEffects.getQueues(), mSurface.getWidth()/2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime);
178 178
      return 1;
179 179
      }
180 180

  
......
184 184
///////////////////////////////////////////////////////////////////////////////////////////////////
185 185
// return the total number of render calls issued
186 186

  
187
  int draw(long currTime, DistortedOutputSurface surface)
187
  int draw(long currTime, InternalOutputSurface surface)
188 188
    {
189
    DistortedSurface input = getInternalSurface();
189
    InternalSurface input = getInternalSurface();
190 190

  
191 191
    if( input.setAsInput() )
192 192
      {
193 193
      mState.apply();
194
      Distorted.drawPriv(mEffects.getQueues(), mSurface.getWidth()/2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime);
194
      DistortedLibrary.drawPriv(mEffects.getQueues(), mSurface.getWidth()/2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime);
195 195
      return 1;
196 196
      }
197 197

  
......
226 226
      if( mSurface.setAsInput() )
227 227
        {
228 228
        numRenders++;
229
        Distorted.blitPriv(mData.mFBO);
229
        DistortedLibrary.blitPriv(mData.mFBO);
230 230
        }
231 231

  
232 232
      numRenders += mData.mFBO.renderChildren(currTime,numChildren,mChildren,0, mRenderWayOIT);
......
241 241
    {
242 242
    int width  = mFboW <= 0 ? mSurface.getWidth()  : mFboW;
243 243
    int height = mFboH <= 0 ? mSurface.getHeight() : mFboH;
244
    return new DistortedFramebuffer(1,mFboDepthStencil, DistortedSurface.TYPE_TREE, width, height);
244
    return new DistortedFramebuffer(1,mFboDepthStencil, InternalSurface.TYPE_TREE, width, height);
245 245
    }
246 246

  
247 247
///////////////////////////////////////////////////////////////////////////////////////////////////
248 248

  
249
  void setParent(DistortedChildrenList.Parent parent)
249
  void setParent(InternalChildrenList.Parent parent)
250 250
    {
251 251
    mParent = parent;
252 252
    }
......
261 261
 * @param effects DistortedEffects to put into the new Node.
262 262
 * @param mesh MeshBase to put into the new Node.
263 263
 */
264
  public DistortedNode(DistortedSurface surface, DistortedEffects effects, MeshBase mesh)
264
  public DistortedNode(InternalSurface surface, DistortedEffects effects, MeshBase mesh)
265 265
    {
266 266
    mSurface       = surface;
267 267
    mEffects       = effects;
268 268
    mMesh          = mesh;
269
    mState         = new DistortedRenderState();
270
    mChildren      = new DistortedChildrenList(this);
269
    mState         = new InternalRenderState();
270
    mChildren      = new InternalChildrenList(this);
271 271
    mParent        = null;
272 272
    mRenderWayOIT  = false;
273 273

  
......
275 275
    mFboH            = 0;  // mSurface's dimensions
276 276
    mFboDepthStencil = DistortedFramebuffer.DEPTH_NO_STENCIL;
277 277

  
278
    mData = DistortedNodeData.returnData(generateIDList());
278
    mData = InternalNodeData.returnData(generateIDList());
279 279
    }
280 280

  
281 281
///////////////////////////////////////////////////////////////////////////////////////////////////  
......
284 284
 *     
285 285
 * @param node The DistortedNode to copy data from.
286 286
 * @param flags bit field composed of a subset of the following:
287
 *        {@link Distorted#CLONE_SURFACE},  {@link Distorted#CLONE_MATRIX}, {@link Distorted#CLONE_VERTEX},
288
 *        {@link Distorted#CLONE_FRAGMENT} and {@link Distorted#CLONE_CHILDREN}.
287
 *        {@link DistortedLibrary#CLONE_SURFACE},  {@link DistortedLibrary#CLONE_MATRIX}, {@link DistortedLibrary#CLONE_VERTEX},
288
 *        {@link DistortedLibrary#CLONE_FRAGMENT} and {@link DistortedLibrary#CLONE_CHILDREN}.
289 289
 *        For example flags = CLONE_SURFACE | CLONE_CHILDREN.
290 290
 */
291 291
  public DistortedNode(DistortedNode node, int flags)
292 292
    {
293 293
    mEffects      = new DistortedEffects(node.mEffects,flags);
294 294
    mMesh         = node.mMesh;
295
    mState        = new DistortedRenderState();
295
    mState        = new InternalRenderState();
296 296
    mParent       = null;
297 297
    mRenderWayOIT = false;
298 298

  
......
300 300
    mFboH            = node.mFboH;
301 301
    mFboDepthStencil = node.mFboDepthStencil;
302 302

  
303
    if( (flags & Distorted.CLONE_SURFACE) != 0 )
303
    if( (flags & DistortedLibrary.CLONE_SURFACE) != 0 )
304 304
      {
305 305
      mSurface = node.mSurface;
306 306
      }
......
311 311

  
312 312
      if( node.mSurface instanceof DistortedTexture )
313 313
        {
314
        mSurface = new DistortedTexture(w,h, DistortedSurface.TYPE_TREE);
314
        mSurface = new DistortedTexture(w,h, InternalSurface.TYPE_TREE);
315 315
        }
316 316
      else if( node.mSurface instanceof DistortedFramebuffer )
317 317
        {
......
323 323
          depthStencil = (hasStencil ? DistortedFramebuffer.BOTH_DEPTH_STENCIL:DistortedFramebuffer.DEPTH_NO_STENCIL);
324 324
          }
325 325

  
326
        mSurface = new DistortedFramebuffer(1,depthStencil,DistortedSurface.TYPE_TREE,w,h);
326
        mSurface = new DistortedFramebuffer(1,depthStencil, InternalSurface.TYPE_TREE,w,h);
327 327
        }
328 328
      }
329 329

  
330
    if( (flags & Distorted.CLONE_CHILDREN) != 0 )
330
    if( (flags & DistortedLibrary.CLONE_CHILDREN) != 0 )
331 331
      {
332 332
      mChildren = node.mChildren;
333 333
      }
334 334
    else
335 335
      {
336
      mChildren = new DistortedChildrenList(this);
336
      mChildren = new InternalChildrenList(this);
337 337
      }
338 338

  
339
    mData = DistortedNodeData.returnData(generateIDList());
339
    mData = InternalNodeData.returnData(generateIDList());
340 340
    }
341 341

  
342 342
///////////////////////////////////////////////////////////////////////////////////////////////////
......
375 375
    mRenderWayOIT = oit;
376 376

  
377 377
    if( initialSize>0.0f && initialSize<10.0f )
378
      Distorted.setSSBOSize(initialSize);
378
      DistortedLibrary.setSSBOSize(initialSize);
379 379
    }
380 380

  
381 381
///////////////////////////////////////////////////////////////////////////////////////////////////
......
383 383
 * Adds a new child to the last position in the list of our Node's children.
384 384
 * <p>
385 385
 * We cannot do this mid-render - actual attachment will be done just before the next render, by the
386
 * DistortedMaster (by calling doWork())
386
 * InternalMaster (by calling doWork())
387 387
 *
388 388
 * @param node The new Node to add.
389 389
 */
......
397 397
 * Adds a new child to the last position in the list of our Node's children.
398 398
 * <p>
399 399
 * We cannot do this mid-render - actual attachment will be done just before the next render, by the
400
 * DistortedMaster (by calling doWork())
400
 * InternalMaster (by calling doWork())
401 401
 *
402 402
 * @param surface InputSurface to initialize our child Node with.
403 403
 * @param effects DistortedEffects to initialize our child Node with.
404 404
 * @param mesh MeshBase to initialize our child Node with.
405 405
 * @return the newly constructed child Node, or null if we couldn't allocate resources.
406 406
 */
407
  public DistortedNode attach(DistortedSurface surface, DistortedEffects effects, MeshBase mesh)
407
  public DistortedNode attach(InternalSurface surface, DistortedEffects effects, MeshBase mesh)
408 408
    {
409 409
    return mChildren.attach(surface,effects,mesh);
410 410
    }
......
414 414
 * Removes the first occurrence of a specified child from the list of children of our Node.
415 415
 * <p>
416 416
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
417
 * DistortedMaster (by calling doWork())
417
 * InternalMaster (by calling doWork())
418 418
 *
419 419
 * @param node The Node to remove.
420 420
 */
......
431 431
 * of them having the same Effects but - for instance - different Mesh. Use with care.
432 432
 * <p>
433 433
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
434
 * DistortedMaster (by calling doWork())
434
 * InternalMaster (by calling doWork())
435 435
 *
436 436
 * @param effects DistortedEffects to remove.
437 437
 */
......
445 445
 * Removes all children Nodes.
446 446
 * <p>
447 447
 * We cannot do this mid-render - actual detachment will be done just before the next render, by the
448
 * DistortedMaster (by calling doWork())
448
 * InternalMaster (by calling doWork())
449 449
 */
450 450
  public void detachAll()
451 451
    {
......
465 465

  
466 466
///////////////////////////////////////////////////////////////////////////////////////////////////
467 467
/**
468
 * Returns the DistortedSurface object that's in the Node.
468
 * Returns the InternalSurface object that's in the Node.
469 469
 *
470
 * @return The DistortedSurface contained in the Node.
470
 * @return The InternalSurface contained in the Node.
471 471
 */
472
  public DistortedSurface getSurface()
472
  public InternalSurface getSurface()
473 473
    {
474 474
    return mSurface;
475 475
    }
476 476

  
477 477
///////////////////////////////////////////////////////////////////////////////////////////////////
478 478
  /**
479
   * Returns the DistortedSurface object that's in the Node.
479
   * Returns the InternalSurface object that's in the Node.
480 480
   *
481
   * @return The DistortedSurface contained in the Node (if a leaf), or the FBO (if an internal Node)
481
   * @return The InternalSurface contained in the Node (if a leaf), or the FBO (if an internal Node)
482 482
   */
483
  public DistortedSurface getInternalSurface()
483
  public InternalSurface getInternalSurface()
484 484
    {
485 485
    return mChildren.getNumChildren()==0 ? mSurface : mData.mFBO;
486 486
    }

Also available in: Unified diff