c++ - Loss of data between the CPU and GPU when rendering with OpenGL -
i have been writing code basic rendering application.
the renderer code consists of setting vertex array , vertex buffer objects rendering entities, , 3 texture units created use diffuse, specular , emission component respectively. wrote wrapper class shader, create , set uniforms.
void shader::setvec3uniform(const glchar * name, vec3 data) { gluniform3f(glgetuniformlocation(this->program, name), data); }
when set uniforms using above function, doesn't render expected result. when find location before set uniform, renders correctly. use function below set it.
void shader::setvec3uniform(glint loc, vec3 data) { gluniform3f(loc, data.x, data.y, data.z); }
so question is, data lost, data not reaching shader on gpu in time? stumped. no idea why subtle difference in way uniforms set causing such difference in render.
can shed light on this?
well, according docs, prototype function gluniform3f
is:
void gluniform3f(glint location, glfloat v0, glfloat v1, glfloat v2);
and function gluniform3fv
is:
void gluniform3fv(glint location, glsizei count, const glfloat *value);
how vec3
defined? program work if had like:
// struct vec3 { float x; float y; float z; }; gluseprogram(this->program); gluniform3f(glgetuniformlocation(this->program, name), data.x, data.y, data.z);
or
// struct vec3 { float arr[3]; }; gluseprogram(this->program); gluniform3fv(glgetuniformlocation(this->program, name), 1, &data.arr[0]);
depending on vec3
implementation of course.
Comments
Post a Comment