/// <summary>
        /// Get access to the singleton instance.
        /// </summary>
        /// <param name="handle">A pointer to window handle.</param>
        /// <param name="width">The width of the devices back-buffer.</param>
        /// <param name="height">The height of the devices back-buffer.</param>
        /// <returns>A reference to the graphics device service.</returns>
        public static GraphicsDeviceService GetInstance(IntPtr handle, int width, int height)
        {
            // Create a new singleton instance of the graphics device if this is the 
            // first component which wants to perform calculations on the GPU
            if (Interlocked.Increment(ref _referenceCount) == 1)
                _instance = new GraphicsDeviceService(handle, width, height);

            return _instance;
        }
Beispiel #2
0
        /// <summary>
        /// Initializes the control. Retrieves a reference to the graphics device.
        /// </summary>
        protected override void OnCreateControl()
        {
            if (!DesignMode)
            {
                _graphicsDeviceService = GraphicsDeviceService.GetInstance(Handle, ClientSize.Width, ClientSize.Height);

                Initialize();
            }

            base.OnCreateControl();
        }