public XNAWindowBase() { graphicsDeviceService = XNAGraphicsDeviceService.AddRef(Handle, ClientSize.Width, ClientSize.Height); graphicsDevice = graphicsDeviceService.GraphicsDevice; Application.Idle += delegate { Invalidate(); }; InitializeComponent(); }
/// <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); }
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; }