-
-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Colours are broken #561
Comments
The reason is here. To my mind, pixel format depends on the O.S. and we can not just hard-code one format to work everywhere, because it does not work everywhere. |
I have opened the source code of SDL, and it looks like they are using an RGBA channel sequence. /** * The bits of this structure can be directly reinterpreted as an integer-packed * color which uses the SDL_PIXELFORMAT_RGBA32 format (SDL_PIXELFORMAT_ABGR8888 * on little-endian systems and SDL_PIXELFORMAT_RGBA8888 on big-endian systems). */ typedef struct SDL_Color { Uint8 r; Uint8 g; Uint8 b; Uint8 a; } SDL_Color; #define SDL_Colour SDL_Color So, this is not a Big-Endian vs Little-Endian problem. |
Documentation of SDL says that https://wiki.libsdl.org/SDL2/SDL_FillRect
That All this means that
So, the error is much and much deeper than I thought at the first time ! |
https://wiki.libsdl.org/SDL2/SDL_GetRGBA SDL_GetRGBA
Looks like |
I have found more evidence about that typo. https://wiki.libsdl.org/SDL2/SDL_PixelFormat#bytesperpixel
|
Hi @vault-thirteen, would using
|
Yes, it solves the problem, but the Go's method called
I think, you should at least add comments to it about its behaviour (it works here and does not work there). The best thing would be to get rid of non-cross-platform methods, or to add a platform name postfix to it, if you are sure that it works on a specific platform. But if you add a method for a platfom X like
If you want to save the method, it would be cool to rename it as The name without any postfix is misleading. |
Hi @vault-thirteen, I understand. I have updated it to have comments on the documentation to warn users not to use it for SDL2's rendering operations. |
Go version: 1.20.
Go-SDL2 version: v0.4.34.
SDL2 version: 2.26.5.
OS: Windows 10.
Architecture: Intel x86-64.
I draw a simple rectangle using a white colour, and get the yellow colour.
The reason of the bug is stated in the message:
#561 (comment)
renders as White
renders as Yellow
renders as Yellow
renders as White
It looks like Red channel and Alpha channel are swapped for some reason !
The text was updated successfully, but these errors were encountered: