示例#1
0
 public XNAWindowBase()
 {
     graphicsDeviceService = XNAGraphicsDeviceService.AddRef(Handle, ClientSize.Width, ClientSize.Height);
     graphicsDevice = graphicsDeviceService.GraphicsDevice;
     Application.Idle += delegate { Invalidate(); };
     InitializeComponent();
 }
示例#2
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (graphicsDeviceService != null)
            {
                graphicsDeviceService.Release(disposing);
                graphicsDeviceService = null;
            }

            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
示例#3
0
        public static XNAGraphicsDeviceService AddRef(IntPtr windowHandle,
            int width, int height)
        {
            Interlocked.Increment(ref referenceCount);
            if (singletonInstance == null)
            {
                singletonInstance = new XNAGraphicsDeviceService(windowHandle,
                                                              width, height);
            }

            return singletonInstance;
        }