diff options
| -rw-r--r-- | .gitignore | 67 | ||||
| -rw-r--r-- | .gitmodules | 3 | ||||
| -rw-r--r-- | CMakeLists.txt | 27 | ||||
| -rwxr-xr-x | build | 2 | ||||
| -rwxr-xr-x | configure | 3 | ||||
| m--------- | external/SDL | 0 | ||||
| -rwxr-xr-x | run | 3 | ||||
| -rw-r--r-- | src/compile_flags.txt | 2 | ||||
| -rw-r--r-- | src/lib/lib.c | 6 | ||||
| -rw-r--r-- | src/lib/lib.h | 3 | ||||
| -rw-r--r-- | src/main.c | 69 |
11 files changed, 185 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bd379b4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,67 @@ +[Bb]uild_[Dd]ir + +# CMake +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..993223c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "external/SDL"] + path = external/SDL + url = https://github.com/libsdl-org/SDL.git diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..99b7b45 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.25.1) + +project(space_squad) + +file(GLOB SOURCES + "src/main.c" + "src/lib/lib.c" + ) + +#add_library(lib src/lib.c) + +add_executable(${PROJECT_NAME} ${SOURCES}) + +add_subdirectory(external/SDL) + +target_include_directories(${PROJECT_NAME} + PUBLIC external/SDL/include + ) + +target_link_directories(${PROJECT_NAME} + PRIVATE external/SDL + ) + +target_link_libraries(${PROJECT_NAME} + SDL3::SDL3 # dynamic lib + #SDL3::SDL3-static # static lib + ) @@ -0,0 +1,2 @@ +#! /bin/sh +cd build_dir ; make diff --git a/configure b/configure new file mode 100755 index 0000000..352dcd6 --- /dev/null +++ b/configure @@ -0,0 +1,3 @@ +#! /bin/sh + +cmake -S . -B build_dir diff --git a/external/SDL b/external/SDL new file mode 160000 +Subproject 87c8e2b942108555f36a3ae951de9557a5b41da @@ -0,0 +1,3 @@ +#! /bin/sh + +./build_dir/space_squad 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 <stdio.h> +#include <stdbool.h> +#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; +} |
