Created
January 16, 2021 11:18
-
-
Save tk3/a7abd69eb62387f14e6090cd7e7e1c4d to your computer and use it in GitHub Desktop.
Lesson 01 Hello SDL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open FSharp.SDL2 | |
open System | |
open System.Runtime.InteropServices | |
[<EntryPoint>] | |
let main argv = | |
if SDL.Init(SDL.INIT_VIDEO) < 0 then | |
printfn"SDL could not initialize! SDL_Error: %s\n" (SDL.GetError()) | |
Environment.Exit 1 | |
let screenWidth = 640 | |
let screenHeight = 480 | |
let window = SDL.CreateWindow("SDL Tutorial", SDL.WINDOWPOS_CENTERED, SDL.WINDOWPOS_CENTERED, screenWidth, screenHeight, SDL.WindowFlags.WINDOW_SHOWN) | |
let screenSurfacePtr = SDL.GetWindowSurface(window) | |
let screenSurface: SDL.Surface = Marshal.PtrToStructure(screenSurfacePtr, typeof<SDL.Surface>) :?> SDL.Surface | |
let mapRgb = SDL.MapRGB(screenSurface.format, 0xffuy, 0xffuy, 0xffuy) | |
SDL.FillRect(screenSurfacePtr, IntPtr.Zero, mapRgb) |> ignore | |
SDL.UpdateWindowSurface(screenSurfacePtr) |> ignore | |
SDL.Delay(2000u) | |
SDL.DestroyWindow(window) | |
SDL.Quit() | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment