Initialize SDL

This commit is contained in:
2025-01-20 22:32:30 +01:00
parent e60c508e97
commit b438dd7bf4
3 changed files with 45 additions and 0 deletions

View File

@ -9,6 +9,8 @@ build:windows --cxxopt=-Xclang=-std=c++20
common --incompatible_autoload_externally=+@rules_python
build --features=external_include_paths
build --cxxopt=-Wall
build --cxxopt=-Wno-c++98-compat
build --cxxopt=-Wno-c++98-compat-pedantic

10
game/BUILD.bazel Normal file
View File

@ -0,0 +1,10 @@
cc_binary(
name = "game",
srcs = [
"main.cpp",
],
deps = [
"@asl//asl",
"@sdl3_windows//:sdl3",
],
)

33
game/main.cpp Normal file
View File

@ -0,0 +1,33 @@
#include <asl/print.hpp>
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
int SDL_main(int /* argc */, char* /* argv */[])
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* window = SDL_CreateWindow("HK-21 - 460nm", 1280, 720, SDL_WINDOW_VULKAN);
SDL_ShowWindow(window);
bool running = true;
while (running)
{
SDL_Event e;
while (SDL_PollEvent(&e))
{
if (e.type == SDL_EVENT_QUIT || (e.type == SDL_EVENT_KEY_DOWN && e.key.key == SDLK_ESCAPE))
{
running = false;
}
}
SDL_Delay(16);
}
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}