You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
but instead of using full RGBA PixelFormat, we want to use only one channel, so we define:
type GrayscalePixel = uint8
proc kind*(x: typedesc[GrayscalePixel]): PixelFormat = UncompressedGrayscale
(...)
var pixels = newSeq[GrayscalePixel](width*height)
for y in 0..<height:
for x in 0..<width:
if ((x div 32 + y div 32) div 1) mod 2 == 0:
pixels[y*width + x] = 0
else:
pixels[y*width + x] = 250
let checked = loadTextureFromData(pixels, width, height)
This will compile. But as soon as we try to use the setShaderValue() function (or use any custom shader in general), the code fails to compile, with errors like type mismatch Expression: kind(T)
or
type mismatch
Expression: setShaderValue(myShader, myUniform, myValue)
[1] myShader: Shader
[2] myUniform: ShaderLocation
[3] myValue: Vector2
Expected one of (first mismatch at [position]):
[3] proc setShaderValue[T: ShaderV](shader: Shader; locIndex: ShaderLocation;
value: T)
or similar.
I'm still learning Nim, if this issue isn't legitimate, let me know to close it.
The text was updated successfully, but these errors were encountered:
Yep, I fear my decision to use concepts was rushed and should have stayed with plain generics. I had a similar issue when two types failing to match the Pixel concept in the same module.
I can reproduce your issue, however if I redefine template kind*(x: typedesc[float32]): ShaderUniformDataType = Float in the current module it compiles. Tell me how it goes and depending, it might be time to remove concepts.
Yes, redefining it for shaders solved the problem, thanks!
I've also tried to modify the lib (raylib.nim file), to use separate kind name for PixelFormat, and kind2 name for ShaderUniformDataType. Strangely this didn't help.
First of all, thank you for your great work!
Problem:
In
raylib.nim
there is:and there is also:
now let's say we want to make similar thing to this example: textures/raw_data.nim
but instead of using full RGBA PixelFormat, we want to use only one channel, so we define:
This will compile. But as soon as we try to use the
setShaderValue()
function (or use any custom shader in general), the code fails to compile, with errors liketype mismatch Expression: kind(T)
or
or similar.
I'm still learning Nim, if this issue isn't legitimate, let me know to close it.
The text was updated successfully, but these errors were encountered: