Exemplo n.º 1
0
		/// <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;
		}
Exemplo n.º 2
0
		/// <summary>
		/// Applies graphics parameters.
		/// </summary>
		/// <param name="p"></param>
		internal void ApplyParameters ( ref GraphicsParameters p )
		{
			p.Width				=	Width;
			p.Height			=	Height;
			p.FullScreen		=	Fullscreen;
			p.StereoMode		=	(Fusion.Drivers.Graphics.StereoMode)StereoMode;
			p.InterlacingMode	=	(Fusion.Drivers.Graphics.InterlacingMode)InterlacingMode;
			p.UseDebugDevice	=	UseDebugDevice;
			p.MsaaLevel			=	MsaaEnabled ? 4 : 1;
		}
Exemplo n.º 3
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;
        }