예제 #1
0
        public static Sdl2Window CreateWindow(
            ref WindowProps windowProps,
            GraphicsBackend preferredBackend)
        {
#if DEBUG
            using Profiler fullProfiler = new Profiler(typeof(WindowStartup));
#endif
            SDL_WindowFlags flags = SDL_WindowFlags.Resizable
                                    | GetWindowFlags(windowProps.WindowInitialState);

            if (windowProps.WindowInitialState != WindowState.Hidden)
            {
                flags |= SDL_WindowFlags.Shown;
            }

            if (preferredBackend == GraphicsBackend.OpenGL || preferredBackend == GraphicsBackend.OpenGLES)
            {
                flags |= SDL_WindowFlags.OpenGL;
            }

            return(new Sdl2Window(
                       windowProps.Title,
                       windowProps.X,
                       windowProps.Y,
                       windowProps.Width,
                       windowProps.Height,
                       flags,
                       false));
        }
예제 #2
0
 public static void CreateWindowAndGraphicsDevice(
     WindowProps windowProps,
     out Sdl2Window window,
     out GraphicsDevice gd)
 => CreateWindowAndGraphicsDevice(
     windowProps,
     new GraphicsDeviceOptions(),
     GetPlatformDefaultBackend(),
     out window,
     out gd);
예제 #3
0
        public static WindowBase CreateMainWindow(Type windowType, WindowProps props = null, GraphicsBackend backend = GraphicsBackend.Direct3D11)
        {
#if DEBUG
            using Profiler fullProfiler = new Profiler(typeof(WindowBase));
#endif
            if (windowType == typeof(WindowsWindow))
            {
                return(new WindowsWindow(props ?? new WindowProps(), backend));
            }
            return(null);
        }
예제 #4
0
        public static void CreateWindowAndGraphicsDevice(
            WindowProps windowProps,
            GraphicsDeviceOptions deviceOptions,
            GraphicsBackend preferredBackend,
            out Sdl2Window window,
            out GraphicsDevice gd)
        {
#if DEBUG
            using Profiler fullProfiler = new Profiler(typeof(WindowStartup));
            using (Profiler sdlProfiler = new Profiler("SDL_Init"))
#endif
            Sdl2Native.SDL_Init(SDLInitFlags.Video);

            window = CreateWindow(ref windowProps, preferredBackend);
            gd     = CreateGraphicsDevice(window, deviceOptions, preferredBackend);
        }