當前位置: 首頁>>代碼示例>>C#>>正文


C# Graphics.PresentationParameters類代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Graphics.PresentationParameters的典型用法代碼示例。如果您正苦於以下問題:C# PresentationParameters類的具體用法?C# PresentationParameters怎麽用?C# PresentationParameters使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PresentationParameters類屬於Microsoft.Xna.Framework.Graphics命名空間,在下文中一共展示了PresentationParameters類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateDevice

        private void CreateDevice(IntPtr windowHandle, int width, int height)
        {
            try
            {
                parameters = new PresentationParameters();

                parameters.BackBufferWidth = Math.Max(width, 1);
                parameters.BackBufferHeight = Math.Max(height, 1);
                parameters.BackBufferFormat = SurfaceFormat.Color;
                parameters.DepthStencilFormat = DepthFormat.Depth24;
                parameters.DeviceWindowHandle = windowHandle;
                parameters.PresentationInterval = PresentInterval.Immediate;
                parameters.IsFullScreen = false;

                graphicsDevice = new GraphicsDevice(
                    GraphicsAdapter.DefaultAdapter,
                    GraphicsProfile.Reach,
                    parameters);

                if (DeviceCreated != null)
                    DeviceCreated(this, EventArgs.Empty);

            }
            catch (Exception ex)
            {
                throw new ApplicationException("Failed to initialize GraphicsDeviceService. See inner exception for details.", ex);
            }
        }
開發者ID:liquidradio,項目名稱:Terraria-Map-Editor,代碼行數:28,代碼來源:GraphicsDeviceService.cs

示例2: GraphicsDeviceService

        public GraphicsDeviceService(IntPtr windowHandle)
        {
            var screenBounds = System.Windows.Forms.Screen.FromHandle(windowHandle).Bounds;
            _parameters = new PresentationParameters
            {
                BackBufferWidth = screenBounds.Width,
                BackBufferHeight = screenBounds.Height,
                BackBufferFormat = SurfaceFormat.Color,
                DepthStencilFormat = DepthFormat.Depth24,
                DeviceWindowHandle = windowHandle,
                IsFullScreen = false,
                PresentationInterval = PresentInterval.Immediate,
            };

            var profilingAdapter = GraphicsAdapter.Adapters.FirstOrDefault(a => a.Description.Contains("PerfHUD"));
            var useAdapter = profilingAdapter ?? GraphicsAdapter.DefaultAdapter;
            if (profilingAdapter != null) GraphicsAdapter.UseReferenceDevice = true;

            if (!useAdapter.IsProfileSupported(GraphicsProfile.Reach))
                GraphicsAdapter.UseReferenceDevice = !GraphicsAdapter.UseReferenceDevice;
            if (!useAdapter.IsProfileSupported(GraphicsProfile.Reach))
                throw new NotSupportedException("No suitable graphics adapter found");
            try
            {
                GraphicsDevice = new GraphicsDevice(useAdapter, GraphicsProfile.Reach, _parameters);
            }
            catch (InvalidOperationException)
            {
                // With VMware, GraphicsDevice.ctor may throw InvalidOperationException when using reference device.
                GraphicsAdapter.UseReferenceDevice = false;
                GraphicsDevice = new GraphicsDevice(useAdapter, GraphicsProfile.Reach, _parameters);
            }
            if (DeviceCreated != null) DeviceCreated(this, EventArgs.Empty);
        }
開發者ID:vvnurmi,項目名稱:assaultwing,代碼行數:34,代碼來源:GraphicsDeviceService.cs

示例3: XNAGraphicsDeviceService

        private XNAGraphicsDeviceService(IntPtr windowHandle, int width, int height)
        {
            parameters = new PresentationParameters();

            parameters.BackBufferWidth = Math.Max(width, 1);
            parameters.BackBufferHeight = Math.Max(height, 1);
            parameters.BackBufferFormat = SurfaceFormat.Color;
            parameters.DepthStencilFormat = DepthFormat.Depth16;
            parameters.DeviceWindowHandle = windowHandle;
            parameters.PresentationInterval = PresentInterval.Immediate;
            parameters.IsFullScreen = false;

            if (GraphicsAdapter.DefaultAdapter.IsProfileSupported(GraphicsProfile.HiDef))
                graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter,
                                                    GraphicsProfile.HiDef,
                                                    parameters);
            else
            {
                MessageBox.Show(
                    "WARNING: Your graphics device does not support the HiDef Profile, switching to the Reach profile.",
                    "Rose");
                graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter,
                                                    GraphicsProfile.Reach,
                                                    parameters);
            }
            XnaResourceManager.Instance.DeviceCreate(graphicsDevice);
        }
開發者ID:sgrzeda,項目名稱:rose,代碼行數:27,代碼來源:XNAGraphicsDeviceService.cs

示例4: InitializeMainScrn

        private void InitializeMainScrn()
        {
            mainScreen = new MainScreen();

            PresentationParameters pp = new PresentationParameters();
            pp.BackBufferCount = 1;
            pp.IsFullScreen = false;
            pp.SwapEffect = SwapEffect.Discard;
            pp.BackBufferWidth = mainScreen.canvas.Width;
            pp.BackBufferHeight = mainScreen.canvas.Height;

            pp.AutoDepthStencilFormat = DepthFormat.Depth24Stencil8;
            pp.EnableAutoDepthStencil = true;
            pp.PresentationInterval = PresentInterval.Default;
            pp.BackBufferFormat = SurfaceFormat.Unknown;
            pp.MultiSampleType = MultiSampleType.None;

            mainDevice = new GraphicsDevice( GraphicsAdapter.DefaultAdapter,
                DeviceType.Hardware, this.mainScreen.canvas.Handle,
                pp );

            mainScreen.canvas.SizeChanged += new EventHandler( mainScreen_canvas_SizeChanged );
            mainScreen.canvas.Paint += new EventHandler( mainScreen_canvas_Paint );

            mainDevice.Reset();

            mainScreen.Show( dockPanel, DockState.Document );

            mainScrnBatch = new SpriteBatch( mainDevice );

            //BasicGraphics.Initial( mainDevice );
        }
開發者ID:ingex0,項目名稱:smarttank,代碼行數:32,代碼來源:MapEditer.cs

示例5: GraphicsDeviceService

        /// <summary>
        /// Constructor is private, because this is a singleton class:
        /// client controls should use the public AddRef method instead.
        /// </summary>
        GraphicsDeviceService(IntPtr windowHandle, int width, int height)
        {
            parameters = new PresentationParameters();

            parameters.BackBufferWidth = Math.Max(width, 1);
            parameters.BackBufferHeight = Math.Max(height, 1);
            parameters.BackBufferFormat = SurfaceFormat.Color;
            parameters.DepthStencilFormat = DepthFormat.Depth24;

            parameters.DeviceWindowHandle = windowHandle;
            parameters.RenderTargetUsage = RenderTargetUsage.DiscardContents;
            parameters.IsFullScreen = false;
             
            /*PORT XNA 4
            parameters.EnableAutoDepthStencil = true;
            parameters.AutoDepthStencilFormat = DepthFormat.Depth24;
            */

            if(GraphicsAdapter.DefaultAdapter.IsProfileSupported(GraphicsProfile.HiDef))
                graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, parameters);
            else if (GraphicsAdapter.DefaultAdapter.IsProfileSupported(GraphicsProfile.Reach))
                graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach, parameters);
           else
            {
                System.Windows.Forms.MessageBox.Show("Default graphics adapter does not support XNA");
                throw new System.InvalidOperationException("Default graphics adapter does not support XNA");
            }
   
        }
開發者ID:abordt,項目名稱:Viking,代碼行數:33,代碼來源:GraphicsDeviceService.cs

示例6: Renderer

        public Renderer( PresentationParameters p_PresentationParameters )
        {
            m_GraphicsAdapter = GraphicsAdapter.DefaultAdapter;

            m_PresentationParameters = p_PresentationParameters;
            #if XBOX360
            m_PresentationParameters.BackBufferWidth =
                m_GraphicsAdapter.CurrentDisplayMode.Width;
            m_PresentationParameters.BackBufferHeight =
                m_GraphicsAdapter.CurrentDisplayMode.Height;
            m_PresentationParameters.IsFullScreen = true;
            #endif

            m_GraphicsDeviceService = GraphicsDeviceService.AddReference(
                m_PresentationParameters );

            m_ServiceContainer.AddService< IGraphicsDeviceService >(
                m_GraphicsDeviceService );

            m_ClearColour = new Color( 1.0f, 1.0f, 1.0f );

            m_Width = m_PresentationParameters.BackBufferWidth;
            m_Height = m_PresentationParameters.BackBufferHeight;

            if( GamerServicesDispatcher.IsInitialized == false )
            {
                GamerServicesDispatcher.WindowHandle =
                    m_GraphicsDeviceService.GraphicsDevice.
                        PresentationParameters.DeviceWindowHandle;

                GamerServicesDispatcher.Initialize( m_ServiceContainer );

                GamerServicesDispatcher.Update( );
            }
        }
開發者ID:RedRingRico,項目名稱:BloodBullet,代碼行數:35,代碼來源:Renderer.cs

示例7: GraphicsDeviceInformation

 public GraphicsDeviceInformation()
 {
     deviceType = DeviceType.Hardware;
     adapter = GraphicsAdapter.DefaultAdapter;
     presentationParameters = new PresentationParameters();
     presentationParameters.Clear();
 }
開發者ID:sergios1234,項目名稱:monoxna,代碼行數:7,代碼來源:GraphicsDeviceInformation.cs

示例8: GraphicsDeviceService

        /// <summary>
        /// Constructor is private, because this is a singleton class:
        /// client controls should use the public AddRef method instead.
        /// </summary>
        GraphicsDeviceService(IntPtr windowHandle, int width, int height)
        {
            parameters = new PresentationParameters();

            // Basic settings.
            parameters.BackBufferWidth = Math.Max(width, 1);
            parameters.BackBufferHeight = Math.Max(height, 1);
            parameters.BackBufferFormat = SurfaceFormat.Color;
            parameters.DepthStencilFormat = DepthFormat.Depth24;
            parameters.DeviceWindowHandle = windowHandle;
            parameters.PresentationInterval = PresentInterval.Immediate;
            parameters.IsFullScreen = false;

            // High-quality settings.
            parameters.MultiSampleCount = 4;

            // Try for high-quality graphics, otherwise drop down to basic settings.
            try
            {
                graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter,
                                                    GraphicsProfile.HiDef,
                                                    parameters);
            }
            catch
            {
                parameters.MultiSampleCount = 0;
                graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter,
                                                       GraphicsProfile.Reach,
                                                       parameters);
            }

        }
開發者ID:tuannsofta,項目名稱:kinect4bag,代碼行數:36,代碼來源:GraphicsDeviceService.cs

示例9: SelectTeleportationForm

        public SelectTeleportationForm(Map map, System.Drawing.Point premier, int layer, Map firstMap, SpriteBatch Mapbatch)
        {
            InitializeComponent();
            utils = new XNAUtils();
            this.map = map;
            this.premier = premier;
            this.layer = layer;
            this.firstMap = firstMap;
            this.batch = Mapbatch;

            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Size = Screen.PrimaryScreen.Bounds.Size;
            this.StartPosition = FormStartPosition.Manual;
            this.Location = new System.Drawing.Point(0, 0);

            PN_Map.Size = Screen.PrimaryScreen.Bounds.Size;
            PresentationParameters pp = new PresentationParameters()
            {
                BackBufferHeight = PN_Map.Height,
                BackBufferWidth = PN_Map.Width,
                DeviceWindowHandle = PN_Map.Handle,
                IsFullScreen = false
            };
            XNADevices.graphicsdevice.Reset(pp);
        }
開發者ID:rykdesjardins,項目名稱:pixel-lion,代碼行數:25,代碼來源:SelectTeleportationForm.cs

示例10: Reset

 public static unsafe void Reset(GraphicsDevice graphicsDevice, PresentationParameters parameters)
 {
     var fi = typeof(GraphicsDevice).GetField("pComPtr", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
     var ptr = fi.GetValue(graphicsDevice);
     var pComPtr = new IntPtr(System.Reflection.Pointer.Unbox(ptr));
     if (g_mdxAssembly == null) throw new ApplicationException("GraphicsDevice.Reset failed. Please install Managed DirectX from the Assault Wing web site.");
     var mdxDeviceType = g_mdxAssembly.GetType("Microsoft.DirectX.Direct3D.Device");
     var mdxPresentParametersType = g_mdxAssembly.GetType("Microsoft.DirectX.Direct3D.PresentParameters");
     var dev = Activator.CreateInstance(mdxDeviceType, pComPtr);
     dynamic dxParameters = new MDXPresentParameters(Activator.CreateInstance(mdxPresentParametersType));
     dxParameters.AutoDepthStencilFormat = parameters.DepthStencilFormat.ToD3D();
     dxParameters.BackBufferCount = 1;
     dxParameters.BackBufferFormat = parameters.BackBufferFormat.ToD3D();
     dxParameters.BackBufferHeight = parameters.BackBufferHeight;
     dxParameters.BackBufferWidth = parameters.BackBufferWidth;
     dxParameters.DeviceWindow = null;
     dxParameters.DeviceWindowHandle = parameters.DeviceWindowHandle;
     dxParameters.EnableAutoDepthStencil = false; // ???
     dxParameters.ForceNoMultiThreadedFlag = false; // ???
     dxParameters.FullScreenRefreshRateInHz = 0; // ??? should be 0 for windowed mode; in fullscreen mode take value from DisplayModeCollection
     dxParameters.MultiSample = GetMDXEnumValue("MultiSampleType", "None");
     dxParameters.MultiSampleQuality = 0;
     dxParameters.PresentationInterval = parameters.PresentationInterval.ToD3D();
     dxParameters.PresentFlag = GetMDXEnumValue("PresentFlag", "None"); // ???
     dxParameters.SwapEffect = GetMDXEnumValue("SwapEffect", "Flip"); // ??? see _parameters.RenderTargetUsage
     dxParameters.Windowed = !parameters.IsFullScreen;
     var resetMethod = mdxDeviceType.GetMethod("Reset");
     var mdxPresentParametersArray = Array.CreateInstance(mdxPresentParametersType, 1);
     mdxPresentParametersArray.SetValue(((MDXPresentParameters)dxParameters).WrappedValue, 0);
     resetMethod.Invoke(dev, new[] { mdxPresentParametersArray });
 }
開發者ID:vvnurmi,項目名稱:assaultwing,代碼行數:31,代碼來源:Direct3D.cs

示例11: GraphicsDeviceService

        /// <summary>
        /// Constructor is private, because this is a singleton class:
        /// client controls should use the public AddRef method instead.
        /// </summary>
        GraphicsDeviceService(IntPtr windowHandle, int width, int height)
        {
            //parameters = new PresentationParameters();

            //parameters.BackBufferWidth = Math.Max(width, 1);
            //parameters.BackBufferHeight = Math.Max(height, 1);
            //parameters.BackBufferFormat = SurfaceFormat.Color;

            //parameters.EnableAutoDepthStencil = true;
            //parameters.AutoDepthStencilFormat = DepthFormat.Depth24;

            this.Parameters = new PresentationParameters()
            {
                BackBufferWidth = Math.Max(width, 1),
                BackBufferHeight = Math.Max(height, 1),
                BackBufferFormat = SurfaceFormat.Color,
                DepthStencilFormat = DepthFormat.Depth24,
                DeviceWindowHandle = windowHandle,
                PresentationInterval = PresentInterval.Immediate,
                IsFullScreen = false,
                MultiSampleCount = 4
            };

            //graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter,
            //                                    DeviceType.Hardware,
            //                                    windowHandle,
            //                                    parameters);

            this.graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach, this.Parameters);

            if (this.DeviceCreated != null)
            {
                this.DeviceCreated(this, EventArgs.Empty);
            }
        }
開發者ID:rzellertownson,項目名稱:neurorighter,代碼行數:39,代碼來源:GraphicsDeviceService.cs

示例12: GraphicsDevice

 public GraphicsDevice()
 {
     BitmapCacheEnabled = true;
     RenderAtScale = 1;
     RenderState = new RenderState();
     PresentationParameters = new PresentationParameters();
     PresentationParameters.BackBufferFormat = SurfaceFormat.Canvas;
 }
開發者ID:liwq-net,項目名稱:SilverSprite,代碼行數:8,代碼來源:GraphicsDevice.cs

示例13: EqualsTest

 public void EqualsTest()
 {
     PresentationParameters b = new PresentationParameters();
     Assert.IsFalse(b == a, "#1");
     Assert.IsTrue(b != a, "#2");
     Assert.IsFalse(b == null, "#3");
     Assert.IsTrue(b.Equals(b), "#4");
 }
開發者ID:sergios1234,項目名稱:monoxna,代碼行數:8,代碼來源:PresentationParametersTests.cs

示例14: GraphicsDeviceService

        GraphicsDeviceService(
            PresentationParameters p_PresentationParameters)
        {
            m_PresentationParameters = p_PresentationParameters;

            m_GraphicsDevice = new GraphicsDevice(
                GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef,
                m_PresentationParameters );
        }
開發者ID:RedRingRico,項目名稱:BloodBullet,代碼行數:9,代碼來源:GraphicsDeviceService.cs

示例15: GraphicsDeviceService

 private GraphicsDeviceService(IntPtr windowHandle, int width, int height)
 {
     this.parameters = new PresentationParameters();
     this.parameters.BackBufferWidth = Math.Max(width, 1);
     this.parameters.BackBufferHeight = Math.Max(height, 1);
     this.parameters.BackBufferFormat = SurfaceFormat.Color;
     this.parameters.EnableAutoDepthStencil = true;
     this.parameters.AutoDepthStencilFormat = DepthFormat.Depth24;
     this.graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware, windowHandle, this.parameters);
 }
開發者ID:Jiwan,項目名稱:ROSE-Content-Importer,代碼行數:10,代碼來源:GraphicsDeviceService.cs


注:本文中的Microsoft.Xna.Framework.Graphics.PresentationParameters類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。