Hello all,
Thanks in advance for taking the time to read this.
I have come across an issue when trying to render multiple textures. The debugging process is slightly confounded by the fact that I am using haskell, so its not super straight forward to map, opengl calls to haskell functions. Still the below code should be pretty reminiscent of what you would expect:
GL.activeTexture $= GL.TextureUnit 1
wall <- either error id <$> GLUtil.readTexture "assets/wall.jpg"
GL.textureFilter GL.Texture2D $= ((GL.Linear', Nothing), GL.Linear')
GLUtil.texture2DWrap $= (GL.Repeated, GL.ClampToBorder)
GL.textureBinding GL.Texture2D $= Just wall
GL.texture GL.Texture2D $= GL.Enabled
GL.activeTexture $= GL.TextureUnit 2
smiley <- either error id <$>
readTexInfoFlipped "assets/awesomeface.png" GLUtil.loadTexture
GL.textureFilter GL.Texture2D $= ((GL.Linear', Nothing), GL.Linear')
GLUtil.texture2DWrap $= (GL.Repeated, GL.ClampToBorder)
GL.textureBinding GL.Texture2D $= Just smiley
GL.texture GL.Texture2D $= GL.Enabled
texture1 <- GL.get $ GL.uniformLocation program "texture1"
GL.uniform texture1 $= GL.TextureUnit 1
texture2 <- GL.get $ GL.uniformLocation program "texture2"
GL.uniform texture2 $= GL.TextureUnit 2
This code does not work, and in fact renders a black screen (I have tried just rendering one or the other texture and it only works if I use the default texture unit (0), so I suspect I am having issues communicating texture units to the shader)
The only way I can make it work is by doing this with the uniforms in my fragment shader:
...
layout(binding=1) uniform sampler2D texture1;
layout(binding=2) uniform sampler2D texture2;
...
Does anyone have any ideas why I am running into this? Could it be something with my gpu (NVIDIA GeForce RTX 3050 Mobile
)? Any help is appreciated!