main
Sara 2024-11-14 15:50:12 +01:00
commit 0cc02e94fe
5 changed files with 52 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# binaries
*.o
PROJECTNAME

BIN
.sconsign.dblite Normal file

Binary file not shown.

6
SConstruct Normal file
View File

@ -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'))

8
init-project.sh Executable file
View File

@ -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"

35
src/main.cpp Normal file
View File

@ -0,0 +1,35 @@
#include <SDL2/SDL.h>
#include <SDL2/SDL_quit.h>
#include <SDL2/SDL_video.h>
#include <SDL2/SDL_events.h>
#include <assert.h>
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();
}