Skip to content
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

sdl2:get-texture-color-mod gives garbage results #118

Open
minusmaterial opened this issue Aug 12, 2019 · 1 comment
Open

sdl2:get-texture-color-mod gives garbage results #118

minusmaterial opened this issue Aug 12, 2019 · 1 comment

Comments

@minusmaterial
Copy link

Hello. I've started using cl-sdl2 for a small personal project; for the most part, the experience has been good. Thanks!

However, when I tried to use sdl2:get-texture-color-mod to get the current color mod state of a texture, I got back garbage results; even when I ran a loop, setting the texture color just before printing out the results of ( sdl2:get-texture-color-mod tex ), the values were basically random.

I had a look at the source code, and found this definition-

(defun get-texture-color-mod (texture)
"Use this function to get the additional color value multiplied into render copy operations."
(c-with ((r :unsigned-short)
(g :unsigned-short)
(b :unsigned-short))
(check-rc (sdl-get-texture-color-mod texture (r &) (g &) (b &)))
(values r g b)))

I replicated it in my code, and found that my problem was fixed by changing the types of r, g, and b to :char rather than :unsigned-short; I'm on a 64-bit machine- I'm guessing there's something going on with discrepancies in the sizes of different types?

For now, my problem is fixed (on my machine...), but I thought I ought to let you know.
If you need any more info, just ask.

@mfiano
Copy link
Contributor

mfiano commented Aug 12, 2019

Hello, thanks for reporting this. After looking at the SDL2 documentation, I have no idea if things changed or not, or why the previous maintainer used a 2-byte type, when it is marked as Uint8. Would you mind sending that PR over?

Edit: It's been a while since I looked at this code, but that definitely has to be unsigned, which you didn't mention in your fix above. I'm not sure if :char maps to :unsigned-byte, :signed-byte, or what. So that has to be taken into consideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants