[rlgl] introduced rlStartBatch
This commit is contained in:
parent
b185f482d0
commit
9b989c4ac0
7 changed files with 137 additions and 149 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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++)
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
|
|||
// Draw rectangle using rlgl OpenGL 1.1 style coding (translated to OpenGL 3.3 internally)
|
||||
static void DrawRectangleV(Vector2 position, Vector2 size, Color color)
|
||||
{
|
||||
rlBegin(RL_TRIANGLES);
|
||||
rlStartBatch(RL_TRIANGLES, rlGetTextureIdDefault());
|
||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||
|
||||
rlVertex2f(position.x, position.y);
|
||||
|
|
@ -299,7 +299,7 @@ static void DrawGrid(int slices, float spacing)
|
|||
{
|
||||
int halfSlices = slices / 2;
|
||||
|
||||
rlBegin(RL_LINES);
|
||||
rlStartBatch(RL_LINES, rlGetTextureIdDefault());
|
||||
for (int i = -halfSlices; i <= halfSlices; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
|
|
@ -341,7 +341,7 @@ static void DrawCube(Vector3 position, float width, float height, float length,
|
|||
//rlScalef(2.0f, 2.0f, 2.0f);
|
||||
//rlRotatef(45, 0, 1, 0);
|
||||
|
||||
rlBegin(RL_TRIANGLES);
|
||||
rlStartBatch(RL_TRIANGLES, rlGetTextureIdDefault());
|
||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||
|
||||
// Front Face -----------------------------------------------------
|
||||
|
|
@ -413,7 +413,7 @@ static void DrawCubeWires(Vector3 position, float width, float height, float len
|
|||
rlTranslatef(position.x, position.y, position.z);
|
||||
//rlRotatef(45, 0, 1, 0);
|
||||
|
||||
rlBegin(RL_LINES);
|
||||
rlStartBatch(RL_LINES, rlGetTextureIdDefault());
|
||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||
|
||||
// Front Face -----------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -143,10 +143,10 @@ static void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, fl
|
|||
const float angles[4] = { 180.0f, 270.0f, 0.0f, 90.0f };
|
||||
|
||||
#if defined(SUPPORT_QUADS_DRAW_MODE)
|
||||
rlSetTexture(GetShapesTexture().id);
|
||||
Texture texShapes = GetShapesTexture();
|
||||
Rectangle shapeRect = GetShapesTextureRectangle();
|
||||
|
||||
rlBegin(RL_QUADS);
|
||||
rlStartBatch(RL_QUADS, texShapes.id);
|
||||
// Draw all the 4 corners: [1] Upper Left Corner, [3] Upper Right Corner, [5] Lower Right Corner, [7] Lower Left Corner
|
||||
for (int k = 0; k < 4; ++k)
|
||||
{
|
||||
|
|
@ -262,7 +262,7 @@ static void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, fl
|
|||
rlVertex2f(point[9].x, point[9].y);
|
||||
|
||||
rlEnd();
|
||||
rlSetTexture(0);
|
||||
rlEndBatch();
|
||||
#else
|
||||
|
||||
// Here we use the 'Diagram' to guide ourselves to which point receives what color.
|
||||
|
|
@ -270,7 +270,7 @@ static void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, fl
|
|||
// will naturally come from OpenGL interpolation.
|
||||
// But this time instead of Quad, we think in triangles.
|
||||
|
||||
rlBegin(RL_TRIANGLES);
|
||||
rlStartBatch(RL_TRIANGLES, rlGetTextureIdDefault());
|
||||
// Draw all of the 4 corners: [1] Upper Left Corner, [3] Upper Right Corner, [5] Lower Right Corner, [7] Lower Left Corner
|
||||
for (int k = 0; k < 4; ++k)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -488,12 +488,11 @@ static void DrawTextCodepoint3D(Font font, int codepoint, Vector3 position, floa
|
|||
if (SHOW_LETTER_BOUNDRY) DrawCubeWiresV((Vector3){ position.x + width/2, position.y, position.z + height/2}, (Vector3){ width, LETTER_BOUNDRY_SIZE, height }, LETTER_BOUNDRY_COLOR);
|
||||
|
||||
rlCheckRenderBatchLimit(4 + 4*backface);
|
||||
rlSetTexture(font.texture.id);
|
||||
|
||||
rlPushMatrix();
|
||||
rlTranslatef(position.x, position.y, position.z);
|
||||
|
||||
rlBegin(RL_QUADS);
|
||||
rlStartBatch(RL_QUADS, font.texture.id);
|
||||
rlColor4ub(tint.r, tint.g, tint.b, tint.a);
|
||||
|
||||
// Front Face
|
||||
|
|
@ -515,7 +514,7 @@ static void DrawTextCodepoint3D(Font font, int codepoint, Vector3 position, floa
|
|||
rlEnd();
|
||||
rlPopMatrix();
|
||||
|
||||
rlSetTexture(0);
|
||||
rlEndBatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,10 +115,8 @@ int main(void)
|
|||
// without crossing perimeter, points must be in anticlockwise order
|
||||
void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint)
|
||||
{
|
||||
rlBegin(RL_TRIANGLES);
|
||||
rlStartBatch(RL_TRIANGLES, texture.id);
|
||||
|
||||
rlSetTexture(texture.id);
|
||||
|
||||
rlColor4ub(tint.r, tint.g, tint.b, tint.a);
|
||||
|
||||
for (int i = 0; i < pointCount - 1; i++)
|
||||
|
|
@ -134,5 +132,5 @@ void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2
|
|||
}
|
||||
rlEnd();
|
||||
|
||||
rlSetTexture(0);
|
||||
rlEndBatch();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,8 +208,7 @@ static void DrawTexturedCurve(void)
|
|||
Vector2 currentNegNormal = Vector2Add(current, Vector2Scale(normal, -curveWidth));
|
||||
|
||||
// Draw the segment as a quad
|
||||
rlSetTexture(texRoad.id);
|
||||
rlBegin(RL_QUADS);
|
||||
rlStartBatch(RL_QUADS, texRoad.id);
|
||||
rlColor4ub(255,255,255,255);
|
||||
rlNormal3f(0.0f, 0.0f, 1.0f);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue