internal override void SetPresentationInterval(PresentInterval interval) { if (interval == PresentInterval.Default || interval == PresentInterval.One) { if (OSVersion.Equals("Mac OS X")) { // Apple is a big fat liar about swap_control_tear. Use stock VSync. SDL.SDL_GL_SetSwapInterval(1); } else { if (SDL.SDL_GL_SetSwapInterval(-1) != -1) { System.Console.WriteLine("Using EXT_swap_control_tear VSync!"); } else { System.Console.WriteLine("EXT_swap_control_tear unsupported. Fall back to standard VSync."); SDL.SDL_ClearError(); SDL.SDL_GL_SetSwapInterval(1); } } } else if (interval == PresentInterval.Immediate) { SDL.SDL_GL_SetSwapInterval(0); } else if (interval == PresentInterval.Two) { SDL.SDL_GL_SetSwapInterval(2); } else { throw new Exception("Unrecognized PresentInterval!"); } }
public int CompareTo(Metrics other) { if (!(OS == null && other.OS == null)) { if (OS == null) { return(-1); } if (other.OS == null) { return(1); } if (!OS.Equals(other.OS)) { return(OS.CompareTo(other.OS)); } } if (!(OSVersion == null && other.OSVersion == null)) { if (OSVersion == null) { return(-1); } if (other.OSVersion == null) { return(1); } if (!OSVersion.Equals(other.OSVersion)) { return(OSVersion.CompareTo(other.OSVersion)); } } if (!(Device == null && other.Device == null)) { if (Device == null) { return(-1); } if (other.Device == null) { return(1); } if (!Device.Equals(other.Device)) { return(Device.CompareTo(other.Device)); } } if (!(Resolution == null && other.Resolution == null)) { if (Resolution == null) { return(-1); } if (other.Resolution == null) { return(1); } if (!Resolution.Equals(other.Resolution)) { return(Resolution.CompareTo(other.Resolution)); } } if (!(Carrier == null && other.Carrier == null)) { if (Carrier == null) { return(-1); } if (other.Carrier == null) { return(1); } if (!Carrier.Equals(other.Carrier)) { return(Carrier.CompareTo(other.Carrier)); } } if (!(AppVersion == null && other.AppVersion == null)) { if (AppVersion == null) { return(-1); } if (other.AppVersion == null) { return(1); } if (!AppVersion.Equals(other.AppVersion)) { return(AppVersion.CompareTo(other.AppVersion)); } } return(0); }
public SDL2_GamePlatform(Game game) : base(game, SDL.SDL_GetPlatform()) { /* SDL2 might complain if an OS that uses SDL_main has not actually * used SDL_main by the time you initialize SDL2. * The only platform that is affected is Windows, but we can skip * their WinMain. This was only added to prevent iOS from exploding. * -flibit */ SDL.SDL_SetMainReady(); // This _should_ be the first real SDL call we make... SDL.SDL_Init( SDL.SDL_INIT_VIDEO | SDL.SDL_INIT_JOYSTICK | SDL.SDL_INIT_GAMECONTROLLER | SDL.SDL_INIT_HAPTIC ); // Set and initialize the SDL2 window Window = new SDL2_GameWindow(); // Disable the screensaver. SDL.SDL_DisableScreenSaver(); // We hide the mouse cursor by default. if (IsMouseVisible) { IsMouseVisible = false; } else { /* Since IsMouseVisible is already false, OnMouseVisibleChanged * will NOT be called! So we get to do it ourselves. * -flibit */ SDL.SDL_ShowCursor(0); } // OSX has some fancy fullscreen features, let's use them! if (OSVersion.Equals("Mac OS X")) { string hint = SDL.SDL_GetHint(SDL.SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES); INTERNAL_useFullscreenSpaces = (String.IsNullOrEmpty(hint) || hint.Equals("1")); } else { INTERNAL_useFullscreenSpaces = false; } // Create OpenGL context INTERNAL_GLContext = SDL.SDL_GL_CreateContext(Window.Handle); OpenTK.Graphics.GraphicsContext.CurrentContext = INTERNAL_GLContext; #if THREADED_GL // Create a background context SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1); Threading.WindowInfo = Window.Handle; Threading.BackgroundContext = new GL_ContextHandle() { context = SDL.SDL_GL_CreateContext(Window.Handle) }; // Make the foreground context current. SDL.SDL_GL_MakeCurrent(Window.Handle, INTERNAL_GLContext); #endif // Set up the OpenGL Device. Loads entry points. OpenGLDevice.Initialize(); // Create the OpenAL device OpenALDevice.Initialize(); // Initialize Active Key List keys = new List <Keys>(); // Setup Text Input Control Character Arrays (Only 4 control keys supported at this time) INTERNAL_TextInputControlDown = new bool[4]; INTERNAL_TextInputControlRepeat = new int[4]; // Assume we will have focus. IsActive = true; // Ready to run the loop! INTERNAL_runApplication = true; #if WIIU_GAMEPAD wiiuStream = DRC.drc_new_streamer(); if (wiiuStream == IntPtr.Zero) { System.Console.WriteLine("Failed to alloc GamePad stream!"); return; } if (DRC.drc_start_streamer(wiiuStream) < 1) // ??? { System.Console.WriteLine("Failed to start GamePad stream!"); DRC.drc_delete_streamer(wiiuStream); wiiuStream = IntPtr.Zero; return; } DRC.drc_enable_system_input_feeder(wiiuStream); wiiuPixelData = new byte[ OpenGLDevice.Instance.Backbuffer.Width * OpenGLDevice.Instance.Backbuffer.Height * 4 ]; #endif }
public SDL2_GamePlatform(Game game) : base(game, SDL.SDL_GetPlatform()) { /* SDL2 might complain if an OS that uses SDL_main has not actually * used SDL_main by the time you initialize SDL2. * The only platform that is affected is Windows, but we can skip * their WinMain. This was only added to prevent iOS from exploding. * -flibit */ SDL.SDL_SetMainReady(); // This _should_ be the first real SDL call we make... SDL.SDL_Init( SDL.SDL_INIT_VIDEO | SDL.SDL_INIT_JOYSTICK | SDL.SDL_INIT_GAMECONTROLLER | SDL.SDL_INIT_HAPTIC ); // Set any hints to match XNA4 behavior... string hint = SDL.SDL_GetHint(SDL.SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS); if (String.IsNullOrEmpty(hint)) { SDL.SDL_SetHint( SDL.SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1" ); } // If available, load the SDL_GameControllerDB string mappingsDB = Path.Combine( TitleContainer.Location, "gamecontrollerdb.txt" ); if (File.Exists(mappingsDB)) { SDL.SDL_GameControllerAddMappingsFromFile( mappingsDB ); } // Set and initialize the SDL2 window bool forceES2 = Environment.GetEnvironmentVariable( "FNA_OPENGL_FORCE_ES2" ) == "1"; Window = new SDL2_GameWindow( forceES2 || OSVersion.Equals("Emscripten") || OSVersion.Equals("Android") || OSVersion.Equals("iOS") ); // Create the DisplayMode list displayIndex = SDL.SDL_GetWindowDisplayIndex( Window.Handle ); INTERNAL_GenerateDisplayModes(); // Disable the screensaver. SDL.SDL_DisableScreenSaver(); // We hide the mouse cursor by default. if (IsMouseVisible) { IsMouseVisible = false; } else { /* Since IsMouseVisible is already false, OnMouseVisibleChanged * will NOT be called! So we get to do it ourselves. * -flibit */ SDL.SDL_ShowCursor(0); } // OSX has some fancy fullscreen features, let's use them! if (OSVersion.Equals("Mac OS X")) { hint = SDL.SDL_GetHint(SDL.SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES); INTERNAL_useFullscreenSpaces = (String.IsNullOrEmpty(hint) || hint.Equals("1")); } else { INTERNAL_useFullscreenSpaces = false; } // Initialize Active Key List keys = new List <Keys>(); // Setup Text Input Control Character Arrays (Only 4 control keys supported at this time) INTERNAL_TextInputControlDown = new bool[4]; INTERNAL_TextInputControlRepeat = new int[4]; // Assume we will have focus. IsActive = true; // Ready to run the loop! INTERNAL_runApplication = true; #if WIIU_GAMEPAD wiiuStream = DRC.drc_new_streamer(); if (wiiuStream == IntPtr.Zero) { System.Console.WriteLine("Failed to alloc GamePad stream!"); return; } if (DRC.drc_start_streamer(wiiuStream) < 1) // ??? { System.Console.WriteLine("Failed to start GamePad stream!"); DRC.drc_delete_streamer(wiiuStream); wiiuStream = IntPtr.Zero; return; } DRC.drc_enable_system_input_feeder(wiiuStream); Rectangle bounds = Window.ClientBounds; wiiuPixelData = new byte[bounds.Width * bounds.Height * 4]; #endif }
public SDL2_GamePlatform(Game game) : base(game, Fna.FnaPlatform.Platform.GetSDLPlatform()) { /* SDL2 might complain if an OS that uses SDL_main has not actually * used SDL_main by the time you initialize SDL2. * The only platform that is affected is Windows, but we can skip * their WinMain. This was only added to prevent iOS from exploding. * -flibit */ SDL.SDL_SetMainReady(); // This _should_ be the first real SDL call we make... SDL.SDL_Init( SDL.SDL_INIT_VIDEO | SDL.SDL_INIT_JOYSTICK | SDL.SDL_INIT_GAMECONTROLLER | SDL.SDL_INIT_HAPTIC ); // Set and initialize the SDL2 window Window = new SDL2_GameWindow(); // Create the DisplayMode list displayIndex = SDL.SDL_GetWindowDisplayIndex( Window.Handle ); INTERNAL_GenerateDisplayModes(); // Disable the screensaver. SDL.SDL_DisableScreenSaver(); // We hide the mouse cursor by default. if (IsMouseVisible) { IsMouseVisible = false; } else { /* Since IsMouseVisible is already false, OnMouseVisibleChanged * will NOT be called! So we get to do it ourselves. * -flibit */ SDL.SDL_ShowCursor(0); } // OSX has some fancy fullscreen features, let's use them! if (OSVersion.Equals("Mac OS X")) { string hint = SDL.SDL_GetHint(SDL.SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES); INTERNAL_useFullscreenSpaces = (String.IsNullOrEmpty(hint) || hint.Equals("1")); } else { INTERNAL_useFullscreenSpaces = false; } // Create the OpenAL device OpenALDevice.Initialize(); // Initialize Active Key List keys = new List <Keys>(); // Setup Text Input Control Character Arrays (Only 4 control keys supported at this time) INTERNAL_TextInputControlDown = new bool[4]; INTERNAL_TextInputControlRepeat = new int[4]; // Assume we will have focus. IsActive = true; // Ready to run the loop! INTERNAL_runApplication = true; #if WIIU_GAMEPAD wiiuStream = DRC.drc_new_streamer(); if (wiiuStream == IntPtr.Zero) { System.Console.WriteLine("Failed to alloc GamePad stream!"); return; } if (DRC.drc_start_streamer(wiiuStream) < 1) // ??? { System.Console.WriteLine("Failed to start GamePad stream!"); DRC.drc_delete_streamer(wiiuStream); wiiuStream = IntPtr.Zero; return; } DRC.drc_enable_system_input_feeder(wiiuStream); Rectangle bounds = Window.ClientBounds; wiiuPixelData = new byte[bounds.Width * bounds.Height * 4]; #endif }
public int CompareTo(ExceptionEvent other) { if (!(OS == null && other.OS == null)) { if (OS == null) { return(-1); } if (other.OS == null) { return(1); } if (!OS.Equals(other.OS)) { return(OS.CompareTo(other.OS)); } } if (!(OSVersion == null && other.OSVersion == null)) { if (OSVersion == null) { return(-1); } if (other.OSVersion == null) { return(1); } if (!OSVersion.Equals(other.OSVersion)) { return(OSVersion.CompareTo(other.OSVersion)); } } if (!(Manufacture == null && other.Manufacture == null)) { if (Manufacture == null) { return(-1); } if (other.Manufacture == null) { return(1); } if (!Manufacture.Equals(other.Manufacture)) { return(Manufacture.CompareTo(other.Manufacture)); } } if (!(Device == null && other.Device == null)) { if (Device == null) { return(-1); } if (other.Device == null) { return(1); } if (!Device.Equals(other.Device)) { return(Device.CompareTo(other.Device)); } } if (!(Resolution == null && other.Resolution == null)) { if (Resolution == null) { return(-1); } if (other.Resolution == null) { return(1); } if (!Resolution.Equals(other.Resolution)) { return(Resolution.CompareTo(other.Resolution)); } } if (!(AppVersion == null && other.AppVersion == null)) { if (AppVersion == null) { return(-1); } if (other.AppVersion == null) { return(1); } if (!AppVersion.Equals(other.AppVersion)) { return(AppVersion.CompareTo(other.AppVersion)); } } if (!(Orientation == null && other.Orientation == null)) { if (Orientation == null) { return(-1); } if (other.Orientation == null) { return(1); } if (!Orientation.Equals(other.Orientation)) { return(Orientation.CompareTo(other.Orientation)); } } if (!(RamCurrent == null && other.RamCurrent == null)) { if (RamCurrent == null) { return(-1); } if (other.RamCurrent == null) { return(1); } if (!RamCurrent.Equals(other.RamCurrent)) { return(RamCurrent.Value.CompareTo(other.RamCurrent.Value)); } } if (!(RamTotal == null && other.RamTotal == null)) { if (RamTotal == null) { return(-1); } if (other.RamTotal == null) { return(1); } if (!RamTotal.Equals(other.RamTotal)) { return(RamTotal.Value.CompareTo(other.RamTotal.Value)); } } if (!Online.Equals(other.Online)) { return(Online.CompareTo(other.Online)); } if (!(Name == null && other.Name == null)) { if (Name == null) { return(-1); } if (other.Name == null) { return(1); } if (!Name.Equals(other.Name)) { return(Name.CompareTo(other.Name)); } } if (!(Error == null && other.Error == null)) { if (Error == null) { return(-1); } if (other.Error == null) { return(1); } if (!Error.Equals(other.Error)) { return(Error.CompareTo(other.Error)); } } if (!NonFatal.Equals(other.NonFatal)) { return(NonFatal.CompareTo(other.NonFatal)); } if (!(Logs == null && other.Logs == null)) { if (Logs == null) { return(-1); } if (other.Logs == null) { return(1); } if (!Logs.Equals(other.Logs)) { return(Logs.CompareTo(other.Logs)); } } if (!Run.Equals(other.Run)) { return(Run.CompareTo(other.Run)); } if (!(OS == null && other.OS == null)) { if (OS == null) { return(-1); } if (other.OS == null) { return(1); } if (!OS.Equals(other.OS)) { return(OS.CompareTo(other.OS)); } } if (!(Custom == null && other.Custom == null)) { if (Custom == null) { return(-1); } if (other.Custom == null) { return(1); } if (!Custom.Count.Equals(other.Custom.Count)) { return(Custom.Count.CompareTo(other.Custom.Count)); } foreach (var a in Custom.Keys) { if (!other.Custom.ContainsKey(a)) { return(-1); } if (!Custom[a].Equals(other.Custom[a])) { return(Custom[a].CompareTo(other.Custom[a])); } } } return(0); }