[rlgl] introduced rlStartBatch

This commit is contained in:
Bruno Cabral 2025-04-20 10:10:10 -07:00
commit 9b989c4ac0
2 changed files with 137 additions and 149 deletions

View file

@ -103,8 +103,6 @@ void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float hei
float y = position.y;
float z = position.z;
// Set desired texture to be enabled while drawing following vertex data
rlSetTexture(texture.id);
// Vertex data transformation can be defined with the commented lines,
// but in this example we calculate the transformed vertex data directly when calling rlVertex3f()
@ -114,7 +112,8 @@ void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float hei
//rlRotatef(45, 0, 1, 0);
//rlScalef(2.0f, 2.0f, 2.0f);
rlBegin(RL_QUADS);
// Set desired texture to be enabled while drawing following vertex data
rlStartBatch(RL_QUADS, texture.id);
rlColor4ub(color.r, color.g, color.b, color.a);
// Front Face
rlNormal3f(0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer
@ -155,7 +154,7 @@ void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float hei
rlEnd();
//rlPopMatrix();
rlSetTexture(0);
rlEndBatch();
}
// Draw cube with texture piece applied to all faces
@ -168,11 +167,9 @@ void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, f
float texHeight = (float)texture.height;
// Set desired texture to be enabled while drawing following vertex data
rlSetTexture(texture.id);
// We calculate the normalized texture coordinates for the desired texture-source-rectangle
// It means converting from (tex.width, tex.height) coordinates to [0.0f, 1.0f] equivalent
rlBegin(RL_QUADS);
rlStartBatch(RL_QUADS, texture.id);
// We calculate the normalized texture coordinates for the desired texture-source-rectangle
// It means converting from (tex.width, tex.height) coordinates to [0.0f, 1.0f] equivalent
rlColor4ub(color.r, color.g, color.b, color.a);
// Front face
@ -243,5 +240,5 @@ void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, f
rlEnd();
rlSetTexture(0);
rlEndBatch();
}

View file

@ -142,7 +142,7 @@ void DrawSphereBasic(Color color)
// buffer to store all required vertex, batch is reseted if required
rlCheckRenderBatchLimit((rings + 2)*slices*6);
rlBegin(RL_TRIANGLES);
rlStartBatch(RL_TRIANGLES, rlGetTextureIdDefault());
rlColor4ub(color.r, color.g, color.b, color.a);
for (int i = 0; i < (rings + 2); i++)