I can’t figure out why one of the lines in each my buttons isn’t straight. This shows up on arm64 GNU/Linux, but not on x86_64. In this screenshot, you can see the bottom lines of the buttons rise/fall 1 pixel or so. It doesn’t look great lol.
Any ideas on why this would happen? It doesn’t happen in other apps. For example, here is the browser in which I am typing. The lines go straight across:
EDIT: changing to SDL development tag, as this seems like a bug in SDL? Or maybe a bug in my arm64 system? (hopefully I can find a work-around either way)
If your coordinates are stored as floating-point numbers, you might want to print them with higher precision (more decimal digits) to see their true values. Maybe it’s 397.999... instead of 398 which gets truncated to 397 when you convert them to SDL_Point (which uses int) ? To fix this you might need to round your coordinates.
EDIT: SDL_RenderDrawLines doesn’t use floats so it cannot round/truncate internally but the truncation could still happen in your code when converting your float coordinates to SDL_Point.
Nice! Thanks. I came up with a different workaround, that also seems to work, first filling a black rectangle, then filling a white rectangle 1pixel smaller on all sides:
EDIT: I had to also call SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE)
Does a rect without fill not work? (SDL_RenderDrawRect)
When I switched to SDL3 (it prefers floats) I noticed I would have minor glitches because my code assumed values would be truncated after a divide like how it does with int. If you plan on using this code with SDL3 you may want to keep that in mind