public AutoConstantEntry(AutoConstantType type, int index, float fdata, GpuParamVariability variability,
                          int elementCount)
 {
     this.Type          = type;
     this.PhysicalIndex = index;
     this.FData         = fdata;
     this.Variability   = variability;
     this.ElementCount  = elementCount;
 }
            public AutoConstantEntry(AutoConstantType type, int index, int data, GpuParamVariability variability,
                                     int elementCount)
            {
                this.Type          = type;
                this.PhysicalIndex = index;
                this.Data          = data;
                this.Variability   = variability;
                this.ElementCount  = elementCount;

                // this is likeley obsolete in as ogre doesnt have this (anymore?)
                System.Diagnostics.Debug.Assert(type != AutoConstantType.SinTime_0_X);
            }
		public void SetNamedAutoConstantReal( string name, AutoConstantType acType, Real rData )
		{
			// look up, and throw an exception if we're not ignoring missing
			var def = FindNamedConstantDefinition( name, !this.ignoreMissingParameters );
			if ( def != null )
			{
				def.Variability = DeriveVariability( acType );
				// make sure we also set variability on the logical index map
				var indexUse = GetFloatConstantLogicalIndexUse( def.LogicalIndex, def.ElementSize*def.ArraySize, def.Variability );
				if ( indexUse != null )
				{
					indexUse.Variability = def.Variability;
				}

				SetRawAutoConstantReal( def.PhysicalIndex, acType, rData, def.Variability, def.ElementSize );
			}
		}
		public void SetAutoConstantReal( int index, AutoConstantType acType, Real extraInfo )
		{
			// Get auto constant definition for sizing
			AutoConstantDefinition autoDef;
			GetAutoConstantDefinition( (int)acType, out autoDef );
			// round up to nearest multiple of 4
			var sz = autoDef.ElementCount;
			if ( sz%4 > 0 )
			{
				sz += 4 - ( sz%4 );
			}

			var indexUse = GetFloatConstantLogicalIndexUse( index, sz, DeriveVariability( acType ) );

			if ( indexUse != null )
			{
				SetRawAutoConstantReal( indexUse.PhysicalIndex, acType, extraInfo, indexUse.Variability, sz );
			}
		}
		protected internal void SetRawAutoConstantReal( int physicalIndex, AutoConstantType acType, Real extraInfo,
														GpuParamVariability variability, int elementSize )
		{
			// update existing index if it exists
			var found = false;
			foreach ( var i in this.autoConstants )
			{
				if ( i.PhysicalIndex == physicalIndex )
				{
					i.Type = acType;
					i.FData = extraInfo;
					i.ElementCount = elementSize;
					i.Variability = variability;
					found = true;
					break;
				}
			}
			if ( !found )
			{
				this.autoConstants.Add( new AutoConstantEntry( acType, physicalIndex, extraInfo, variability, elementSize ) );
			}

			this._combinedVariability |= variability;
		}
 public void setNamedAutoConstant(String name, AutoConstantType acType, ulong extraInfo1, ulong extraInfo2)
 {
     GpuProgramParameters_setNamedAutoConstant3(ptr, name, acType, new UIntPtr(extraInfo1), new UIntPtr(extraInfo2));
     OgreExceptionManager.fireAnyException();
 }
		/// <summary>
		///    Sets up a constant which will automatically be updated by the engine.
		/// </summary>
		/// <remarks>
		///    Vertex and fragment programs often need parameters which are to do with the
		///    current render state, or particular values which may very well change over time,
		///    and often between objects which are being rendered. This feature allows you
		///    to set up a certain number of predefined parameter mappings that are kept up to
		///    date for you.
		/// </remarks>
		/// <param name="name">
		///    Name of the param.
		/// </param>
		/// <param name="type">
		///    The type of automatic constant to set.
		/// </param>
		/// <param name="extraInfo">
		///    Any extra information needed by the auto constant (i.e. light index, etc).
		/// </param>
		public void SetNamedAutoConstant( string name, AutoConstantType type, int extraInfo )
		{
			int index = GetParamIndex( name );
			if ( index != -1 )
				SetAutoConstant( GetParamIndex( name ), type, extraInfo );
		}
		/// <summary>
		///    Overloaded method.
		/// </summary>
		/// <param name="type">The type of automatic constant to set.</param>
		/// <param name="index">
		///    The location in the constant list to place this updated constant every time
		///    it is changed. Note that because of the nature of the types, we know how big the
		///    parameter details will be so you don't need to set that like you do for manual constants.
		/// </param>
		/// <param name="extraInfo">If the constant type needs more information (like a light index) put it here.</param>
		public void SetAutoConstant( int index, AutoConstantType type, float extraInfo )
		{
			AutoConstantEntry entry = new AutoConstantEntry( type, index, extraInfo, 0 );
			autoConstantList.Add( entry );
		}
		/// <summary>
		///    Sets up a constant which will automatically be updated by the engine.
		/// </summary>
		/// <remarks>
		///    Vertex and fragment programs often need parameters which are to do with the
		///    current render state, or particular values which may very well change over time,
		///    and often between objects which are being rendered. This feature allows you
		///    to set up a certain number of predefined parameter mappings that are kept up to
		///    date for you.
		/// </remarks>
		/// <param name="type">The type of automatic constant to set.</param>
		/// <param name="index">
		///    The location in the constant list to place this updated constant every time
		///    it is changed. Note that because of the nature of the types, we know how big the
		///    parameter details will be so you don't need to set that like you do for manual constants.
		/// </param>
		public void SetAutoConstant( int index, AutoConstantType type )
		{
			SetAutoConstant( index, type, 0 );
		}
 public AutoConstantEntry(AutoConstantType type, int index, float fdata, GpuParamVariability variability)
     : this(type, index, fdata, variability, 4)
 {
 }
 private static extern void GpuProgramParameters_setNamedAutoConstantReal(IntPtr param, String name, AutoConstantType acType, float rData);
 private static extern void GpuProgramParameters_setNamedAutoConstant3(IntPtr param, String name, AutoConstantType acType, UIntPtr extraInfo1, UIntPtr extraInfo2);
 private static extern void GpuProgramParameters_setNamedAutoConstant1(IntPtr param, String name, AutoConstantType acType);
 public void setNamedAutoConstantReal(String name, AutoConstantType acType, float rData)
 {
     GpuProgramParameters_setNamedAutoConstantReal(ptr, name, acType, rData);
     OgreExceptionManager.fireAnyException();
 }
		public void SetNamedAutoConstant( string name, AutoConstantType acType, ushort extraInfo1, ushort extraInfo2 )
		{
			var extraInfo = extraInfo1 | ( extraInfo2 << 16 );
			SetNamedAutoConstant( name, acType, extraInfo );
		}
		protected GpuParamVariability DeriveVariability( AutoConstantType act )
		{
			switch ( act )
			{
				case AutoConstantType.ViewMatrix:
				case AutoConstantType.InverseViewMatrix:
				case AutoConstantType.TransposeViewMatrix:
				case AutoConstantType.InverseTransposeViewMatrix:
				case AutoConstantType.ProjectionMatrix:
				case AutoConstantType.InverseProjectionMatrix:
				case AutoConstantType.TransposeProjectionMatrix:
				case AutoConstantType.InverseTransposeProjectionMatrix:
				case AutoConstantType.ViewProjMatrix:
				case AutoConstantType.InverseViewProjMatrix:
				case AutoConstantType.TransposeViewProjMatrix:
				case AutoConstantType.InverseTransposeViewProjMatrix:
				case AutoConstantType.RenderTargetFlipping:
				case AutoConstantType.VertexWinding:
				case AutoConstantType.AmbientLightColor:
				case AutoConstantType.DerivedAmbientLightColor:
				case AutoConstantType.DerivedSceneColor:
				case AutoConstantType.FogColor:
				case AutoConstantType.FogParams:
				case AutoConstantType.SurfaceAmbientColor:
				case AutoConstantType.SurfaceDiffuseColor:
				case AutoConstantType.SurfaceSpecularColor:
				case AutoConstantType.SurfaceEmissiveColor:
				case AutoConstantType.SurfaceShininess:
				case AutoConstantType.CameraPosition:
				case AutoConstantType.Time:
				case AutoConstantType.Time_0_X:
				case AutoConstantType.CosTime_0_X:
				case AutoConstantType.SinTime_0_X:
				case AutoConstantType.TanTime_0_X:
				case AutoConstantType.Time_0_X_Packed:
				case AutoConstantType.Time_0_1:
				case AutoConstantType.CosTime_0_1:
				case AutoConstantType.SinTime_0_1:
				case AutoConstantType.TanTime_0_1:
				case AutoConstantType.Time_0_1_Packed:
				case AutoConstantType.Time_0_2PI:
				case AutoConstantType.CosTime_0_2PI:
				case AutoConstantType.SinTime_0_2PI:
				case AutoConstantType.TanTime_0_2PI:
				case AutoConstantType.Time_0_2PI_Packed:
				case AutoConstantType.FrameTime:
				case AutoConstantType.FPS:
				case AutoConstantType.ViewportWidth:
				case AutoConstantType.ViewportHeight:
				case AutoConstantType.InverseViewportWidth:
				case AutoConstantType.InverseViewportHeight:
				case AutoConstantType.ViewportSize:
				case AutoConstantType.TexelOffsets:
				case AutoConstantType.TextureSize:
				case AutoConstantType.InverseTextureSize:
				case AutoConstantType.PackedTextureSize:
				case AutoConstantType.SceneDepthRange:
				case AutoConstantType.ViewDirection:
				case AutoConstantType.ViewSideVector:
				case AutoConstantType.ViewUpVector:
				case AutoConstantType.FOV:
				case AutoConstantType.NearClipDistance:
				case AutoConstantType.FarClipDistance:
				case AutoConstantType.PassNumber:
				case AutoConstantType.TextureMatrix:
				case AutoConstantType.LODCameraPosition:
					return GpuParamVariability.Global;

				case AutoConstantType.WorldMatrix:
				case AutoConstantType.InverseWorldMatrix:
				case AutoConstantType.TransposeWorldMatrix:
				case AutoConstantType.InverseTransposeWorldMatrix:
				case AutoConstantType.WorldMatrixArray3x4:
				case AutoConstantType.WorldMatrixArray:
				case AutoConstantType.WorldViewMatrix:
				case AutoConstantType.InverseWorldViewMatrix:
				case AutoConstantType.TransposeWorldViewMatrix:
				case AutoConstantType.InverseTransposeWorldViewMatrix:
				case AutoConstantType.WorldViewProjMatrix:
				case AutoConstantType.InverseWorldViewProjMatrix:
				case AutoConstantType.TransposeWorldViewProjMatrix:
				case AutoConstantType.InverseTransposeWorldViewProjMatrix:
				case AutoConstantType.CameraPositionObjectSpace:
				case AutoConstantType.LODCameraPositionObjectSpace:
				case AutoConstantType.Custom:
				case AutoConstantType.AnimationParametric:
					return GpuParamVariability.PerObject;

				case AutoConstantType.LightPositionObjectSpace:
				case AutoConstantType.LightDirectionObjectSpace:
				case AutoConstantType.LightDistanceObjectSpace:
				case AutoConstantType.LightPositionObjectSpaceArray:
				case AutoConstantType.LightDirectionObjectSpaceArray:
				case AutoConstantType.LightDistanceObjectSpaceArray:
				case AutoConstantType.TextureWorldViewProjMatrix:
				case AutoConstantType.TextureWorldViewProjMatrixArray:
				case AutoConstantType.SpotLightWorldViewProjMatrix:

					// These depend on BOTH lights and objects
					return GpuParamVariability.PerObject | GpuParamVariability.Lights;

				case AutoConstantType.LightCount:
				case AutoConstantType.LightDiffuseColor:
				case AutoConstantType.LightSpecularColor:
				case AutoConstantType.LightPosition:
				case AutoConstantType.LightDirection:
				case AutoConstantType.LightPositionViewSpace:
				case AutoConstantType.LightDirectionViewSpace:
				case AutoConstantType.ShadowExtrusionDistance:
				case AutoConstantType.ShadowSceneDepthRange:
				case AutoConstantType.ShadowColor:
				case AutoConstantType.LightPowerScale:
				case AutoConstantType.LightDiffuseColorPowerScaled:
				case AutoConstantType.LightSpecularColorPowerScaled:
				case AutoConstantType.LightNumber:
				case AutoConstantType.LightCastsShadows:
				case AutoConstantType.LightAttenuation:
				case AutoConstantType.SpotLightParams:
				case AutoConstantType.LightDiffuseColorArray:
				case AutoConstantType.LightSpecularColorArray:
				case AutoConstantType.LightDiffuseColorPowerScaledArray:
				case AutoConstantType.LightSpecularColorPowerScaledArray:
				case AutoConstantType.LightPositionArray:
				case AutoConstantType.LightDirectionArray:
				case AutoConstantType.LightPositionViewSpaceArray:
				case AutoConstantType.LightDirectionViewSpaceArray:
				case AutoConstantType.LightPowerScaleArray:
				case AutoConstantType.LightAttenuationArray:
				case AutoConstantType.SpotLightParamsArray:
				case AutoConstantType.TextureViewProjMatrix:
				case AutoConstantType.TextureViewProjMatrixArray:
				case AutoConstantType.SpotLightViewProjMatrix:
				case AutoConstantType.LightCustom:
					return GpuParamVariability.Lights;

				case AutoConstantType.DerivedLightDiffuseColor:
				case AutoConstantType.DerivedLightSpecularColor:
				case AutoConstantType.DerivedLightDiffuseColorArray:
				case AutoConstantType.DerivedLightSpecularColorArray:
					return GpuParamVariability.Global | GpuParamVariability.Lights;

				case AutoConstantType.PassIterationNumber:
					return GpuParamVariability.PassIterationNumber;

				default:
					return GpuParamVariability.Global;
			}
			;
		}
			public AutoConstantDefinition( AutoConstantType autoConstantType, string name, int elementCount,
			                               ElementType elementType, AutoConstantDataType dataType )
			{
				this.AutoConstantType = autoConstantType;
				this.Name = name;
				this.ElementCount = elementCount;
				this.ElementType = elementType;
				this.DataType = dataType;
			}
		/// <summary>
		///    Overloaded method.
		/// </summary>
		/// <param name="type">The type of automatic constant to set.</param>
		/// <param name="index">
		///    The location in the constant list to place this updated constant every time
		///    it is changed. Note that because of the nature of the types, we know how big the
		///    parameter details will be so you don't need to set that like you do for manual constants.
		/// </param>
		/// <param name="extraInfo">If the constant type needs more information (like a light index) put it here.</param>
		public void SetAutoConstant( int index, AutoConstantType type, int extraInfo )
		{
			AutoConstantEntry entry = new AutoConstantEntry( type, index, extraInfo, 0 );
			System.Diagnostics.Debug.Assert( type != AutoConstantType.SinTime_0_X );
			autoConstantList.Add( entry );
		}
		public void SetAutoConstant( int index, AutoConstantType acType, int extraInfo = 0 )
 /// <see cref="GpuProgramParameters.SetNamedAutoConstant(string, AutoConstantType, int)"/>
 public void SetNamedAutoConstant( string name, AutoConstantType type )
 {
     SetNamedAutoConstant( name, type, 0 );
 }
		public void SetAutoConstant( int index, AutoConstantType acType, ushort extraInfo1, ushort extraInfo2 )
		{
			var extraInfo = extraInfo1 | ( extraInfo2 << 16 );
			SetAutoConstant( index, acType, extraInfo );
		}
 public AutoConstantDefinition( AutoConstantType autoConstantType, string name, int elementCount, ElementType elementType, AutoConstantDataType dataType )
 {
     AutoConstantType = autoConstantType;
     Name = name;
     ElementCount = elementCount;
     ElementType = elementType;
     DataType = dataType;
 }
 public void setNamedAutoConstant(String name, AutoConstantType acType)
 {
     GpuProgramParameters_setNamedAutoConstant1(ptr, name, acType);
     OgreExceptionManager.fireAnyException();
 }