Project

General

Profile

« Previous | Next » 

Revision 16d8b8f3

Added by Leszek Koltunski almost 8 years ago

DistortedFramebuffer should we working now, including deletions.

View differences:

src/main/java/org/distorted/library/DistortedBitmapGrid.java
175 175
      //android.util.Log.d("CUBES", "normal: "  +debug(  normalData,3) );
176 176
      //android.util.Log.d("CUBES", "texture: " +debug( textureData,2) );
177 177

  
178
      android.util.Log.d("BITMAP", "remainingVert " +remainingVert );
178
      if( remainingVert!=0 )
179
        android.util.Log.d("BITMAP", "remainingVert " +remainingVert );
179 180

  
180 181
      mGridPositions = ByteBuffer.allocateDirect(POSITION_DATA_SIZE*dataLength*BYTES_PER_FLOAT).order(ByteOrder.nativeOrder()).asFloatBuffer();
181 182
      mGridPositions.put(positionData).position(0);
src/main/java/org/distorted/library/DistortedCubesGrid.java
776 776
     android.util.Log.d("CUBES", "normal: "  +debug(  normalData,3) );
777 777
     android.util.Log.d("CUBES", "texture: " +debug( textureData,2) );
778 778
     */
779
     android.util.Log.d("CUBES", "remainingVert " +remainingVert );
779

  
780
     if( remainingVert!=0 )
781
       android.util.Log.d("CUBES", "remainingVert " +remainingVert );
780 782

  
781 783
     mGridPositions = ByteBuffer.allocateDirect(POSITION_DATA_SIZE*dataLength*BYTES_PER_FLOAT).order(ByteOrder.nativeOrder()).asFloatBuffer();
782 784
     mGridPositions.put(positionData).position(0);
src/main/java/org/distorted/library/DistortedFramebuffer.java
55 55
      mDistance = (int)(mHeight*near/(top-bottom));
56 56
      far = 2*mDistance-near;
57 57

  
58
      Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
58
      if( far<=0 )
59
        {
60
        android.util.Log.e("FBO", "error: far<=0. width="+mWidth+" height="+mHeight+
61
                           " mFOV="+mFOV+" mDistance="+mDistance+" far="+far+" near="+near);
62
        }
63
      else
64
        Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
59 65
      }
60 66
    else                      // parallel projection
61 67
      {
......
104 110

  
105 111
    mFramebufferID = mFBORenderToTexture[0];
106 112

  
113
    android.util.Log.e("FBO", "creating ("+mWidth+","+mHeight+") "+mFramebufferID);
114

  
107 115
    return true;
108 116
    }
109 117

  
......
112 120

  
113 121
  private void deleteFBO()
114 122
    {
123
    android.util.Log.e("FBO", "deleting ("+mWidth+","+mHeight+") "+mFramebufferID);
124

  
115 125
    int[] textureIds = new int[1];
116 126
    int[] mFBORenderToTexture = new int[1];
117 127

  
......
126 136
    }
127 137

  
128 138
///////////////////////////////////////////////////////////////////////////////////////////////////
129
// must be called form a thread holding OpenGL Context
139
// must be called from a thread holding OpenGL Context
130 140

  
131 141
  void release()
132 142
    {
......
152 162

  
153 163
    mHeight        = height;
154 164
    mWidth         = width;
155
    mFramebufferID = 0;
165
    mFramebufferID = -1;
156 166
    mTextureID     = TEXTURE_NOT_CREATED_YET;
157 167
    mFOV           = 60.0f;
158 168
    mX             = 0.0f;
......
161 171
    mMarked = false;
162 172

  
163 173
    createProjection();
174

  
175
    DistortedFramebufferList.add(this);
164 176
    }
165 177

  
166 178
///////////////////////////////////////////////////////////////////////////////////////////////////
......
182 194

  
183 195
  public void markForDeletion()
184 196
    {
197
    android.util.Log.e("FBO", "marking for deletion ("+mWidth+","+mHeight+") "+mFramebufferID);
198

  
185 199
    DistortedFramebufferList.markForDeletion();
186 200
    mMarked = true;
187 201
    }
src/main/java/org/distorted/library/DistortedNode.java
114 114
        }
115 115

  
116 116
      df.setOutput();
117
      mData.mDF.setInput();   // this is safe because we must have called createFBO() above before.
117
      mData.mDF.setInput();
118 118
      }
119 119
    
120 120
    mObject.drawPriv(currTime, df);
......
173 173
      if( otherNodesPoint )  mData = new NodeData(++mNextNodeID);
174 174
      else                   mData.ID = ++mNextNodeID;  // numPointingNodes must be 1 already
175 175

  
176
      if( newList.size()>1 && mData.mDF==null )
177
        mData.mDF = new DistortedFramebuffer(mObject.getWidth(), mObject.getHeight());
176
      if( newList.size()>1 )
177
        {
178
        if( mData.mDF==null )
179
          mData.mDF = new DistortedFramebuffer(mObject.getWidth(), mObject.getHeight());
180
        }
181
      else
182
        {
183
        if( mData.mDF!=null )
184
          {
185
          mData.mDF.markForDeletion();
186
          mData.mDF = null;
187
          }
188
        else
189
          {
190
          android.util.Log.e("DistortedNode", "adjustNodeData: impossible situation??");
191
          }
192
        }
178 193

  
179 194
      mMapNodeID.put(newList, mData);
180 195
      }
src/main/java/org/distorted/library/DistortedObject.java
161 161
   
162 162
  void drawPriv(long currTime, DistortedFramebuffer df)
163 163
    {
164
    DistortedFramebufferList.deleteAllMarked();
165

  
164 166
    GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
165 167
      
166 168
    mM.compute(currTime);
......
275 277
    GLES20.glUniform1i(Distorted.mTextureUniformH, 0);
276 278
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);
277 279

  
278
    DistortedFramebufferList.deleteAllMarked();
279

  
280 280
    drawPriv(currTime, Distorted.mFramebuffer);
281 281
    }
282 282
 

Also available in: Unified diff