EffectHLSL::Argument::Argument(const char* descriptor) { StringP typeName; strseparate( descriptor, ",", typeName ); typeName.first = strtrim( typeName.first, " " ); typeName.second = strtrim( typeName.second, " " ); if( typeName.first == "int" ) { type = vtInt; size = sizeof( int ); } else if( typeName.first == "float" ) { type = vtFloat; size = sizeof( float ); } else if( typeName.first == "vector" ) { type = vtVector4f; size = sizeof( Quartector ); } else { throw Exception( "Unsupported argument type: %s", typeName.first.c_str() ); } name = typeName.second; offset = 0; }
Color xmlColor(TiXmlNode* node, const char* attributeName) { assert( node->Type() == TiXmlNode::ELEMENT ); const char* value = static_cast<TiXmlElement*>( node )->Attribute( attributeName ); assert( value ); StringL rgba; strseparate( value, ",", rgba ); Vector4f color( 0,0,0,1 ); unsigned int i = 0; for( StringI stringI = rgba.begin(); stringI != rgba.end(); stringI++, i++ ) { color[i] = float( atof( stringI->c_str() ) ); } return wrap( color ); }
RECT xmlRect(TiXmlNode* node, const char* attributeName) { assert( node->Type() == TiXmlNode::ELEMENT ); const char* value = static_cast<TiXmlElement*>( node )->Attribute( attributeName ); assert( value ); assert( value ); StringL ltrb; strseparate( value, ",", ltrb ); assert( ltrb.size() == 4 ); RECT result; StringI stringI = ltrb.begin(); result.left = atoi( stringI->c_str() ); stringI++; result.top = atoi( stringI->c_str() ); stringI++; result.right = atoi( stringI->c_str() ); stringI++; result.bottom = atoi( stringI->c_str() ); return result; }