I'm studying OpenGL with GLUT and GLEW library. But I have a question about setting uniform values into the program's fragment shader.
Here's a part of the fragment shader code.
#version 110
uniform vec4 cameraPosition;
uniform vec4 lightPosition;
varying vec4 fragColor;
varying vec4 fragNormal;
varying vec4 fragPosition;
void main() {
vec4 L = lightPosition - fragPosition;
vec4 V = cameraPosition - fragPosition;
What I want to do is set 'cameraPosition' and 'lightPosition' uniform variables. Also, in the main program, I put some code to get these variables ID and pass some values into the variables like below.
GLuint cameraPositionID = glGetUniformLocation(programID, "cameraPosition");
GLuint lightPositionID = glGetUniformLocation(programID, "lightPosition");
GLfloat camPos[4] = { 1, 1, -3, 1 };
GLfloat lightPos[4] = { 1, 0, 0, 1 };
glUniform4fv(cameraPositionID, 4, &cameraPos[0]);
glUniform4fv(lightPositionID, 4, &lightPos[0]);
So, I try to pass camPos into cameraPosition, and lightPos into lightPosition. is it correct or incorrect? If you think incorrect, Do you have any idea about this?