/// <summary> /// Sets the video mode of the application /// </summary> /// <param name="width">screen width</param> /// <param name="height">screen height</param> /// <param name="bitsPerPixel">bits per pixel</param> /// <param name="resizable">window will be resizable</param> /// <param name="openGL">OpenGL surface</param> /// <param name="fullScreen">fullscreen</param> /// <param name="hardwareSurface"></param> /// <param name="frame"> /// If true, the window will have a frame around it. If fullscreen is true, then the frame will not appear /// </param> /// <returns>a surface to draw to</returns> public static Surface SetVideoMode(int width, int height, int bitsPerPixel, bool resizable, bool openGL, bool fullScreen, bool hardwareSurface, bool frame) { VideoModes flags = VideoModes.None; if (hardwareSurface) { flags |= VideoModes.HardwareSurface; flags |= VideoModes.DoubleBuffering; } if (fullScreen) { flags |= VideoModes.FullScreen; } if (openGL) { flags |= VideoModes.OpenGL; } if (resizable) { flags |= VideoModes.Resizable; } if (!frame) { flags |= VideoModes.NoFrame; } return(new Surface(Sdl.SDL_SetVideoMode(width, height, bitsPerPixel, (int)flags), true)); }
public DrawerControl CreateAndRunDrawerInStandaloneForm(VideoModes videoMode, DrawerSettings drawerSettings, Func <Form> formFactory) { FormDrawer drawer = CreateDrawer(videoMode, drawerSettings); DrawerControl drawerControl = null; var localsync = new ManualResetEventSlim(); var t = new Thread(() => { var form = formFactory(); drawerControl = new DrawerControl(drawer) { Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom }; form.Controls.Add(drawerControl); form.Shown += (o, e) => localsync.Set(); Application.Run(form); }); t.SetApartmentState(ApartmentState.STA); t.Start(); localsync.Wait(); if (drawer != null) { drawer.WaitForInitialization(); } return(drawerControl); }
/// <summary> /// Restore and validate configuration /// </summary> public void RestoreConfiguration() { Device = Devices.SingleOrDefault(d => d.Name == configFile["Device"]); VideoMode = VideoModes.SingleOrDefault(v => v.Name == configFile["VideoMode"]) ?? VideoModes.First(); TimecodeMode = TimecodeModes.SingleOrDefault(t => t.Name == configFile["TimecodeMode"]) ?? TimecodeModes.First(); Host = configFile["Host"]; Port = configFile["Port"]; FirLength = configFile["FirLength"]; Validate(); }
protected virtual void OnModeControlRegisterChanged() { // http://www.seasip.info/VintagePC/cga.html uint v = (uint)(X8086.BitsArrayToWord(CGAModeControlRegister)); VideoModes newMode = (VideoModes)(v & 0x17); // 10111 if ((v & vidModeChangeFlag) != 0 && (int)newMode != mVideoMode) { VideoMode = (uint)newMode; } mVideoEnabled = CGAModeControlRegister[(int)CGAModeControlRegisters.video_enabled] || VideoMode == (int)VideoModes.Mode7_Text_BW_80x25; }
/// <summary> /// Returns the highest bitsperpixel supported /// for the given width and height /// </summary> /// <param name="width">Width of mode</param> /// <param name="height">Height of mode</param> /// <param name="fullScreen">Fullscreen mode</param> public static int BestBitsPerPixel(int width, int height, bool fullScreen) { VideoModes flags = VideoModes.None; if (fullScreen) { flags = VideoModes.FullScreen; } return(Sdl.SDL_VideoModeOK( width, height, VideoInfo.BitsPerPixel, (int)flags)); }
/// <summary> /// Returns array of modes supported /// </summary> /// <returns>Array of Size structs</returns> public static Size[] ListModes() { VideoModes flags = VideoModes.FullScreen; IntPtr format = IntPtr.Zero; Sdl.SDL_Rect[] rects = Sdl.SDL_ListModes(format, (int)flags); Size[] size = new Size[rects.Length]; for (int i = 0; i < rects.Length; i++) { size[i].Width = rects[i].w; size[i].Height = rects[i].h; } return(size); }
public override FormDrawer CreateDrawer(VideoModes videoModes, DrawerSettings drawerSettings) { switch(videoModes) { case VideoModes.DirectX: return new DirectXFormDrawer(GetDirectXScene(), drawerSettings); case VideoModes.Winforms: return new WinformsDrawer(_root, drawerSettings); case VideoModes.No: return null; default: throw new Exception("Video mode not supported"); } }
public override FormDrawer CreateDrawer(VideoModes videoModes, DrawerSettings drawerSettings) { switch (videoModes) { case VideoModes.DirectX: return(new DirectXFormDrawer(GetDirectXScene(), drawerSettings)); case VideoModes.Winforms: return(new WinformsDrawer(_root, drawerSettings)); case VideoModes.No: return(null); default: throw new Exception("Video mode not supported"); } }
public DrawerControl CreateAndRunDrawerInStandaloneForm(VideoModes videoMode, DrawerSettings drawerSettings, Func<Form> formFactory) { FormDrawer drawer = CreateDrawer(videoMode, drawerSettings); DrawerControl drawerControl = null; var localsync = new ManualResetEventSlim(); var t = new Thread(() => { var form = formFactory(); drawerControl = new DrawerControl(drawer) { Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom }; form.Controls.Add(drawerControl); form.Shown += (o, e) => localsync.Set(); Application.Run(form); }); t.SetApartmentState(ApartmentState.STA); t.Start(); localsync.Wait(); if (drawer!=null) drawer.WaitForInitialization(); return drawerControl; }
// /// <summary> // /// Queries if the Video subsystem has been intialized. // /// </summary> // /// <remarks> // /// </remarks> // /// <returns>True if Video subsystem has been initialized, false if it has not.</returns> // public static bool IsInitialized // { // get // { // if ((Sdl.SDL_WasInit(Sdl.SDL_INIT_VIDEO) & Sdl.SDL_INIT_VIDEO) // != (int) SdlFlag.FalseValue) // { // return true; // } // else // { // return false; // } // } // } /// <summary> /// Checks if the requested video mode is supported /// </summary> /// <param name="width">Width of mode</param> /// <param name="height">Height of mode</param> /// <param name="fullScreen">Fullscreen or not</param> /// <param name="bitsPerPixel"> /// Bits per pixel. Typically 8, 16, 24 or 32 /// </param> /// <remarks></remarks> /// <returns> /// True is mode is supported, false if it is not. /// </returns> public static bool IsVideoModeOk(int width, int height, bool fullScreen, int bitsPerPixel) { VideoModes flags = VideoModes.None; if (fullScreen) { flags = VideoModes.FullScreen; } int result = Sdl.SDL_VideoModeOK( width, height, bitsPerPixel, (int)flags); if (result == bitsPerPixel) { return(true); } else { return(false); } }
public DrawerControl CreateAndRunDrawerInStandaloneForm(VideoModes videoMode) { return(CreateAndRunDrawerInStandaloneForm(videoMode, new DrawerSettings())); }
public DrawerControl CreateAndRunDrawerInStandaloneForm(VideoModes videoMode, DrawerSettings drawerSettings) { return CreateAndRunDrawerInStandaloneForm(videoMode, drawerSettings, EmptyFormFactory); }
public DrawerControl CreateAndRunDrawerInStandaloneForm(VideoModes videoMode) { return CreateAndRunDrawerInStandaloneForm(videoMode, new DrawerSettings()); }
public FormDrawer CreateDrawer(VideoModes videoModes) { return CreateDrawer(videoModes, new DrawerSettings()); }
public abstract FormDrawer CreateDrawer(VideoModes videoModes, DrawerSettings drawerSettings);
public FormDrawer CreateDrawer(VideoModes videoModes) { return(CreateDrawer(videoModes, new DrawerSettings())); }
public DrawerControl CreateAndRunDrawerInStandaloneForm(VideoModes videoMode, DrawerSettings drawerSettings) { return(CreateAndRunDrawerInStandaloneForm(videoMode, drawerSettings, EmptyFormFactory)); }