aboutsummaryrefslogtreecommitdiff
path: root/src/textures.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/textures.c')
-rw-r--r--src/textures.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/src/textures.c b/src/textures.c
index 439311f6..8c59f3f2 100644
--- a/src/textures.c
+++ b/src/textures.c
@@ -1394,39 +1394,43 @@ void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, Co
// NOTE: origin is relative to destination rectangle size
void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, Vector2 origin, float rotation, Color tint)
{
- if (sourceRec.width < 0) sourceRec.x -= sourceRec.width;
- if (sourceRec.height < 0) sourceRec.y -= sourceRec.height;
-
- rlEnableTexture(texture.id);
+ // Check if texture is valid
+ if (texture.id != 0)
+ {
+ if (sourceRec.width < 0) sourceRec.x -= sourceRec.width;
+ if (sourceRec.height < 0) sourceRec.y -= sourceRec.height;
+
+ rlEnableTexture(texture.id);
- rlPushMatrix();
- rlTranslatef(destRec.x, destRec.y, 0);
- rlRotatef(rotation, 0, 0, 1);
- rlTranslatef(-origin.x, -origin.y, 0);
+ rlPushMatrix();
+ rlTranslatef(destRec.x, destRec.y, 0);
+ rlRotatef(rotation, 0, 0, 1);
+ rlTranslatef(-origin.x, -origin.y, 0);
- rlBegin(RL_QUADS);
- rlColor4ub(tint.r, tint.g, tint.b, tint.a);
- rlNormal3f(0.0f, 0.0f, 1.0f); // Normal vector pointing towards viewer
+ rlBegin(RL_QUADS);
+ rlColor4ub(tint.r, tint.g, tint.b, tint.a);
+ rlNormal3f(0.0f, 0.0f, 1.0f); // Normal vector pointing towards viewer
- // Bottom-left corner for texture and quad
- rlTexCoord2f((float)sourceRec.x / texture.width, (float)sourceRec.y / texture.height);
- rlVertex2f(0.0f, 0.0f);
+ // Bottom-left corner for texture and quad
+ rlTexCoord2f((float)sourceRec.x / texture.width, (float)sourceRec.y / texture.height);
+ rlVertex2f(0.0f, 0.0f);
- // Bottom-right corner for texture and quad
- rlTexCoord2f((float)sourceRec.x / texture.width, (float)(sourceRec.y + sourceRec.height) / texture.height);
- rlVertex2f(0.0f, destRec.height);
+ // Bottom-right corner for texture and quad
+ rlTexCoord2f((float)sourceRec.x / texture.width, (float)(sourceRec.y + sourceRec.height) / texture.height);
+ rlVertex2f(0.0f, destRec.height);
- // Top-right corner for texture and quad
- rlTexCoord2f((float)(sourceRec.x + sourceRec.width) / texture.width, (float)(sourceRec.y + sourceRec.height) / texture.height);
- rlVertex2f(destRec.width, destRec.height);
+ // Top-right corner for texture and quad
+ rlTexCoord2f((float)(sourceRec.x + sourceRec.width) / texture.width, (float)(sourceRec.y + sourceRec.height) / texture.height);
+ rlVertex2f(destRec.width, destRec.height);
- // Top-left corner for texture and quad
- rlTexCoord2f((float)(sourceRec.x + sourceRec.width) / texture.width, (float)sourceRec.y / texture.height);
- rlVertex2f(destRec.width, 0.0f);
- rlEnd();
- rlPopMatrix();
+ // Top-left corner for texture and quad
+ rlTexCoord2f((float)(sourceRec.x + sourceRec.width) / texture.width, (float)sourceRec.y / texture.height);
+ rlVertex2f(destRec.width, 0.0f);
+ rlEnd();
+ rlPopMatrix();
- rlDisableTexture();
+ rlDisableTexture();
+ }
}
//----------------------------------------------------------------------------------