Project

General

Profile

« Previous | Next » 

Revision 8b7b2398

Added by Leszek Koltunski almost 6 years ago

Fix the bug where the postprocessed halo would not work for the first few frames of each quality level (before this commit the bug was visible in the 'GLOW' app).

View differences:

src/main/java/org/distorted/library/main/DistortedOutputSurface.java
182 182

  
183 183
  private static void createPostprocessingBuffers(int width, int height, float near)
184 184
    {
185
    final float CLEAR_R = 1.0f;
186
    final float CLEAR_G = 1.0f;
187
    final float CLEAR_B = 1.0f;
188
    final float CLEAR_A = 0.0f;
189
    final float CLEAR_D = 1.0f;
190
    final int   CLEAR_S = 0;
191

  
185 192
    mBuffer = new DistortedFramebuffer[EffectQuality.LENGTH];
186 193
    float mipmap=1.0f;
187 194

  
......
190 197
      mBuffer[j] = new DistortedFramebuffer(Distorted.FBO_QUEUE_SIZE,2,BOTH_DEPTH_STENCIL,TYPE_SYST, (int)(width*mipmap), (int)(height*mipmap) );
191 198
      mBuffer[j].mMipmap = mipmap;
192 199
      mBuffer[j].mNear = near;  // copy mNear as well (for blitting- see PostprocessEffect.apply() )
193
      mBuffer[j].glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
200
      mBuffer[j].glClearColor(CLEAR_R, CLEAR_G, CLEAR_B, CLEAR_A);
194 201

  
195 202
      mipmap *= EffectQuality.MULTIPLIER;
196 203
      }
197 204

  
198 205
    DistortedObject.toDo(); // create the FBOs immediately. This is safe as we must be holding the OpenGL context now.
199 206

  
200
    GLES31.glStencilMask(0xff);
201
    GLES31.glDepthMask(true);
202
    GLES31.glColorMask(true, true, true, true);
203
    GLES31.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
204
    GLES31.glClearDepthf(1.0f);
205
    GLES31.glClearStencil(0);
207
    DistortedRenderState.colorDepthStencilOn();
208
    GLES31.glClearColor(CLEAR_R, CLEAR_G, CLEAR_B, CLEAR_A);
209
    GLES31.glClearDepthf(CLEAR_D);
210
    GLES31.glClearStencil(CLEAR_S);
206 211

  
207 212
    for (int j=0; j<EffectQuality.LENGTH; j++)
208 213
      {
......
216 221
        }
217 222
      }
218 223

  
224
    DistortedRenderState.colorDepthStencilRestore();
225

  
219 226
    GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, 0);
220 227
    }
221 228

  
......
300 307
    GLES31.glStencilMask(0xff);
301 308
    GLES31.glDepthMask(true);
302 309
    GLES31.glColorMask(true,true,true,true);
303
    GLES31.glClearColor(0.0f,0.0f,0.0f,0.0f);
304
    GLES31.glClearDepthf(1.0f);
305
    GLES31.glClearStencil(0);
310
    GLES31.glClearColor(buffer.mClearR,buffer.mClearG,buffer.mClearB,buffer.mClearA);
311
    GLES31.glClearDepthf(buffer.mClearDepth);
312
    GLES31.glClearStencil(buffer.mClearStencil);
306 313

  
307 314
    buffer.setAsOutput();
308 315
    GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, buffer.mColorH[2*fbo+1], 0);

Also available in: Unified diff