diff options
| author | Ray <[email protected]> | 2023-06-28 00:37:24 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2023-06-28 00:37:24 +0200 |
| commit | ceafbcf9d2d722886c40d0ba12eaad2f232a2782 (patch) | |
| tree | e55a06259e1327447f71e24959e151d1b2af4e66 /src | |
| parent | 5834e970ebb50edc95cb5b5dbc6dd772f99c366f (diff) | |
| download | raylib-ceafbcf9d2d722886c40d0ba12eaad2f232a2782.tar.gz raylib-ceafbcf9d2d722886c40d0ba12eaad2f232a2782.zip | |
REVIEWED: `SetShapesTexture()`, allow reseting
Diffstat (limited to 'src')
| -rw-r--r-- | src/rshapes.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/rshapes.c b/src/rshapes.c index 27888642..d726ff0e 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -80,7 +80,7 @@ //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- -Texture2D texShapes = { 1, 1, 1, 1, 7 }; // Texture used on shapes drawing (usually a white pixel) +Texture2D texShapes = { 1, 1, 1, 1, 7 }; // Texture used on shapes drawing (white pixel loaded by rlgl) Rectangle texShapesRec = { 0.0f, 0.0f, 1.0f, 1.0f }; // Texture source rectangle used on shapes drawing //---------------------------------------------------------------------------------- @@ -97,8 +97,19 @@ static float EaseCubicInOut(float t, float b, float c, float d); // Cubic eas // defining a font char white rectangle would allow drawing everything in a single draw call void SetShapesTexture(Texture2D texture, Rectangle source) { - texShapes = texture; - texShapesRec = source; + // Reset texture to default pixel if required + // WARNING: Shapes texture should be probably better validated, + // it can break the rendering of all shapes if missused + if ((texture.id == 0) || (source.width == 0) || (source.height == 0)) + { + texShapes = (Texture2D){ 1, 1, 1, 1, 7 }; + texShapesRec = (Rectangle){ 0.0f, 0.0f, 1.0f, 1.0f }; + } + else + { + texShapes = texture; + texShapesRec = source; + } } // Draw a pixel |
