commit 199a3636a567096b7823dade961b6339aaf41bf9 Author: tovjemam Date: Mon Aug 4 16:05:56 2025 +0200 Init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a7458c2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build/ +out/ + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..22bb653 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.15) +project(PortalGame) + +# Enable C++17 +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Add src directory +add_executable(PortalGame src/main.cpp) + +# Platform-specific SDL2 handling +if(EMSCRIPTEN) + # Emscripten provides SDL2 via its system libraries + message(STATUS "Target platform: WebAssembly (Emscripten)") + set(CMAKE_EXECUTABLE_SUFFIX ".html") # Optional: build HTML page + target_link_options(PortalGame PRIVATE + "-sUSE_SDL=2" + "-sASYNCIFY" + "--preload-file assets" + ) +else() + # Native platform + find_package(SDL2 REQUIRED) + target_include_directories(PortalGame PRIVATE ${SDL2_INCLUDE_DIRS}) + target_link_libraries(PortalGame PRIVATE ${SDL2_LIBRARIES}) +endif() diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..75e3314 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,21 @@ +#include +#include + +int main(int argc, char* argv[]) { + if (SDL_Init(SDL_INIT_VIDEO) != 0) { + std::cerr << "SDL_Init Error: " << SDL_GetError() << std::endl; + return 1; + } + + SDL_Window* win = SDL_CreateWindow("Hello SDL2", 100, 100, 640, 480, SDL_WINDOW_SHOWN); + if (!win) { + std::cerr << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl; + SDL_Quit(); + return 1; + } + + SDL_Delay(2000); + SDL_DestroyWindow(win); + SDL_Quit(); + return 0; +}