Exemplo n.º 1
0
 /// <summary>
 /// Initialize the device on the control.
 /// </summary>
 /// <param name="control"></param>
 public void Initialize(Control control)
 {
     padding = control.Padding;
     size    = control.Size;
     //! Dispose the layers.
     for (int i = 0; i < layers.Count; i++)
     {
         if (layers[i] != null)
         {
             layers[i].Dispose();
         }
     }
     //! Dispose the sprite.
     if (sprite != null)
     {
         sprite.Dispose();
         sprite = null;
     }
     //! Dispose the main surface.
     if (mainSurface != null)
     {
         mainSurface.Dispose();
         mainSurface = null;
     }
     System.GC.Collect();
     //! if device isn't null then reset the device size.
     if (device != null)
     {
         device.Reset(new SharpDX.Direct3D9.PresentParameters(control.ClientSize.Width, control.ClientSize.Height));
     }
     else
     {
         //! create a new device.
         device = new SharpDX.Direct3D9.Device(new SharpDX.Direct3D9.Direct3D(), 0, SharpDX.Direct3D9.DeviceType.Hardware, control.Handle,
                                               SharpDX.Direct3D9.CreateFlags.HardwareVertexProcessing, new SharpDX.Direct3D9.PresentParameters(control.ClientSize.Width, control.ClientSize.Height));
     }
     //! create a new sprite.
     sprite = new SharpDX.Direct3D9.Sprite(device);
     //! Create layers.
     for (int i = 0; i < layers.Count; i++)
     {
         layers[i] = new Layer(new SharpDX.Direct3D9.Texture(device, size.Width, size.Height, 1, SharpDX.Direct3D9.Usage.RenderTarget, SharpDX.Direct3D9.Format.A8R8G8B8, SharpDX.Direct3D9.Pool.Default));
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Dispose the layer.
        /// </summary>
        public void Dispose()
        {
            if (surface != null)
            {
                surface.Dispose();
                surface = null;
            }

            if (texture != null)
            {
                texture.Dispose();
                texture = null;
            }
        }