I've written a program using the OpenGL library and I've hit a wall trying to "send" a texture for use in a GLSL fragment shader.
On the GLSL fragment shader side, I've got code like:
uniform sampler2D texture0;
gl_FragColor = texture2D(texture0, gl_TexCoord.xy);
On the Haskell side, I can "create" a texture (an image) with texImage2D, but how do I then associate that texture with a uniform called "texture0" for the GLSL code?
An example of something I tried, which did not work (or even typecheck) is:
do GL.currentProgram $= Just program
textureObjectName <- GL.genObjectName
GL.textureBinding GL.Texture2D $= Just textureObjectName
GL.texImage2D GL.Texture2D [...etc...]
textureUniformLoc <- GL.uniformLocation program "texture0"
GL.uniform textureUniformLoc $= textureObjectName
The above doesn't work though, as there's no instance for (Uniform TextureObject).
Help would be very much appreciated!