void OpenGLShaderQuad::SetParametersFromList(IPluginObjectInstance *pInstance) { for(int i=0;i<shaderParams.size();i++) { OpenGLShaderParameter *param = shaderParams[i]; std::string name = param->GetName(); unsigned int idParam = program->GetUniform(name.c_str()); if (idParam == -1) { // missing in shader if (!param->WarningIssued()) { pInstance->GetLogger()->Error("Parameter '%s' not found in shader!", name.c_str()); param->SetWarningFlag(); } continue; } switch(param->GetType()) { case kParamType_Float : glUniform1f(idParam, param->GetFloat()); break; case kParamType_Vec3 : { float tmp[3]; param->GetVec3(tmp); glUniform3f(idParam, tmp[0], tmp[1], tmp[2]); } break; default : // not supported just yet... break; } } }
void OpenGLShaderQuad::SetParametersFromList(IPluginObjectInstance *pInstance) { for(int i=0;i<shaderParams.size();i++) { OpenGLShaderParameter *param = shaderParams[i]; std::string name = param->GetName(); int idParam = program->GetUniform(name.c_str()); if (idParam == -1) { // missing in shader if (!param->WarningIssued()) { pInstance->GetLogger()->Error("Parameter '%s' not found in shader!", name.c_str()); param->SetWarningFlag(); exit(1); } continue; } // printf("%d:%s\n",i,name.c_str()); switch(param->GetType()) { case kParamType_Float : glUniform1f(idParam, param->GetFloat()); break; case kParamType_Vec3 : { float tmp[3]; param->GetVec3(tmp); glUniform3f(idParam, tmp[0], tmp[1], tmp[2]); } break; case kParamType_Texture : { glActiveTexture(GL_TEXTURE0+texture_count); glBindTexture(GL_TEXTURE_2D,param->GetTexture()); glUniform1i(idParam, texture_count); // texture_count); int err = glGetError(); if (err != GL_NO_ERROR) { pInstance->GetLogger()->Error("Unable to bind texture for param: %s (error=%d)",name.c_str(),err); } texture_count++; } default : // not supported just yet... break; } } }