Project

General

Profile

« Previous | Next » 

Revision a0f644b7

Added by Leszek Koltunski over 7 years ago

Again change of API. Now instead of the 'DistortedEffects.draw() and DistortedTree.draw()' we have 'DistortedFramebuffer.renderTo()'

View differences:

src/main/java/org/distorted/library/DistortedTree.java
69 69
    mMapNodeID.clear();
70 70
    }
71 71

  
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73
  
74
  private void drawRecursive(long currTime, DistortedFramebuffer df)
75
    {
76
    mTexture.createTexture();
77

  
78
    if( mNumChildren[0]<=0 )
79
      {
80
      GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexture.mTextureDataH[0]);
81
      }
82
    else
83
      {
84
      mData.mDF.createFBO();
85

  
86
      if( mData.numRendered==0 )
87
        {
88
        GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mData.mDF.fboIds[0]);
89

  
90
        GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
91
        GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
92
      
93
        if( mTexture.mBitmapSet[0] )
94
          {
95
          GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexture.mTextureDataH[0]);
96
          mQueues.drawNoEffectsPriv(mTexture, mGrid, mData.mDF);
97
          }
98
      
99
        synchronized(this)
100
          {
101
          for(int i=0; i<mNumChildren[0]; i++)
102
            {
103
            mChildren.get(i).drawRecursive(currTime, mData.mDF);
104
            }
105
          }
106
        }
107

  
108
      mData.numRendered++;
109
      mData.numRendered %= mData.numPointingNodes;
110

  
111
      GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, df.fboIds[0]);
112
      GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mData.mDF.texIds[0]);
113
      }
114
    
115
    mQueues.drawPriv(currTime, mTexture, mGrid, df);
116
    }
117
  
118 72
///////////////////////////////////////////////////////////////////////////////////////////////////
119 73
// tree isomorphism
120 74
  
......
246 200
      }
247 201
    }
248 202

  
203
///////////////////////////////////////////////////////////////////////////////////////////////////
204

  
205
  void drawRecursive(long currTime, DistortedFramebuffer df)
206
    {
207
    mTexture.createTexture();
208

  
209
    if( mNumChildren[0]<=0 )
210
      {
211
      GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexture.mTextureDataH[0]);
212
      }
213
    else
214
      {
215
      mData.mDF.createFBO();
216

  
217
      if( mData.numRendered==0 )
218
        {
219
        GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mData.mDF.fboIds[0]);
220

  
221
        GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
222
        GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
223

  
224
        if( mTexture.mBitmapSet[0] )
225
          {
226
          GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexture.mTextureDataH[0]);
227
          mQueues.drawNoEffectsPriv(mTexture, mGrid, mData.mDF);
228
          }
229

  
230
        synchronized(this)
231
          {
232
          for(int i=0; i<mNumChildren[0]; i++)
233
            {
234
            mChildren.get(i).drawRecursive(currTime, mData.mDF);
235
            }
236
          }
237
        }
238

  
239
      mData.numRendered++;
240
      mData.numRendered %= mData.numPointingNodes;
241

  
242
      GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, df.fboIds[0]);
243
      GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mData.mDF.texIds[0]);
244
      }
245

  
246
    mQueues.drawPriv(currTime, mTexture, mGrid, df);
247
    }
248

  
249 249
///////////////////////////////////////////////////////////////////////////////////////////////////
250 250
// PUBLIC API
251 251
///////////////////////////////////////////////////////////////////////////////////////////////////
......
450 450
      }
451 451
    }
452 452

  
453
///////////////////////////////////////////////////////////////////////////////////////////////////
454
/**
455
 * Draws the Node, and all its children, to the Framebuffer passed.
456
 * <p>
457
 * Must be called from a thread holding OpenGL Context
458
 *
459
 * @param currTime Current time, in milliseconds.
460
 * @param df       Framebuffer to render this to.
461
 */
462
  public void draw(long currTime, DistortedFramebuffer df)
463
    {
464
    df.createFBO();
465
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, df.fboIds[0]);
466
    drawRecursive(currTime,df);
467
    DistortedFramebuffer.deleteAllMarked();
468
    DistortedTexture.deleteAllMarked();
469
    }
470

  
471 453
///////////////////////////////////////////////////////////////////////////////////////////////////
472 454
/**
473 455
 * Returns the DistortedEffects object that's in the Node.

Also available in: Unified diff