@@ -3492,7 +3492,7 @@ void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector
34923492void DrawBillboardPro (Camera camera , Texture2D texture , Rectangle source , Vector3 position , Vector3 up , Vector2 size , Vector2 origin , float rotation , Color tint )
34933493{
34943494 // NOTE: Billboard size will maintain source rectangle aspect ratio, size will represent billboard width
3495- Vector2 sizeRatio = { size .x * ( float )source .width /source .height , size .y };
3495+ Vector2 sizeRatio = { size .x * fabsf (( float )source .width /source .height ) , size .y };
34963496
34973497 Matrix matView = MatrixLookAt (camera .position , camera .target , camera .up );
34983498
@@ -3558,21 +3558,40 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
35583558 rlBegin (RL_QUADS );
35593559 rlColor4ub (tint .r , tint .g , tint .b , tint .a );
35603560
3561- // Bottom-left corner for texture and quad
3562- rlTexCoord2f ((float )source .x /texture .width , (float )source .y /texture .height );
3563- rlVertex3f (topLeft .x , topLeft .y , topLeft .z );
3561+ if (sizeRatio .x * sizeRatio .y >= 0.0f )
3562+ {
3563+ // Bottom-left corner for texture and quad
3564+ rlTexCoord2f ((float )source .x /texture .width , (float )source .y /texture .height );
3565+ rlVertex3f (topLeft .x , topLeft .y , topLeft .z );
3566+
3567+ // Top-left corner for texture and quad
3568+ rlTexCoord2f ((float )source .x /texture .width , (float )(source .y + source .height )/texture .height );
3569+ rlVertex3f (bottomLeft .x , bottomLeft .y , bottomLeft .z );
35643570
3565- // Top-left corner for texture and quad
3566- rlTexCoord2f ((float )source .x /texture .width , (float )(source .y + source .height )/texture .height );
3567- rlVertex3f (bottomLeft .x , bottomLeft .y , bottomLeft .z );
3571+ // Top-right corner for texture and quad
3572+ rlTexCoord2f ((float )( source .x + source . width ) /texture .width , (float )(source .y + source .height )/texture .height );
3573+ rlVertex3f (bottomRight .x , bottomRight .y , bottomRight .z );
35683574
3569- // Top-right corner for texture and quad
3570- rlTexCoord2f ((float )(source .x + source .width )/texture .width , (float )(source .y + source .height )/texture .height );
3571- rlVertex3f (bottomRight .x , bottomRight .y , bottomRight .z );
3575+ // Bottom-right corner for texture and quad
3576+ rlTexCoord2f ((float )(source .x + source .width )/texture .width , (float )source .y /texture .height );
3577+ rlVertex3f (topRight .x , topRight .y , topRight .z );
3578+ }
3579+ else
3580+ {
3581+ // Reverse vertex order if the size has only one negative dimension
3582+ rlTexCoord2f ((float )(source .x + source .width )/texture .width , (float )source .y /texture .height );
3583+ rlVertex3f (topRight .x , topRight .y , topRight .z );
3584+
3585+ rlTexCoord2f ((float )(source .x + source .width )/texture .width , (float )(source .y + source .height )/texture .height );
3586+ rlVertex3f (bottomRight .x , bottomRight .y , bottomRight .z );
3587+
3588+ rlTexCoord2f ((float )source .x /texture .width , (float )(source .y + source .height )/texture .height );
3589+ rlVertex3f (bottomLeft .x , bottomLeft .y , bottomLeft .z );
3590+
3591+ rlTexCoord2f ((float )source .x /texture .width , (float )source .y /texture .height );
3592+ rlVertex3f (topLeft .x , topLeft .y , topLeft .z );
3593+ }
35723594
3573- // Bottom-right corner for texture and quad
3574- rlTexCoord2f ((float )(source .x + source .width )/texture .width , (float )source .y /texture .height );
3575- rlVertex3f (topRight .x , topRight .y , topRight .z );
35763595 rlEnd ();
35773596
35783597 rlSetTexture (0 );
0 commit comments