Project

General

Profile

« Previous | Next » 

Revision c5369f1b

Added by Leszek Koltunski about 7 years ago

Major: change of API.

Split DFramebuffer into Framebuffer and Screen; introduce the 'DistortedInputSurface' and 'DistortedOutputSurface' interfaces.

View differences:

src/main/java/org/distorted/library/DistortedTree.java
38 38

  
39 39
  private MeshObject mMesh;
40 40
  private DistortedEffects mEffects;
41
  private DistortedRenderable mRenderable;
41
  private DistortedInputSurface mSurface;
42 42
  private NodeData mData;
43 43

  
44 44
  private DistortedTree mParent;
......
94 94
    {
95 95
    ArrayList<Long> ret = new ArrayList<>();
96 96
     
97
    ret.add( mRenderable.getID() );
97
    ret.add( mSurface.getID() );
98 98
    DistortedTree node;
99 99
   
100 100
    for(int i=0; i<mNumChildren[0]; i++)
......
125 125
      if( newList.size()>1 )
126 126
        {
127 127
        if( mData.mFBO ==null )
128
          mData.mFBO = new DistortedFramebuffer(mRenderable.getWidth(), mRenderable.getHeight());
128
          mData.mFBO = new DistortedFramebuffer(mSurface.getWidth(), mSurface.getHeight());
129 129
        }
130 130
      else
131 131
        {
......
198 198
*/
199 199
///////////////////////////////////////////////////////////////////////////////////////////////////
200 200

  
201
  void drawRecursive(long currTime, DistortedFramebuffer df)
201
  void drawRecursive(long currTime, DistortedOutputSurface surface)
202 202
    {
203
    mRenderable.create();
204
    float halfX = mRenderable.getWidth()/2.0f;
205
    float halfY = mRenderable.getHeight()/2.0f;
203
    mSurface.create();
204
    float halfX = mSurface.getWidth()/2.0f;
205
    float halfY = mSurface.getHeight()/2.0f;
206 206

  
207 207
    if( mNumChildren[0]<=0 )
208 208
      {
209
      mRenderable.setAsInput();
209
      mSurface.setAsInput();
210 210
      }
211 211
    else
212 212
      {
......
219 219
        GLES30.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
220 220
        GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
221 221

  
222
        if( mRenderable.setAsInput() )
223
          DistortedEffects.drawNoEffectsPriv(halfX, halfY, mMesh, mData.mFBO);
222
        if( mSurface.setAsInput() )
223
          DistortedEffects.drawNoEffectsPriv(halfX, halfY, mMesh, mData.mFBO.getProjection() );
224 224

  
225 225
        synchronized(this)
226 226
          {
......
236 236
      mData.mFBO.setAsInput();
237 237
      }
238 238

  
239
    mEffects.drawPriv(halfX, halfY, mMesh, df, currTime);
239
    mEffects.drawPriv(halfX, halfY, mMesh, surface, currTime);
240 240
    }
241 241

  
242 242
///////////////////////////////////////////////////////////////////////////////////////////////////
......
245 245
/**
246 246
 * Constructs new Node of the Tree.
247 247
 *     
248
 * @param renderable DistortedRenderable to put into the new Node.
248
 * @param surface InputSurface to put into the new Node.
249 249
 * @param effects DistortedEffects to put into the new Node.
250 250
 * @param mesh MeshObject to put into the new Node.
251 251
 */
252
  public DistortedTree(DistortedRenderable renderable, DistortedEffects effects, MeshObject mesh)
252
  public DistortedTree(DistortedInputSurface surface, DistortedEffects effects, MeshObject mesh)
253 253
    {
254
    mRenderable    = renderable;
254
    mSurface       = surface;
255 255
    mEffects       = effects;
256 256
    mMesh          = mesh;
257 257
    mParent        = null;
......
260 260
    mNumChildren[0]= 0;
261 261
   
262 262
    ArrayList<Long> list = new ArrayList<>();
263
    list.add(mRenderable.getID());
263
    list.add(mSurface.getID());
264 264

  
265 265
    mData = mMapNodeID.get(list);
266 266
   
......
293 293

  
294 294
    if( (flags & Distorted.CLONE_RENDERABLE) != 0 )
295 295
      {
296
      mRenderable = node.mRenderable;
296
      mSurface = node.mSurface;
297 297
      }
298 298
    else
299 299
      {
300
      int w = node.mRenderable.getWidth();
301
      int h = node.mRenderable.getHeight();
300
      int w = node.mSurface.getWidth();
301
      int h = node.mSurface.getHeight();
302 302

  
303
      if( node.mRenderable instanceof DistortedTexture )
303
      if( node.mSurface instanceof DistortedTexture )
304 304
        {
305
        mRenderable = new DistortedTexture(w,h);
305
        mSurface = new DistortedTexture(w,h);
306 306
        }
307
      else if( node.mRenderable instanceof DistortedFramebuffer )
307
      else if( node.mSurface instanceof DistortedFramebuffer )
308 308
        {
309
        boolean hasDepth = ((DistortedFramebuffer) node.mRenderable).hasDepth();
310
        mRenderable = new DistortedFramebuffer(w,h,hasDepth);
309
        boolean hasDepth = ((DistortedFramebuffer) node.mSurface).hasDepth();
310
        mSurface = new DistortedFramebuffer(w,h,hasDepth);
311 311
        }
312 312
      }
313 313
    if( (flags & Distorted.CLONE_CHILDREN) != 0 )
......
360 360
/**
361 361
 * Adds a new child to the last position in the list of our Node's children.
362 362
 * 
363
 * @param renderable DistortedRenderable to initialize our child Node with.
363
 * @param surface InputSurface to initialize our child Node with.
364 364
 * @param effects DistortedEffects to initialize our child Node with.
365 365
 * @param mesh MeshObject to initialize our child Node with.
366 366
 * @return the newly constructed child Node, or null if we couldn't allocate resources.
367 367
 */
368
  public synchronized DistortedTree attach(DistortedRenderable renderable, DistortedEffects effects, MeshObject mesh)
368
  public synchronized DistortedTree attach(DistortedInputSurface surface, DistortedEffects effects, MeshObject mesh)
369 369
    {
370 370
    ArrayList<Long> prev = generateIDList(); 
371 371
      
372 372
    if( mChildren==null ) mChildren = new ArrayList<>(2);
373
    DistortedTree node = new DistortedTree(renderable,effects,mesh);
373
    DistortedTree node = new DistortedTree(surface,effects,mesh);
374 374
    node.mParent = this;
375 375
    mChildren.add(node);
376 376
    mNumChildren[0]++;
......
474 474

  
475 475
///////////////////////////////////////////////////////////////////////////////////////////////////
476 476
/**
477
 * Returns the DistortedRenderable object that's in the Node.
477
 * Returns the DistortedInputSurface object that's in the Node.
478 478
 *
479
 * @return The DistortedRenderable contained in the Node.
479
 * @return The DistortedInputSurface contained in the Node.
480 480
 */
481
  public DistortedRenderable getRenderable()
481
  public DistortedInputSurface getSurface()
482 482
    {
483
    return mRenderable;
483
    return mSurface;
484 484
    }
485 485

  
486 486
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff