Browse Source

Corrected issue with MSAA

Ray 6 years ago
parent
commit
fcb2b74342
1 changed files with 9 additions and 7 deletions
  1. 9 7
      src/shapes.c

+ 9 - 7
src/shapes.c

@@ -442,7 +442,7 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col
         rlTranslatef(center.x, center.y, 0.0);
         rlTranslatef(center.x, center.y, 0.0);
         rlRotatef(rotation, 0, 0, 1);
         rlRotatef(rotation, 0, 0, 1);
 
 
-    #if defined(SUPPORT_QUADS_DRAW_MODE)
+#if defined(SUPPORT_QUADS_DRAW_MODE)
         rlEnableTexture(GetShapesTexture().id);
         rlEnableTexture(GetShapesTexture().id);
 
 
         rlBegin(RL_QUADS);
         rlBegin(RL_QUADS);
@@ -464,7 +464,7 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col
             }
             }
         rlEnd();
         rlEnd();
         rlDisableTexture();
         rlDisableTexture();
-    #else
+#else
         rlBegin(RL_TRIANGLES);
         rlBegin(RL_TRIANGLES);
             for (int i = 0; i < 360; i += 360/sides)
             for (int i = 0; i < 360; i += 360/sides)
             {
             {
@@ -475,7 +475,7 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col
                 rlVertex2f(sinf(DEG2RAD*(i + 360/sides))*radius, cosf(DEG2RAD*(i + 360/sides))*radius);
                 rlVertex2f(sinf(DEG2RAD*(i + 360/sides))*radius, cosf(DEG2RAD*(i + 360/sides))*radius);
             }
             }
         rlEnd();
         rlEnd();
-    #endif
+#endif
     rlPopMatrix();
     rlPopMatrix();
 }
 }
 
 
@@ -486,7 +486,7 @@ void DrawPolyEx(Vector2 *points, int pointsCount, Color color)
     {
     {
         if (rlCheckBufferLimit(RL_QUADS, pointsCount)) rlglDraw();
         if (rlCheckBufferLimit(RL_QUADS, pointsCount)) rlglDraw();
 
 
-    #if defined(SUPPORT_QUADS_DRAW_MODE)
+#if defined(SUPPORT_QUADS_DRAW_MODE)
         rlEnableTexture(GetShapesTexture().id);
         rlEnableTexture(GetShapesTexture().id);
 
 
         rlBegin(RL_QUADS);
         rlBegin(RL_QUADS);
@@ -501,7 +501,7 @@ void DrawPolyEx(Vector2 *points, int pointsCount, Color color)
             }
             }
         rlEnd();
         rlEnd();
         rlDisableTexture();
         rlDisableTexture();
-    #else
+#else
         rlBegin(RL_TRIANGLES);
         rlBegin(RL_TRIANGLES);
             rlColor4ub(color.r, color.g, color.b, color.a);
             rlColor4ub(color.r, color.g, color.b, color.a);
 
 
@@ -512,7 +512,7 @@ void DrawPolyEx(Vector2 *points, int pointsCount, Color color)
                 rlVertex2f(points[i + 1].x, points[i + 1].y);
                 rlVertex2f(points[i + 1].x, points[i + 1].y);
             }
             }
         rlEnd();
         rlEnd();
-    #endif
+#endif
     }
     }
 }
 }
 
 
@@ -716,7 +716,9 @@ static Texture2D GetShapesTexture(void)
     {
     {
 #if defined(SUPPORT_FONT_TEXTURE)
 #if defined(SUPPORT_FONT_TEXTURE)
         texShapes = GetFontDefault().texture;           // Use font texture white character
         texShapes = GetFontDefault().texture;           // Use font texture white character
-        recTexShapes = GetFontDefault().chars[95].rec;
+        Rectangle rec = GetFontDefault().chars[95].rec;
+        // NOTE: We setup a 1px padding on char rectangle to avoid texture bleeding on MSAA filtering
+        recTexShapes = (Rectangle){ rec.x + 1, rec.y + 1, rec.width - 2, rec.height - 2 };
 #else
 #else
         texShapes = GetTextureDefault();                // Use default white texture
         texShapes = GetTextureDefault();                // Use default white texture
         recTexShapes = { 0.0f, 0.0f, 1.0f, 1.0f };
         recTexShapes = { 0.0f, 0.0f, 1.0f, 1.0f };