pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
766 stars 120 forks source link

_sdl2.video.Renderer.fill_triangle, .fill_quad not respecting logical_size, unlike their draw_* counterparts #2923

Open ImNotMeAnymore opened 2 weeks ago

ImNotMeAnymore commented 2 weeks ago

Environment: OS: Pop_OS 22.04 LTS pygame-ce version: 2.4.1 python version: 3.12.2

Current behavior: If you change the logical_size property of Renderer, most shape drawing operations will change resolution accordingly, the functions Renderer.fill_triangle and Renderer.fill_quad however do not.

Expected behavior: The filled shapes should be respectful of the logical_size property while drawing

Screenshots Minimal example

Steps to reproduce:

  1. Make a _sdl2.video.Renderer object
  2. Lower it's .logical_size property
  3. Call it's .fill_triangle or .fill_quad function

Test code

from pygame._sdl2.video import Renderer, Window
import pygame

pygame.init()

win = Window(size=(400,400))
scr = Renderer(win)

n = pygame.Vector2(15,15)
scr.logical_size = size = 100, 100

while True:
    scr.draw_color = 0,0,0,0
    scr.clear()
    scr.draw_color = 0,255,0,0
    scr.draw_quad((25,75)+n.rotate(60),(25,75)+n.rotate(150),(25,75)+n.rotate(240),(25,75)+n.rotate(330))
    scr.draw_triangle((25,25)+n.rotate(120),(25,25)+n.rotate(240),(25,25)+n)
    scr.draw_color = 255,0,0,0
    scr.fill_quad((75,75)+n.rotate(60),(75,75)+n.rotate(150),(75,75)+n.rotate(240),(75,75)+n.rotate(330))
    scr.fill_triangle((75,25)+n.rotate(120),(75,25)+n.rotate(240),(75,25)+n)
    scr.present()
ankith26 commented 1 week ago

Hello, thanks for the bug report and the clear reproducer.

To the best of my (limited) knowledge in this area, I believe this bug is on the SDL side, we just invoke SDL_RenderGeometry to handle the fill_* cases internally.