I am trying to add lighting to my current simple cube scene. After setting up my uniform, I get error 1282 from glGetError () for this piece of code
GLuint ambientHandle = glGetUniformLocation(program->getHandle(), "ambientProduct"); glUniform4fv( ambientHandle, 1, ambientProduct ); GLuint diffuseHandle = glGetUniformLocation(program->getHandle(), "diffuseProduct"); glUniform4fv( diffuseHandle, 1, diffuseProduct ); GLuint specularHandle = glGetUniformLocation(program->getHandle(), "specularProduct"); glUniform4fv( specularHandle, 1, specularProduct ); GLuint lightPosHandle = glGetUniformLocation(program->getHandle(), "lightPosition"); glUniform4fv( lightPosHandle, 1, light.position ); GLuint shinyHandle = glGetUniformLocation(program->getHandle(), "shininess"); glUniform1f( shinyHandle, materialShininess );
Here are my shaders: vertex.glsl
#version 120 attribute vec4 coord3d; attribute vec3 normal3d;
fragment.glsl
Products and position represent a structure of three GLfloats, and gloss is a float. I checked all the descriptor values ββand the values ββthat I pass, and they all seem valid. Ideas?
- EDIT: I narrowed it down to glUniform4fv calls. This happens after each. I also double checked that the program-> getHandle () indicates that it looks valid.
I checked the program-> getHandle - a valid program Here are the values ββof all the descriptors: Program control 3 ambientHandle 0 diffuseHandle 1 specularHandle 5 lightPosHandle 2 shinyHandle 4
So they all look good. For testing, I comment on the lines below for ambientProduct. For clarity, I explicitly use this line instead
glUniform4f( ambientHandle, ambientProd.x, ambientProd.y, ambientProd.z, ambientProd.w );
These are the values ββfor ambientProd at runtime of this line. x = 0.200000003, y = 0.0, z = 0.200000003, w = 1.0
The project employee has moved the glUseProgram call. Thanks for helping people.