mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-28 05:58:30 +00:00
Support indexed mesh data on OpenGL 1.1 path
Keep asking myself why I maintain this rendering path... -___-
This commit is contained in:
@@ -1104,7 +1104,9 @@ void rlglDrawEx(Mesh mesh, Material material, Matrix transform, bool wires)
|
|||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
rlMultMatrixf(MatrixToFloat(transform));
|
rlMultMatrixf(MatrixToFloat(transform));
|
||||||
rlColor4ub(material.colDiffuse.r, material.colDiffuse.g, material.colDiffuse.b, material.colDiffuse.a);
|
rlColor4ub(material.colDiffuse.r, material.colDiffuse.g, material.colDiffuse.b, material.colDiffuse.a);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, mesh.vertexCount);
|
|
||||||
|
if (mesh.indices != NULL) glDrawElements(GL_TRIANGLES, mesh.triangleCount*3, GL_UNSIGNED_SHORT, mesh.indices);
|
||||||
|
else glDrawArrays(GL_TRIANGLES, 0, mesh.vertexCount);
|
||||||
rlPopMatrix();
|
rlPopMatrix();
|
||||||
|
|
||||||
glDisableClientState(GL_VERTEX_ARRAY); // Disable vertex array
|
glDisableClientState(GL_VERTEX_ARRAY); // Disable vertex array
|
||||||
@@ -1209,7 +1211,7 @@ void rlglDrawEx(Mesh mesh, Material material, Matrix transform, bool wires)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw call!
|
// Draw call!
|
||||||
if (mesh.indices != NULL) glDrawElements(GL_TRIANGLES, mesh.trianglesCount*3, GL_UNSIGNED_SHORT, 0); // Indexed vertices draw
|
if (mesh.indices != NULL) glDrawElements(GL_TRIANGLES, mesh.triangleCount*3, GL_UNSIGNED_SHORT, 0); // Indexed vertices draw
|
||||||
else glDrawArrays(GL_TRIANGLES, 0, mesh.vertexCount);
|
else glDrawArrays(GL_TRIANGLES, 0, mesh.vertexCount);
|
||||||
|
|
||||||
if (material.texNormal.id != 0)
|
if (material.texNormal.id != 0)
|
||||||
@@ -1787,7 +1789,7 @@ void rlglLoadMesh(Mesh *mesh)
|
|||||||
{
|
{
|
||||||
glGenBuffers(1, &vboId[6]);
|
glGenBuffers(1, &vboId[6]);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboId[6]);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboId[6]);
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned short)*mesh->trianglesCount*3, mesh->indices, GL_STATIC_DRAW);
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned short)*mesh->triangleCount*3, mesh->indices, GL_STATIC_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user