Skip to content

SDL_gfx: Circle radius greater than 1023 results in deformation #272

Open
@atomicdad

Description

@atomicdad

I don't know if this is the correct place to bring up this issue...partially because I don't know the exact cause. It looks like the pysdl2-dll package uses version 1.0.4 of the SDL_gfx library, but I don't know exactly how to confirm this. I say this because the change log at https://www.ferzkopp.net/wordpress/2016/01/02/sdl_gfx-sdl2_gfx/ shows a fix in 1.0.4 for large radius values resulting in an int overflow. I'm not sure if this is related or not.

import sdl2
import sdl2.sdlgfx
import sdl2.ext


def run():

    sdl2.ext.init()
    window = sdl2.ext.Window("circle test", size=(1700, 900))
    window.show()

    if "-hardware" in sys.argv:
        renderflags = sdl2.render.SDL_RENDERER_ACCELERATED | sdl2.render.SDL_RENDERER_PRESENTVSYNC
    else:
        renderflags = sdl2.render.SDL_RENDERER_SOFTWARE
    context = sdl2.ext.Renderer(window, flags=renderflags)

    color = 0xFFFFFFFF
    x, y = -400, 450
    r = 1023
    sdl2.sdlgfx.circleColor(context.sdlrenderer, x, y, r, color)
    x, y = 0, 450
    r = 1024
    sdl2.sdlgfx.circleColor(context.sdlrenderer, x, y, r, color)
    
    context.present()
    running = True
    while running:
        events = sdl2.ext.get_events()
        for event in events:
            if event.type == sdl2.SDL_QUIT:
                running = False
                break
    sdl2.ext.quit()
    return 0


if __name__ == "__main__":
    sys.exit(run())
  • OS: Windows 10 64-bit
  • Python Version: 3.11
  • PySDL2 Version: 0.9.16
  • Using pysdl2-dll: Yes

Here is an image of the result.
https://i.stack.imgur.com/Cpmvh.png

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions