summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2022-11-15 12:16:28 +0100
committerRay <[email protected]>2022-11-15 12:16:28 +0100
commitfadc29d811de346218b4d03a41e3d90904043bd6 (patch)
tree275cc83db29c67e721ddf6b2be139501444b1d55
parent4bb71c8fa2e4965bf416f5dbf5838284cdf8a333 (diff)
downloadraylib-fadc29d811de346218b4d03a41e3d90904043bd6.tar.gz
raylib-fadc29d811de346218b4d03a41e3d90904043bd6.zip
WARNING: REMOVED: `DrawCubeTexture()`, `DrawCubeTextureRec()`
Those two functions have been moved to a new example: `models_draw_cube_texture`. The reasons for this decision: - Function inflexibility: Many users with the need to draw a textured cube could need to customize the texture applied to every face, that function did not allow that kind of functionality. - rlgl functionality exposure: The implementation exposed will teach users how to implement custom textured triangles drawing.
-rw-r--r--examples/models/models_draw_cube_texture.c245
-rw-r--r--examples/models/models_draw_cube_texture.pngbin0 -> 63170 bytes
-rw-r--r--src/raylib.h2
-rw-r--r--src/rmodels.c145
4 files changed, 245 insertions, 147 deletions
diff --git a/examples/models/models_draw_cube_texture.c b/examples/models/models_draw_cube_texture.c
new file mode 100644
index 00000000..b36e968f
--- /dev/null
+++ b/examples/models/models_draw_cube_texture.c
@@ -0,0 +1,245 @@
+/*******************************************************************************************
+*
+* raylib [models] example - Draw textured cube
+*
+* Example originally created with raylib 4.5, last time updated with raylib 4.5
+*
+* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
+* BSD-like license that allows static linking with closed source software
+*
+* Copyright (c) 2022 Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#include "rlgl.h" // Required to define vertex data (immediate-mode style)
+
+//------------------------------------------------------------------------------------
+// Custom Functions Declaration
+//------------------------------------------------------------------------------------
+void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color); // Draw cube textured
+void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color); // Draw cube with a region of a texture
+
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
+int main(void)
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ const int screenWidth = 800;
+ const int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [models] example - draw cube texture");
+
+ // Define the camera to look into our 3d world
+ Camera camera = { 0 };
+ camera.position = (Vector3){ 0.0f, 10.0f, 10.0f };
+ camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
+ camera.fovy = 45.0f;
+ camera.projection = CAMERA_PERSPECTIVE;
+
+ // Load texture to be applied to the cubes sides
+ Texture2D texture = LoadTexture("resources/cubicmap_atlas.png");
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ // TODO: Update your variables here
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ BeginMode3D(camera);
+
+ // Draw cube with an applied texture
+ DrawCubeTexture(texture, (Vector3){ -2.0f, 2.0f, 0.0f }, 2.0f, 4.0f, 2.0f, WHITE);
+
+ // Draw cube with an applied texture, but only a defined rectangle piece of the texture
+ DrawCubeTextureRec(texture, (Rectangle){ 0, texture.height/2, texture.width/2, texture.height/2 },
+ (Vector3){ 2.0f, 1.0f, 0.0f }, 2.0f, 2.0f, 2.0f, WHITE);
+
+ DrawGrid(10, 1.0f); // Draw a grid
+
+ EndMode3D();
+
+ DrawFPS(10, 10);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadTexture(texture); // Unload texture
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------------
+// Custom Functions Definition
+//------------------------------------------------------------------------------------
+// Draw cube textured
+// NOTE: Cube position is the center position
+void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color)
+{
+ float x = position.x;
+ 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()
+ //rlPushMatrix();
+ // NOTE: Transformation is applied in inverse order (scale -> rotate -> translate)
+ //rlTranslatef(2.0f, 0.0f, 0.0f);
+ //rlRotatef(45, 0, 1, 0);
+ //rlScalef(2.0f, 2.0f, 2.0f);
+
+ rlBegin(RL_QUADS);
+ rlColor4ub(color.r, color.g, color.b, color.a);
+ // Front Face
+ rlNormal3f(0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer
+ rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom Left Of The Texture and Quad
+ rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z + length/2); // Bottom Right Of The Texture and Quad
+ rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z + length/2); // Top Right Of The Texture and Quad
+ rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z + length/2); // Top Left Of The Texture and Quad
+ // Back Face
+ rlNormal3f(0.0f, 0.0f, - 1.0f); // Normal Pointing Away From Viewer
+ rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z - length/2); // Bottom Right Of The Texture and Quad
+ rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z - length/2); // Top Right Of The Texture and Quad
+ rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z - length/2); // Top Left Of The Texture and Quad
+ rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z - length/2); // Bottom Left Of The Texture and Quad
+ // Top Face
+ rlNormal3f(0.0f, 1.0f, 0.0f); // Normal Pointing Up
+ rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z - length/2); // Top Left Of The Texture and Quad
+ rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x - width/2, y + height/2, z + length/2); // Bottom Left Of The Texture and Quad
+ rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x + width/2, y + height/2, z + length/2); // Bottom Right Of The Texture and Quad
+ rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z - length/2); // Top Right Of The Texture and Quad
+ // Bottom Face
+ rlNormal3f(0.0f, - 1.0f, 0.0f); // Normal Pointing Down
+ rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x - width/2, y - height/2, z - length/2); // Top Right Of The Texture and Quad
+ rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x + width/2, y - height/2, z - length/2); // Top Left Of The Texture and Quad
+ rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z + length/2); // Bottom Left Of The Texture and Quad
+ rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom Right Of The Texture and Quad
+ // Right face
+ rlNormal3f(1.0f, 0.0f, 0.0f); // Normal Pointing Right
+ rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z - length/2); // Bottom Right Of The Texture and Quad
+ rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z - length/2); // Top Right Of The Texture and Quad
+ rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z + length/2); // Top Left Of The Texture and Quad
+ rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z + length/2); // Bottom Left Of The Texture and Quad
+ // Left Face
+ rlNormal3f( - 1.0f, 0.0f, 0.0f); // Normal Pointing Left
+ rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z - length/2); // Bottom Left Of The Texture and Quad
+ rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom Right Of The Texture and Quad
+ rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z + length/2); // Top Right Of The Texture and Quad
+ rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z - length/2); // Top Left Of The Texture and Quad
+ rlEnd();
+ //rlPopMatrix();
+
+ 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 texWidth = (float)texture.width;
+ 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);
+ rlColor4ub(color.r, color.g, color.b, color.a);
+
+ // 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);
+
+ rlEnd();
+
+ rlSetTexture(0);
+} \ No newline at end of file
diff --git a/examples/models/models_draw_cube_texture.png b/examples/models/models_draw_cube_texture.png
new file mode 100644
index 00000000..45b3a13d
--- /dev/null
+++ b/examples/models/models_draw_cube_texture.png
Binary files differ
diff --git a/src/raylib.h b/src/raylib.h
index bebd3e01..1abce717 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -1412,8 +1412,6 @@ RLAPI void DrawCube(Vector3 position, float width, float height, float length, C
RLAPI void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version)
RLAPI void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires
RLAPI void DrawCubeWiresV(Vector3 position, Vector3 size, Color color); // Draw cube wires (Vector version)
-RLAPI void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color); // Draw cube textured
-RLAPI void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color); // Draw cube with a region of a texture
RLAPI void DrawSphere(Vector3 centerPos, float radius, Color color); // Draw sphere
RLAPI void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere with extended parameters
RLAPI void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere wires
diff --git a/src/rmodels.c b/src/rmodels.c
index 2ca5ef09..290d6e29 100644
--- a/src/rmodels.c
+++ b/src/rmodels.c
@@ -397,151 +397,6 @@ void DrawCubeWiresV(Vector3 position, Vector3 size, Color color)
DrawCubeWires(position, size.x, size.y, size.z, color);
}
-// Draw cube
-// NOTE: Cube position is the center position
-void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color)
-{
- float x = position.x;
- float y = position.y;
- float z = position.z;
-
- rlSetTexture(texture.id);
-
- //rlPushMatrix();
- // NOTE: Transformation is applied in inverse order (scale -> rotate -> translate)
- //rlTranslatef(2.0f, 0.0f, 0.0f);
- //rlRotatef(45, 0, 1, 0);
- //rlScalef(2.0f, 2.0f, 2.0f);
-
- rlBegin(RL_QUADS);
- rlColor4ub(color.r, color.g, color.b, color.a);
- // Front Face
- rlNormal3f(0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer
- rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom Left Of The Texture and Quad
- rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z + length/2); // Bottom Right Of The Texture and Quad
- rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z + length/2); // Top Right Of The Texture and Quad
- rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z + length/2); // Top Left Of The Texture and Quad
- // Back Face
- rlNormal3f(0.0f, 0.0f, - 1.0f); // Normal Pointing Away From Viewer
- rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z - length/2); // Bottom Right Of The Texture and Quad
- rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z - length/2); // Top Right Of The Texture and Quad
- rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z - length/2); // Top Left Of The Texture and Quad
- rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z - length/2); // Bottom Left Of The Texture and Quad
- // Top Face
- rlNormal3f(0.0f, 1.0f, 0.0f); // Normal Pointing Up
- rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z - length/2); // Top Left Of The Texture and Quad
- rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x - width/2, y + height/2, z + length/2); // Bottom Left Of The Texture and Quad
- rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x + width/2, y + height/2, z + length/2); // Bottom Right Of The Texture and Quad
- rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z - length/2); // Top Right Of The Texture and Quad
- // Bottom Face
- rlNormal3f(0.0f, - 1.0f, 0.0f); // Normal Pointing Down
- rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x - width/2, y - height/2, z - length/2); // Top Right Of The Texture and Quad
- rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x + width/2, y - height/2, z - length/2); // Top Left Of The Texture and Quad
- rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z + length/2); // Bottom Left Of The Texture and Quad
- rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom Right Of The Texture and Quad
- // Right face
- rlNormal3f(1.0f, 0.0f, 0.0f); // Normal Pointing Right
- rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z - length/2); // Bottom Right Of The Texture and Quad
- rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z - length/2); // Top Right Of The Texture and Quad
- rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x + width/2, y + height/2, z + length/2); // Top Left Of The Texture and Quad
- rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x + width/2, y - height/2, z + length/2); // Bottom Left Of The Texture and Quad
- // Left Face
- rlNormal3f( - 1.0f, 0.0f, 0.0f); // Normal Pointing Left
- rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z - length/2); // Bottom Left Of The Texture and Quad
- rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom Right Of The Texture and Quad
- rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z + length/2); // Top Right Of The Texture and Quad
- rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x - width/2, y + height/2, z - length/2); // Top Left Of The Texture and Quad
- rlEnd();
- //rlPopMatrix();
-
- 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 texWidth = (float)texture.width;
- float texHeight = (float)texture.height;
-
- rlSetTexture(texture.id);
-
- rlBegin(RL_QUADS);
- rlColor4ub(color.r, color.g, color.b, color.a);
-
- // 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);
-
- rlEnd();
-
- rlSetTexture(0);
-}
-
// Draw sphere
void DrawSphere(Vector3 centerPos, float radius, Color color)
{