std::vector<VariableDeclaration> Declaration::GetVariableDeclarations() const { Assert(declSpecs->storageClass != SC_TYPEDEF); std::vector<VariableDeclaration> vars; for (unsigned int i = 0; i < declarators.size(); ++i) { Declarator *decl = declarators[i]; if (decl == NULL || decl->type == NULL) { // Ignore earlier errors Assert(m->errorCount > 0); continue; } if (Type::Equal(decl->type, AtomicType::Void)) Error(decl->pos, "\"void\" type variable illegal in declaration."); else if (CastType<FunctionType>(decl->type) == NULL) { decl->type = decl->type->ResolveUnboundVariability(Variability::Varying); Symbol *sym = new Symbol(decl->name, decl->pos, decl->type, decl->storageClass); m->symbolTable->AddVariable(sym); vars.push_back(VariableDeclaration(sym, decl->initExpr)); } } return vars; }
std::vector<VariableDeclaration> Declaration::GetVariableDeclarations() const { Assert(declSpecs->storageClass != SC_TYPEDEF); std::vector<VariableDeclaration> vars; for (unsigned int i = 0; i < declarators.size(); ++i) { if (declarators[i] == NULL) continue; Declarator *decl = declarators[i]; if (decl == NULL) // Ignore earlier errors continue; Symbol *sym = decl->GetSymbol(); if (dynamic_cast<const FunctionType *>(sym->type) != NULL) { // function declaration m->symbolTable->AddFunction(sym); } else { m->symbolTable->AddVariable(sym); vars.push_back(VariableDeclaration(sym, decl->initExpr)); } } return vars; }
std::vector<VariableDeclaration> Declaration::GetVariableDeclarations() const { Assert(declSpecs->storageClass != SC_TYPEDEF); std::vector<VariableDeclaration> vars; for (unsigned int i = 0; i < declarators.size(); ++i) { Declarator *decl = declarators[i]; if (decl == NULL) { // Ignore earlier errors Assert(m->errorCount > 0); continue; } Symbol *sym = decl->GetSymbol(); if (sym == NULL || sym->type == NULL) { // Ignore errors Assert(m->errorCount > 0); continue; } sym->type = sym->type->ResolveUnboundVariability(Type::Varying); if (sym->type == AtomicType::Void) Error(sym->pos, "\"void\" type variable illegal in declaration."); else if (dynamic_cast<const FunctionType *>(sym->type) == NULL) { m->symbolTable->AddVariable(sym); vars.push_back(VariableDeclaration(sym, decl->initExpr)); } } return vars; }
void ProgramUse::setUniform(const std::string& name, const math::Mat4<GLfloat>& value) const { glUniformMatrix4fv(program_.uniformLocation(VariableDeclaration(name, VariableDeclaration::Type::MAT4)), 1, GL_FALSE, &value[0][0]); }
void ProgramUse::setUniform(const std::string& name, const math::Vec4<GLfloat>& value) const { glUniform4f(program_.uniformLocation(VariableDeclaration(name, VariableDeclaration::Type::VEC4)), value.x, value.y, value.z, value.w); }
void ProgramUse::setUniformi(const std::string& name, GLuint value) const { glUniform1i(program_.uniformLocation(VariableDeclaration(name, VariableDeclaration::Type::SAMPLER2D)), value); }
void ProgramUse::setUniformf(const std::string& name, GLfloat value) const { glUniform1f(program_.uniformLocation(VariableDeclaration(name, VariableDeclaration::Type::FLOAT)), value); }