haskell-opengl / OpenGL

Haskell bindings to OpenGL
http://www.haskell.org/haskellwiki/OpenGL
BSD 3-Clause "New" or "Revised" License
147 stars 26 forks source link

Uniform TextureUnit for a sampler causes GL_INVALID_OPERATION error #35

Closed daoo closed 11 years ago

daoo commented 11 years ago

The Uniform instance for TextureUnit implements the setter with uniform1 and the value stored in the TextureUnit as a GLuint. This results in a call to glUniform1ui which, for sampler uniforms, results in a GL_INVALID_OPERATION error.

As stated in the OpenGL 2.0 (and later) reference[1], samplers must be loaded by glUniform1i or glUniform1iv and loading with any other function will cause a GL_INVALID_OPERATION error.

Can be fixed by casting the GLuint to GLint in the Uniform instance or changing the GLuint to a GLint in TextureUnit (don't know what this would change elsewhere). Though, it might make sens to store it as GLuint anyway, because in glActiveTexture accepts a GLenum which in GL.h on my machine is typedefed to a unsigned int. The standard is a bit confusing here.

[1] See "Notes" section: http://www.opengl.org/sdk/docs/man2/xhtml/glUniform.xml