Revision ae71f169
Added by Leszek Koltunski almost 2 years ago
src/main/java/org/distorted/library/mesh/MeshBase.java | ||
---|---|---|
811 | 811 |
|
812 | 812 |
int index1 = mVBO1.createImmediatelyFloat(mNumVertices*VERT1_SIZE, mVertAttribs1); |
813 | 813 |
int index2 = mVBO2.createImmediatelyFloat(mNumVertices*VERT2_SIZE, mVertAttribs2); |
814 |
int[] attr = program.mAttribute; |
|
814 | 815 |
|
815 | 816 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, index1 ); |
816 |
GLES30.glVertexAttribPointer(program.mAttribute[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, VERT1_SIZE, OFFSET_POS);
|
|
817 |
GLES30.glVertexAttribPointer(program.mAttribute[1], NOR_DATA_SIZE, GLES30.GL_FLOAT, false, VERT1_SIZE, OFFSET_NOR);
|
|
817 |
GLES30.glVertexAttribPointer(attr[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, VERT1_SIZE, OFFSET_POS);
|
|
818 |
GLES30.glVertexAttribPointer(attr[1], NOR_DATA_SIZE, GLES30.GL_FLOAT, false, VERT1_SIZE, OFFSET_NOR);
|
|
818 | 819 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, index2 ); |
819 |
GLES30.glVertexAttribPointer(program.mAttribute[2], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, VERT2_SIZE, OFFSET_TEX); |
|
820 |
GLES30.glVertexAttribPointer(program.mAttribute[3], COM_DATA_SIZE, GLES30.GL_FLOAT, false, VERT2_SIZE, OFFSET_COM); |
|
820 |
GLES30.glVertexAttribPointer(attr[2], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, VERT2_SIZE, OFFSET_TEX); |
|
821 |
|
|
822 |
// if we are not using component centers and there are no vertex effects enabled, |
|
823 |
// then this attribute does not exist in the Vertex Shader |
|
824 |
if( attr.length>=4 ) |
|
825 |
{ |
|
826 |
GLES30.glVertexAttribPointer(attr[3], COM_DATA_SIZE, GLES30.GL_FLOAT, false, VERT2_SIZE, OFFSET_COM); |
|
827 |
} |
|
828 |
|
|
821 | 829 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0); |
822 | 830 |
} |
823 | 831 |
|
src/main/java/org/distorted/library/program/DistortedProgram.java | ||
---|---|---|
191 | 191 |
|
192 | 192 |
if( currChar==' ' || currChar=='\t' ) |
193 | 193 |
{ |
194 |
mNumAttributes++; |
|
195 | 194 |
return subline.substring(nameBegin+1,subLen); |
196 | 195 |
} |
197 | 196 |
} |
... | ... | |
230 | 229 |
} |
231 | 230 |
} |
232 | 231 |
|
233 |
if( doAttributes ) mAttributeName = attrList.split(" "); |
|
232 |
if( doAttributes ) |
|
233 |
{ |
|
234 |
mAttributeName = attrList.split(" "); |
|
235 |
mNumAttributes = mAttributeName.length; |
|
236 |
} |
|
234 | 237 |
} |
235 | 238 |
|
236 | 239 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
268 | 271 |
return null; |
269 | 272 |
} |
270 | 273 |
|
271 |
if( doAttributes ) mAttributeName = attrList.split(" "); |
|
274 |
if( doAttributes ) |
|
275 |
{ |
|
276 |
mAttributeName = attrList.split(" "); |
|
277 |
mNumAttributes = mAttributeName.length; |
|
278 |
} |
|
272 | 279 |
|
273 | 280 |
return body.toString(); |
274 | 281 |
} |
... | ... | |
333 | 340 |
|
334 | 341 |
private void setUpAttributes() |
335 | 342 |
{ |
336 |
mAttribute = new int[mNumAttributes];
|
|
343 |
int[] att = new int[mNumAttributes];
|
|
337 | 344 |
|
338 | 345 |
for(int i=0; i<mNumAttributes; i++) |
339 | 346 |
{ |
340 |
mAttribute[i] = GLES30.glGetAttribLocation( mProgramHandle, mAttributeName[i]);
|
|
347 |
att[i] = GLES30.glGetAttribLocation( mProgramHandle, mAttributeName[i]);
|
|
341 | 348 |
} |
342 | 349 |
|
343 | 350 |
int emptyAttrs = 0; |
344 | 351 |
|
345 | 352 |
for(int i=0; i<mNumAttributes; i++) |
346 | 353 |
{ |
347 |
if( mAttribute[i] < 0 )
|
|
354 |
if( att[i] < 0 )
|
|
348 | 355 |
{ |
349 | 356 |
emptyAttrs++; |
350 | 357 |
|
351 | 358 |
for(int j=i; j<mNumAttributes-1; j++) |
352 | 359 |
{ |
353 |
mAttribute[j] = mAttribute[j+1];
|
|
360 |
att[j] = att[j+1];
|
|
354 | 361 |
mAttributeName[j] = mAttributeName[j+1]; |
355 | 362 |
} |
356 | 363 |
} |
357 | 364 |
} |
358 | 365 |
|
359 |
mNumAttributes -= emptyAttrs; |
|
366 |
if( emptyAttrs>0 ) |
|
367 |
{ |
|
368 |
mNumAttributes -= emptyAttrs; |
|
369 |
mAttribute = new int[mNumAttributes]; |
|
370 |
System.arraycopy(att, 0, mAttribute, 0, mNumAttributes); |
|
371 |
} |
|
372 |
else |
|
373 |
{ |
|
374 |
mAttribute = att; |
|
375 |
} |
|
360 | 376 |
} |
361 | 377 |
|
362 | 378 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Finally fix the reason foor 'incorrect vertex attribute' message spamming the Log of the Emulator.