void Graphics::SetShaderParameter(StringHash param, const Variant& value) { switch (value.GetType()) { case VAR_BOOL: SetShaderParameter(param, value.GetBool()); break; case VAR_INT: SetShaderParameter(param, value.GetInt()); break; case VAR_FLOAT: case VAR_DOUBLE: SetShaderParameter(param, value.GetFloat()); break; case VAR_VECTOR2: SetShaderParameter(param, value.GetVector2()); break; case VAR_VECTOR3: SetShaderParameter(param, value.GetVector3()); break; case VAR_VECTOR4: SetShaderParameter(param, value.GetVector4()); break; case VAR_COLOR: SetShaderParameter(param, value.GetColor()); break; case VAR_MATRIX3: SetShaderParameter(param, value.GetMatrix3()); break; case VAR_MATRIX3X4: SetShaderParameter(param, value.GetMatrix3x4()); break; case VAR_MATRIX4: SetShaderParameter(param, value.GetMatrix4()); break; case VAR_BUFFER: { const PODVector<unsigned char>& buffer = value.GetBuffer(); if (buffer.Size() >= sizeof(float)) SetShaderParameter(param, reinterpret_cast<const float*>(&buffer[0]), buffer.Size() / sizeof(float)); } break; default: // Unsupported parameter type, do nothing break; } }
bool Serializer::WriteVariantData(const Variant& value) { switch (value.GetType()) { case VAR_NONE: return true; case VAR_INT: return WriteInt(value.GetInt()); case VAR_BOOL: return WriteBool(value.GetBool()); case VAR_FLOAT: return WriteFloat(value.GetFloat()); case VAR_VECTOR2: return WriteVector2(value.GetVector2()); case VAR_VECTOR3: return WriteVector3(value.GetVector3()); case VAR_VECTOR4: return WriteVector4(value.GetVector4()); case VAR_QUATERNION: return WriteQuaternion(value.GetQuaternion()); case VAR_COLOR: return WriteColor(value.GetColor()); case VAR_STRING: return WriteString(value.GetString()); case VAR_BUFFER: return WriteBuffer(value.GetBuffer()); // Serializing pointers is not supported. Write null case VAR_VOIDPTR: case VAR_PTR: return WriteUInt(0); case VAR_RESOURCEREF: return WriteResourceRef(value.GetResourceRef()); case VAR_RESOURCEREFLIST: return WriteResourceRefList(value.GetResourceRefList()); case VAR_VARIANTVECTOR: return WriteVariantVector(value.GetVariantVector()); case VAR_VARIANTMAP: return WriteVariantMap(value.GetVariantMap()); case VAR_INTRECT: return WriteIntRect(value.GetIntRect()); case VAR_INTVECTOR2: return WriteIntVector2(value.GetIntVector2()); case VAR_MATRIX3: return WriteMatrix3(value.GetMatrix3()); case VAR_MATRIX3X4: return WriteMatrix3x4(value.GetMatrix3x4()); case VAR_MATRIX4: return WriteMatrix4(value.GetMatrix4()); default: return false; } }