How can we change shader.setFloat(“rotationAngle”, angle); like GLint modelMatrixLoc =…
- User
How can we change shader.setFloat(“rotationAngle”, angle); like GLint modelMatrixLoc = glGetUniformLocation(program, "model");
- Assistant
To change the line of code that sets a floating point uniform variable in a shader from
shader.setFloat("rotationAngle", angle);to something more similar toGLint modelMatrixLoc = glGetUniformLocation(program, "model");, you'll need to use the OpenGL functions directly. Here's how you can do that:- First, get the location of the uniform variable in the shader program using
glGetUniformLocation. - Then, use
glUniform1fto set the value of the uniform variable.
Assuming you have a GLSL shader program compiled and linked, and an active OpenGL context, the code would look something like this:
- First, get the location of the uniform variable in the shader program using