Project

General

Profile

« Previous | Next » 

Revision af4cc5db

Added by Leszek Koltunski about 7 years ago

Simplify yesterday's refactoring.

View differences:

src/main/java/org/distorted/library/DistortedEffects.java
194 194

  
195 195
    float x,y,z, X,Y,W, ndcX,ndcY;
196 196

  
197
    DistortedProjection projection = surface.getProjection();
198

  
199 197
    for(int i=0; i<len; i++)
200 198
      {
201 199
      x = 2*halfX*vertices[3*i  ];
......
209 207
      ndcX = X/W;
210 208
      ndcY = Y/W;
211 209

  
212
      wx = (int)(projection.mWidth *(ndcX+1)/2);
213
      wy = (int)(projection.mHeight*(ndcY+1)/2);
210
      wx = (int)(surface.mWidth *(ndcX+1)/2);
211
      wy = (int)(surface.mHeight*(ndcY+1)/2);
214 212

  
215 213
      if( wx<minx ) minx = wx;
216 214
      if( wx>maxx ) maxx = wx;
......
222 220
    surface.setAsOutput();
223 221

  
224 222
    Matrix.setIdentityM( mTmpMatrix, 0);
225
    Matrix.translateM  ( mTmpMatrix, 0, minx-projection.mWidth/2, maxy-projection.mHeight/2, -projection.mDistance);
223
    Matrix.translateM  ( mTmpMatrix, 0, minx-surface.mWidth/2, maxy-surface.mHeight/2, -surface.mDistance);
226 224
    Matrix.scaleM      ( mTmpMatrix, 0, (float)(maxx-minx)/(2*halfX), (float)(maxy-miny)/(2*halfY), 1.0f);
227 225
    Matrix.translateM  ( mTmpMatrix, 0, halfX,-halfY, 0);
228
    Matrix.multiplyMM  ( mMVPMatrix, 0, projection.mProjectionMatrix, 0, mTmpMatrix, 0);
226
    Matrix.multiplyMM  ( mMVPMatrix, 0, surface.mProjectionMatrix, 0, mTmpMatrix, 0);
229 227

  
230 228
    GLES30.glUniform2f( mObjDH , 2*halfX, 2*halfY);
231 229
    GLES30.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPMatrix , 0);
......
244 242
    mP.compute(currTime);
245 243

  
246 244
    float halfZ = halfInputW*mesh.zFactor;
247
    DistortedProjection projection = surface.getProjection();
248
    GLES30.glViewport(0, 0, projection.mWidth, projection.mHeight);
245
    GLES30.glViewport(0, 0, surface.mWidth, surface.mHeight);
249 246

  
250 247
    if( mP.mNumEffects==0 )
251 248
      {
252 249
      mProgram.useProgram();
253 250
      surface.setAsOutput();
254
      mM.send(projection,halfInputW,halfInputH,halfZ);
251
      mM.send(surface,halfInputW,halfInputH,halfZ);
255 252
      mV.send(halfInputW,halfInputH,halfZ);
256 253
      mF.send(halfInputW,halfInputH);
257 254
      GLES30.glVertexAttribPointer(mProgram.mAttribute[0], POSITION_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mesh.mMeshPositions);
......
263 260
      {
264 261
      if( mV.mNumEffects==0 && mF.mNumEffects==0 && (mesh instanceof MeshFlat) && mM.canUseShortcut() )
265 262
        {
266
        mM.constructMatrices(projection,halfInputW,halfInputH);
263
        mM.constructMatrices(surface,halfInputW,halfInputH);
267 264
        mP.render(2*halfInputW, 2*halfInputH, mM.getMVP(), surface);
268 265
        }
269 266
      else
270 267
        {
271 268
        mProgram.useProgram();
272
        mBufferFBO.resizeFast(projection.mWidth, projection.mHeight);
269
        mBufferFBO.resizeFast(surface.mWidth, surface.mHeight);
273 270
        mBufferFBO.setAsOutput();
274 271
        GLES30.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
275 272
        GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
276
        mM.send(mBufferFBO.getProjection(),halfInputW,halfInputH,halfZ);
273
        mM.send(mBufferFBO,halfInputW,halfInputH,halfZ);
277 274
        mV.send(halfInputW,halfInputH,halfZ);
278 275
        mF.send(halfInputW,halfInputH);
279 276
        GLES30.glVertexAttribPointer(mProgram.mAttribute[0], POSITION_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mesh.mMeshPositions);
......
282 279
        GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
283 280

  
284 281
        Matrix.setIdentityM(mTmpMatrix, 0);
285
        Matrix.translateM(mTmpMatrix, 0, 0, 0, -projection.mDistance);
286
        Matrix.multiplyMM(mMVPMatrix, 0, projection.mProjectionMatrix, 0, mTmpMatrix, 0);
282
        Matrix.translateM(mTmpMatrix, 0, 0, 0, -surface.mDistance);
283
        Matrix.multiplyMM(mMVPMatrix, 0, surface.mProjectionMatrix, 0, mTmpMatrix, 0);
287 284

  
288 285
        mBufferFBO.setAsInput();
289
        mP.render(projection.mWidth, projection.mHeight, mMVPMatrix, surface);
286
        mP.render(surface.mWidth, surface.mHeight, mMVPMatrix, surface);
290 287
        }
291 288
      }
292 289

  
......
297 294

  
298 295
///////////////////////////////////////////////////////////////////////////////////////////////////
299 296
   
300
  static void drawNoEffectsPriv(float halfInputW, float halfInputH, MeshObject mesh, DistortedProjection projection)
297
  static void drawNoEffectsPriv(float halfInputW, float halfInputH, MeshObject mesh, DistortedOutputSurface projection)
301 298
    {
302 299
    GLES30.glViewport(0, 0, projection.mWidth, projection.mHeight);
303 300

  

Also available in: Unified diff