Init
This commit is contained in:
commit
199a3636a5
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
build/
|
||||
out/
|
||||
|
||||
26
CMakeLists.txt
Normal file
26
CMakeLists.txt
Normal file
@ -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()
|
||||
21
src/main.cpp
Normal file
21
src/main.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include <SDL.h>
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user