Created
February 13, 2023 22:08
-
-
Save ClearlyKyle/1f8056a343015a3325eccbc016371c87 to your computer and use it in GitHub Desktop.
SDL2 Hello World | SDL2 Open Window Odin | SDL
This file contains hidden or 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
| package main | |
| import "core:fmt" | |
| import SDL "vendor:sdl2" | |
| SCREEN_WIDTH : i32 = 640 | |
| SCREEN_HEIGHT : i32 = 480 | |
| main :: proc() | |
| { | |
| if SDL.Init(SDL.INIT_VIDEO) < 0 | |
| { | |
| fmt.println("Could not initilize SDL2 : ", SDL.GetError()) | |
| return | |
| } | |
| window_title :cstring = "hellope SDL" | |
| window : ^SDL.Window = SDL.CreateWindow(window_title, | |
| SDL.WINDOWPOS_UNDEFINED, | |
| SDL.WINDOWPOS_UNDEFINED, | |
| SCREEN_WIDTH, | |
| SCREEN_HEIGHT, | |
| SDL.WINDOW_SHOWN) | |
| if window == nil | |
| { | |
| fmt.println("Could not create window : ", SDL.GetError()) | |
| return | |
| } | |
| screen_surface : ^SDL.Surface = SDL.GetWindowSurface(window) | |
| SDL.FillRect(screen_surface, nil, SDL.MapRGB(screen_surface.format, 0x88, 0x77, 0x66)) | |
| SDL.UpdateWindowSurface(window) | |
| SDL.Delay(2000) | |
| SDL.DestroyWindow(window) | |
| SDL.Quit() | |
| return | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment