The constant buffer collection.
Inheritance: GraphicsResource
		/// <summary>
		/// Initializes graphics device
		/// </summary>
		internal void Initialize ( GraphicsParameters parameters )
		{
			this.GraphicsProfile	=	parameters.GraphicsProfile;

			try {
				if (parameters.StereoMode==StereoMode.Disabled) 	display	=	new GenericDisplay( Game, this, parameters ); else
				if (parameters.StereoMode==StereoMode.NV3DVision)	display	=	new NV3DVisionDisplay( Game, this, parameters ); else 
				if (parameters.StereoMode==StereoMode.DualHead)		display	=	new StereoDualHeadDisplay( Game, this, parameters ); else 
				if (parameters.StereoMode==StereoMode.Interlaced)	display	=	new StereoInterlacedDisplay( Game, this, parameters ); else 
				if (parameters.StereoMode==StereoMode.OculusRift)	display	=	new OculusRiftDisplay( Game, this, parameters ); else 
					throw new ArgumentException("parameters.StereoMode");

			} catch ( GraphicsException e ) {
				Log.Warning("Failed to intialize graphics device.");
				Log.Warning("{0}", e.Message );
				Log.Warning("Attempt to use default parameters...");

				parameters.FullScreen	=	false;
				parameters.StereoMode	=	StereoMode.Disabled;

				display	=	new GenericDisplay( Game, this, parameters ); 
			}
			

			device			=	display.d3dDevice;
			deviceContext	=	device.ImmediateContext;

			display.CreateDisplayResources();


			//
			//	create color buffer :
			//	
			PixelShaderResources	=	new ShaderResourceCollection( this, DeviceContext.PixelShader		);
			VertexShaderResources 	=	new ShaderResourceCollection( this, DeviceContext.VertexShader		);
			GeometryShaderResources =	new ShaderResourceCollection( this, DeviceContext.GeometryShader	);
			ComputeShaderResources 	=	new ShaderResourceCollection( this, DeviceContext.ComputeShader		);
			DomainShaderResources 	=	new ShaderResourceCollection( this, DeviceContext.DomainShader		);
			HullShaderResources 	=	new ShaderResourceCollection( this, DeviceContext.HullShader		);

			PixelShaderSamplers		=	new SamplerStateCollection	( this, DeviceContext.PixelShader		);
			VertexShaderSamplers	=	new SamplerStateCollection	( this, DeviceContext.VertexShader		);
			GeometryShaderSamplers	=	new SamplerStateCollection	( this, DeviceContext.GeometryShader	);
			ComputeShaderSamplers	=	new SamplerStateCollection	( this, DeviceContext.ComputeShader		);
			DomainShaderSamplers	=	new SamplerStateCollection	( this, DeviceContext.DomainShader		);
			HullShaderSamplers		=	new SamplerStateCollection	( this, DeviceContext.HullShader		);

			PixelShaderConstants	=	new ConstantBufferCollection( this, DeviceContext.PixelShader		);
			VertexShaderConstants	=	new ConstantBufferCollection( this, DeviceContext.VertexShader		);
			GeometryShaderConstants	=	new ConstantBufferCollection( this, DeviceContext.GeometryShader	);
			ComputeShaderConstants	=	new ConstantBufferCollection( this, DeviceContext.ComputeShader		);
			DomainShaderConstants	=	new ConstantBufferCollection( this, DeviceContext.DomainShader		);
			HullShaderConstants		=	new ConstantBufferCollection( this, DeviceContext.HullShader		);

			ResetStates();

			FullScreen	=	parameters.FullScreen;
		}
Beispiel #2
0
        /// <summary>
        /// Initializes graphics device
        /// </summary>
        internal void Initialize(GraphicsParameters parameters)
        {
            IsInitialized        = false;
            this.GraphicsProfile = parameters.GraphicsProfile;

            try {
                if (parameters.StereoMode == StereoMode.Disabled)
                {
                    display = new GenericDisplay(Game, this, parameters);
                }
                else
                if (parameters.StereoMode == StereoMode.NV3DVision)
                {
                    display = new NV3DVisionDisplay(Game, this, parameters);
                }
                else
                if (parameters.StereoMode == StereoMode.DualHead)
                {
                    display = new StereoDualHeadDisplay(Game, this, parameters);
                }
                else
                if (parameters.StereoMode == StereoMode.Interlaced)
                {
                    display = new StereoInterlacedDisplay(Game, this, parameters);
                }
                else
                                #if OCULUS
                //if (parameters.StereoMode==StereoMode.OculusRift)	display	=	new OculusRiftDisplay( Game, this, parameters ); else
                                #endif
                { throw new ArgumentException("parameters.StereoMode"); }
            } catch (GraphicsException e) {
                Log.Warning("Failed to intialize graphics device.");
                Log.Warning("{0}", e.Message);
                Log.Warning("Attempt to use default parameters...");

                parameters.FullScreen = false;
                parameters.StereoMode = StereoMode.Disabled;

                display = new GenericDisplay(Game, this, parameters);
            }


            device        = display.d3dDevice;
            deviceContext = device.ImmediateContext;

            display.CreateDisplayResources();


            //
            //	create color buffer :
            //
            PixelShaderResources    = new ShaderResourceCollection(this, DeviceContext.PixelShader);
            VertexShaderResources   = new ShaderResourceCollection(this, DeviceContext.VertexShader);
            GeometryShaderResources = new ShaderResourceCollection(this, DeviceContext.GeometryShader);
            ComputeShaderResources  = new ShaderResourceCollection(this, DeviceContext.ComputeShader);
            DomainShaderResources   = new ShaderResourceCollection(this, DeviceContext.DomainShader);
            HullShaderResources     = new ShaderResourceCollection(this, DeviceContext.HullShader);

            PixelShaderSamplers    = new SamplerStateCollection(this, DeviceContext.PixelShader);
            VertexShaderSamplers   = new SamplerStateCollection(this, DeviceContext.VertexShader);
            GeometryShaderSamplers = new SamplerStateCollection(this, DeviceContext.GeometryShader);
            ComputeShaderSamplers  = new SamplerStateCollection(this, DeviceContext.ComputeShader);
            DomainShaderSamplers   = new SamplerStateCollection(this, DeviceContext.DomainShader);
            HullShaderSamplers     = new SamplerStateCollection(this, DeviceContext.HullShader);

            PixelShaderConstants    = new ConstantBufferCollection(this, DeviceContext.PixelShader);
            VertexShaderConstants   = new ConstantBufferCollection(this, DeviceContext.VertexShader);
            GeometryShaderConstants = new ConstantBufferCollection(this, DeviceContext.GeometryShader);
            ComputeShaderConstants  = new ConstantBufferCollection(this, DeviceContext.ComputeShader);
            DomainShaderConstants   = new ConstantBufferCollection(this, DeviceContext.DomainShader);
            HullShaderConstants     = new ConstantBufferCollection(this, DeviceContext.HullShader);

            ResetStates();

            //FullScreen	=	parameters.FullScreen;

            IsInitialized = true;
        }