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);
            }
        }
示例#2
0
        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);
        }
示例#3
0
        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 );
        }
        /// <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);
            }
        }
示例#5
0
 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 });
 }
        /// <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);
            }

        }
 public GraphicsDeviceInformation()
 {
     deviceType = DeviceType.Hardware;
     adapter = GraphicsAdapter.DefaultAdapter;
     presentationParameters = new PresentationParameters();
     presentationParameters.Clear();
 }
示例#8
0
        /// <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");
            }
   
        }
        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);
        }
        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);
        }
示例#11
0
        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( );
            }
        }
 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");
 }
示例#13
0
 public GraphicsDevice()
 {
     BitmapCacheEnabled = true;
     RenderAtScale = 1;
     RenderState = new RenderState();
     PresentationParameters = new PresentationParameters();
     PresentationParameters.BackBufferFormat = SurfaceFormat.Canvas;
 }
        GraphicsDeviceService(
            PresentationParameters p_PresentationParameters)
        {
            m_PresentationParameters = p_PresentationParameters;

            m_GraphicsDevice = new GraphicsDevice(
                GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef,
                m_PresentationParameters );
        }
示例#15
0
        public void CreateDevice()
        {
            PresentationParameters pp = new PresentationParameters();
            pp.IsFullScreen = false;
            pp.BackBufferHeight = this.m_renderControl.Height;
            pp.BackBufferWidth = this.m_renderControl.Width;
            pp.DeviceWindowHandle = this.m_renderControl.Handle;

            this.m_graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, pp);
        }
 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);
 }
        public static GraphicsDeviceService AddReference(
            PresentationParameters p_PresentationParameters)
        {
            if( Interlocked.Increment( ref m_ReferenceCount ) == 1 )
            {
                Instance = new GraphicsDeviceService(
                    p_PresentationParameters );
            }

            return Instance;
        }
示例#18
0
 private static GraphicsDevice setupGraphicsDevice()
 {
     PresentationParameters windowParams = new PresentationParameters();
     windowParams.DeviceWindowHandle = new IntPtr(1);
     GraphicsAdapter.UseNullDevice = true;
     GraphicsDevice device = new GraphicsDevice(
         GraphicsAdapter.DefaultAdapter,
         GraphicsProfile.Reach,
         windowParams);
     return device;
 }
        GraphicsDeviceService(IntPtr windowHandle, int width, int height)
        {
            parameters = new PresentationParameters();
            parameters.BackBufferWidth = Math.Max(width, 1);
            parameters.BackBufferHeight = Math.Max(height, 1);
            parameters.DepthStencilFormat = DepthFormat.Depth24;
            parameters.DeviceWindowHandle = windowHandle;
            parameters.PresentationInterval = PresentInterval.Immediate;
            parameters.IsFullScreen = false;

            graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, parameters);
        }
        public override bool InitializeHandler(IntPtr hAttachedWindow)
        {
            m_XNA_GraphicsDevice = null;
            pp = null;

            if (!base.InitializeHandler(hAttachedWindow))
                return false;

            UWB_XNAGraphicsDevice.m_TheAPI.CreateGraphicsContext(hAttachedWindow, ref pp);
            m_XNA_GraphicsDevice = UWB_XNAGraphicsDevice.m_TheAPI.GraphicsDevice;
            return true;
        }
 /// <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)
 {
     GraphicsAdapter adapter = GraphicsAdapter.DefaultAdapter;
     GraphicsProfile profile = GraphicsProfile.Reach;
     PresentationParameters pp = new PresentationParameters()
     {
         DeviceWindowHandle = windowHandle,
         BackBufferWidth = Math.Max(width, 1),
         BackBufferHeight = Math.Max(height, 1),
     };
     graphicsDevice = new GraphicsDevice(adapter, profile, pp);
 }
        /// <summary>
        /// Constructor is private, because this is a singleton class:
        /// client controls should use the public AddRef method instead.
        /// </summary>
        GraphicsDeviceService(GraphicsProfile profile, 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.Depth24Stencil8;
            parameters.DeviceWindowHandle = windowHandle;
            parameters.IsFullScreen = false;

            graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, profile, parameters);
        }
示例#23
0
        public static GraphicsDevice CreateDevice()
        {
            //init PresentationParameters
            pp = new PresentationParameters();
            pp.AutoDepthStencilFormat = DepthFormat.Depth24Stencil8;
            pp.EnableAutoDepthStencil = true;
            pp.PresentOptions = PresentOptions.DiscardDepthStencil;
            pp.RenderTargetUsage = RenderTargetUsage.DiscardContents;
            pp.SwapEffect = SwapEffect.Discard;
            pp.BackBufferFormat = SurfaceFormat.Color;

            return new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware, Static.RenderTarget.Handle, pp);
        }
 internal XNASwapChainImplementation(XNA.GraphicsDeviceManager gdManager, IntPtr windowHandle, PresentationParameters presentParams)
 {
     _gdManager             = gdManager;
     _graphicsDevice        = gdManager.GraphicsDevice;
     _windowHandle          = windowHandle;
     _presentParams         = presentParams;
     _pp                    = new XFG.PresentationParameters();
     _pp.DeviceWindowHandle = windowHandle;
     _pp.IsFullScreen       = false;
     _pp.DisplayOrientation = XNA.DisplayOrientation.Default;
     SetXNAPresentationParameters(presentParams);
     _graphicsDevice.Reset(_pp);
 }
示例#25
0
 internal XNARenderer(XFG.GraphicsProfile profile)
 {
     _dummyForm = new System.Windows.Forms.Form();
     XFG.PresentationParameters pp = new XFG.PresentationParameters();
     pp.BackBufferFormat     = XFG.SurfaceFormat.Color;
     pp.BackBufferHeight     = 1;
     pp.BackBufferWidth      = 1;
     pp.DepthStencilFormat   = XFG.DepthFormat.None;
     pp.DeviceWindowHandle   = _dummyForm.Handle;
     pp.PresentationInterval = XFG.PresentInterval.Immediate;
     pp.IsFullScreen         = false;
     _device = new XFG.GraphicsDevice(XFG.GraphicsAdapter.DefaultAdapter, profile, pp);
 }
示例#26
0
        public RendererImpl(IntPtr hwnd, int multiSampleCount, int minWidth, int minHeight)
        {
            Adapter = GraphicsAdapter.DefaultAdapter;

            PresentParams = new PresentationParameters()
            {
                DeviceWindowHandle = hwnd,
                BackBufferWidth = Math.Max(minWidth, GraphicsAdapter.Adapters.Max(a => a.CurrentDisplayMode.Width)),
                BackBufferHeight = Math.Max(minHeight, GraphicsAdapter.Adapters.Max(a => a.CurrentDisplayMode.Height)),
                BackBufferFormat = Adapter.CurrentDisplayMode.Format,
                DepthStencilFormat = DepthFormat.Depth24Stencil8,                
                PresentationInterval = PresentInterval.Immediate,
                RenderTargetUsage = RenderTargetUsage.PreserveContents,
                MultiSampleCount = multiSampleCount,
                IsFullScreen = false,
            };

            Device = new GraphicsDevice(Adapter, GraphicsProfile.HiDef, PresentParams);

            DeviceService = new GraphicsDeviceService(Device);
            Loader = new ContentManager(DeviceService, Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

            SpriteBatch = new SpriteBatch(Device);
            DebugFont = Loader.Load<SpriteFont>("Content/Fonts/Debug");

            WhiteTexel = new Texture2D(Device, 1, 1);
            WhiteTexel.SetData(new Color[] { Color.White });

            if (Global.No)
            {
                CoordinateSystemTexture2D = Loader.Load<Texture2D>("Content/Textures/UV");

                var ptw = 800;
                var pth = 600;
                var ptd = from y in Enumerable.Range(0, pth)
                          from x in Enumerable.Range(0, ptw)
                          let yb = y == 0 || y == (pth - 1)
                          let xb = x == 0 || x == (ptw - 1)
                          let bw = ((x / 8) % 2) == 0 ? Color.Black : Color.White
                          select (xb || yb)
                               ? Color.Black.Alpha(0.1f)
                               : bw;

                HorizontalStripes = new Texture2D(Device, ptw, pth, false, SurfaceFormat.Color);
                HorizontalStripes.SetData(ptd.ToArray());

                RenderTarget2D = new RenderTarget2D(Device, PresentParams.BackBufferWidth, PresentParams.BackBufferHeight, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.PreserveContents);
            }

            PostOps = new List<Action>();
        }
示例#27
0
    public TestingApp()
    {
      App.Instance = this;
      
      PresentationParameters pp = new PresentationParameters();
      graphics = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.NullReference, System.IntPtr.Zero, pp);

      model = new GameModel();
      model.Music.TimeSignature = new TimeSignature(4, 4);
      model.Music.Tempo = 60;
      model.Music.ClicksPerBeat = 4;

      controller = new ContactParser();
    }
示例#28
0
 static void InitGraphics()
 {
     PresentationParameters parameters = new PresentationParameters();
     parameters.BackBufferWidth = 1024;
     parameters.BackBufferHeight = 1024;
     parameters.BackBufferFormat = SurfaceFormat.Color;
     parameters.DepthStencilFormat = DepthFormat.None;
     parameters.IsFullScreen = false;
     parameters.MultiSampleCount = 0;
     parameters.PresentationInterval = PresentInterval.Default;
     form = new Form();
     parameters.DeviceWindowHandle = form.Handle;
     GraphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, parameters);
 }
示例#29
0
        /// <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)
        {
            PresentationParameters pp = new PresentationParameters();
            pp.DeviceWindowHandle = windowHandle;
            pp.BackBufferWidth = Math.Max(width, 1);
            pp.BackBufferHeight = Math.Max(height, 1);
            pp.PresentationInterval = PresentInterval.Two;

            graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, pp);
            //graphicsDevice.PresentationParameters.DeviceWindowHandle = windowHandle;
            //graphicsDevice.PresentationParameters.BackBufferWidth = Math.Max(width, 1);
            //graphicsDevice.PresentationParameters.BackBufferHeight = Math.Max(height, 1);
            //graphicsDevice.PresentationParameters.PresentationInterval = PresentInterval.Two;
        }
        /// <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;

            //CURRENTLY HORRIBLY BROKEN! DO NOT USE!!!

            //graphicsDevice = new GraphicsDevice();
        }
        protected void CreateDevice (IntPtr windowHandle, int width, int height)
        {
            GraphicsAdapter adapter = GraphicsAdapter.DefaultAdapter;
            GraphicsProfile profile = GraphicsProfile.Reach;
            PresentationParameters pp = new PresentationParameters() {
                DeviceWindowHandle = windowHandle,
                BackBufferWidth = Math.Max(width, 1),
                BackBufferHeight = Math.Max(height, 1),
            };

            _device = new GraphicsDevice(adapter, profile, pp);

            if (DeviceCreated != null)
                DeviceCreated(this, EventArgs.Empty);
        }
        private static void CreateGraphicsDevice(IntPtr windowHandle, int width, int height)
        {
            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
            };

            graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach, parameters);
        }
示例#33
0
 void ToggleFullScreen()
 {
     Microsoft.Xna.Framework.Graphics.PresentationParameters presentation = CommonItem.GraphicsDevice.PresentationParameters;
     if (presentation.IsFullScreen)
     {
         CommonItem.GraphicsDeviceManager.PreferredBackBufferWidth  = Prefs.WindowSizeW;
         CommonItem.GraphicsDeviceManager.PreferredBackBufferHeight = Prefs.WindowSizeH;
         CommonItem.Game.Window.AllowUserResizing = false;
     }
     else
     {
         GraphicsAdapter adapter = CommonItem.GraphicsDeviceManager.GraphicsDevice.Adapter;
         CommonItem.GraphicsDeviceManager.PreferredBackBufferWidth  = adapter.CurrentDisplayMode.Width;
         CommonItem.GraphicsDeviceManager.PreferredBackBufferHeight = adapter.CurrentDisplayMode.Height;
     }
     CommonItem.GraphicsDeviceManager.ToggleFullScreen();
 }
示例#34
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDevice" /> class.
        /// </summary>
        /// <param name="adapter">The graphics adapter.</param>
        /// <param name="graphicsProfile">The graphics profile.</param>
        /// <param name="presentationParameters">The presentation options.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="presentationParameters"/> is <see langword="null"/>.
        /// </exception>
        public GraphicsDevice(GraphicsAdapter adapter, GraphicsProfile graphicsProfile, PresentationParameters presentationParameters)
        {
            if (adapter == null)
            {
                throw new ArgumentNullException("adapter");
            }
            if (!adapter.IsProfileSupported(graphicsProfile))
            {
                throw new NoSuitableGraphicsDeviceException(String.Format("Adapter '{0}' does not support the {1} profile.", adapter.Description, graphicsProfile));
            }
            if (presentationParameters == null)
            {
                throw new ArgumentNullException("presentationParameters");
            }
            Adapter = adapter;
            PresentationParameters = presentationParameters;
            _graphicsProfile       = graphicsProfile;
            Setup();
            GraphicsCapabilities = new GraphicsCapabilities();
            GraphicsCapabilities.Initialize(this);

            Initialize();
        }
示例#35
0
        public override bool Equals(object obj)
        {
            PresentationParameters parameters = obj as PresentationParameters;

            if (parameters == null)
            {
                return(false);
            }
            return((parameters.autoDepthStencilFormat == this.autoDepthStencilFormat) &&
                   (parameters.backBufferCount == this.backBufferCount) &&
                   (parameters.backBufferFormat == this.backBufferFormat) &&
                   (parameters.backBufferHeight == this.backBufferHeight) &&
                   (parameters.backBufferWidth == this.backBufferWidth) &&
                   (parameters.deviceWindowHandle == this.deviceWindowHandle) &&
                   (parameters.enableAutoDepthStencil == this.enableAutoDepthStencil) &&
                   (parameters.fullScreenRefreshRateInHz == this.fullScreenRefreshRateInHz) &&
                   (parameters.isFullScreen == this.isFullScreen) &&
                   (parameters.multiSampleQuality == this.multiSampleQuality) &&
                   (parameters.multiSampleType == this.multiSampleType) &&
                   (parameters.presentationInterval == this.presentationInterval) &&
                   (parameters.presentOptions == this.presentOptions) &&
                   (parameters.swapEffect == this.swapEffect));
        }
示例#36
0
        public ThreadedGLDevice(PresentationParameters presentationParameters)
        {
            csThread = new Thread(new ThreadStart(csThreadProc));
            csThread.Start();

            FNALoggerEXT.LogInfo("Running with ThreadedGLDevice!");
            ForceToMainThread(() =>
            {
                if (Environment.GetEnvironmentVariable(
                        "FNA_THREADEDGLDEVICE_GLDEVICE"
                        ) == "OpenGLDevice")
                {
                    GLDevice = new OpenGLDevice(
                        presentationParameters
                        );
                }
                else
                {
                    GLDevice = new ModernGLDevice(
                        presentationParameters
                        );
                }
            });             // End ForceToMainThread
        }
 internal void PlatformSetMultiSamplingToMaximum(PresentationParameters presentationParameters, out int quality)
 {
     presentationParameters.MultiSampleCount = 4;
     quality = 0;
 }
示例#38
0
 public void Reset(PresentationParameters presentationParameters, GraphicsAdapter graphicsAdapter)
 {
     throw new NotImplementedException();
 }
示例#39
0
        public void Reset(
            PresentationParameters presentationParameters,
            GraphicsAdapter graphicsAdapter
            )
        {
            if (presentationParameters == null)
            {
                throw new ArgumentNullException("presentationParameters");
            }
            PresentationParameters = presentationParameters;
            Adapter = graphicsAdapter;

            // Verify MSAA before we really start...
            PresentationParameters.MultiSampleCount = Math.Min(
                MathHelper.ClosestMSAAPower(
                    PresentationParameters.MultiSampleCount
                    ),
                GLDevice.MaxMultiSampleCount
                );

            // We're about to reset, let the application know.
            if (DeviceResetting != null)
            {
                DeviceResetting(this, EventArgs.Empty);
            }

            /* FIXME: Why are we not doing this...? -flibit
             * lock (resourcesLock)
             * {
             *      foreach (WeakReference resource in resources)
             *      {
             *              object target = resource.Target;
             *              if (target != null)
             *              {
             *                      (target as GraphicsResource).GraphicsDeviceResetting();
             *              }
             *      }
             *
             *      // Remove references to resources that have been garbage collected.
             *      resources.RemoveAll(wr => !wr.IsAlive);
             * }
             */

            /* Reset the backbuffer first, before doing anything else.
             * The GLDevice needs to know what we're up to right away.
             * -flibit
             */
            GLDevice.ResetBackbuffer(
                PresentationParameters,
                Adapter
                );

            // The mouse needs to know this for faux-backbuffer mouse scaling.
            Input.Mouse.INTERNAL_BackBufferWidth  = PresentationParameters.BackBufferWidth;
            Input.Mouse.INTERNAL_BackBufferHeight = PresentationParameters.BackBufferHeight;

            // The Touch Panel needs this too, for the same reason.
            Input.Touch.TouchPanel.DisplayWidth  = PresentationParameters.BackBufferWidth;
            Input.Touch.TouchPanel.DisplayHeight = PresentationParameters.BackBufferHeight;

#if WIIU_GAMEPAD
            wiiuPixelData = new byte[
                PresentationParameters.BackBufferWidth *
                PresentationParameters.BackBufferHeight *
                4
                            ];
#endif

            // Now, update the viewport
            Viewport = new Viewport(
                0,
                0,
                PresentationParameters.BackBufferWidth,
                PresentationParameters.BackBufferHeight
                );

            // Update the scissor rectangle to our new default target size
            ScissorRectangle = new Rectangle(
                0,
                0,
                PresentationParameters.BackBufferWidth,
                PresentationParameters.BackBufferHeight
                );

            // Finally, update the swap interval
            GLDevice.SetPresentationInterval(
                PresentationParameters.PresentationInterval
                );

            // We just reset, let the application know.
            if (DeviceReset != null)
            {
                DeviceReset(this, EventArgs.Empty);
            }
        }
示例#40
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDevice" /> class.
        /// </summary>
        /// <param name="adapter">The graphics adapter.</param>
        /// <param name="graphicsProfile">The graphics profile.</param>
        /// <param name="presentationParameters">The presentation options.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="presentationParameters"/> is <see langword="null"/>.
        /// </exception>
        public GraphicsDevice(
            GraphicsAdapter adapter,
            GraphicsProfile graphicsProfile,
            PresentationParameters presentationParameters
            )
        {
            if (presentationParameters == null)
            {
                throw new ArgumentNullException("presentationParameters");
            }

            // Set the properties from the constructor parameters.
            Adapter = adapter;
            PresentationParameters = presentationParameters;
            GraphicsProfile        = graphicsProfile;
            PresentationParameters.MultiSampleCount = MathHelper.ClosestMSAAPower(
                PresentationParameters.MultiSampleCount
                );

            // Set up the IGLDevice
            GLDevice = FNAPlatform.CreateGLDevice(PresentationParameters, adapter);

            // The mouse needs to know this for faux-backbuffer mouse scaling.
            Input.Mouse.INTERNAL_BackBufferWidth  = PresentationParameters.BackBufferWidth;
            Input.Mouse.INTERNAL_BackBufferHeight = PresentationParameters.BackBufferHeight;

            // The Touch Panel needs this too, for the same reason.
            Input.Touch.TouchPanel.DisplayWidth  = PresentationParameters.BackBufferWidth;
            Input.Touch.TouchPanel.DisplayHeight = PresentationParameters.BackBufferHeight;

            // Force set the default render states.
            BlendState        = BlendState.Opaque;
            DepthStencilState = DepthStencilState.Default;
            RasterizerState   = RasterizerState.CullCounterClockwise;

            // Initialize the Texture/Sampler state containers
            int maxTextures       = Math.Min(GLDevice.MaxTextureSlots, MAX_TEXTURE_SAMPLERS);
            int maxVertexTextures = MathHelper.Clamp(
                GLDevice.MaxTextureSlots - MAX_TEXTURE_SAMPLERS,
                0,
                MAX_VERTEXTEXTURE_SAMPLERS
                );

            vertexSamplerStart = GLDevice.MaxTextureSlots - maxVertexTextures;
            Textures           = new TextureCollection(
                maxTextures,
                modifiedSamplers
                );
            SamplerStates = new SamplerStateCollection(
                maxTextures,
                modifiedSamplers
                );
            VertexTextures = new TextureCollection(
                maxVertexTextures,
                modifiedVertexSamplers
                );
            VertexSamplerStates = new SamplerStateCollection(
                maxVertexTextures,
                modifiedVertexSamplers
                );

            // Set the default viewport and scissor rect.
            Viewport         = new Viewport(PresentationParameters.Bounds);
            ScissorRectangle = Viewport.Bounds;

            // Allocate the pipeline cache to be used by Effects
            PipelineCache = new PipelineCache(this);
#if WIIU_GAMEPAD
            wiiuStream = DRC.drc_new_streamer();
            if (wiiuStream == IntPtr.Zero)
            {
                FNALoggerEXT.LogError("Failed to alloc GamePad stream!");
                return;
            }
            if (DRC.drc_start_streamer(wiiuStream) < 1)             // ???
            {
                FNALoggerEXT.LogError("Failed to start GamePad stream!");
                DRC.drc_delete_streamer(wiiuStream);
                wiiuStream = IntPtr.Zero;
                return;
            }
            DRC.drc_enable_system_input_feeder(wiiuStream);
            wiiuPixelData = new byte[
                PresentationParameters.BackBufferWidth *
                PresentationParameters.BackBufferHeight *
                4
                            ];
#endif
        }
示例#41
0
 public PresentationEventArgs(PresentationParameters presentationParameters)
 {
     PresentationParameters = presentationParameters;
 }
示例#42
0
        public GraphicsDevice(GraphicsAdapter adapter, DeviceType deviceType, IntPtr renderWindowHandle, PresentationParameters presentationParameters)
        {
            if (adapter == null || presentationParameters == null)
            {
                throw new ArgumentNullException("adapter or presentationParameters is null.");
            }

            graphicsDeviceCapabilities = adapter.GetCapabilities(deviceType);
            numActiveRenderTargets     = 0;
            renderTargets = new RenderTarget[graphicsDeviceCapabilities.MaxSimultaneousRenderTargets];
            initGL();

            this.adapter            = adapter;
            this.deviceType         = deviceType;
            this.renderWindowHandle = renderWindowHandle;
            PresentationParameters  = presentationParameters;            // set through property to ensure OpenGL propagation

            this.textures   = new TextureCollection();
            this.clearColor = Color.Black;
        }
 public unsafe void Reset(PresentationParameters presentationParameters, GraphicsAdapter graphicsAdapter)
 {
 }
示例#44
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDevice" /> class.
        /// </summary>
        /// <param name="adapter">The graphics adapter.</param>
        /// <param name="graphicsProfile">The graphics profile.</param>
        /// <param name="presentationParameters">The presentation options.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="presentationParameters"/> is <see langword="null"/>.
        /// </exception>
        public GraphicsDevice(GraphicsAdapter adapter, GraphicsProfile graphicsProfile, PresentationParameters presentationParameters)
        {
            if (presentationParameters == null)
            {
                throw new ArgumentNullException("presentationParameters");
            }

            // Set the properties from the constructor parameters.
            Adapter = adapter;
            PresentationParameters = presentationParameters;
            GraphicsProfile        = graphicsProfile;

            // Force set the default render states.
            BlendState        = BlendState.Opaque;
            DepthStencilState = DepthStencilState.Default;
            RasterizerState   = RasterizerState.CullCounterClockwise;

            // Initialize the Texture/Sampler state containers
            Textures      = new TextureCollection(OpenGLDevice.Instance.MaxTextureSlots);
            SamplerStates = new SamplerStateCollection(OpenGLDevice.Instance.MaxTextureSlots);
            Textures.Clear();
            SamplerStates.Clear();

            // Clear constant buffers
            vertexConstantBuffers.Clear();
            pixelConstantBuffers.Clear();

            // Force set the buffers and shaders on next ApplyState() call
            vertexBufferBindings = new VertexBufferBinding[OpenGLDevice.Instance.MaxVertexAttributes];

            // First draw will need to set the shaders.
            vertexShaderDirty = true;
            pixelShaderDirty  = true;

            // Set the default scissor rect.
            ScissorRectangle = Viewport.Bounds;

            // Free all the cached shader programs.
            programCache.Clear();
            shaderProgram = null;
        }
示例#45
0
        public void Reset(
            PresentationParameters presentationParameters,
            GraphicsAdapter graphicsAdapter
            )
        {
            if (presentationParameters == null)
            {
                throw new ArgumentNullException("presentationParameters");
            }

            // We're about to reset, let the application know.
            if (DeviceResetting != null)
            {
                DeviceResetting(this, EventArgs.Empty);
            }

            /* FIXME: Why are we not doing this...? -flibit
             * lock (resourcesLock)
             * {
             *      foreach (WeakReference resource in resources)
             *      {
             *              object target = resource.Target;
             *              if (target != null)
             *              {
             *                      (target as GraphicsResource).GraphicsDeviceResetting();
             *              }
             *      }
             *
             *      // Remove references to resources that have been garbage collected.
             *      resources.RemoveAll(wr => !wr.IsAlive);
             * }
             */

            // Set the new PresentationParameters first.
            PresentationParameters = presentationParameters;
            PresentationParameters.MultiSampleCount = Math.Min(
                MathHelper.ClosestMSAAPower(
                    PresentationParameters.MultiSampleCount
                    ),
                GLDevice.MaxMultiSampleCount
                );

            /* Reset the backbuffer first, before doing anything else.
             * The GLDevice needs to know what we're up to right away.
             * -flibit
             */
            GLDevice.ResetBackbuffer(
                PresentationParameters,
                RenderTargetCount > 0
                );

            // Now, update the viewport
            Viewport = new Viewport(
                0,
                0,
                PresentationParameters.BackBufferWidth,
                PresentationParameters.BackBufferHeight
                );

            // Update the scissor rectangle to our new default target size
            ScissorRectangle = new Rectangle(
                0,
                0,
                PresentationParameters.BackBufferWidth,
                PresentationParameters.BackBufferHeight
                );

            // FIXME: This should probably mean something. -flibit
            Adapter = graphicsAdapter;

            // We just reset, let the application know.
            if (DeviceReset != null)
            {
                DeviceReset(this, EventArgs.Empty);
            }
        }
示例#46
0
 public void Reset(PresentationParameters presentationParameters)
 {
     raise_DeviceResetting(this, EventArgs.Empty);
     PresentationParameters = presentationParameters;
     raise_DeviceReset(this, EventArgs.Empty);
 }
 public void Reset(PresentationParameters presentationParameters)
 {
 }
示例#48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GraphicsDevice" /> class.
 /// </summary>
 /// <param name="adapter">The graphics adapter.</param>
 /// <param name="graphicsProfile">The graphics profile.</param>
 /// <param name="presentationParameters">The presentation options.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="presentationParameters"/> is <see langword="null"/>.
 /// </exception>
 public GraphicsDevice(GraphicsAdapter adapter, GraphicsProfile graphicsProfile, PresentationParameters presentationParameters)
 {
     Adapter = adapter;
     if (presentationParameters == null)
     {
         throw new ArgumentNullException("presentationParameters");
     }
     PresentationParameters = presentationParameters;
     Setup();
     GraphicsCapabilities = new GraphicsCapabilities(this);
     GraphicsProfile      = graphicsProfile;
     Initialize();
 }
示例#49
0
 public void Reset(PresentationParameters presentationParameters)
 {
     Reset(presentationParameters, Adapter);
 }
 public GraphicsDevice(GraphicsAdapter adapter, GraphicsProfile graphicsProfile, PresentationParameters presentationParameters)
 {
 }
示例#51
0
 public void Reset(PresentationParameters presentationParameters)
 {
     throw new NotImplementedException();
 }
示例#52
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDevice" /> class.
        /// </summary>
        /// <param name="adapter">The graphics adapter.</param>
        /// <param name="graphicsProfile">The graphics profile.</param>
        /// <param name="presentationParameters">The presentation options.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="presentationParameters"/> is <see langword="null"/>.
        /// </exception>
        public GraphicsDevice(GraphicsAdapter adapter, GraphicsProfile graphicsProfile, PresentationParameters presentationParameters, IntPtr hnw)
        {
            windowsHandle    = hnw;
            windowsHandleSet = true;

            Adapter = adapter;
            if (presentationParameters == null)
            {
                throw new ArgumentNullException("presentationParameters");
            }
            PresentationParameters = presentationParameters;
            Setup();
            GraphicsCapabilities = new GraphicsCapabilities(this);
            GraphicsProfile      = graphicsProfile;
            Initialize();
        }