dwmkerr / sharpgl

Use OpenGL in .NET applications. SharpGL wraps all modern OpenGL features and offers a powerful scene graph to aid development.
MIT License
749 stars 300 forks source link

ShaderProgram.SetUniform1 does not work for int uniforms #226

Open VE3NEA opened 8 months ago

VE3NEA commented 8 months ago

This statement does not change the integer uniform:

shaderProgram.SetUniform1(gl, "my_texture", 1);

This one works orrectly:

 gl.Uniform1(shaderProgram.GetUniformLocation(gl, "my_texture"), 1);

The problem with the first statement is that the third parameter of SetUniform1 is declared as float, so if an int value is passed, it is typecasted to float before the call to gl.Uniform1.

brisingre commented 1 month ago

This got me as well! Took us a week to figure it out before my friend found this ticket...