Example #1
0
        protected override void OnCreateControl()
        {
            if (!DesignMode)
            {
                graphicsDeviceService = GraphicsDeviceService.AddRef(Handle, ClientSize.Width, ClientSize.Height);
                gameServiceContainer.AddService(typeof(IGraphicsDeviceService), graphicsDeviceService);
                gameServiceContainer.AddService(typeof(ISystemServices), this);
                Initialize();
            }

            base.OnCreateControl();
        }
Example #2
0
 public static GraphicsDeviceService AddRef(IntPtr windowHandle, int width, int height)
 {
     if (Interlocked.Increment(ref referenceCount) == 1)
         instance = new GraphicsDeviceService(windowHandle, width, height);
     return instance;
 }
Example #3
0
        protected override void Dispose(bool disposing)
        {
            if (graphicsDeviceService != null)
            {
                gameServiceContainer.RemoveService(typeof(IGraphicsDeviceService));
                graphicsDeviceService.Release(disposing);
                graphicsDeviceService = null;
            }

            base.Dispose(disposing);
        }