|
|
@ -1500,7 +1500,7 @@ void rlglGenerateMipmaps(Texture2D texture) |
|
|
|
} |
|
|
|
|
|
|
|
// Upload vertex data into a VAO (if supported) and VBO |
|
|
|
void rlglLoadMesh(Mesh *mesh) |
|
|
|
void rlglLoadMesh(Mesh *mesh, bool dynamic) |
|
|
|
{ |
|
|
|
mesh->vaoId = 0; // Vertex Array Object |
|
|
|
mesh->vboId[0] = 0; // Vertex positions VBO |
|
|
@ -1510,6 +1510,9 @@ void rlglLoadMesh(Mesh *mesh) |
|
|
|
mesh->vboId[4] = 0; // Vertex tangents VBO |
|
|
|
mesh->vboId[5] = 0; // Vertex texcoords2 VBO |
|
|
|
mesh->vboId[6] = 0; // Vertex indices VBO |
|
|
|
|
|
|
|
int drawHint = GL_STATIC_DRAW; |
|
|
|
if (dynamic) drawHint = GL_DYNAMIC_DRAW; |
|
|
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
GLuint vaoId = 0; // Vertex Array Objects (VAO) |
|
|
@ -1527,14 +1530,14 @@ void rlglLoadMesh(Mesh *mesh) |
|
|
|
// Enable vertex attributes: position (shader-location = 0) |
|
|
|
glGenBuffers(1, &vboId[0]); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, vboId[0]); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*mesh->vertexCount, mesh->vertices, GL_STATIC_DRAW); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*mesh->vertexCount, mesh->vertices, drawHint); |
|
|
|
glVertexAttribPointer(0, 3, GL_FLOAT, 0, 0, 0); |
|
|
|
glEnableVertexAttribArray(0); |
|
|
|
|
|
|
|
// Enable vertex attributes: texcoords (shader-location = 1) |
|
|
|
glGenBuffers(1, &vboId[1]); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, vboId[1]); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*2*mesh->vertexCount, mesh->texcoords, GL_STATIC_DRAW); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*2*mesh->vertexCount, mesh->texcoords, drawHint); |
|
|
|
glVertexAttribPointer(1, 2, GL_FLOAT, 0, 0, 0); |
|
|
|
glEnableVertexAttribArray(1); |
|
|
|
|
|
|
@ -1543,7 +1546,7 @@ void rlglLoadMesh(Mesh *mesh) |
|
|
|
{ |
|
|
|
glGenBuffers(1, &vboId[2]); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, vboId[2]); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*mesh->vertexCount, mesh->normals, GL_STATIC_DRAW); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*mesh->vertexCount, mesh->normals, drawHint); |
|
|
|
glVertexAttribPointer(2, 3, GL_FLOAT, 0, 0, 0); |
|
|
|
glEnableVertexAttribArray(2); |
|
|
|
} |
|
|
@ -1559,7 +1562,7 @@ void rlglLoadMesh(Mesh *mesh) |
|
|
|
{ |
|
|
|
glGenBuffers(1, &vboId[3]); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, vboId[3]); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(unsigned char)*4*mesh->vertexCount, mesh->colors, GL_STATIC_DRAW); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(unsigned char)*4*mesh->vertexCount, mesh->colors, drawHint); |
|
|
|
glVertexAttribPointer(3, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0); |
|
|
|
glEnableVertexAttribArray(3); |
|
|
|
} |
|
|
@ -1575,7 +1578,7 @@ void rlglLoadMesh(Mesh *mesh) |
|
|
|
{ |
|
|
|
glGenBuffers(1, &vboId[4]); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, vboId[4]); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*mesh->vertexCount, mesh->tangents, GL_STATIC_DRAW); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*mesh->vertexCount, mesh->tangents, drawHint); |
|
|
|
glVertexAttribPointer(4, 3, GL_FLOAT, 0, 0, 0); |
|
|
|
glEnableVertexAttribArray(4); |
|
|
|
} |
|
|
@ -1591,7 +1594,7 @@ void rlglLoadMesh(Mesh *mesh) |
|
|
|
{ |
|
|
|
glGenBuffers(1, &vboId[5]); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, vboId[5]); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*2*mesh->vertexCount, mesh->texcoords2, GL_STATIC_DRAW); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*2*mesh->vertexCount, mesh->texcoords2, drawHint); |
|
|
|
glVertexAttribPointer(5, 2, GL_FLOAT, 0, 0, 0); |
|
|
|
glEnableVertexAttribArray(5); |
|
|
|
} |
|
|
|