Rust-SDL2 / rust-sdl2

SDL2 bindings for Rust
MIT License
2.77k stars 474 forks source link

draw_line not working? #1339

Open StayWithMeSenpai opened 1 year ago

StayWithMeSenpai commented 1 year ago

The rect above renders correctly, but the line below it doesn't.

It doesn't even warn or error, just doesn't draw.

image

StayWithMeSenpai commented 1 year ago

This issue only seems to happen when drawing on the Canvas type, not on the WindowCanvas type

Cobrand commented 1 year ago

Can you short self-contained example where this happens please? We can't help you unless we have more info.

WindowCanvas is an alias of Canvas, so if that doesn't work with "Canvas" this makes me think you are using a surface canvas?

SebastienBellanger commented 1 day ago

I had the same issue and while writing up an example I also stumbled upon what could be wrong.

TLDR; It wont work if the canvas has the underlying pixel format PixelFormatEnum::RGB24

Here is what I am trying to do in the code below:

I tried two things where drawing to the canvas worked as intended:

The error seems to happen when trying to draw to a canvas with pixel format PixelFormatEnum::RGB24

Cobrand commented 17 hours ago

Sounds like a problem with sdl2 directly and not this binding library, can you reproduce this in C?