I am trying to update the position of the eyes in my shader from my application, but I always get error 1281 when I try to do this. I have no problem after initialization, only when I try to update the values. Here is my code:
void GraphicsObject :: SendShadersDDS (char vertFile [], char fragFile [], char file_name []) {
char *vs = NULL,*fs = NULL; vert = glCreateShader(GL_VERTEX_SHADER); frag = glCreateShader(GL_FRAGMENT_SHADER); vs = textFileRead(vertFile); fs = textFileRead(fragFile); const char * ff = fs; const char * vv = vs; glShaderSource(vert, 1, &vv, NULL); glShaderSource(frag, 1, &ff, NULL); free(vs); free(fs); glCompileShader(vert); glCompileShader(frag); program = glCreateProgram(); glAttachShader(program, frag); glAttachShader(program, vert); glLinkProgram(program); glUseProgram(program); LoadCubeTexture(filename, compressedTexture); GLint location = glGetUniformLocation(program, "tex"); glUniform1i(location, 0); glActiveTexture(GL_TEXTURE0); EyePos = glGetUniformLocation(program, "EyePosition"); glUniform4f(EyePos, EyePosition.X(),EyePosition.Y(), EyePosition.Z(), 1.0); DWORD bob = glGetError();
}
And here is the function that I call to update the position of the eyes:
void GraphicsObject :: UpdateEyePosition (Vector3d & eyePosition) {
glUniform4f(EyePos, eyePosition.X(),eyePosition.Y(), eyePosition.Z(), 1.0); DWORD bob = glGetError(); //bob equals 1281 after this call
}
I tried several ways to update the variable, and this is the last incarnation, thanks for watching, welcome all comments.
UPDATE: the error does not occur at all at all, my error is to assume that the error actually occurs when I draw a few spring:
for (int i = 0; i <2; i ++) {
springs[i].Draw(); }
When I draw the first, this is normal, but I get an error when calling the second at the point where glEnd () was called in response to glBegin (GL_LINE_STRIP). Sorry for the inconvenience, since this was not a mistake I posted, but at least if someone wants to know how to update single variables, then he is here.