summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2021-10-12 12:08:12 +0200
committerraysan5 <[email protected]>2021-10-12 12:08:12 +0200
commit4a1bd12e2dbb34ab6aec8de07fe9ee79613234df (patch)
treed0ace97b9e4c6972cc5401929327f80b62402a29 /src
parent282ec9bb76aad9d01d0339180cdd232346ac0728 (diff)
downloadraylib-4a1bd12e2dbb34ab6aec8de07fe9ee79613234df.tar.gz
raylib-4a1bd12e2dbb34ab6aec8de07fe9ee79613234df.zip
REVIEWED: DrawCubeTextureRec() formatting
Diffstat (limited to 'src')
-rw-r--r--src/rmodels.c308
1 files changed, 122 insertions, 186 deletions
diff --git a/src/rmodels.c b/src/rmodels.c
index 2069aaab..9cba9453 100644
--- a/src/rmodels.c
+++ b/src/rmodels.c
@@ -341,57 +341,57 @@ void DrawCubeWires(Vector3 position, float width, float height, float length, Co
rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a);
- // Front Face -----------------------------------------------------
- // Bottom Line
- rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
- rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
-
- // Left Line
- rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
- rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right
-
- // Top Line
- rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right
- rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
-
- // Right Line
- rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
- rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
-
- // Back Face ------------------------------------------------------
- // Bottom Line
- rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left
- rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
-
- // Left Line
- rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
- rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
-
- // Top Line
- rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
- rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
-
- // Right Line
- rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
- rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left
-
- // Top Face -------------------------------------------------------
- // Left Line
- rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left Front
- rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left Back
-
- // Right Line
- rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right Front
- rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right Back
-
- // Bottom Face ---------------------------------------------------
- // Left Line
- rlVertex3f(x-width/2, y-height/2, z+length/2); // Top Left Front
- rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left Back
-
- // Right Line
- rlVertex3f(x+width/2, y-height/2, z+length/2); // Top Right Front
- rlVertex3f(x+width/2, y-height/2, z-length/2); // Top Right Back
+ // Front face -----------------------------------------------------
+ // Bottom line
+ rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom left
+ rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom right
+
+ // Left line
+ rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom right
+ rlVertex3f(x+width/2, y+height/2, z+length/2); // Top right
+
+ // Top line
+ rlVertex3f(x+width/2, y+height/2, z+length/2); // Top right
+ rlVertex3f(x-width/2, y+height/2, z+length/2); // Top left
+
+ // Right line
+ rlVertex3f(x-width/2, y+height/2, z+length/2); // Top left
+ rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom left
+
+ // Back face ------------------------------------------------------
+ // Bottom line
+ rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom left
+ rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom right
+
+ // Left line
+ rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom right
+ rlVertex3f(x+width/2, y+height/2, z-length/2); // Top right
+
+ // Top line
+ rlVertex3f(x+width/2, y+height/2, z-length/2); // Top right
+ rlVertex3f(x-width/2, y+height/2, z-length/2); // Top left
+
+ // Right line
+ rlVertex3f(x-width/2, y+height/2, z-length/2); // Top left
+ rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom left
+
+ // Top face -------------------------------------------------------
+ // Left line
+ rlVertex3f(x-width/2, y+height/2, z+length/2); // Top left front
+ rlVertex3f(x-width/2, y+height/2, z-length/2); // Top left back
+
+ // Right line
+ rlVertex3f(x+width/2, y+height/2, z+length/2); // Top right front
+ rlVertex3f(x+width/2, y+height/2, z-length/2); // Top right back
+
+ // Bottom face ---------------------------------------------------
+ // Left line
+ rlVertex3f(x-width/2, y-height/2, z+length/2); // Top left front
+ rlVertex3f(x-width/2, y-height/2, z-length/2); // Top left back
+
+ // Right line
+ rlVertex3f(x+width/2, y-height/2, z+length/2); // Top right front
+ rlVertex3f(x+width/2, y-height/2, z-length/2); // Top right back
rlEnd();
rlPopMatrix();
}
@@ -464,153 +464,89 @@ void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float hei
rlSetTexture(0);
}
+// Draw cube with texture piece applied to all faces
void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color)
{
float x = position.x;
float y = position.y;
float z = position.z;
- float texture_width = (float)texture.width;
- float texture_height = (float)texture.height;
+ float texWidth = (float)texture.width;
+ float texHeight = (float)texture.height;
rlCheckRenderBatchLimit(36);
rlSetTexture(texture.id);
- rlBegin(RL_QUADS);
- rlColor4ub(color.r, color.g, color.b, color.a);
-
- // Front Face
- {
- // Normal Pointing Towards Viewer
- rlNormal3f(0.0f, 0.0f, 1.0f);
-
- // Bottom Left Of The Texture and Quad
- rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
- rlVertex3f(x - width/2, y - height/2, z + length/2);
-
- // Bottom Right Of The Texture and Quad
- rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
- rlVertex3f(x + width/2, y - height/2, z + length/2);
-
- // Top Right Of The Texture and Quad
- rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
- rlVertex3f(x + width/2, y + height/2, z + length/2);
-
- // Top Left Of The Texture and Quad
- rlTexCoord2f(source.x / texture_width, source.y / texture_height);
- rlVertex3f(x - width/2, y + height/2, z + length/2);
- }
-
- // Back Face
- {
- // Normal Pointing Away From Viewer
- rlNormal3f(0.0f, 0.0f, - 1.0f);
-
- // Bottom Right Of The Texture and Quad
- rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
- rlVertex3f(x - width/2, y - height/2, z - length/2);
-
- // Top Right Of The Texture and Quad
- rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
- rlVertex3f(x - width/2, y + height/2, z - length/2);
-
- // Top Left Of The Texture and Quad
- rlTexCoord2f(source.x / texture_width, source.y / texture_height);
- rlVertex3f(x + width/2, y + height/2, z - length/2);
-
- // Bottom Left Of The Texture and Quad
- rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
- rlVertex3f(x + width/2, y - height/2, z - length/2);
- }
-
- // Top Face
- {
- // Normal Pointing Up
- rlNormal3f(0.0f, 1.0f, 0.0f);
-
- // Top Left Of The Texture and Quad
- rlTexCoord2f(source.x / texture_width, source.y / texture_height);
- rlVertex3f(x - width/2, y + height/2, z - length/2);
-
- // Bottom Left Of The Texture and Quad
- rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
- rlVertex3f(x - width/2, y + height/2, z + length/2);
-
- // Bottom Right Of The Texture and Quad
- rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
- rlVertex3f(x + width/2, y + height/2, z + length/2);
-
- // Top Right Of The Texture and Quad
- rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
- rlVertex3f(x + width/2, y + height/2, z - length/2);
- }
-
- // Bottom Face
- {
- // Normal Pointing Down
- rlNormal3f(0.0f, - 1.0f, 0.0f);
-
- // Top Right Of The Texture and Quad
- rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
- rlVertex3f(x - width/2, y - height/2, z - length/2);
-
- // Top Left Of The Texture and Quad
- rlTexCoord2f(source.x / texture_width, source.y / texture_height);
- rlVertex3f(x + width/2, y - height/2, z - length/2);
-
- // Bottom Left Of The Texture and Quad
- rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
- rlVertex3f(x + width/2, y - height/2, z + length/2);
-
- // Bottom Right Of The Texture and Quad
- rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
- rlVertex3f(x - width/2, y - height/2, z + length/2);
- }
-
- // Right face
- {
- // Normal Pointing Right
- rlNormal3f(1.0f, 0.0f, 0.0f);
-
- // Bottom Right Of The Texture and Quad
- rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
- rlVertex3f(x + width/2, y - height/2, z - length/2);
-
- // Top Right Of The Texture and Quad
- rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
- rlVertex3f(x + width/2, y + height/2, z - length/2);
-
- // Top Left Of The Texture and Quad
- rlTexCoord2f(source.x / texture_width, source.y / texture_height);
- rlVertex3f(x + width/2, y + height/2, z + length/2);
-
- // Bottom Left Of The Texture and Quad
- rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
- rlVertex3f(x + width/2, y - height/2, z + length/2);
- }
-
- // Left Face
- {
- // Normal Pointing Left
- rlNormal3f( - 1.0f, 0.0f, 0.0f);
-
- // Bottom Left Of The Texture and Quad
- rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
- rlVertex3f(x - width/2, y - height/2, z - length/2);
-
- // Bottom Right Of The Texture and Quad
- rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
- rlVertex3f(x - width/2, y - height/2, z + length/2);
+ rlBegin(RL_QUADS);
+ rlColor4ub(color.r, color.g, color.b, color.a);
- // Top Right Of The Texture and Quad
- rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
- rlVertex3f(x - width/2, y + height/2, z + length/2);
+ // Front face
+ rlNormal3f(0.0f, 0.0f, 1.0f);
+ rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x - width/2, y - height/2, z + length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x + width/2, y - height/2, z + length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
+ rlVertex3f(x + width/2, y + height/2, z + length/2);
+ rlTexCoord2f(source.x/texWidth, source.y/texHeight);
+ rlVertex3f(x - width/2, y + height/2, z + length/2);
+
+ // Back face
+ rlNormal3f(0.0f, 0.0f, - 1.0f);
+ rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x - width/2, y - height/2, z - length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
+ rlVertex3f(x - width/2, y + height/2, z - length/2);
+ rlTexCoord2f(source.x/texWidth, source.y/texHeight);
+ rlVertex3f(x + width/2, y + height/2, z - length/2);
+ rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x + width/2, y - height/2, z - length/2);
+
+ // Top face
+ rlNormal3f(0.0f, 1.0f, 0.0f);
+ rlTexCoord2f(source.x/texWidth, source.y/texHeight);
+ rlVertex3f(x - width/2, y + height/2, z - length/2);
+ rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x - width/2, y + height/2, z + length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x + width/2, y + height/2, z + length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
+ rlVertex3f(x + width/2, y + height/2, z - length/2);
+
+ // Bottom face
+ rlNormal3f(0.0f, - 1.0f, 0.0f);
+ rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
+ rlVertex3f(x - width/2, y - height/2, z - length/2);
+ rlTexCoord2f(source.x/texWidth, source.y/texHeight);
+ rlVertex3f(x + width/2, y - height/2, z - length/2);
+ rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x + width/2, y - height/2, z + length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x - width/2, y - height/2, z + length/2);
+
+ // Right face
+ rlNormal3f(1.0f, 0.0f, 0.0f);
+ rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x + width/2, y - height/2, z - length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
+ rlVertex3f(x + width/2, y + height/2, z - length/2);
+ rlTexCoord2f(source.x/texWidth, source.y/texHeight);
+ rlVertex3f(x + width/2, y + height/2, z + length/2);
+ rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x + width/2, y - height/2, z + length/2);
+
+ // Left face
+ rlNormal3f( - 1.0f, 0.0f, 0.0f);
+ rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x - width/2, y - height/2, z - length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
+ rlVertex3f(x - width/2, y - height/2, z + length/2);
+ rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
+ rlVertex3f(x - width/2, y + height/2, z + length/2);
+ rlTexCoord2f(source.x/texWidth, source.y/texHeight);
+ rlVertex3f(x - width/2, y + height/2, z - length/2);
- // Top Left Of The Texture and Quad
- rlTexCoord2f(source.x / texture_width, source.y / texture_height);
- rlVertex3f(x - width/2, y + height/2, z - length/2);
- }
- rlEnd();
+ rlEnd();
rlSetTexture(0);
}