Project

General

Profile

« Previous | Next » 

Revision 86eb00a9

Added by Leszek Koltunski over 7 years ago

Initial version of the first post-processing effect - BLUR - ready for the first app!

View differences:

src/main/java/org/distorted/library/DistortedEffects.java
49 49
  private static long mNextID =0;
50 50
  private long mID;
51 51

  
52
  private static DistortedFramebuffer mBufferFBO;
53

  
52 54
  private EffectQueueMatrix      mM;
53 55
  private EffectQueueFragment    mF;
54 56
  private EffectQueueVertex      mV;
......
67 69
    mQuadPositions.put(positionData).position(0);
68 70
    mQuadTexture   = ByteBuffer.allocateDirect(TEX_DATA_SIZE     *dataLength*BYTES_PER_FLOAT).order(ByteOrder.nativeOrder()).asFloatBuffer();
69 71
    mQuadTexture.put(textureData).position(0);
72

  
73
    mBufferFBO = new DistortedFramebuffer(1,1);
70 74
    }
71 75

  
72 76
///////////////////////////////////////////////////////////////////////////////////////////////////
......
130 134
    float halfZ = halfInputW*mesh.zFactor;
131 135

  
132 136
    GLES20.glUseProgram(Distorted.mainProgramH);
137
    GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
133 138

  
134 139
    if( mP.mNumEffects==0 )
135 140
      {
136
      GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
137

  
138 141
      mM.send(df,halfInputW,halfInputH,halfZ);
139 142
      mV.send(halfInputW,halfInputH,halfZ);
140 143
      mF.send(halfInputW,halfInputH);
......
143 146
      }
144 147
    else
145 148
      {
146
      DistortedFramebuffer buffer = Distorted.getFBO(df.mWidth,df.mHeight);
147

  
148
      GLES20.glViewport(0, 0, buffer.mWidth, buffer.mHeight);
149
      buffer.setAsOutput();
149
      mBufferFBO.resizeFast(df.mWidth, df.mHeight);
150
      mBufferFBO.setAsOutput();
150 151

  
151
      mM.send(buffer,halfInputW,halfInputH,halfZ);
152
      mM.send(mBufferFBO,halfInputW,halfInputH,halfZ);
152 153
      mV.send(halfInputW,halfInputH,halfZ);
153 154
      mF.send(halfInputW,halfInputH);
154 155

  
......
156 157

  
157 158
      GLES20.glUseProgram(Distorted.postProgramH);
158 159
      GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
159
      buffer.setAsInput();
160
      mBufferFBO.setAsInput();
160 161
      df.setAsOutput();
161 162
      mP.send(halfInputW,halfInputH);
162 163

  

Also available in: Unified diff