fg_geometry: GL2 fixed: glDrawElements' indices is byte offset, not element offset

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1278 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
beuc 2012-05-01 22:16:33 +00:00
parent 9b1a6ab1dd
commit ae35d72efd

View File

@ -166,7 +166,8 @@ static void fghDrawGeometryWire20(GLfloat *vertices, GLfloat *normals, GLsizei n
} else { } else {
fghBindBuffer(FGH_ELEMENT_ARRAY_BUFFER, ibo_elements); fghBindBuffer(FGH_ELEMENT_ARRAY_BUFFER, ibo_elements);
for (i=0; i<numParts; i++) for (i=0; i<numParts; i++)
glDrawElements(vertexMode,numVertPerPart,GL_UNSIGNED_SHORT,(void*)(long)(i*numVertPerPart)); glDrawElements(vertexMode, numVertPerPart,
GL_UNSIGNED_SHORT, (GLvoid*)(sizeof(vertIdxs[0])*i*numVertPerPart));
/* Clean existing bindings before clean-up */ /* Clean existing bindings before clean-up */
/* Android showed instability otherwise */ /* Android showed instability otherwise */
fghBindBuffer(FGH_ELEMENT_ARRAY_BUFFER, 0); fghBindBuffer(FGH_ELEMENT_ARRAY_BUFFER, 0);
@ -174,8 +175,13 @@ static void fghDrawGeometryWire20(GLfloat *vertices, GLfloat *normals, GLsizei n
if (vertIdxs2) { if (vertIdxs2) {
fghBindBuffer(FGH_ELEMENT_ARRAY_BUFFER, ibo_elements2); fghBindBuffer(FGH_ELEMENT_ARRAY_BUFFER, ibo_elements2);
static float t2 = 0;
t2 += 0.1;
if (t2 >= numParts2)
t2 = 0;
for (i=0; i<numParts2; i++) for (i=0; i<numParts2; i++)
glDrawElements(GL_LINE_LOOP,numVertPerPart2,GL_UNSIGNED_SHORT,(void*)(long)(i*numVertPerPart2)); glDrawElements(GL_LINE_LOOP, numVertPerPart2,
GL_UNSIGNED_SHORT, (GLvoid*)(sizeof(vertIdxs2[0])*i*numVertPerPart2));
/* Clean existing bindings before clean-up */ /* Clean existing bindings before clean-up */
/* Android showed instability otherwise */ /* Android showed instability otherwise */
fghBindBuffer(FGH_ELEMENT_ARRAY_BUFFER, 0); fghBindBuffer(FGH_ELEMENT_ARRAY_BUFFER, 0);
@ -321,7 +327,7 @@ static void fghDrawGeometrySolid20(GLfloat *vertices, GLfloat *normals, GLushort
fghBindBuffer(FGH_ELEMENT_ARRAY_BUFFER, ibo_elements); fghBindBuffer(FGH_ELEMENT_ARRAY_BUFFER, ibo_elements);
if (numParts>1) { if (numParts>1) {
for (i=0; i<numParts; i++) { for (i=0; i<numParts; i++) {
glDrawElements(GL_TRIANGLE_STRIP, numVertIdxsPerPart, GL_UNSIGNED_SHORT, (void*)(long)(i*numVertIdxsPerPart)); glDrawElements(GL_TRIANGLE_STRIP, numVertIdxsPerPart, GL_UNSIGNED_SHORT, (GLvoid*)(sizeof(vertIdxs[0])*i*numVertIdxsPerPart));
} }
} else { } else {
glDrawElements(GL_TRIANGLES, numVertIdxsPerPart, GL_UNSIGNED_SHORT, 0); glDrawElements(GL_TRIANGLES, numVertIdxsPerPart, GL_UNSIGNED_SHORT, 0);