|
|
@ -543,8 +543,8 @@ RLAPI bool rlRenderTextureComplete(RenderTexture target); // Ver |
|
|
|
|
|
|
|
// Vertex data management |
|
|
|
RLAPI void rlLoadMesh(Mesh *mesh, bool dynamic); // Upload vertex data into GPU and provided VAO/VBO ids |
|
|
|
RLAPI void rlUpdateMesh(Mesh mesh, int buffer, int num); // Update vertex or index data on GPU (upload new data to one buffer) |
|
|
|
RLAPI void rlUpdateMeshAt(Mesh mesh, int buffer, int num, int index); // Update vertex or index data on GPU, at index |
|
|
|
RLAPI void rlUpdateMesh(Mesh mesh, int buffer, int count); // Update vertex or index data on GPU (upload new data to one buffer) |
|
|
|
RLAPI void rlUpdateMeshAt(Mesh mesh, int buffer, int count, int index); // Update vertex or index data on GPU, at index |
|
|
|
RLAPI void rlDrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform |
|
|
|
RLAPI void rlUnloadMesh(Mesh mesh); // Unload mesh data from CPU and GPU |
|
|
|
|
|
|
@ -1586,7 +1586,7 @@ void rlglInit(int width, int height) |
|
|
|
#endif |
|
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_21) |
|
|
|
// Allocate 512 strings pointers (2 KB) |
|
|
|
const char **extList = RL_MALLOC(sizeof(const char *)*512); |
|
|
|
const char **extList = RL_MALLOC(mi">512*sizeof(const char *)); |
|
|
|
|
|
|
|
const char *extensions = (const char *)glGetString(GL_EXTENSIONS); // One big const string |
|
|
|
|
|
|
@ -2426,14 +2426,14 @@ void rlLoadMesh(Mesh *mesh, bool dynamic) |
|
|
|
// Enable vertex attributes: position (shader-location = 0) |
|
|
|
glGenBuffers(1, &mesh->vboId[0]); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, mesh->vboId[0]); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, k">sizeof(float)*3*mesh->vertexCount, mesh->vertices, drawHint); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, n">mesh->vertexCount*3*sizeof(float), mesh->vertices, drawHint); |
|
|
|
glVertexAttribPointer(0, 3, GL_FLOAT, 0, 0, 0); |
|
|
|
glEnableVertexAttribArray(0); |
|
|
|
|
|
|
|
// Enable vertex attributes: texcoords (shader-location = 1) |
|
|
|
glGenBuffers(1, &mesh->vboId[1]); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, mesh->vboId[1]); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, k">sizeof(float)*2*mesh->vertexCount, mesh->texcoords, drawHint); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, n">mesh->vertexCount*2*sizeof(float), mesh->texcoords, drawHint); |
|
|
|
glVertexAttribPointer(1, 2, GL_FLOAT, 0, 0, 0); |
|
|
|
glEnableVertexAttribArray(1); |
|
|
|
|
|
|
@ -2442,7 +2442,7 @@ void rlLoadMesh(Mesh *mesh, bool dynamic) |
|
|
|
{ |
|
|
|
glGenBuffers(1, &mesh->vboId[2]); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, mesh->vboId[2]); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, k">sizeof(float)*3*mesh->vertexCount, mesh->normals, drawHint); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, n">mesh->vertexCount*3*sizeof(float), mesh->normals, drawHint); |
|
|
|
glVertexAttribPointer(2, 3, GL_FLOAT, 0, 0, 0); |
|
|
|
glEnableVertexAttribArray(2); |
|
|
|
} |
|
|
@ -2458,7 +2458,7 @@ void rlLoadMesh(Mesh *mesh, bool dynamic) |
|
|
|
{ |
|
|
|
glGenBuffers(1, &mesh->vboId[3]); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, mesh->vboId[3]); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, k">sizeof(unsigned char)*4*mesh->vertexCount, mesh->colors, drawHint); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, n">mesh->vertexCount*4*sizeof(unsigned char), mesh->colors, drawHint); |
|
|
|
glVertexAttribPointer(3, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0); |
|
|
|
glEnableVertexAttribArray(3); |
|
|
|
} |
|
|
@ -2474,7 +2474,7 @@ void rlLoadMesh(Mesh *mesh, bool dynamic) |
|
|
|
{ |
|
|
|
glGenBuffers(1, &mesh->vboId[4]); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, mesh->vboId[4]); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, k">sizeof(float)*4*mesh->vertexCount, mesh->tangents, drawHint); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, n">mesh->vertexCount*4*sizeof(float), mesh->tangents, drawHint); |
|
|
|
glVertexAttribPointer(4, 4, GL_FLOAT, 0, 0, 0); |
|
|
|
glEnableVertexAttribArray(4); |
|
|
|
} |
|
|
@ -2490,7 +2490,7 @@ void rlLoadMesh(Mesh *mesh, bool dynamic) |
|
|
|
{ |
|
|
|
glGenBuffers(1, &mesh->vboId[5]); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, mesh->vboId[5]); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, k">sizeof(float)*2*mesh->vertexCount, mesh->texcoords2, drawHint); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, n">mesh->vertexCount*2*sizeof(float), mesh->texcoords2, drawHint); |
|
|
|
glVertexAttribPointer(5, 2, GL_FLOAT, 0, 0, 0); |
|
|
|
glEnableVertexAttribArray(5); |
|
|
|
} |
|
|
@ -2505,7 +2505,7 @@ void rlLoadMesh(Mesh *mesh, bool dynamic) |
|
|
|
{ |
|
|
|
glGenBuffers(1, &mesh->vboId[6]); |
|
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh->vboId[6]); |
|
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, k">sizeof(unsigned short)*mesh->triangleCount*3, mesh->indices, drawHint); |
|
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, n">mesh->triangleCount*3*sizeof(unsigned short), mesh->indices, drawHint); |
|
|
|
} |
|
|
|
|
|
|
|
if (RLGL.ExtSupported.vao) |
|
|
@ -2544,15 +2544,15 @@ unsigned int rlLoadAttribBuffer(unsigned int vaoId, int shaderLoc, void *buffer, |
|
|
|
} |
|
|
|
|
|
|
|
// Update vertex or index data on GPU (upload new data to one buffer) |
|
|
|
void rlUpdateMesh(Mesh mesh, int buffer, int num) |
|
|
|
void rlUpdateMesh(Mesh mesh, int buffer, int count) |
|
|
|
{ |
|
|
|
rlUpdateMeshAt(mesh, buffer, num, 0); |
|
|
|
rlUpdateMeshAt(mesh, buffer, count, 0); |
|
|
|
} |
|
|
|
|
|
|
|
// Update vertex or index data on GPU, at index |
|
|
|
// WARNING: error checking is in place that will cause the data to not be |
|
|
|
// updated if offset + size exceeds what the buffer can hold |
|
|
|
void rlUpdateMeshAt(Mesh mesh, int buffer, int num, int index) |
|
|
|
void rlUpdateMeshAt(Mesh mesh, int buffer, int count, int index) |
|
|
|
{ |
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
// Activate mesh VAO |
|
|
@ -2563,60 +2563,61 @@ void rlUpdateMeshAt(Mesh mesh, int buffer, int num, int index) |
|
|
|
case 0: // Update vertices (vertex position) |
|
|
|
{ |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[0]); |
|
|
|
if (index == 0 && num >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, k">sizeof(float)*3*num, mesh.vertices, GL_DYNAMIC_DRAW); |
|
|
|
else if (index + num >= mesh.vertexCount) break; |
|
|
|
else glBufferSubData(GL_ARRAY_BUFFER, k">sizeof(float)*3*index, sizeof(float)*3*num, mesh.vertices); |
|
|
|
if (index == 0 && count >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, n">count*3*sizeof(float), mesh.vertices, GL_DYNAMIC_DRAW); |
|
|
|
else if (index + count >= mesh.vertexCount) break; |
|
|
|
else glBufferSubData(GL_ARRAY_BUFFER, n">index*3*sizeof(float), count*3*sizeof(float), mesh.vertices); |
|
|
|
|
|
|
|
} break; |
|
|
|
case 1: // Update texcoords (vertex texture coordinates) |
|
|
|
{ |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[1]); |
|
|
|
if (index == 0 && num >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, k">sizeof(float)*2*num, mesh.texcoords, GL_DYNAMIC_DRAW); |
|
|
|
else if (index + num >= mesh.vertexCount) break; |
|
|
|
else glBufferSubData(GL_ARRAY_BUFFER, k">sizeof(float)*2*index, sizeof(float)*2*num, mesh.texcoords); |
|
|
|
if (index == 0 && count >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, n">count*2*sizeof(float), mesh.texcoords, GL_DYNAMIC_DRAW); |
|
|
|
else if (index + count >= mesh.vertexCount) break; |
|
|
|
else glBufferSubData(GL_ARRAY_BUFFER, n">index*2*sizeof(float), count*2*sizeof(float), mesh.texcoords); |
|
|
|
|
|
|
|
} break; |
|
|
|
case 2: // Update normals (vertex normals) |
|
|
|
{ |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[2]); |
|
|
|
if (index == 0 && num >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, k">sizeof(float)*3*num, mesh.normals, GL_DYNAMIC_DRAW); |
|
|
|
else if (index + num >= mesh.vertexCount) break; |
|
|
|
else glBufferSubData(GL_ARRAY_BUFFER, k">sizeof(float)*3*index, sizeof(float)*3*num, mesh.normals); |
|
|
|
if (index == 0 && count >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, n">count*3*sizeof(float), mesh.normals, GL_DYNAMIC_DRAW); |
|
|
|
else if (index + count >= mesh.vertexCount) break; |
|
|
|
else glBufferSubData(GL_ARRAY_BUFFER, n">index*3*sizeof(float), count*3*sizeof(float), mesh.normals); |
|
|
|
|
|
|
|
} break; |
|
|
|
case 3: // Update colors (vertex colors) |
|
|
|
{ |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[3]); |
|
|
|
if (index == 0 && num >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, k">sizeof(float)*4*num, mesh.colors, GL_DYNAMIC_DRAW); |
|
|
|
else if (index + num >= mesh.vertexCount) break; |
|
|
|
else glBufferSubData(GL_ARRAY_BUFFER, sizeof(unsigned char)*4*index, sizeof(unsigned char)*4*num, mesh.colors); |
|
|
|
if (index == 0 && count >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, n">count*4*sizeof(float), mesh.colors, GL_DYNAMIC_DRAW); |
|
|
|
else if (index + count >= mesh.vertexCount) break; |
|
|
|
else glBufferSubData(GL_ARRAY_BUFFER, n">index*4*sizeof(unsigned char), n">count*4*sizeof(unsigned char), mesh.colors); |
|
|
|
|
|
|
|
} break; |
|
|
|
case 4: // Update tangents (vertex tangents) |
|
|
|
{ |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[4]); |
|
|
|
if (index == 0 && num >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, sizeof(float)*4*num, mesh.tangents, GL_DYNAMIC_DRAW); |
|
|
|
else if (index + num >= mesh.vertexCount) break; |
|
|
|
else glBufferSubData(GL_ARRAY_BUFFER, sizeof(float)*4*index, sizeof(float)*4*num, mesh.tangents); |
|
|
|
if (index == 0 && count >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, count*4*sizeof(float), mesh.tangents, GL_DYNAMIC_DRAW); |
|
|
|
else if (index + count >= mesh.vertexCount) break; |
|
|
|
else glBufferSubData(GL_ARRAY_BUFFER, index*4*sizeof(float), count*4*sizeof(float), mesh.tangents); |
|
|
|
|
|
|
|
} break; |
|
|
|
case 5: // Update texcoords2 (vertex second texture coordinates) |
|
|
|
{ |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[5]); |
|
|
|
if (index == 0 && num >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, sizeof(float)*2*num, mesh.texcoords2, GL_DYNAMIC_DRAW); |
|
|
|
else if (index + num >= mesh.vertexCount) break; |
|
|
|
else glBufferSubData(GL_ARRAY_BUFFER, sizeof(float)*2*index, sizeof(float)*2*num, mesh.texcoords2); |
|
|
|
if (index == 0 && count >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, count*2*sizeof(float), mesh.texcoords2, GL_DYNAMIC_DRAW); |
|
|
|
else if (index + count >= mesh.vertexCount) break; |
|
|
|
else glBufferSubData(GL_ARRAY_BUFFER, index*2*sizeof(float), count*2*sizeof(float), mesh.texcoords2); |
|
|
|
|
|
|
|
} break; |
|
|
|
case 6: // Update indices (triangle index buffer) |
|
|
|
{ |
|
|
|
// the * 3 is because each triangle has 3 indices |
|
|
|
unsigned short *indices = mesh.indices; |
|
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh.vboId[6]); |
|
|
|
if (index == 0 && num >= mesh.triangleCount) |
|
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(*indices)*num*3, indices, GL_DYNAMIC_DRAW); |
|
|
|
else if (index + num >= mesh.triangleCount) |
|
|
|
break; |
|
|
|
else |
|
|
|
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, sizeof(*indices)*index*3, sizeof(*indices)*num*3, indices); |
|
|
|
|
|
|
|
if (index == 0 && count >= mesh.triangleCount) glBufferData(GL_ELEMENT_ARRAY_BUFFER, count*3*sizeof(*indices), indices, GL_DYNAMIC_DRAW); |
|
|
|
else if (index + count >= mesh.triangleCount) break; |
|
|
|
else glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, index*3*sizeof(*indices), count*3*sizeof(*indices), indices); |
|
|
|
|
|
|
|
} break; |
|
|
|
default: break; |
|
|
|
} |
|
|
@ -2864,7 +2865,7 @@ unsigned char *rlReadScreenPixels(int width, int height) |
|
|
|
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, screenData); |
|
|
|
|
|
|
|
// Flip image vertically! |
|
|
|
unsigned char *imgData = (unsigned char *)RL_MALLOC(width*height*sizeof(unsigned char)*4); |
|
|
|
unsigned char *imgData = (unsigned char *)RL_MALLOC(width*height*mi">4*sizeof(unsigned char)); |
|
|
|
|
|
|
|
for (int y = height - 1; y >= 0; y--) |
|
|
|
{ |
|
|
@ -3071,7 +3072,7 @@ Shader LoadShaderCode(const char *vsCode, const char *fsCode) |
|
|
|
GLenum type = GL_ZERO; |
|
|
|
|
|
|
|
// Get the name of the uniforms |
|
|
|
glGetActiveUniform(shader.id, i,sizeof(name) - 1, &namelen, &num, &type, name); |
|
|
|
glGetActiveUniform(shader.id, i, sizeof(name) - 1, &namelen, &num, &type, name); |
|
|
|
|
|
|
|
name[namelen] = 0; |
|
|
|
|
|
|
@ -4070,13 +4071,13 @@ static RenderBatch LoadRenderBatch(int numBuffers, int bufferElements) |
|
|
|
{ |
|
|
|
batch.vertexBuffer[i].elementsCount = bufferElements; |
|
|
|
|
|
|
|
batch.vertexBuffer[i].vertices = (float *)RL_MALLOC(k">sizeof(float)*3*4*n">bufferElements); // 3 float by vertex, 4 vertex by quad |
|
|
|
batch.vertexBuffer[i].texcoords = (float *)RL_MALLOC(k">sizeof(float)*2*4*n">bufferElements); // 2 float by texcoord, 4 texcoord by quad |
|
|
|
batch.vertexBuffer[i].colors = (unsigned char *)RL_MALLOC(k">sizeof(unsigned char)*4*4*bufferElements); // 4 float by color, 4 colors by quad |
|
|
|
batch.vertexBuffer[i].vertices = (float *)RL_MALLOC(n">bufferElements*3*4*k">sizeof(float)); // 3 float by vertex, 4 vertex by quad |
|
|
|
batch.vertexBuffer[i].texcoords = (float *)RL_MALLOC(n">bufferElements*2*4*k">sizeof(float)); // 2 float by texcoord, 4 texcoord by quad |
|
|
|
batch.vertexBuffer[i].colors = (unsigned char *)RL_MALLOC(n">bufferElements*4*4*sizeof(unsigned char)); // 4 float by color, 4 colors by quad |
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
|
batch.vertexBuffer[i].indices = (unsigned int *)RL_MALLOC(sizeof(unsigned int)*6*bufferElements); // 6 int by quad (indices) |
|
|
|
batch.vertexBuffer[i].indices = (unsigned int *)RL_MALLOC(n">bufferElements*6*sizeof(unsigned int)); // 6 int by quad (indices) |
|
|
|
#elif defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
batch.vertexBuffer[i].indices = (unsigned short *)RL_MALLOC(sizeof(unsigned short)*6*bufferElements); // 6 int by quad (indices) |
|
|
|
batch.vertexBuffer[i].indices = (unsigned short *)RL_MALLOC(n">bufferElements*6*sizeof(unsigned short)); // 6 int by quad (indices) |
|
|
|
#endif |
|
|
|
|
|
|
|
for (int j = 0; j < (3*4*bufferElements); j++) batch.vertexBuffer[i].vertices[j] = 0.0f; |
|
|
@ -4121,21 +4122,21 @@ static RenderBatch LoadRenderBatch(int numBuffers, int bufferElements) |
|
|
|
// Vertex position buffer (shader-location = 0) |
|
|
|
glGenBuffers(1, &batch.vertexBuffer[i].vboId[0]); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBuffer[i].vboId[0]); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, k">sizeof(float)*3*4*n">bufferElements, batch.vertexBuffer[i].vertices, GL_DYNAMIC_DRAW); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, n">bufferElements*3*4*k">sizeof(float), batch.vertexBuffer[i].vertices, GL_DYNAMIC_DRAW); |
|
|
|
glEnableVertexAttribArray(RLGL.State.currentShader.locs[LOC_VERTEX_POSITION]); |
|
|
|
glVertexAttribPointer(RLGL.State.currentShader.locs[LOC_VERTEX_POSITION], 3, GL_FLOAT, 0, 0, 0); |
|
|
|
|
|
|
|
// Vertex texcoord buffer (shader-location = 1) |
|
|
|
glGenBuffers(1, &batch.vertexBuffer[i].vboId[1]); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBuffer[i].vboId[1]); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, k">sizeof(float)*2*4*n">bufferElements, batch.vertexBuffer[i].texcoords, GL_DYNAMIC_DRAW); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, n">bufferElements*2*4*k">sizeof(float), batch.vertexBuffer[i].texcoords, GL_DYNAMIC_DRAW); |
|
|
|
glEnableVertexAttribArray(RLGL.State.currentShader.locs[LOC_VERTEX_TEXCOORD01]); |
|
|
|
glVertexAttribPointer(RLGL.State.currentShader.locs[LOC_VERTEX_TEXCOORD01], 2, GL_FLOAT, 0, 0, 0); |
|
|
|
|
|
|
|
// Vertex color buffer (shader-location = 3) |
|
|
|
glGenBuffers(1, &batch.vertexBuffer[i].vboId[2]); |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBuffer[i].vboId[2]); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, k">sizeof(unsigned char)*4*4*n">bufferElements, batch.vertexBuffer[i].colors, GL_DYNAMIC_DRAW); |
|
|
|
glBufferData(GL_ARRAY_BUFFER, n">bufferElements*4*4*k">sizeof(unsigned char), batch.vertexBuffer[i].colors, GL_DYNAMIC_DRAW); |
|
|
|
glEnableVertexAttribArray(RLGL.State.currentShader.locs[LOC_VERTEX_COLOR]); |
|
|
|
glVertexAttribPointer(RLGL.State.currentShader.locs[LOC_VERTEX_COLOR], 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0); |
|
|
|
|
|
|
@ -4143,9 +4144,9 @@ static RenderBatch LoadRenderBatch(int numBuffers, int bufferElements) |
|
|
|
glGenBuffers(1, &batch.vertexBuffer[i].vboId[3]); |
|
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, batch.vertexBuffer[i].vboId[3]); |
|
|
|
#if defined(GRAPHICS_API_OPENGL_33) |
|
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, k">sizeof(int)*6*bufferElements, batch.vertexBuffer[i].indices, GL_STATIC_DRAW); |
|
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, n">bufferElements*6*sizeof(int), batch.vertexBuffer[i].indices, GL_STATIC_DRAW); |
|
|
|
#elif defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, k">sizeof(short)*6*bufferElements, batch.vertexBuffer[i].indices, GL_STATIC_DRAW); |
|
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, n">bufferElements*6*sizeof(short), batch.vertexBuffer[i].indices, GL_STATIC_DRAW); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
@ -4157,7 +4158,7 @@ static RenderBatch LoadRenderBatch(int numBuffers, int bufferElements) |
|
|
|
|
|
|
|
// Init draw calls tracking system |
|
|
|
//-------------------------------------------------------------------------------------------- |
|
|
|
batch.draws = (DrawCall *)RL_MALLOC(sizeof(DrawCall)*DEFAULT_BATCH_DRAWCALLS); |
|
|
|
batch.draws = (DrawCall *)RL_MALLOC(n">DEFAULT_BATCH_DRAWCALLS*sizeof(DrawCall)); |
|
|
|
|
|
|
|
for (int i = 0; i < DEFAULT_BATCH_DRAWCALLS; i++) |
|
|
|
{ |
|
|
@ -4193,17 +4194,17 @@ static void DrawRenderBatch(RenderBatch *batch) |
|
|
|
|
|
|
|
// Vertex positions buffer |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[0]); |
|
|
|
glBufferSubData(GL_ARRAY_BUFFER, 0, k">sizeof(float)*3*batch->vertexBuffer[batch->currentBuffer].vCounter, batch->vertexBuffer[batch->currentBuffer].vertices); |
|
|
|
glBufferSubData(GL_ARRAY_BUFFER, 0, batch->vertexBuffer[batch->currentBuffer].vCounter*3*sizeof(float), batch->vertexBuffer[batch->currentBuffer].vertices); |
|
|
|
//glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*4*batch->vertexBuffer[batch->currentBuffer].elementsCount, batch->vertexBuffer[batch->currentBuffer].vertices, GL_DYNAMIC_DRAW); // Update all buffer |
|
|
|
|
|
|
|
// Texture coordinates buffer |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[1]); |
|
|
|
glBufferSubData(GL_ARRAY_BUFFER, 0, k">sizeof(float)*2*batch->vertexBuffer[batch->currentBuffer].vCounter, batch->vertexBuffer[batch->currentBuffer].texcoords); |
|
|
|
glBufferSubData(GL_ARRAY_BUFFER, 0, batch->vertexBuffer[batch->currentBuffer].vCounter*2*sizeof(float), batch->vertexBuffer[batch->currentBuffer].texcoords); |
|
|
|
//glBufferData(GL_ARRAY_BUFFER, sizeof(float)*2*4*batch->vertexBuffer[batch->currentBuffer].elementsCount, batch->vertexBuffer[batch->currentBuffer].texcoords, GL_DYNAMIC_DRAW); // Update all buffer |
|
|
|
|
|
|
|
// Colors buffer |
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[2]); |
|
|
|
glBufferSubData(GL_ARRAY_BUFFER, 0, k">sizeof(unsigned char)*4*batch->vertexBuffer[batch->currentBuffer].vCounter, batch->vertexBuffer[batch->currentBuffer].colors); |
|
|
|
glBufferSubData(GL_ARRAY_BUFFER, 0, batch->vertexBuffer[batch->currentBuffer].vCounter*4*sizeof(unsigned char), batch->vertexBuffer[batch->currentBuffer].colors); |
|
|
|
//glBufferData(GL_ARRAY_BUFFER, sizeof(float)*4*4*batch->vertexBuffer[batch->currentBuffer].elementsCount, batch->vertexBuffer[batch->currentBuffer].colors, GL_DYNAMIC_DRAW); // Update all buffer |
|
|
|
|
|
|
|
// NOTE: glMapBuffer() causes sync issue. |
|
|
@ -4301,9 +4302,9 @@ static void DrawRenderBatch(RenderBatch *batch) |
|
|
|
// We need to define the number of indices to be processed: quadsCount*6 |
|
|
|
// NOTE: The final parameter tells the GPU the offset in bytes from the |
|
|
|
// start of the index buffer to the location of the first index to process |
|
|
|
glDrawElements(GL_TRIANGLES, batch->draws[i].vertexCount/4*6, GL_UNSIGNED_INT, (GLvoid *)(k">sizeof(GLuint)*vertexOffset/4*6)); |
|
|
|
glDrawElements(GL_TRIANGLES, batch->draws[i].vertexCount/4*6, GL_UNSIGNED_INT, (GLvoid *)(n">vertexOffset/4*6*sizeof(GLuint))); |
|
|
|
#elif defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
glDrawElements(GL_TRIANGLES, batch->draws[i].vertexCount/4*6, GL_UNSIGNED_SHORT, (GLvoid *)(k">sizeof(GLushort)*vertexOffset/4*6)); |
|
|
|
glDrawElements(GL_TRIANGLES, batch->draws[i].vertexCount/4*6, GL_UNSIGNED_SHORT, (GLvoid *)(n">vertexOffset/4*6*sizeof(GLushort))); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
@ -4689,7 +4690,7 @@ char *LoadFileText(const char *fileName) |
|
|
|
|
|
|
|
if (size > 0) |
|
|
|
{ |
|
|
|
text = (char *)RL_MALLOC(k">sizeof(char)*(size + 1)); |
|
|
|
text = (char *)RL_MALLOC(p">(size + 1)*sizeof(char)); |
|
|
|
int count = fread(text, sizeof(char), size, textFile); |
|
|
|
|
|
|
|
// WARNING: \r\n is converted to \n on reading, so, |
|
|
|