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; } }
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); }
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); }
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); } }
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;
public unsafe SdlBuffer(int w, int h) : this() { Handle = SdlFactory.CreateSurface(w, h); surface = Handle.ToStruct <SurfaceInfo>(); }
protected override void OnDispose() { SdlFactory.FreeSurface(Handle); }