Fix GLSL bugs with passing Vec2 and Vec3

This commit is contained in:
rdb 2013-02-23 10:55:43 +00:00
parent fbc097c323
commit 21472cda9b
2 changed files with 14 additions and 10 deletions

View File

@ -397,7 +397,7 @@ CLP(ShaderContext)(Shader *s, GSG *gsg) : ShaderContext(s) {
continue;
}
if (param_size==1) {
if (param_size == 1) {
switch (param_type) {
#ifndef OPENGLES
case GL_SAMPLER_1D_SHADOW:
@ -836,9 +836,9 @@ issue_parameters(GSG *gsg, int altered) {
}
GLint p = _glsl_parameter_map[_shader->_ptr_spec[i]._id._seqno];
switch(_ptr._dim[1]) {
case 1: gsg->_glUniform4fv(p, _ptr._dim[0], (float*)_ptr_data->_ptr); continue;
case 2: gsg->_glUniform4fv(p, _ptr._dim[0], (float*)_ptr_data->_ptr); continue;
case 3: gsg->_glUniform4fv(p, _ptr._dim[0], (float*)_ptr_data->_ptr); continue;
case 1: gsg->_glUniform1fv(p, _ptr._dim[0], (float*)_ptr_data->_ptr); continue;
case 2: gsg->_glUniform2fv(p, _ptr._dim[0], (float*)_ptr_data->_ptr); continue;
case 3: gsg->_glUniform3fv(p, _ptr._dim[0], (float*)_ptr_data->_ptr); continue;
case 4: gsg->_glUniform4fv(p, _ptr._dim[0], (float*)_ptr_data->_ptr); continue;
}
}

View File

@ -130,7 +130,7 @@ ShaderInput(const InternalName *name, const LVecBase4f &vec, int priority) :
_type(M_numeric),
_priority(priority),
_stored_ptr(vec),
_stored_vector(LCAST(PN_stdfloat, vec)) //old GLSL inputs must be supported
_stored_vector(LCAST(PN_stdfloat, vec))
{
}
@ -144,7 +144,8 @@ ShaderInput(const InternalName *name, const LVecBase3f &vec, int priority) :
_name(name),
_type(M_numeric),
_priority(priority),
_stored_ptr(vec)
_stored_ptr(vec),
_stored_vector(vec.get_x(), vec.get_y(), vec.get_z(), 0.0)
{
}
@ -158,7 +159,8 @@ ShaderInput(const InternalName *name, const LVecBase2f &vec, int priority) :
_name(name),
_type(M_numeric),
_priority(priority),
_stored_ptr(vec)
_stored_ptr(vec),
_stored_vector(vec.get_x(), vec.get_y(), 0.0, 0.0)
{
}
@ -285,7 +287,7 @@ ShaderInput(const InternalName *name, const LVecBase4d &vec, int priority) :
_type(M_numeric),
_priority(priority),
_stored_ptr(vec),
_stored_vector(LCAST(PN_stdfloat, vec)) //old GLSL inputs must be supported
_stored_vector(LCAST(PN_stdfloat, vec))
{
}
@ -299,7 +301,8 @@ ShaderInput(const InternalName *name, const LVecBase3d &vec, int priority) :
_name(name),
_type(M_numeric),
_priority(priority),
_stored_ptr(vec)
_stored_ptr(vec),
_stored_vector(vec.get_x(), vec.get_y(), vec.get_z(), 0.0)
{
}
@ -313,7 +316,8 @@ ShaderInput(const InternalName *name, const LVecBase2d &vec, int priority) :
_name(name),
_type(M_numeric),
_priority(priority),
_stored_ptr(vec)
_stored_ptr(vec),
_stored_vector(vec.get_x(), vec.get_y(), 0.0, 0.0)
{
}