Hi everyone, I've been searching for a few hours for a solution to this problem. I was hoping someone might be able to help me out. I've just recently added shaders to my game and I've been learning the basics of GLSL. Everything has been going smoothly until I tried to use a uniform variable and edit it from the Draw() function. I am trying to change the v.z value of my vertices in the shader based on a time variable and a sin function. Here is the vertex shader code
varying vec2 texture_coordinate;
uniform float time;
void main(void)
{
// Transforming The Vertex
vec4 v = vec4(gl_Vertex);
v.z = sin(time*5.0)*10.0;
gl_Position = gl_ModelViewProjectionMatrix * v;
//gl_Position = ftransform();
// Passing The Texture Coordinate Of Texture Unit 0 To The Fragment Shader
texture_coordinate = vec2(gl_MultiTexCoord0);
}
I'm getting the address to this uniform variable using:
GLint loc;
loc = glGetUniformLocation(ProgramObject, name);
loc is getting the correct address, so there is (as far as I can tell) no problems up until now. I have error checking to see if the uniform variable does not exist, but that code is not being called. So, up until now I assume everything is fine.
I then try and set the uniform variable using
glUniform1fARB(loc, tTime);
tTime is of type float, and is being updated every time a call is made to DrawGLScene (every 1/60th of a second). The errors are generated when I use the shader.
glUseProgram(ProgramObject);
CHECK_GL_ERROR();
glUseProgram(0);
CHECK_GL_ERROR();
My scene is still drawing, but the model I am rendering is completely flat. My error logger returns this in my debug.txt file.
GLSL: OpenGL Vendor: NVIDIA Corporation
GLSL: OpenGL Renderer: GeForce 8600 GT/PCI/SSE2
GLSL: OpenGL Version: 2.1.2
GLSL: OpenGL 2.0 (or higher) is available!
GLSL: [OK] OpenGL Shading Language is available!
GLSL: Compiler Log (Vertex Shader)
[e06] Compiler log is not available!
GLSL: Compiler Log (Fragment Shader)
[e06] Compiler log is not available!
GLSL: Linker Error Log
[e05] Linker log is not available!
ContentManager: MyFirstShader shader loaded properly.
GLSL: GL Error #1280 (invalid enumerant) in File source files\glsl.cpp at line: 400
GLSL: GL Error #1280 (invalid enumerant) in File source files\glsl.cpp at line: 411
These lines (400 and 411) are called at my two glUseProgram() calls. This only happens when I am using a uniform variable and trying to edit it. My first experiments with shaders (doing stuff like texturing) were all fine. Can anyone help me out?
Giawa
[Edited by - Giawa on February 17, 2008 12:00:40 AM]