bool DX9RenderSystem::Begin2d( ) { SetCullMode( CullMode::NONE ); SetFillMode( FillMode::SOLID ); SetProjectionMatrix( Matrix4::CreateOrthoLH( (float)mSize.x, -(float)mSize.y, 0.0f, 1.0f ) ); SetViewMatrix( Matrix4::IDENTITY ); SetWorldMatrix( Matrix4::IDENTITY ); SetVertexDeclaration( m2dDecl ); SetTextureStageState( 0, TextureState::TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); SetTextureStageState( 0, TextureState::COLOROP, BlendOp::MODULATE ); SetTextureStageState( 0, TextureState::COLORARG1, BlendArg::TEXTURE ); SetTextureStageState( 0, TextureState::COLORARG2, BlendArg::DIFFUSE ); SetTextureStageState( 0, TextureState::ALPHAOP, BlendOp::MODULATE ); SetTextureStageState( 0, TextureState::ALPHAARG1, BlendArg::TEXTURE ); SetTextureStageState( 0, TextureState::ALPHAARG2, BlendArg::DIFFUSE ); SetTextureStageState( 1, TextureState::COLOROP, BlendOp::DISABLE ); SetTextureStageState( 1, TextureState::ALPHAOP, BlendOp::DISABLE ); SetAlphaBlendEnabled( true ); SetAlphaTestEnabled( false ); SetDepthWriteEnabled( true ); SetDepthBufferEnabled( false ); SetSpecularEnabled( false ); return true; };
PRBool nsSMILTimedElement::SetAttr(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult, nsresult* aParseResult) { PRBool foundMatch = PR_TRUE; nsresult parseResult = NS_OK; if (aAttribute == nsGkAtoms::begin) { parseResult = SetBeginSpec(aValue); } else if (aAttribute == nsGkAtoms::dur) { parseResult = SetSimpleDuration(aValue); } else if (aAttribute == nsGkAtoms::end) { parseResult = SetEndSpec(aValue); } else if (aAttribute == nsGkAtoms::fill) { parseResult = SetFillMode(aValue); } else if (aAttribute == nsGkAtoms::max) { parseResult = SetMax(aValue); } else if (aAttribute == nsGkAtoms::min) { parseResult = SetMin(aValue); } else if (aAttribute == nsGkAtoms::repeatCount) { parseResult = SetRepeatCount(aValue); } else if (aAttribute == nsGkAtoms::repeatDur) { parseResult = SetRepeatDur(aValue); } else if (aAttribute == nsGkAtoms::restart) { parseResult = SetRestart(aValue); } else { foundMatch = PR_FALSE; } if (foundMatch) { aResult.SetTo(aValue); if (aParseResult) { *aParseResult = parseResult; } } return foundMatch; }
bool Material::Load(const XMLElement& source) { ResetToDefaults(); if (source.IsNull()) { LOGERROR("Can not load material from null XML element"); return false; } ResourceCache* cache = GetSubsystem<ResourceCache>(); XMLElement techniqueElem = source.GetChild("technique"); techniques_.Clear(); while (techniqueElem) { Technique* tech = cache->GetResource<Technique>(techniqueElem.GetAttribute("name")); if (tech) { TechniqueEntry newTechnique; newTechnique.technique_ = tech; if (techniqueElem.HasAttribute("quality")) newTechnique.qualityLevel_ = techniqueElem.GetInt("quality"); if (techniqueElem.HasAttribute("loddistance")) newTechnique.lodDistance_ = techniqueElem.GetFloat("loddistance"); techniques_.Push(newTechnique); } techniqueElem = techniqueElem.GetNext("technique"); } SortTechniques(); XMLElement textureElem = source.GetChild("texture"); while (textureElem) { TextureUnit unit = TU_DIFFUSE; if (textureElem.HasAttribute("unit")) unit = ParseTextureUnitName(textureElem.GetAttribute("unit")); if (unit < MAX_TEXTURE_UNITS) { String name = textureElem.GetAttribute("name"); // Detect cube maps by file extension: they are defined by an XML file /// \todo Differentiate with 3D textures by actually reading the XML content if (GetExtension(name) == ".xml") { #ifdef DESKTOP_GRAPHICS if (unit == TU_VOLUMEMAP) SetTexture(unit, cache->GetResource<Texture3D>(name)); else #endif SetTexture(unit, cache->GetResource<TextureCube>(name)); } else SetTexture(unit, cache->GetResource<Texture2D>(name)); } textureElem = textureElem.GetNext("texture"); } batchedParameterUpdate_ = true; XMLElement parameterElem = source.GetChild("parameter"); while (parameterElem) { String name = parameterElem.GetAttribute("name"); SetShaderParameter(name, ParseShaderParameterValue(parameterElem.GetAttribute("value"))); parameterElem = parameterElem.GetNext("parameter"); } batchedParameterUpdate_ = false; XMLElement parameterAnimationElem = source.GetChild("parameteranimation"); while (parameterAnimationElem) { String name = parameterAnimationElem.GetAttribute("name"); SharedPtr<ValueAnimation> animation(new ValueAnimation(context_)); if (!animation->LoadXML(parameterAnimationElem)) { LOGERROR("Could not load parameter animation"); return false; } String wrapModeString = parameterAnimationElem.GetAttribute("wrapmode"); WrapMode wrapMode = WM_LOOP; for (int i = 0; i <= WM_CLAMP; ++i) { if (wrapModeString == wrapModeNames[i]) { wrapMode = (WrapMode)i; break; } } float speed = parameterAnimationElem.GetFloat("speed"); SetShaderParameterAnimation(name, animation, wrapMode, speed); parameterAnimationElem = parameterAnimationElem.GetNext("parameteranimation"); } XMLElement cullElem = source.GetChild("cull"); if (cullElem) SetCullMode((CullMode)GetStringListIndex(cullElem.GetAttribute("value").CString(), cullModeNames, CULL_CCW)); XMLElement shadowCullElem = source.GetChild("shadowcull"); if (shadowCullElem) SetShadowCullMode((CullMode)GetStringListIndex(shadowCullElem.GetAttribute("value").CString(), cullModeNames, CULL_CCW)); XMLElement fillElem = source.GetChild("fill"); if (fillElem) SetFillMode((FillMode)GetStringListIndex(fillElem.GetAttribute("value").CString(), fillModeNames, FILL_SOLID)); XMLElement depthBiasElem = source.GetChild("depthbias"); if (depthBiasElem) SetDepthBias(BiasParameters(depthBiasElem.GetFloat("constant"), depthBiasElem.GetFloat("slopescaled"))); RefreshShaderParameterHash(); RefreshMemoryUse(); CheckOcclusion(); return true; }