This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,3 +2,5 @@ build/
|
|||||||
build-web/
|
build-web/
|
||||||
resources/
|
resources/
|
||||||
release/
|
release/
|
||||||
|
out/
|
||||||
|
external/
|
||||||
81
.vscode/launch.json
vendored
81
.vscode/launch.json
vendored
@@ -1,28 +1,61 @@
|
|||||||
{
|
{
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Debug (CMake Debug preset)",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "cmake: build debug",
|
||||||
|
"program": "${workspaceFolder}/out/build/linux-debug/bin/Debug/snivy",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${workspaceFolder}/out/build/linux-debug",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "/usr/bin/gdb",
|
||||||
|
"setupCommands": [
|
||||||
{
|
{
|
||||||
"name": "Debug",
|
"description": "Enable pretty-printing for gdb",
|
||||||
"type": "cppdbg",
|
"text": "-enable-pretty-printing"
|
||||||
"request": "launch",
|
|
||||||
"program": "${workspaceFolder}/build/snivy",
|
|
||||||
"args": [],
|
|
||||||
"stopAtEntry": false,
|
|
||||||
"cwd": "${workspaceFolder}/build",
|
|
||||||
"environment": [],
|
|
||||||
"externalConsole": false,
|
|
||||||
"MIMode": "gdb",
|
|
||||||
"miDebuggerPath": "/usr/bin/gdb",
|
|
||||||
"setupCommands": [
|
|
||||||
{
|
|
||||||
"description": "Enable pretty-printing for gdb",
|
|
||||||
"text": "-enable-pretty-printing"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Set disassembly flavor to Intel",
|
|
||||||
"text": "-gdb-set disassembly-flavor intel"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
]
|
{
|
||||||
|
"description": "Set disassembly flavor to Intel",
|
||||||
|
"text": "-gdb-set disassembly-flavor intel"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"windows": {
|
||||||
|
"type": "cppvsdbg",
|
||||||
|
"program": "${workspaceFolder}/out/build/x64-Debug/bin/Debug/snivy.exe",
|
||||||
|
"cwd": "${workspaceFolder}/out/build/x64-Debug"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Run (CMake Release preset)",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"noDebug": true,
|
||||||
|
"preLaunchTask": "cmake: build release",
|
||||||
|
"program": "${workspaceFolder}/out/build/linux-release/bin/Release/snivy",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}/out/build/linux-release",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "/usr/bin/gdb",
|
||||||
|
"windows": {
|
||||||
|
"type": "cppvsdbg",
|
||||||
|
"program": "${workspaceFolder}/out/build/x64-Release/bin/Release/snivy.exe",
|
||||||
|
"cwd": "${workspaceFolder}/out/build/x64-Release"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Web (Emscripten + Chromium)",
|
||||||
|
"type": "node-terminal",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "web: run",
|
||||||
|
"command": "echo \"Web task complete. If Chromium did not open, run task: web: open chromium\"",
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
199
.vscode/tasks.json
vendored
199
.vscode/tasks.json
vendored
@@ -1,44 +1,159 @@
|
|||||||
{
|
{
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"label": "build",
|
"label": "cmake: configure debug",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "cmake --build build",
|
"linux": {
|
||||||
"group": {
|
"command": "cmake --preset linux-debug"
|
||||||
"kind": "build",
|
},
|
||||||
"isDefault": true
|
"windows": {
|
||||||
},
|
"command": "cmake --preset x64-Debug"
|
||||||
"problemMatcher": [
|
},
|
||||||
"$gcc"
|
"problemMatcher": []
|
||||||
]
|
},
|
||||||
},
|
{
|
||||||
{
|
"label": "cmake: build debug",
|
||||||
"label": "start-wasm-devserver",
|
"type": "shell",
|
||||||
"type": "shell",
|
"linux": {
|
||||||
"command": "${workspaceFolder}/scripts/start_wasm_dev.sh",
|
"command": "cmake --build --preset linux-debug"
|
||||||
"presentation": {
|
},
|
||||||
"reveal": "silent",
|
"windows": {
|
||||||
"panel": "dedicated"
|
"command": "cmake --build --preset x64-Debug"
|
||||||
},
|
},
|
||||||
"problemMatcher": []
|
"dependsOn": "cmake: configure debug",
|
||||||
},
|
"group": {
|
||||||
{
|
"kind": "build",
|
||||||
"label": "stop-wasm-devserver",
|
"isDefault": true
|
||||||
"type": "shell",
|
},
|
||||||
"command": "${workspaceFolder}/scripts/stop_wasm_dev.sh",
|
"problemMatcher": [
|
||||||
"problemMatcher": []
|
"$gcc"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"type": "cmake",
|
{
|
||||||
"label": "CMake: build",
|
"label": "cmake: configure release",
|
||||||
"command": "build",
|
"type": "shell",
|
||||||
"targets": [
|
"linux": {
|
||||||
"[N/A - Select Kit]"
|
"command": "cmake --preset linux-release"
|
||||||
],
|
},
|
||||||
"group": "build",
|
"windows": {
|
||||||
"problemMatcher": [],
|
"command": "cmake --preset x64-Release"
|
||||||
"detail": "CMake template build task"
|
},
|
||||||
}
|
"problemMatcher": []
|
||||||
]
|
},
|
||||||
|
{
|
||||||
|
"label": "cmake: build release",
|
||||||
|
"type": "shell",
|
||||||
|
"linux": {
|
||||||
|
"command": "cmake --build --preset linux-release"
|
||||||
|
},
|
||||||
|
"windows": {
|
||||||
|
"command": "cmake --build --preset x64-Release"
|
||||||
|
},
|
||||||
|
"dependsOn": "cmake: configure release",
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "linux: run debug",
|
||||||
|
"type": "shell",
|
||||||
|
"linux": {
|
||||||
|
"command": "${workspaceFolder}/out/build/linux-debug/bin/Debug/snivy"
|
||||||
|
},
|
||||||
|
"windows": {
|
||||||
|
"command": "echo \"linux: run debug is Linux-only\" && exit 1"
|
||||||
|
},
|
||||||
|
"dependsOn": "cmake: build debug",
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "linux: run release",
|
||||||
|
"type": "shell",
|
||||||
|
"linux": {
|
||||||
|
"command": "${workspaceFolder}/out/build/linux-release/bin/Release/snivy"
|
||||||
|
},
|
||||||
|
"windows": {
|
||||||
|
"command": "echo \"linux: run release is Linux-only\" && exit 1"
|
||||||
|
},
|
||||||
|
"dependsOn": "cmake: build release",
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "web: configure",
|
||||||
|
"type": "shell",
|
||||||
|
"linux": {
|
||||||
|
"command": "sh -lc 'if ! command -v emcmake >/dev/null 2>&1; then if [ -n \"$EMSDK\" ] && [ -f \"$EMSDK/emsdk_env.sh\" ]; then . \"$EMSDK/emsdk_env.sh\" >/dev/null 2>&1; elif [ -f \"$HOME/emsdk/emsdk_env.sh\" ]; then . \"$HOME/emsdk/emsdk_env.sh\" >/dev/null 2>&1; elif [ -f \"../emsdk/emsdk_env.sh\" ]; then . \"../emsdk/emsdk_env.sh\" >/dev/null 2>&1; else echo \"Emscripten not found. Install emsdk or set EMSDK env var.\"; exit 1; fi; fi; emcmake cmake -S . -B out/build/web -DCMAKE_BUILD_TYPE=Release'"
|
||||||
|
},
|
||||||
|
"windows": {
|
||||||
|
"command": "echo \"web tasks are configured for Linux (emsdk + python + chromium).\" && exit 1"
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "web: build",
|
||||||
|
"type": "shell",
|
||||||
|
"linux": {
|
||||||
|
"command": "sh -lc 'if ! command -v emcmake >/dev/null 2>&1; then if [ -n \"$EMSDK\" ] && [ -f \"$EMSDK/emsdk_env.sh\" ]; then . \"$EMSDK/emsdk_env.sh\" >/dev/null 2>&1; elif [ -f \"$HOME/emsdk/emsdk_env.sh\" ]; then . \"$HOME/emsdk/emsdk_env.sh\" >/dev/null 2>&1; elif [ -f \"../emsdk/emsdk_env.sh\" ]; then . \"../emsdk/emsdk_env.sh\" >/dev/null 2>&1; else echo \"Emscripten not found. Install emsdk or set EMSDK env var.\"; exit 1; fi; fi; cmake --build out/build/web -j$(nproc)'"
|
||||||
|
},
|
||||||
|
"windows": {
|
||||||
|
"command": "echo \"web tasks are configured for Linux (emsdk + python + chromium).\" && exit 1"
|
||||||
|
},
|
||||||
|
"dependsOn": "web: configure",
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "web: serve",
|
||||||
|
"type": "shell",
|
||||||
|
"linux": {
|
||||||
|
"command": "sh -lc 'PID_FILE=/tmp/snivy-web-http.pid; LOG_FILE=/tmp/snivy-web-http.log; WEB_ROOT=out/build/web; URL=http://127.0.0.1:8000/bin/Release/index.html; [ -f \"$WEB_ROOT/bin/Release/index.html\" ] || { echo \"Web output not found at $WEB_ROOT/bin/Release/index.html (run web: build)\"; exit 1; }; if [ -f \"$PID_FILE\" ] && kill -0 \"$(cat \"$PID_FILE\")\" 2>/dev/null; then kill \"$(cat \"$PID_FILE\")\" >/dev/null 2>&1 || true; rm -f \"$PID_FILE\"; fi; nohup python3 -m http.server 8000 --bind 127.0.0.1 --directory \"$WEB_ROOT\" >\"$LOG_FILE\" 2>&1 & echo $! >\"$PID_FILE\"; echo \"Started web server on http://127.0.0.1:8000 (root: $WEB_ROOT)\"; READY=0; for _ in $(seq 1 40); do if command -v curl >/dev/null 2>&1; then curl -fsS \"$URL\" >/dev/null 2>&1 && READY=1 && break; elif command -v wget >/dev/null 2>&1; then wget -qO- \"$URL\" >/dev/null 2>&1 && READY=1 && break; fi; sleep 0.1; done; [ \"$READY\" = \"1\" ] || { echo \"Web server did not become ready. See /tmp/snivy-web-http.log\"; exit 1; }'"
|
||||||
|
},
|
||||||
|
"windows": {
|
||||||
|
"command": "echo \"web tasks are configured for Linux (emsdk + python + chromium).\" && exit 1"
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "web: stop server",
|
||||||
|
"type": "shell",
|
||||||
|
"linux": {
|
||||||
|
"command": "sh -lc 'PID_FILE=/tmp/snivy-web-http.pid; if [ -f \"$PID_FILE\" ] && kill -0 \"$(cat \"$PID_FILE\")\" 2>/dev/null; then kill \"$(cat \"$PID_FILE\")\" && rm -f \"$PID_FILE\" && echo \"Stopped web server\"; else rm -f \"$PID_FILE\" && echo \"Web server not running\"; fi'"
|
||||||
|
},
|
||||||
|
"windows": {
|
||||||
|
"command": "echo \"web tasks are configured for Linux (emsdk + python + chromium).\" && exit 1"
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "web: open chromium",
|
||||||
|
"type": "shell",
|
||||||
|
"linux": {
|
||||||
|
"command": "sh -lc 'URL=http://127.0.0.1:8000/bin/Release/index.html; (xdg-open \"$URL\" >/dev/null 2>&1 || chromium --new-tab \"$URL\" >/dev/null 2>&1 || chromium-browser --new-tab \"$URL\" >/dev/null 2>&1 || google-chrome --new-tab \"$URL\" >/dev/null 2>&1 || google-chrome-stable --new-tab \"$URL\" >/dev/null 2>&1 || python3 -m webbrowser \"$URL\" >/dev/null 2>&1) & sleep 0.15; echo \"Requested browser open: $URL\"'"
|
||||||
|
},
|
||||||
|
"windows": {
|
||||||
|
"command": "start http://127.0.0.1:8000/index.html"
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "web: prepare",
|
||||||
|
"dependsOrder": "sequence",
|
||||||
|
"dependsOn": [
|
||||||
|
"web: build",
|
||||||
|
"web: serve"
|
||||||
|
],
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "web: run",
|
||||||
|
"type": "shell",
|
||||||
|
"linux": {
|
||||||
|
"command": "sh -lc 'set -e; if ! command -v emcmake >/dev/null 2>&1; then if [ -n \"$EMSDK\" ] && [ -f \"$EMSDK/emsdk_env.sh\" ]; then . \"$EMSDK/emsdk_env.sh\" >/dev/null 2>&1; elif [ -f \"$HOME/emsdk/emsdk_env.sh\" ]; then . \"$HOME/emsdk/emsdk_env.sh\" >/dev/null 2>&1; elif [ -f \"../emsdk/emsdk_env.sh\" ]; then . \"../emsdk/emsdk_env.sh\" >/dev/null 2>&1; else echo \"Emscripten not found. Install emsdk or set EMSDK env var.\"; exit 1; fi; fi; emcmake cmake -S . -B out/build/web -DCMAKE_BUILD_TYPE=Release; cmake --build out/build/web -j$(nproc); PID_FILE=/tmp/snivy-web-http.pid; LOG_FILE=/tmp/snivy-web-http.log; WEB_ROOT=out/build/web; URL=http://127.0.0.1:8000/bin/Release/index.html; [ -f \"$WEB_ROOT/bin/Release/index.html\" ] || { echo \"Web output not found at $WEB_ROOT/bin/Release/index.html\"; exit 1; }; if [ -f \"$PID_FILE\" ] && kill -0 \"$(cat \"$PID_FILE\")\" 2>/dev/null; then kill \"$(cat \"$PID_FILE\")\" >/dev/null 2>&1 || true; rm -f \"$PID_FILE\"; fi; nohup python3 -m http.server 8000 --bind 127.0.0.1 --directory \"$WEB_ROOT\" >\"$LOG_FILE\" 2>&1 & echo $! >\"$PID_FILE\"; echo \"Started web server on http://127.0.0.1:8000 (root: $WEB_ROOT)\"; READY=0; for _ in $(seq 1 40); do if command -v curl >/dev/null 2>&1; then curl -fsS \"$URL\" >/dev/null 2>&1 && READY=1 && break; elif command -v wget >/dev/null 2>&1; then wget -qO- \"$URL\" >/dev/null 2>&1 && READY=1 && break; fi; sleep 0.1; done; [ \"$READY\" = \"1\" ] || { echo \"Web server did not become ready. See /tmp/snivy-web-http.log\"; exit 1; }; (xdg-open \"$URL\" >/dev/null 2>&1 || chromium --new-tab \"$URL\" >/dev/null 2>&1 || chromium-browser --new-tab \"$URL\" >/dev/null 2>&1 || google-chrome --new-tab \"$URL\" >/dev/null 2>&1 || google-chrome-stable --new-tab \"$URL\" >/dev/null 2>&1 || python3 -m webbrowser \"$URL\" >/dev/null 2>&1 || { echo \"Could not launch browser automatically. Open: $URL\"; exit 0; }) & sleep 0.15; echo \"Requested browser open: $URL\"'"
|
||||||
|
},
|
||||||
|
"windows": {
|
||||||
|
"command": "echo \"web tasks are configured for Linux (emsdk + python + chromium).\" && exit 1"
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,6 +127,11 @@ add_executable(${PROJECT_NAME}
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/include/glad/glad.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/include/glad/glad.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||||
|
"$<$<CONFIG:Debug>:DEBUG=1>"
|
||||||
|
"$<$<NOT:$<CONFIG:Debug>>:DEBUG=0>"
|
||||||
|
)
|
||||||
|
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
|
||||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin/Debug"
|
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin/Debug"
|
||||||
@@ -186,13 +191,15 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(PROJECT_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
|
set(PROJECT_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
|
||||||
set(PROJECT_RESOURCES_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/resources")
|
set(PROJECT_RESOURCES_BINARY_DIR "$<TARGET_FILE_DIR:${PROJECT_NAME}>/resources")
|
||||||
if(EXISTS "${PROJECT_RESOURCES_DIR}")
|
if(EXISTS "${PROJECT_RESOURCES_DIR}")
|
||||||
file(GLOB_RECURSE PROJECT_RESOURCE_FILES CONFIGURE_DEPENDS
|
file(GLOB_RECURSE PROJECT_RESOURCE_FILES CONFIGURE_DEPENDS
|
||||||
"${PROJECT_RESOURCES_DIR}/*")
|
"${PROJECT_RESOURCES_DIR}/*")
|
||||||
add_custom_target(copy_resources ALL
|
add_custom_target(copy_resources ALL
|
||||||
COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_RESOURCES_BINARY_DIR}"
|
COMMAND ${CMAKE_COMMAND}
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_RESOURCES_DIR}" "${PROJECT_RESOURCES_BINARY_DIR}"
|
-DSRC_DIR="${PROJECT_RESOURCES_DIR}"
|
||||||
|
-DDST_DIR="${PROJECT_RESOURCES_BINARY_DIR}"
|
||||||
|
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/copy_resources.cmake"
|
||||||
DEPENDS ${PROJECT_RESOURCE_FILES}
|
DEPENDS ${PROJECT_RESOURCE_FILES}
|
||||||
COMMENT "Copying resources directory")
|
COMMENT "Copying resources directory")
|
||||||
add_dependencies(${PROJECT_NAME} copy_resources)
|
add_dependencies(${PROJECT_NAME} copy_resources)
|
||||||
@@ -207,6 +214,7 @@ if(HAS_PROJECT_RESOURCES)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
||||||
|
set(EMSCRIPTEN_SHELL_FILE "${CMAKE_CURRENT_SOURCE_DIR}/web/index.html")
|
||||||
target_link_options(${PROJECT_NAME} PRIVATE
|
target_link_options(${PROJECT_NAME} PRIVATE
|
||||||
"-sMIN_WEBGL_VERSION=2"
|
"-sMIN_WEBGL_VERSION=2"
|
||||||
"-sMAX_WEBGL_VERSION=2"
|
"-sMAX_WEBGL_VERSION=2"
|
||||||
@@ -217,6 +225,8 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
|||||||
"-sFORCE_FILESYSTEM=1"
|
"-sFORCE_FILESYSTEM=1"
|
||||||
"-sASYNCIFY"
|
"-sASYNCIFY"
|
||||||
"-lidbfs.js"
|
"-lidbfs.js"
|
||||||
|
"--shell-file"
|
||||||
|
"${EMSCRIPTEN_SHELL_FILE}"
|
||||||
)
|
)
|
||||||
if(HAS_PROJECT_RESOURCES)
|
if(HAS_PROJECT_RESOURCES)
|
||||||
target_link_options(${PROJECT_NAME} PRIVATE
|
target_link_options(${PROJECT_NAME} PRIVATE
|
||||||
|
|||||||
@@ -39,14 +39,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "x64-Debug",
|
"name": "win32-debug",
|
||||||
"displayName": "x64 Debug",
|
"displayName": "Win32 Debug",
|
||||||
"description": "Visual Studio 2022 x64 Debug",
|
"description": "Visual Studio 2022 x64 Debug",
|
||||||
"generator": "Visual Studio 17 2022",
|
"generator": "Visual Studio 17 2022",
|
||||||
"architecture": "x64",
|
"architecture": "x64",
|
||||||
"binaryDir": "${sourceDir}/out/build/x64-Debug",
|
"binaryDir": "${sourceDir}/out/build/win32-debug",
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/x64-Debug"
|
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/win32-debug"
|
||||||
},
|
},
|
||||||
"condition": {
|
"condition": {
|
||||||
"type": "equals",
|
"type": "equals",
|
||||||
@@ -55,14 +55,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "x64-Release",
|
"name": "win32-release",
|
||||||
"displayName": "x64 Release",
|
"displayName": "Win32 Release",
|
||||||
"description": "Visual Studio 2022 x64 Release",
|
"description": "Visual Studio 2022 x64 Release",
|
||||||
"generator": "Visual Studio 17 2022",
|
"generator": "Visual Studio 17 2022",
|
||||||
"architecture": "x64",
|
"architecture": "x64",
|
||||||
"binaryDir": "${sourceDir}/out/build/x64-Release",
|
"binaryDir": "${sourceDir}/out/build/win32-release",
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/x64-Release"
|
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/win32-release"
|
||||||
},
|
},
|
||||||
"condition": {
|
"condition": {
|
||||||
"type": "equals",
|
"type": "equals",
|
||||||
@@ -81,13 +81,13 @@
|
|||||||
"configurePreset": "linux-release"
|
"configurePreset": "linux-release"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "x64-Debug",
|
"name": "win32-debug",
|
||||||
"configurePreset": "x64-Debug",
|
"configurePreset": "win32-debug",
|
||||||
"configuration": "Debug"
|
"configuration": "Debug"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "x64-Release",
|
"name": "win32-release",
|
||||||
"configurePreset": "x64-Release",
|
"configurePreset": "win32-release",
|
||||||
"configuration": "Release"
|
"configuration": "Release"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "x64-Debug",
|
"name": "win32-debug",
|
||||||
"generator": "Ninja",
|
"generator": "Ninja",
|
||||||
"configurationType": "Debug",
|
"configurationType": "Debug",
|
||||||
"inheritEnvironments": [
|
"inheritEnvironments": [
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"ctestCommandArgs": ""
|
"ctestCommandArgs": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "x64-Release",
|
"name": "win32-release",
|
||||||
"generator": "Ninja",
|
"generator": "Ninja",
|
||||||
"configurationType": "Release",
|
"configurationType": "Release",
|
||||||
"inheritEnvironments": [
|
"inheritEnvironments": [
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
This Is A Video Game Where You Feed The Snivy.
|
This Is A Video Game Where You Feed The Snivy.
|
||||||
|
|
||||||
[Get Resources Here](https://shweetz.net/files/games/feed-snivy/resources.7z)
|
[Resources](https://shweetz.net/files/games/feed-snivy/resources.7z)
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
@@ -16,10 +16,11 @@ After cloning and enter the repository's directory, make sure to initialize the
|
|||||||
Visual Studio is recommended for build.
|
Visual Studio is recommended for build.
|
||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
|
|
||||||
```
|
```
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If using VSCode, several tasks are available to quickly run and build.
|
||||||
17
cmake/copy_resources.cmake
Normal file
17
cmake/copy_resources.cmake
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
if(NOT DEFINED SRC_DIR OR NOT DEFINED DST_DIR)
|
||||||
|
message(FATAL_ERROR "SRC_DIR and DST_DIR must be defined")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
file(REMOVE_RECURSE "${DST_DIR}")
|
||||||
|
file(MAKE_DIRECTORY "${DST_DIR}")
|
||||||
|
|
||||||
|
# Copy all resources except characters/ contents.
|
||||||
|
file(COPY "${SRC_DIR}/" DESTINATION "${DST_DIR}"
|
||||||
|
PATTERN "characters/*" EXCLUDE)
|
||||||
|
|
||||||
|
# Copy only .zip archives from resources/characters.
|
||||||
|
file(MAKE_DIRECTORY "${DST_DIR}/characters")
|
||||||
|
file(GLOB CHARACTER_ZIPS "${SRC_DIR}/characters/*.zip")
|
||||||
|
if(CHARACTER_ZIPS)
|
||||||
|
file(COPY ${CHARACTER_ZIPS} DESTINATION "${DST_DIR}/characters")
|
||||||
|
endif()
|
||||||
@@ -45,6 +45,7 @@ namespace game
|
|||||||
|
|
||||||
Loader::Loader(int argc, const char** argv)
|
Loader::Loader(int argc, const char** argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
util::web_filesystem::init_and_wait();
|
util::web_filesystem::init_and_wait();
|
||||||
#endif
|
#endif
|
||||||
@@ -83,6 +84,7 @@ namespace game
|
|||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
|
static constexpr glm::vec2 SIZE = {1600, 900};
|
||||||
window = SDL_CreateWindow("Snivy", SIZE.x, SIZE.y, SDL_WINDOW_OPENGL);
|
window = SDL_CreateWindow("Snivy", SIZE.x, SIZE.y, SDL_WINDOW_OPENGL);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ namespace game
|
|||||||
class Loader
|
class Loader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr glm::vec2 SIZE = {1280, 720};
|
|
||||||
|
|
||||||
SDL_Window* window{};
|
SDL_Window* window{};
|
||||||
SDL_GLContext context{};
|
SDL_GLContext context{};
|
||||||
bool isError{};
|
bool isError{};
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ namespace game::resource::xml
|
|||||||
};
|
};
|
||||||
|
|
||||||
util::measurement::System measurementSystem{util::measurement::METRIC};
|
util::measurement::System measurementSystem{util::measurement::METRIC};
|
||||||
int volume{VOLUME_MAX};
|
int volume{50};
|
||||||
|
|
||||||
glm::vec3 color{0.120f, 0.515f, 0.115f};
|
glm::vec3 color{0.120f, 0.515f, 0.115f};
|
||||||
glm::ivec2 windowSize{1280, 720};
|
glm::ivec2 windowSize{1600, 900};
|
||||||
glm::vec2 windowPosition{};
|
glm::vec2 windowPosition{};
|
||||||
|
|
||||||
bool isValid{};
|
bool isValid{};
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ namespace game
|
|||||||
|
|
||||||
void State::update()
|
void State::update()
|
||||||
{
|
{
|
||||||
|
#ifndef __EMSCRIPTEN__
|
||||||
SDL_GetWindowSize(window, &resources.settings.windowSize.x, &resources.settings.windowSize.y);
|
SDL_GetWindowSize(window, &resources.settings.windowSize.x, &resources.settings.windowSize.y);
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
@@ -92,8 +94,10 @@ namespace game
|
|||||||
|
|
||||||
void State::render()
|
void State::render()
|
||||||
{
|
{
|
||||||
ivec2 windowSize{};
|
auto windowSize = resources.settings.windowSize;
|
||||||
|
#ifndef __EMSCRIPTEN__
|
||||||
SDL_GetWindowSize(window, &windowSize.x, &windowSize.y);
|
SDL_GetWindowSize(window, &windowSize.x, &windowSize.y);
|
||||||
|
#endif
|
||||||
|
|
||||||
canvas.bind();
|
canvas.bind();
|
||||||
canvas.size_set(windowSize);
|
canvas.size_set(windowSize);
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ namespace game::state
|
|||||||
{
|
{
|
||||||
World::Focus Main::focus_get()
|
World::Focus Main::focus_get()
|
||||||
{
|
{
|
||||||
|
if (!isWindows) return World::CENTER;
|
||||||
|
|
||||||
return menu.isOpen && tools.isOpen ? World::MENU_TOOLS
|
return menu.isOpen && tools.isOpen ? World::MENU_TOOLS
|
||||||
: menu.isOpen ? World::MENU
|
: menu.isOpen ? World::MENU
|
||||||
: tools.isOpen ? World::TOOLS
|
: tools.isOpen ? World::TOOLS
|
||||||
@@ -84,26 +86,28 @@ namespace game::state
|
|||||||
text.entry = nullptr;
|
text.entry = nullptr;
|
||||||
text.isEnabled = false;
|
text.isEnabled = false;
|
||||||
|
|
||||||
if (auto font = character.data.menuSchema.font.get()) ImGui::GetIO().FontDefault = font;
|
|
||||||
|
|
||||||
if (game == NEW_GAME && dialogue.start.is_valid())
|
|
||||||
{
|
|
||||||
character.queue_play({.animation = dialogue.start.animation, .isInterruptible = false});
|
|
||||||
character.tick();
|
|
||||||
isWindows = false;
|
|
||||||
isStart = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
isPostgame = saveData.isPostgame;
|
isPostgame = saveData.isPostgame;
|
||||||
|
|
||||||
if (isPostgame)
|
if (isPostgame)
|
||||||
menu.isCheats = true;
|
menu.isCheats = true;
|
||||||
else
|
else
|
||||||
menu.isCheats = true; //false;
|
menu.isCheats = false;
|
||||||
|
|
||||||
|
if (game == NEW_GAME) isWindows = false;
|
||||||
|
|
||||||
|
if (auto font = character.data.menuSchema.font.get()) ImGui::GetIO().FontDefault = font;
|
||||||
|
|
||||||
|
character.play_default_animation();
|
||||||
|
character.tick();
|
||||||
worldCanvas.size_set(imgui::to_vec2(ImGui::GetMainViewport()->Size));
|
worldCanvas.size_set(imgui::to_vec2(ImGui::GetMainViewport()->Size));
|
||||||
|
|
||||||
world.set(character, worldCanvas, focus_get());
|
world.set(character, worldCanvas, focus_get());
|
||||||
|
|
||||||
|
if (game == NEW_GAME && dialogue.start.is_valid())
|
||||||
|
{
|
||||||
|
character.queue_play({.animation = dialogue.start.animation, .isInterruptible = false});
|
||||||
|
character.tick();
|
||||||
|
isStart = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Main::exit(Resources& resources)
|
void Main::exit(Resources& resources)
|
||||||
|
|||||||
@@ -91,11 +91,13 @@ namespace game::state::main
|
|||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDebug && WIDGET_FX(ImGui::BeginTabItem("Debug")))
|
#if defined(DEBUG) && DEBUG
|
||||||
|
if (WIDGET_FX(ImGui::BeginTabItem("Debug")))
|
||||||
{
|
{
|
||||||
debug.update(character, cursor, itemManager, canvas);
|
debug.update(character, cursor, itemManager, canvas);
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
ImGui::EndTabBar();
|
ImGui::EndTabBar();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ namespace game::state::main
|
|||||||
state::Configuration configuration;
|
state::Configuration configuration;
|
||||||
|
|
||||||
bool isCheats{true};
|
bool isCheats{true};
|
||||||
bool isDebug{true};
|
|
||||||
bool isOpen{true};
|
bool isOpen{true};
|
||||||
bool isChat{true};
|
bool isChat{true};
|
||||||
util::imgui::WindowSlide slide{};
|
util::imgui::WindowSlide slide{};
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ namespace game::state::main
|
|||||||
void World::set(entity::Character& character, Canvas& canvas, Focus focus)
|
void World::set(entity::Character& character, Canvas& canvas, Focus focus)
|
||||||
{
|
{
|
||||||
character.stage = character.stage_get();
|
character.stage = character.stage_get();
|
||||||
character.queue_idle_animation();
|
|
||||||
character_focus(character, canvas, focus);
|
character_focus(character, canvas, focus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
43
web/index.html
Normal file
43
web/index.html
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<title>snivy</title>
|
||||||
|
<style>
|
||||||
|
html, body {
|
||||||
|
margin: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#canvas {
|
||||||
|
display: block;
|
||||||
|
width: auto !important;
|
||||||
|
height: auto !important;
|
||||||
|
max-width: 100vw;
|
||||||
|
max-height: 100vh;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<canvas id="canvas" oncontextmenu="event.preventDefault()"></canvas>
|
||||||
|
<script>
|
||||||
|
var Module = {
|
||||||
|
canvas: (function() {
|
||||||
|
return document.getElementById("canvas");
|
||||||
|
})()
|
||||||
|
};
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{{{ SCRIPT }}}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user