From 075de0ccc5079bcb2cba056b519172e7c7bd0b73 Mon Sep 17 00:00:00 2001 From: Natsirt867 Date: Thu, 16 Oct 2025 13:31:36 -0500 Subject: [PATCH] adding additional files --- .gitignore | 2 +- CMakeLists.txt | 17 +++++++++++++ main.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 CMakeLists.txt create mode 100644 main.c diff --git a/.gitignore b/.gitignore index a082059..16ec13d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ cmake-build-debug SDL - +.idea/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..3ca7e73 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.31) +project(BeyondDepth C) + +set(CMAKE_C_STANDARD 23) +# set the output directory for built objects. +# This makes sure that the dynamic library goes into the build directory automatically. +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$") + +# This assumes the SDL source is available in SDL +add_subdirectory(SDL EXCLUDE_FROM_ALL) + +# Create your game executable target as usual +add_executable(BeyondDepth WIN32 main.c) + +# Link to the actual SDL3 library. +target_link_libraries(BeyondDepth PRIVATE SDL3::SDL3) \ No newline at end of file diff --git a/main.c b/main.c new file mode 100644 index 0000000..1e67b87 --- /dev/null +++ b/main.c @@ -0,0 +1,67 @@ +/* + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely. +*/ +#define SDL_MAIN_USE_CALLBACKS 1 /* use the callbacks instead of main() */ +#include +#include + +static SDL_Window *window = NULL; +static SDL_Renderer *renderer = NULL; + +/* This function runs once at startup. */ +SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) +{ + /* Create the window */ + if (!SDL_CreateWindowAndRenderer("Hello World", 800, 600, SDL_WINDOW_FULLSCREEN, &window, &renderer)) { + SDL_Log("Couldn't create window and renderer: %s", SDL_GetError()); + return SDL_APP_FAILURE; + } + return SDL_APP_CONTINUE; +} + +/* This function runs when a new event (mouse input, keypresses, etc) occurs. */ +SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) +{ + if (event->type == SDL_EVENT_KEY_DOWN || + event->type == SDL_EVENT_QUIT) { + return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */ + } + return SDL_APP_CONTINUE; +} + +/* This function runs once per frame, and is the heart of the program. */ +SDL_AppResult SDL_AppIterate(void *appstate) +{ + const char *message = "Hello World!"; + int w = 0, h = 0; + float x, y; + const float scale = 4.0f; + + /* Center the message and scale it up */ + SDL_GetRenderOutputSize(renderer, &w, &h); + SDL_SetRenderScale(renderer, scale, scale); + x = ((w / scale) - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE * SDL_strlen(message)) / 2; + y = ((h / scale) - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE) / 2; + + /* Draw the message */ + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderClear(renderer); + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + SDL_RenderDebugText(renderer, x, y, message); + SDL_RenderPresent(renderer); + + return SDL_APP_CONTINUE; +} + +/* This function runs once at shutdown. */ +void SDL_AppQuit(void *appstate, SDL_AppResult result) +{ +}