Example #1
0
        /// <summary>
        ///    Create the specified type of GpuProgram.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        protected override Resource _create(string name, ulong handle, string group, bool isManual,
                                            IManualResourceLoader loader, NameValuePairList createParams)
        {
            if (createParams == null ||
                (createParams.ContainsKey("syntax") == false || createParams.ContainsKey("type") == false))
            {
                throw new Exception("You must supply 'syntax' and 'type' parameters");
            }

            string syntaxCode = createParams["syntax"];
            string type       = createParams["type"];

            // if there is none, this syntax code must not be supported
            // just return the base GL program since it won't be doing anything anyway
            if (this.factories[syntaxCode] == null)
            {
                return(new GLGpuProgram(this, name, handle, group, isManual, loader));
            }

            GpuProgramType gpt;

            if (type == "vertex_program")
            {
                gpt = GpuProgramType.Vertex;
            }
            else
            {
                gpt = GpuProgramType.Fragment;
            }

            return(((IOpenGLGpuProgramFactory)this.factories[syntaxCode]).Create(this, name, handle, group, isManual, loader,
                                                                                 gpt,
                                                                                 syntaxCode));
        }
		/// <summary>
		///    Create the specified type of GpuProgram.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="type"></param>
		/// <returns></returns>
		protected override Resource _create( string name, ulong handle, string group, bool isManual,
		                                     IManualResourceLoader loader, NameValuePairList createParams )
		{
			if ( createParams == null ||
			     ( createParams.ContainsKey( "syntax" ) == false || createParams.ContainsKey( "type" ) == false ) )
			{
				throw new Exception( "You must supply 'syntax' and 'type' parameters" );
			}

			string syntaxCode = createParams[ "syntax" ];
			string type = createParams[ "type" ];

			// if there is none, this syntax code must not be supported
			// just return the base GL program since it won't be doing anything anyway
			if ( this.factories[ syntaxCode ] == null )
			{
				return new GLGpuProgram( this, name, handle, group, isManual, loader );
			}

			GpuProgramType gpt;
			if ( type == "vertex_program" )
			{
				gpt = GpuProgramType.Vertex;
			}
			else
			{
				gpt = GpuProgramType.Fragment;
			}

			return ( (IOpenGLGpuProgramFactory)this.factories[ syntaxCode ] ).Create( this, name, handle, group, isManual, loader,
			                                                                          gpt,
			                                                                          syntaxCode );
		}
Example #3
0
 public override void RestoreState(NameValuePairList state)
 {
     if (state.ContainsKey("CameraPosition") && state.ContainsKey("CameraOrientation"))
     {
         this.CameraManager.setStyle(CameraStyle.FreeLook);
         this.Camera.Position    = StringConverter.ParseVector3(state["CameraPosition"]);
         this.Camera.Orientation = StringConverter.ParseQuaternion(state["CameraOrientation"]);
     }
 }
 protected override Resource _create(string name, ResourceHandle handle, string group, bool isManual,
                                     IManualResourceLoader loader, NameValuePairList createParams)
 {
     if (createParams == null || !createParams.ContainsKey("language"))
     {
         throw new Exception("You must supply a 'language' parameter");
     }
     return(GetFactory(createParams["language"]).CreateInstance(this, name, handle, group, isManual, loader));
 }
Example #5
0
 protected override Resource _create(string name, ResourceHandle handle, string group, bool isManual, IManualResourceLoader loader, NameValuePairList createParams)
 {
     if (!createParams.ContainsKey("type"))
     {
         throw new Exception("You must supply a 'type' parameter.");
     }
     if (createParams["type"] == "vertex_program")
     {
         return(new XnaVertexProgram(this, name, handle, group, isManual, loader, device));
     }
     else
     {
         return(new XnaFragmentProgram(this, name, handle, group, isManual, loader, device));
     }
 }
		protected override Resource _create( string name, ResourceHandle handle, string group, bool isManual,
		                                     IManualResourceLoader loader, NameValuePairList createParams )
		{
			if ( createParams == null || !createParams.ContainsKey( "type" ) )
			{
				throw new AxiomException( "You must supply a 'type' parameter." );
			}

			if ( createParams[ "type" ] == "vertex_program" )
			{
				return new D3D9GpuVertexProgram( this, name, handle, group, isManual, loader );
			}
			else
			{
				return new D3D9GpuFragmentProgram( this, name, handle, group, isManual, loader );
			}
		}
Example #7
0
		/// <summary>
		/// Automatically restores position and orientation for free-look cameras.
		/// </summary>
		/// <param name="state"></param>
		public override void RestoreState( NameValuePairList state )
		{
			if ( state.ContainsKey( "CameraPosition" ) && state.ContainsKey( "CameraOrientation" ) )
			{
				this.CameraManager.setStyle( CameraStyle.FreeLook );
				this.Camera.Position = StringConverter.ParseVector3( state[ "CameraPosition" ] );
				this.Camera.Orientation = StringConverter.ParseQuaternion( state[ "CameraOrientation" ] );
			}
		}
		protected override Resource _create( string name, ResourceHandle handle, string group, bool isManual,
		                                     IManualResourceLoader loader, NameValuePairList createParams )
		{
			if ( createParams == null || !createParams.ContainsKey( "language" ) )
			{
				throw new Exception( "You must supply a 'language' parameter" );
			}
			return GetFactory( createParams[ "language" ] ).CreateInstance( this, name, handle, group, isManual, loader );
		}