Axiom.Graphics.TextureUnitState.GetTextureFiltering C# (CSharp) Method

GetTextureFiltering() public method

Gets the texture filtering for the given type.
public GetTextureFiltering ( FilterType type ) : FilterOptions
type FilterType Type of filtering options to retreive.
return FilterOptions
		public FilterOptions GetTextureFiltering( FilterType type )
		{
			switch ( type )
			{
				case FilterType.Min:
					return isDefaultFiltering ?
												MaterialManager.Instance.GetDefaultTextureFiltering( FilterType.Min ) : minFilter;

				case FilterType.Mag:
					return isDefaultFiltering ?
												MaterialManager.Instance.GetDefaultTextureFiltering( FilterType.Mag ) : magFilter;

				case FilterType.Mip:
					return isDefaultFiltering ?
												MaterialManager.Instance.GetDefaultTextureFiltering( FilterType.Mip ) : mipFilter;
			}

			// should never get here, but makes the compiler happy
			return FilterOptions.None;
		}

Usage Example

        /// <summary>
        ///		Utility function for setting all the properties of a texture unit at once.
        ///		This method is also worth using over the individual texture unit settings because it
        ///		only sets those settings which are different from the current settings for this
        ///		unit, thus minimising render state changes.
        /// </summary>
        /// <param name="textureUnit">Index of the texture unit to configure</param>
        /// <param name="layer">Reference to a TextureLayer object which defines all the settings.</param>
        public virtual void SetTextureUnit(int unit, TextureUnitState unitState, bool fixedFunction)
        {
            // This method is only ever called to set a texture unit to valid details
            // The method _disableTextureUnit is called to turn a unit off

            // Vertex texture binding?
            if (caps.CheckCap(Capabilities.VertexTextureFetch) &&
                !caps.CheckCap(Capabilities.VertexTextureFetch)) {
                if (unitState.BindingType == GpuProgramType.Vertex) {
                    // Bind vertex texture
                    SetVertexTexture(unit, unitState);
                    // bind nothing to fragment unit (hardware isn't shared but fragment
                    // unit can't be using the same index
                    SetTexture(unit, true, string.Empty);
                }
                else {
                    // vice versa
                    SetVertexTexture(unit, unitState);
                    SetTexture(unit, true, unitState.TextureName);
                }
            }
            else {
                // Shared vertex / fragment textures or no vertex texture support
                // Bind texture (may be blank)
                SetTexture(unit, true, unitState.TextureName);
            }

            // Set texture coordinate set
            // SetTextureCoordSet(unit, unitState.TextureCoordSet);
            if (!fixedFunction)
                // From Direct3D9 error log:
                // Texture coordinate index in the stage must be equal to the stage index when programmable vertex pipeline is used
                SetTextureCoordSet(unit, unit);

            // Texture layer filtering
            SetTextureUnitFiltering(
                unit,
                unitState.GetTextureFiltering(FilterType.Min),
                unitState.GetTextureFiltering(FilterType.Mag),
                unitState.GetTextureFiltering(FilterType.Mip));

            // Texture layer anistropy
            SetTextureLayerAnisotropy(unit, unitState.TextureAnisotropy);

            // Set mipmap biasing
            SetTextureMipmapBias(unit, unitState.MipmapBias);

            // Texture addressing mode
            UVWAddressingMode uvw = unitState.GetTextureAddressingMode();
            SetTextureAddressingMode(unit, uvw);
            // Set texture border colour only if required
            if (uvw.u == TextureAddressing.Border ||
                uvw.v == TextureAddressing.Border ||
                uvw.w == TextureAddressing.Border)
                SetTextureBorderColor(unit, unitState.TextureBorderColor);

            // This stuff only gets done for the fixed function pipeline.  It is not needed
            // if we are using a pixel shader.
            if (fixedFunction)
            {
                // Tex Coord Set
                SetTextureCoordSet(unit, unitState.TextureCoordSet);

                // set the texture blending mode
                SetTextureBlendMode(unit, unitState.ColorBlendMode);

                // set the texture blending mode
                SetTextureBlendMode(unit, unitState.AlphaBlendMode);

                bool anyCalcs = false;

                for (int i = 0; i < unitState.NumEffects; i++)
                {
                    TextureEffect effect = unitState.GetEffect(i);

                    switch (effect.type)
                    {
                        case TextureEffectType.EnvironmentMap:
                            if ((EnvironmentMap)effect.subtype == EnvironmentMap.Curved)
                            {
                                SetTextureCoordCalculation(unit, TexCoordCalcMethod.EnvironmentMap);
                                anyCalcs = true;
                            }
                            else if ((EnvironmentMap)effect.subtype == EnvironmentMap.Planar)
                            {
                                SetTextureCoordCalculation(unit, TexCoordCalcMethod.EnvironmentMapPlanar);
                                anyCalcs = true;
                            }
                            else if ((EnvironmentMap)effect.subtype == EnvironmentMap.Reflection)
                            {
                                SetTextureCoordCalculation(unit, TexCoordCalcMethod.EnvironmentMapReflection);
                                anyCalcs = true;
                            }
                            else if ((EnvironmentMap)effect.subtype == EnvironmentMap.Normal)
                            {
                                SetTextureCoordCalculation(unit, TexCoordCalcMethod.EnvironmentMapNormal);
                                anyCalcs = true;
                            }
                            break;

                        case TextureEffectType.Scroll:
                        case TextureEffectType.Rotate:
                        case TextureEffectType.Transform:
                            break;

                        case TextureEffectType.ProjectiveTexture:
                            SetTextureCoordCalculation(unit, TexCoordCalcMethod.ProjectiveTexture, effect.frustum);
                            anyCalcs = true;
                            break;
                    } // switch
                } // for

                // Ensure any previous texcoord calc settings are reset if there are now none
                if (!anyCalcs)
                {
                    SetTextureCoordCalculation(unit, TexCoordCalcMethod.None);
                }

                // set the texture matrix to that of the current layer for any transformations
                SetTextureMatrix(unit, unitState.TextureMatrix);
            }
        }