From bebf2cefe734d154ffaae44fb7c1bb557f2e1bfa Mon Sep 17 00:00:00 2001 From: realtradam Date: Sat, 31 Dec 2022 02:07:46 -0500 Subject: init --- src/compile_flags.txt | 2 ++ src/lib/lib.c | 6 +++++ src/lib/lib.h | 3 +++ src/main.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 src/compile_flags.txt create mode 100644 src/lib/lib.c create mode 100644 src/lib/lib.h create mode 100644 src/main.c (limited to 'src') diff --git a/src/compile_flags.txt b/src/compile_flags.txt new file mode 100644 index 0000000..268f070 --- /dev/null +++ b/src/compile_flags.txt @@ -0,0 +1,2 @@ +-I./ +-I../external/SDL/include diff --git a/src/lib/lib.c b/src/lib/lib.c new file mode 100644 index 0000000..4de4456 --- /dev/null +++ b/src/lib/lib.c @@ -0,0 +1,6 @@ +#include "lib.h" + +int add(int a, int b) +{ + return a + b; +} diff --git a/src/lib/lib.h b/src/lib/lib.h new file mode 100644 index 0000000..77a0e1e --- /dev/null +++ b/src/lib/lib.h @@ -0,0 +1,3 @@ + +int +add(int a, int b); diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..567492f --- /dev/null +++ b/src/main.c @@ -0,0 +1,69 @@ +#include +#include +#include "lib/lib.h" +#include "SDL3/SDL.h" + +const int SCREEN_WIDTH = 640; +const int SCREEN_HEIGHT = 480; + +int +main() +{ + SDL_Window* window = NULL; + + SDL_Surface* screenSurface = NULL; + + if(SDL_Init(SDL_INIT_VIDEO) < 0) + { + printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError()); + } + else + { + window = SDL_CreateWindow( + "SDL Tutorial", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + SCREEN_WIDTH, + SCREEN_HEIGHT, + SDL_WINDOWEVENT_SHOWN + ); + if(window == NULL) + { + printf("Window could not be created! SDL_Error %s\n", SDL_GetError()); + } + else + { + screenSurface = SDL_GetWindowSurface(window); + + SDL_FillSurfaceRect( + screenSurface, + NULL, + SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF) + ); + + SDL_UpdateWindowSurface(window); + + SDL_Event e; + bool quit = false; + while(quit == false) + { + while(SDL_PollEvent(&e)) + { + if(e.type == SDL_QUIT) + { + quit = true; + } + } + } + } + } + + SDL_DestroyWindow(window); + + SDL_Quit(); + + printf("number: %d\n", add(1, 3)); + printf("Hello World"); + + return 0; +} -- cgit v1.2.3