Project

General

Profile

« Previous | Next » 

Revision 8ac0ed3e

Added by Leszek Koltunski over 6 years ago

Correct the way we delay FBOs in DistortedScreen.

View differences:

src/main/java/org/distorted/library/main/DistortedScreen.java
55 55
  private static MatrixEffectMove mMoveEffect = new MatrixEffectMove( new Static3D(5,5,0) );
56 56
  ///// END DEBUGGING //////////////////////////
57 57

  
58
  private int mCurrFBO, mLastFBO;
58
  private int mCurRenderedFBO;    // During the first FBO_QUEUE_SIZE frames, we blit the very first
59
  private int mToBeBlittedFBO;    // FBO one we have rendered. Then, we keep blitting the one we
60
  private boolean mFirstCircle;   // rendered FBO_QUEUE_SIZE ago.
59 61

  
60 62
///////////////////////////////////////////////////////////////////////////////////////////////////
61 63
// PUBLIC API
......
69 71
    {
70 72
    super(Distorted.FBO_QUEUE_SIZE,1,BOTH_DEPTH_STENCIL, TYPE_SYST, 1,1);
71 73
    mShowFPS = false;
72
    mCurrFBO = 0;
73
    mLastFBO = 1;
74
    mCurRenderedFBO = 0;
75
    mToBeBlittedFBO = 0;
76
    mFirstCircle = true;
74 77
    }
75 78

  
76 79
///////////////////////////////////////////////////////////////////////////////////////////////////
......
84 87
 */
85 88
  public int render(long time)
86 89
    {
87
    if( ++mCurrFBO>=Distorted.FBO_QUEUE_SIZE ) mCurrFBO=0;
88
    if( ++mLastFBO>=Distorted.FBO_QUEUE_SIZE ) mLastFBO=0;
89

  
90 90
    if( mShowFPS )
91 91
      {
92 92
      if( lastTime==0 ) lastTime = time;
......
107 107
      lastTime = time;
108 108
      }
109 109

  
110
    int numrender = super.render(time,mCurrFBO);
110
    int numrender = super.render(time,mCurRenderedFBO);
111 111

  
112 112
    GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, 0);
113 113

  
......
116 116
    // make it equal to 3.
117 117
    // This of course introduces a delay and uses more memory, but it does not appear to have any effect
118 118
    // on speed. Maybe a slight positive effect if any!
119
    setAsInput(mLastFBO,0);
119
    setAsInput(mToBeBlittedFBO,0);
120 120

  
121 121
    GLES31.glColorMask(true,true,true,true);
122 122
    GLES31.glDepthMask(false);
......
131 131
      fpsEffects.drawPriv(fpsW / 2.0f, fpsH / 2.0f, fpsMesh, this, time, 0);
132 132
      }
133 133

  
134
    if( ++mCurRenderedFBO>=Distorted.FBO_QUEUE_SIZE )
135
      {
136
      mCurRenderedFBO = 0;
137
      if (mFirstCircle) mFirstCircle = false;
138
      }
139
    if( !mFirstCircle && ++mToBeBlittedFBO>=Distorted.FBO_QUEUE_SIZE )
140
      {
141
      mToBeBlittedFBO=0;
142
      }
143

  
134 144
    return numrender+1;
135 145
    }
136 146

  

Also available in: Unified diff