opengl - Type mismatch vertex attribute -


i write glsl wrapper education purposes, stopped because have misunderstanding. when want insert variable specific location, have mismatch warning. because location glint, glvertexattrib location must gluint.

here's code sample

bool material::addattrib(glchar *variable, std::vector<gldouble> values) { glint location = glgetattriblocation(program,variable); glenum error = glgeterror(); bool isnor = printerror(error); if(!isnor) return isnor; switch (values.size()) {     case 1:         glvertexattrib1d(location, values.at(0));         break;     case 2:         glvertexattrib2d(location, values.at(0), values.at(1));         break;     case 3:         glvertexattrib3d(location, values.at(0), values.at(1), values.at(2));         break;     case 4:         glvertexattrib4d(location, values.at(0), values.at(1), values.at(2), values.at(3));         break;     default:         printerrorsize();         return false; } error = glgeterror(); isnor = printerror(error); return isnor; } 

glgetattriblocation() may return negative indices in case of error. of course, negative index not valid if used glvertexattrib...(). that's why there type mismatch. can resolve simple cast:

glint retrievedlocation = glgetattriblocation(program,variable); if(retrievedlocation < 0)     return ...; //there no variable name gluint location = (gluint) retrievedlocation; 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -