Esempio n. 1
0
 // Create Device(s) and start rendering.
 protected virtual unsafe void CreateDevice(SurfaceType surfaceType)
 {
     this.surfaceType = surfaceType;
     if (surfaceType == SurfaceType.Direct2D)
     {
         // Use shared devices resources.
         graphicsDeviceService10 = SharpDXGraphicsDeviceService10.AddRef();
         graphicsDeviceService10.DeviceResized += new EventHandler(graphicsDeviceService10_DeviceResized);
         graphicsDeviceService10.ResizeDevice(bufferWidth, bufferHeight);
         bufferWidth  = graphicsDeviceService10.Width;
         bufferHeight = graphicsDeviceService10.Height;
     }
     else if (surfaceType == SurfaceType.DirectX9)
     {
         // Use shared devices resources.
         graphicsDeviceService9              = SharpDXGraphicsDeviceService9.AddRef(bufferWidth, bufferHeight);
         graphicsDeviceService9.DeviceReset += new EventHandler(graphicsDeviceService9_DeviceReset);
         afterResizeReset = true;
     }
     Initialize();
     if (d3dImage.IsFrontBufferAvailable)
     {
         SetBackBuffer();
     }
     //CompositionTarget.Rendering += OnRendering;
 }
 /// <summary>
 /// Gets a reference to the singleton instance.
 /// </summary>
 public static SharpDXGraphicsDeviceService10 AddRef()
 {
     // Increment the "how many controls sharing the device" reference count.
     if (Interlocked.Increment(ref referenceCount) == 1)
     {
         // If this is the first control to start using the
         // device, we must create the singleton instance.
         singletonInstance = new SharpDXGraphicsDeviceService10();
     }
     return(singletonInstance);
 }
 /// <summary>
 /// Gets a reference to the singleton instance.
 /// </summary>
 public static SharpDXGraphicsDeviceService10 AddRef()
 {
     // Increment the "how many controls sharing the device" reference count.
     if (Interlocked.Increment(ref referenceCount) == 1)
     {
         // If this is the first control to start using the
         // device, we must create the singleton instance.
         singletonInstance = new SharpDXGraphicsDeviceService10();
     }
     return singletonInstance;
 }
Esempio n. 4
0
 /// <summary>
 /// Disposes the control.
 /// </summary>
 protected void Dispose(bool disposing)
 {
     if (graphicsDeviceService9 != null)
     {
         graphicsDeviceService9.Release(disposing);
         graphicsDeviceService9 = null;
     }
     if (graphicsDeviceService10 != null)
     {
         graphicsDeviceService10.Release(disposing);
         graphicsDeviceService10 = null;
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Disposes the control.
 /// </summary>
 protected void Dispose(bool disposing)
 {
     if (graphicsDeviceService9 != null)
     {
         graphicsDeviceService9.Release(disposing);
         graphicsDeviceService9 = null;
     }
     if (graphicsDeviceService10 != null)
     {
         graphicsDeviceService10.Release(disposing);
         graphicsDeviceService10 = null;
     }
 }
Esempio n. 6
0
 // Create Device(s) and start rendering.
 protected virtual unsafe void CreateDevice(SurfaceType surfaceType)
 {
     this.surfaceType = surfaceType;
     if (surfaceType == SurfaceType.Direct2D)
     {
         // Use shared devices resources.
         graphicsDeviceService10 = SharpDXGraphicsDeviceService10.AddRef();
         graphicsDeviceService10.DeviceResized += new EventHandler(graphicsDeviceService10_DeviceResized);
         graphicsDeviceService10.ResizeDevice(bufferWidth, bufferHeight);
         bufferWidth = graphicsDeviceService10.Width;
         bufferHeight = graphicsDeviceService10.Height;
     }
     else if (surfaceType == SurfaceType.DirectX9)
     {
         // Use shared devices resources.
         graphicsDeviceService9 = SharpDXGraphicsDeviceService9.AddRef(bufferWidth, bufferHeight);
         graphicsDeviceService9.DeviceReset += new EventHandler(graphicsDeviceService9_DeviceReset);
         afterResizeReset = true;
     }
     Initialize();
     if (d3dImage.IsFrontBufferAvailable)
     {
         SetBackBuffer();
     }
     //CompositionTarget.Rendering += OnRendering;
 }