| 27 |
27 |
import org.distorted.library.main.InternalBuffer;
|
| 28 |
28 |
import org.distorted.library.program.DistortedProgram;
|
| 29 |
29 |
|
| 30 |
|
import java.nio.ByteBuffer;
|
| 31 |
|
import java.nio.ByteOrder;
|
| 32 |
|
import java.nio.FloatBuffer;
|
| 33 |
30 |
import java.util.ArrayList;
|
| 34 |
31 |
|
| 35 |
32 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| ... | ... | |
| 187 |
184 |
|
| 188 |
185 |
mComponent.add(new Component(mNumVertices));
|
| 189 |
186 |
|
| 190 |
|
FloatBuffer attribs = ByteBuffer.allocateDirect(mNumVertices*VERT_SIZE).order(ByteOrder.nativeOrder()).asFloatBuffer();
|
| 191 |
|
attribs.put(vertexAttribs).position(0);
|
| 192 |
|
|
| 193 |
|
mVBO.setData(mNumVertices*VERT_SIZE, attribs);
|
| 194 |
|
mTFO.setData(mNumVertices*TRAN_SIZE, null );
|
|
187 |
mVBO.invalidate();
|
|
188 |
mTFO.invalidate();
|
| 195 |
189 |
}
|
| 196 |
190 |
|
| 197 |
191 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| ... | ... | |
| 226 |
220 |
}
|
| 227 |
221 |
|
| 228 |
222 |
num = mesh.mNumVertices;
|
| 229 |
|
mNumVertices+= (i<len-1 ? ( num%2==1 ? num+2 : num+1 ) : num);
|
|
223 |
|
|
224 |
if( mNumVertices==0 ) mNumVertices += (num%2==1 ? num+2 : num+1);
|
|
225 |
else if( i==len-1 ) mNumVertices += (num+1);
|
|
226 |
else mNumVertices += (num%2==1 ? num+3 : num+2);
|
| 230 |
227 |
}
|
| 231 |
228 |
|
| 232 |
229 |
// allocate new attrib array
|
| ... | ... | |
| 251 |
248 |
mesh = meshes[i];
|
| 252 |
249 |
num = mesh.mNumVertices;
|
| 253 |
250 |
|
| 254 |
|
System.arraycopy(mesh.mVertAttribs, 0, newAttribs, VERT_ATTRIBS*origVertices, VERT_ATTRIBS );
|
| 255 |
|
origVertices++;
|
|
251 |
if( origVertices>0 )
|
|
252 |
{
|
|
253 |
System.arraycopy(mesh.mVertAttribs, 0, newAttribs, VERT_ATTRIBS*origVertices, VERT_ATTRIBS );
|
|
254 |
origVertices++;
|
|
255 |
}
|
| 256 |
256 |
System.arraycopy(mesh.mVertAttribs, 0, newAttribs, VERT_ATTRIBS*origVertices, VERT_ATTRIBS*num);
|
| 257 |
257 |
origVertices+=num;
|
| 258 |
258 |
|
| ... | ... | |
| 276 |
276 |
|
| 277 |
277 |
mVertAttribs = newAttribs;
|
| 278 |
278 |
|
| 279 |
|
FloatBuffer attribs = ByteBuffer.allocateDirect(mNumVertices*VERT_SIZE).order(ByteOrder.nativeOrder()).asFloatBuffer();
|
| 280 |
|
attribs.put(mVertAttribs).position(0);
|
| 281 |
|
|
| 282 |
|
mVBO.setData(mNumVertices*VERT_SIZE, attribs);
|
| 283 |
|
mTFO.setData(mNumVertices*TRAN_SIZE, null );
|
|
279 |
mVBO.invalidate();
|
| 284 |
280 |
}
|
| 285 |
281 |
|
| 286 |
282 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| ... | ... | |
| 313 |
309 |
*/
|
| 314 |
310 |
public void bindVertexAttribs(DistortedProgram program)
|
| 315 |
311 |
{
|
|
312 |
mVBO.createImmediately(mNumVertices*VERT_SIZE, mVertAttribs);
|
|
313 |
|
| 316 |
314 |
GLES31.glBindBuffer(GLES31.GL_ARRAY_BUFFER, mVBO.mIndex[0] );
|
| 317 |
315 |
GLES31.glVertexAttribPointer(program.mAttribute[0], POS_DATA_SIZE, GLES31.GL_FLOAT, false, VERT_SIZE, OFFSET_POS);
|
| 318 |
316 |
GLES31.glVertexAttribPointer(program.mAttribute[1], NOR_DATA_SIZE, GLES31.GL_FLOAT, false, VERT_SIZE, OFFSET_NOR);
|
| ... | ... | |
| 329 |
327 |
*/
|
| 330 |
328 |
public void bindTransformAttribs(DistortedProgram program)
|
| 331 |
329 |
{
|
|
330 |
mTFO.createImmediately(mNumVertices*TRAN_SIZE, null);
|
|
331 |
|
| 332 |
332 |
GLES31.glBindBuffer(GLES31.GL_ARRAY_BUFFER, mTFO.mIndex[0] );
|
| 333 |
333 |
GLES31.glVertexAttribPointer(program.mAttribute[0], POS_DATA_SIZE, GLES31.GL_FLOAT, false, 0, 0);
|
| 334 |
334 |
GLES31.glBindBuffer(GLES31.GL_ARRAY_BUFFER, 0);
|
| ... | ... | |
| 456 |
456 |
}
|
| 457 |
457 |
}
|
| 458 |
458 |
|
| 459 |
|
FloatBuffer attribs = ByteBuffer.allocateDirect(mNumVertices*VERT_SIZE).order(ByteOrder.nativeOrder()).asFloatBuffer();
|
| 460 |
|
attribs.put(mVertAttribs).position(0);
|
| 461 |
|
|
| 462 |
|
mVBO.setData(mNumVertices*VERT_SIZE, attribs);
|
| 463 |
|
mTFO.setData(mNumVertices*TRAN_SIZE, null );
|
|
459 |
mTFO.invalidate();
|
| 464 |
460 |
}
|
| 465 |
461 |
|
| 466 |
462 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| ... | ... | |
| 493 |
489 |
}
|
| 494 |
490 |
}
|
| 495 |
491 |
|
| 496 |
|
FloatBuffer attribs = ByteBuffer.allocateDirect(mNumVertices*VERT_SIZE).order(ByteOrder.nativeOrder()).asFloatBuffer();
|
| 497 |
|
attribs.put(mVertAttribs).position(0);
|
| 498 |
|
|
| 499 |
|
mVBO.setData(mNumVertices*VERT_SIZE, attribs);
|
| 500 |
|
mTFO.setData(mNumVertices*TRAN_SIZE, null );
|
|
492 |
mTFO.invalidate();
|
| 501 |
493 |
}
|
| 502 |
494 |
|
| 503 |
495 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
Fix MeshBase.join()
Only upload Mesh Buffers to GPU when we actually use them.