void CSVGAnimateColor:: animate(double t) { if (getAttributeName() == "fill") { CSVGColor fromColor, toColor; svg_.decodeColorString(getFrom(), fromColor); svg_.decodeColorString(getTo (), toColor ); CRGBA c = fromColor.rgba()*(1 - t) + toColor.rgba()*t; getParent()->setFillColor(c); svg_.redraw(); } else if (getAttributeName() == "stroke") { CSVGColor fromColor, toColor; svg_.decodeColorString(getFrom(), fromColor); svg_.decodeColorString(getTo (), toColor ); CRGBA c = fromColor.rgba()*(1 - t) + toColor.rgba()*t; getParent()->setStrokeColor(c); svg_.redraw(); } }
int XmlElement::getAttributeIndex(const char* name) { int i; for (i=0; i<getAttributeSize(); i++) { if (strcmp(name, getAttributeName(i).getBase()) == 0) { return i; } } return -1; }
std::set<std::string> getActiveAttributes(ProgramID id) { std::set<std::string> activeAttributes; GLint attributeCount = getActiveAttributeCount(id); GLint maxAttributeLength = getMaxAttributeNameLength(id); for (int32_t i = 0; i < attributeCount; i++) { activeAttributes.emplace(getAttributeName(id, maxAttributeLength, i)); } return activeAttributes; }
uint MeshData::compareAttributes(MeshData* other) { uint attr; if (other->getAttributeCount() != getAttributeCount()) { #ifndef PLG_RELEASE dprintf(2, "warning: MeshData objects have different number of attributes: %u vs. %u\n", other->getAttributeCount(), getAttributeCount()); #endif return 1; } for (attr = 0; attr < getAttributeCount(); attr++) { if (!other->hasAttribute(getAttributeName(attr))) { #ifndef PLG_RELEASE dprintf(2, "warning: MeshData objects have different attributes: %s\n", getAttributeName(attr)); #endif return 1; } } return 0; }
bool HlslLinker::getArgumentData2( GlslSymbolOrStructMemberBase const* symOrStructMember, EClassifier c, std::string &outName, std::string &ctor, int &pad, int semanticOffset) { int size; EGlslSymbolType base = EgstVoid; // Get the type before suppression because we may not want all of the elements. // note, suppressedBy should *never* be smaller than the suppressed. EGlslSymbolType type = symOrStructMember->type; GlslSymbolOrStructMemberBase const* suppressedBy = symOrStructMember->outputSuppressedBy(); if (suppressedBy) symOrStructMember = suppressedBy; EAttribSemantic sem = parseAttributeSemantic( symOrStructMember->semantic ); const std::string& semantic = symOrStructMember->semantic; // Offset the semantic for the case of an array if ( semanticOffset > 0 ) sem = static_cast<EAttribSemantic>( (int)sem + semanticOffset ); //clear the return values outName = ""; ctor = ""; pad = 0; //compute the # of elements in the type switch (type) { case EgstBool: case EgstBool2: case EgstBool3: case EgstBool4: base = EgstBool; size = type - EgstBool + 1; break; case EgstInt: case EgstInt2: case EgstInt3: case EgstInt4: base = EgstInt; size = type - EgstInt + 1; break; case EgstFloat: case EgstFloat2: case EgstFloat3: case EgstFloat4: base = EgstFloat; size = type - EgstFloat + 1; break; default: return false; }; if ( c != EClassUniform) { ctor = getTypeString( (EGlslSymbolType)((int)base + size - 1)); //default constructor pad = 0; switch (c) { case EClassNone: return false; case EClassAttrib: getAttributeName( symOrStructMember, outName, sem, semanticOffset ); if (outName == "gl_Normal" && size == 4) pad = 1; break; case EClassVarOut: // If using user varyings, create a user varying name // WHY ON EARTH such funny if if ( (bUserVaryings && sem != EAttrSemPosition && sem != EAttrSemPrimitiveID && sem != EAttrSemPSize) || varOutString[sem][0] == 0 ) { outName = kUserVaryingPrefix; outName += semantic; // If an array element, add the semantic offset to the name if ( semanticOffset > 0 ) { outName += "_"; outName += ( semanticOffset + '0' ); } } else { // Use built-in varying name outName = varOutString[sem]; // Always pad built-in varying outputs to 4 elements // exception: psize must be kept float1 if(sem != EAttrSemPSize) { pad = 4 - size; ctor = "vec4"; } } break; case EClassVarIn: // inout COLORn variables translate to framebuffer fetch for GLES if (IsArgumentForFramebufferFetch(symOrStructMember, sem, m_Target)) { int index = sem - EAttrSemColor0; outName = (m_Target == ETargetGLSL_ES_100 ? "gl_LastFragData" : "gl_FragData"); outName += '['; outName += char('0'+index); outName += ']'; m_Extensions.insert("GL_EXT_shader_framebuffer_fetch"); } // If using user varyings, create a user varying name else if ( (bUserVaryings && sem != EAttrSemVPos && sem != EAttrSemVFace && sem != EAttrSemPrimitiveID) || varInString[sem][0] == 0 ) { outName = kUserVaryingPrefix; outName += stripSemanticModifier (semantic, false); // If an array element, add the semantic offset to the name if ( semanticOffset > 0 ) { outName += "_"; outName += ( semanticOffset + '0' ); } } else { // Use built-in varying name outName = varInString[sem]; } break; case EClassRes: outName = resultString[sem]; if (sem == EAttrSemDepth) { if (m_Target == ETargetGLSL_ES_100) { outName = "gl_FragDepthEXT"; m_Extensions.insert("GL_EXT_frag_depth"); } ctor = "float"; } else if (sem == EAttrSemCoverage) ctor = "int"; else { pad = 4 - size; ctor = "vec4"; } break; case EClassUniform: assert(0); // this should have been stripped return false; }; } else { //these should always match exactly outName = "xlu_"; outName += symOrStructMember->name; } return true; }
QualifiedName ParserVocabulary::resolveAttributeName(const QualifiedNameOrIndex &nameOrIndex) const { unsigned int surrogateIndex = nameOrIndex._nameSurrogateIndex; return (surrogateIndex == INDEX_NOT_SET) ? resolveQualifiedName(nameOrIndex) : getAttributeName(surrogateIndex); }