commit 0cc02e94fef0d0a7dccdf400189d6af543a8f84b Author: Sara Date: Thu Nov 14 15:50:12 2024 +0100 TEMPLATE diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ef88a4b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# binaries +*.o +PROJECTNAME diff --git a/.sconsign.dblite b/.sconsign.dblite new file mode 100644 index 0000000..82a4aa5 Binary files /dev/null and b/.sconsign.dblite differ diff --git a/SConstruct b/SConstruct new file mode 100644 index 0000000..41f9123 --- /dev/null +++ b/SConstruct @@ -0,0 +1,6 @@ + +project='PROJECTNAME' + +env = Environment(CCFLAGS=['-std=c++20', '-Wall', '-O0', '-g3']) +env.ParseConfig('sdl2-config --static-libs') +env.Program(project, Glob('src/*.cpp')) diff --git a/init-project.sh b/init-project.sh new file mode 100755 index 0000000..8085373 --- /dev/null +++ b/init-project.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +git init &&\ +git add . && git commit -m "TEMPLATE" &&\ +sed -i -e "s/PROJECTNAME/$1/g" ./SConstruct ./.gitignore &&\ +rm init-project.sh &&\ +git add . && git commit -a -m "INITIALIZED TEMPLATE" + diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..bd91c67 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,35 @@ +#include +#include +#include +#include +#include + +int main(int argc, char* argv[]) { + // initialize SDL2 + assert(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_EVENTS) == 0 && "SDL Initialization failed"); + // open window and create renderer from window + SDL_Window *window{SDL_CreateWindow("new_window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1000, 1000, SDL_WINDOW_BORDERLESS)}; + assert(window != NULL && "SDL window failed to open"); + SDL_Renderer *render{SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED)}; + assert(render != NULL && "SDL Renderer failed to open"); + // start working + SDL_Event event{}; + bool keep_open{true}; + while(keep_open) { + SDL_PollEvent(&event); + switch(event.type) { + case SDL_QUIT: + keep_open = false; + break; + default: + break; + } + + SDL_RenderClear(render); + SDL_RenderPresent(render); + } + + SDL_DestroyRenderer(render); + SDL_DestroyWindow(window); + SDL_Quit(); +}