Project

General

Profile

« Previous | Next » 

Revision 23eecbd9

Added by Leszek Koltunski about 7 years ago

Progress with Stencil app. Rendering through an intermediate FBO still doesn't quite work.

View differences:

src/main/java/org/distorted/library/DistortedNode.java
71 71
  private DistortedInputSurface mSurface;
72 72
  private DistortedRenderState mState;
73 73
  private NodeData mData;
74
  private int mFboW, mFboH, mFboDepthStencil;
74 75

  
75 76
  private class NodeData
76 77
    {
......
245 246
      }
246 247
    else if( createNewFBO )
247 248
      {
248
      newData.mFBO = new DistortedFramebuffer(DistortedFramebuffer.DEPTH_NO_STENCIL, DistortedSurface.TYPE_TREE, mSurface.getWidth(),mSurface.getHeight());
249
      int width  = mFboW <= 0 ? mSurface.getWidth()  : mFboW;
250
      int height = mFboH <= 0 ? mSurface.getHeight() : mFboH;
251
      newData.mFBO = new DistortedFramebuffer(mFboDepthStencil, DistortedSurface.TYPE_TREE, width, height);
249 252
      //android.util.Log.d("NODE", "creating new FBO "+newData.mFBO.getID() );
250 253
      }
251 254

  
......
289 292

  
290 293
      if( mData.mFBO==null )
291 294
        {
292
        mData.mFBO = new DistortedFramebuffer(DistortedFramebuffer.DEPTH_NO_STENCIL, DistortedSurface.TYPE_TREE, mSurface.getWidth(),mSurface.getHeight());
295
        int width  = mFboW <= 0 ? mSurface.getWidth()  : mFboW;
296
        int height = mFboH <= 0 ? mSurface.getHeight() : mFboH;
297
        mData.mFBO = new DistortedFramebuffer(mFboDepthStencil, DistortedSurface.TYPE_TREE, width, height);
293 298
        }
294 299

  
295 300
      mData.mFBO.setAsOutput(currTime);
......
351 356
    mParent        = null;
352 357
    mSurfaceParent = null;
353 358

  
359
    mFboW            = 0;  // i.e. take this from
360
    mFboH            = 0;  // mSurface's dimensions
361
    mFboDepthStencil = DistortedFramebuffer.DEPTH_NO_STENCIL;
362

  
354 363
    ArrayList<Long> list = new ArrayList<>();
355 364
    list.add(mSurface.getID());
356 365
    list.add(-mEffects.getID());
......
387 396
    mParent       = null;
388 397
    mSurfaceParent= null;
389 398

  
399
    mFboW            = node.mFboW;
400
    mFboH            = node.mFboH;
401
    mFboDepthStencil = node.mFboDepthStencil;
402

  
390 403
    if( (flags & Distorted.CLONE_SURFACE) != 0 )
391 404
      {
392 405
      mSurface = node.mSurface;
......
402 415
        }
403 416
      else if( node.mSurface instanceof DistortedFramebuffer )
404 417
        {
405
        int depthStencil = DistortedFramebuffer.NO_DEPTH_STENCIL;
418
        int depthStencil = DistortedFramebuffer.NO_DEPTH_NO_STENCIL;
406 419

  
407 420
        if( ((DistortedFramebuffer) node.mSurface).hasDepth() )
408 421
          {
......
683 696

  
684 697
///////////////////////////////////////////////////////////////////////////////////////////////////
685 698
/**
686
 * Returns the DistortedFramebuffer object that's in the Node.
687
 *
688
 * @return The DistortedFramebuffer contained in the Node.
699
 * Resizes the DistortedFramebuffer object that we render this Node to.
689 700
 */
690
  public DistortedFramebuffer getFramebuffer()
701
  public void resize(int width, int height)
691 702
    {
692
    return mData.mFBO;
703
    mFboW = width;
704
    mFboH = height;
705

  
706
    if ( mData.mFBO !=null )
707
      {
708
      // TODO: potentially allocate a new NodeData if we have to
709
      mData.mFBO.resize(width,height);
710
      }
711
    }
712

  
713
///////////////////////////////////////////////////////////////////////////////////////////////////
714
/**
715
 * Enables/disables DEPTH and STENCIL buffers in the Framebuffer object that we render this Node to.
716
 */
717
  public void enableDepthStencil(int depthStencil)
718
    {
719
    mFboDepthStencil = depthStencil;
720

  
721
    if ( mData.mFBO !=null )
722
      {
723
      // TODO: potentially allocate a new NodeData if we have to
724
      mData.mFBO.enableDepthStencil(depthStencil);
725
      }
693 726
    }
694 727

  
695 728
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff