Hi,
I'm having trouble with one of the procedures from the nim wrapper of sdl2 (nim-lang/sdl2).
Specifically, I am trying to modify the color of a texture using setTextureColorMod(). The proc has a signature of (texture: texturePtr, r, g, b: uint8). The proc works fine if I add in the r, g, b values directly, but I can't find a way for it to accept a constant as an argument for the color. I can't use a tuple of uint8s, because the proc signature won't accept one - I guess it can't be unpacked? I feel like there must be an easy way to use a constant or something similar, but I can't figure it out.
Any help would be appreciated!
What is the error messsage? I don't want to install sdl2 just to find out.
Likely, you need to add 'i8 suffix to the constant to clearly identify the type
It is a problem with the proc signature. If I define a const as follows:
BLUE_RGB = (0.uint8, 0.uint8, 255.uint8)
and call the proc as follows:
texture.texPtr.setTextureColorMod(BLUE_RGB)
the compiler gives the following error when I try to compile:
Error: type mismatch: got (TexturePtr, (uint8, uint8, uint8)) but expected one of: proc setTextureColorMod(texture: TexturePtr; r, g, b: uint8): SDL_Return
Like I said, it seems to be that it can't unpack the tuple, although maybe I am missing something else.
You will need to write
texture.texPtr.setTextureColorMod(BLUE_RGB[0], BLUE_RGB[1], BLUE_RGB[2])
As setTextureColorMod does not accept tuple as argumentYeah, that is doable, but I find it kind of messy, heh. I made a wrapper for the proc that will accept my const directly instead. I was just sort of surprised that it didn't work since it feels like the sort of thing that should work in Nim, and thought I might be missing something.
Anyway, thanks for the help!