예제 #1
0
            static SdlScreens()
            {
                int displays = GetNumVideoDisplays();
                devices = new IScreen[displays];
                for (int d = 0; d < displays; d++)
                {
                    IRectangle bounds;
                    SdlFactory.GetDisplayBounds(d, out Rect rc);
                    bounds = Factory.newRectangle(rc.X, rc.Y, rc.Width, rc.Height);

                    SdlFactory.GetCurrentDisplayMode(d, out DisplayMode dm);

                    int total = GetNumDisplayModes(d);
                    var list = new IResolution[total];

                    for (int m = 0; m < total; m++)
                    {
                        GetDisplayMode(d, m, out DisplayMode sdm);
                        list[m] = new SdlResolution(bounds.X, bounds.Y, sdm.Width, sdm.Height, sdm.Format, sdm.RefreshRate);
                    }

                    var current_resolution = new SdlResolution(bounds.X, bounds.Y, dm.Width, dm.Height, dm.Format, dm.RefreshRate);
                    var device = new SdlScreen(current_resolution, d == 0, list, bounds, d);

                    devices[d] = (device);
                    if (d == 0)
                        primary = device;
                }
            }
예제 #2
0
 public SdlTexture(IRenderWindow window, IBuffer source, bool isPrimary = false, uint? pixelFormat = null)
 {
     Initialize(window, isPrimary);
     Initialize(source.Width, source.Height);
     Renderer = SdlFactory.GetRenderer(window.Handle);
     textureAccess = TextureAccess.Static;
     this.pixelFormat = pixelFormat;
     if (Renderer == IntPtr.Zero)
         Renderer = SdlFactory.CreateRenderer(window.Handle, -1, window.RendererFlags);
     Handle = SdlFactory.CreateTexture(Renderer, source);
     SdlFactory.SetTextureBlendMod(Handle, BlendMode.None);
 }
예제 #3
0
 public SdlTexture(IRenderWindow window, int? w = null, int? h = null, bool isPrimary = false, uint? pixelFormat = null)
 {
     Initialize(window, isPrimary);
     Initialize(w ?? window.Width, window.Height);
     Renderer = SdlFactory.GetRenderer(window.Handle);
     this.pixelFormat = pixelFormat;
     textureAccess = TextureAccess.Streaming;
     if (Renderer == IntPtr.Zero)
         Renderer = SdlFactory.CreateRenderer(window.Handle, -1, window.RendererFlags);
     Handle = SdlFactory.CreateTexture(Renderer,
         pixelFormat ?? Factory.PixelFormat, textureAccess, Width, Height);
     SdlFactory.SetTextureBlendMod(Handle, BlendMode.None);
 }
예제 #4
0
        public unsafe SdlBuffer(int *data, int w, int h, bool makeCopy = false) : this()
        {
            if (makeCopy)
            {
                Handle = SdlFactory.CreateSurface(w, h);
            }
            else
            {
                Handle = SdlFactory.CreateSurface((IntPtr)data, w, h, Factory.PixelFormat);
            }


            surface = Handle.ToStruct <SurfaceInfo>();

            if (makeCopy)
            {
                Implementation.CopyMemory(data, 0, (int *)surface.Pixels, 0, w * h);
            }
        }
예제 #5
0
 public static SdlWindow FromHWnd(IntPtr handle, RendererFlags flags = RendererFlags.Default)
 {
     var key = "Window" + SdlFactory.WindowID(handle);
     if (Factory.Get(key, out SdlWindow window, ObjType.Window))
         return window;
예제 #6
0
 public unsafe SdlBuffer(int w, int h) : this()
 {
     Handle  = SdlFactory.CreateSurface(w, h);
     surface = Handle.ToStruct <SurfaceInfo>();
 }
예제 #7
0
 protected override void OnDispose()
 {
     SdlFactory.FreeSurface(Handle);
 }