Beispiel #1
0
        private static void Main(string[] args)
        {
            using SDL.SDL2 sdl2 = new SDL.SDL2(Subsystems.Video);

            using Window window = new Window(
                      "SDL2_dotnet Example",
                      WindowPosition.Undefined,
                      ScreenResolution.VGA,
                      WindowOptions.Shown);

            bool quit = false;

            // While application is running
            while (!quit)
            {
                while (Event.Next)
                {
                    if (Event.Type == EventType.Quit)
                    {
                        quit = true;
                    }
                }

                window.Surface.Fill(NextColor());
                window.Update();
            }

            Timer.Delay(2000);
        }
Beispiel #2
0
        public static Surface LoadBMP(string imagePath)
        {
            IntPtr filePointer    = SDL2.SDL_RWFromFile(imagePath, "rb");
            IntPtr surfacePointer = SDL_LoadBMP_RW(filePointer, 1);

            if (surfacePointer == null)
            {
                string message = $"Unable to load bitmap {imagePath}! SDL_Error: {SDL2.GetError()}";
                throw new InitializationException(message);
            }

            return(new Surface(surfacePointer));
        }
Beispiel #3
0
        public Window(string title, int x, int y, int width, int height, WindowOptions options)
        {
            _windowPointer = SDL_CreateWindow(title, x, y, width, height, options);

            if (_windowPointer == null)
            {
                string message = $"Window could not be created! SDL_Error: {SDL2.GetError()}";
                throw new InitializationException(message);
            }

            IntPtr surfacePointer = SDL_GetWindowSurface(_windowPointer);

            Surface = new Surface(surfacePointer);
        }
        private static void Main(string[] args)
        {
            // Initializing SDL2
            using SDL.SDL2 sdl2 = new SDL.SDL2(Subsystems.Video);

            // Creating a window
            using Window window = new Window(
                      "SDL2_dotnet Example",
                      WindowPosition.Centered,
                      ScreenResolution.HD,
                      WindowOptions.Shown);

            // Cycle through colors ten times
            DisplayColors(window, 10);
        }
        private static void Main(string[] args)
        {
            using SDL.SDL2 sdl2 = new SDL.SDL2(Subsystems.Video);

            using Window window = new Window(
                      "SDL2_dotnet Example",
                      WindowPosition.Undefined,
                      ScreenResolution.VGA,
                      WindowOptions.Shown);

            using Surface imageSurface = Surface.LoadBMP("Hello_World.bmp");

            window.Surface.Fill(Color.White);
            window.Surface.BlitSurface(imageSurface);
            window.Update();

            Timer.Delay(2000);
        }
Beispiel #6
0
        private static void Main(string[] args)
        {
            // Initializing SDL2
            using SDL.SDL2 sdl2 = new SDL.SDL2(Subsystems.Video);

            // Creating a window
            using Window window = new Window(
                      "SDL2_dotnet Example",
                      WindowPosition.Undefined,
                      WindowPosition.Undefined,
                      WINDOW_WIDTH,
                      WINDOW_HEIGHT,
                      WindowOptions.Shown);

            // Filling window surface with white
            window.Surface.Fill(Color.White);
            window.Update();

            // Waiting 2 seconds
            Timer.Delay(2000);
        }