diff --git a/.gitignore b/.gitignore index 7d939a3..bd55861 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ blends/** *3d-game-shaders-for-beginners* !blends/* !blends/mill-scene/mill-scene-low-poly-backup.blend +demonstration/build/* +*.exe \ No newline at end of file diff --git a/demonstration/CMakeLists.txt b/demonstration/CMakeLists.txt new file mode 100644 index 0000000..12fdd71 --- /dev/null +++ b/demonstration/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.10) +project(3DGameShadersForBeginners LANGUAGES C CXX) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED true) + +add_executable(3d-game-shaders src/main.cxx) +find_package(Python3 REQUIRED) +set(PandaPath "C:\\Panda3D-1.10.15-x64" CACHE STRING "Path to the root of panda sdk") +list(APPEND LIBRARIES + libp3framework + libpanda + libpandafx + libpandaexpress + libpandaphysics + libp3dtoolconfig + libp3dtool +) +target_link_directories(3d-game-shaders PRIVATE "${PandaPath}/lib") +target_include_directories(3d-game-shaders PRIVATE "${PandaPath}/include") +target_link_libraries(3d-game-shaders PRIVATE ${LIBRARIES}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) \ No newline at end of file diff --git a/demonstration/build-for-windows.ps1 b/demonstration/build-for-windows.ps1 new file mode 100644 index 0000000..d4d04c8 --- /dev/null +++ b/demonstration/build-for-windows.ps1 @@ -0,0 +1,65 @@ +function BuildExe() { + # Configure CMake + cmake . -B build + # Build the file in release mode + $result = (cmake --build build --config Release ) + Write-Output $result + if($result -eq 0) { + Write-Error "An error occurred when building the project file! Check logs for more details." + } + return $result +} + +function CopyExe() { + # Copies the exe file to the workspace root + Copy-Item "./build/Release/3d-game-shaders.exe" "./" +} + +$changeCache = (Test-Path "build/cache.json") ? (Get-Content "build/cache.json" | ConvertFrom-Json -AsHashTable) : @{} + +function GetFileHash { + param( + $file + ) + return (Get-FileHash "$file" -Algorithm SHA256).Hash +} + +function SetFileHash { + param ( + $file + ) + $changeCache["$file"] = GetFileHash($file) +} + +function CheckDiff { + param ($file) + return ((GetFileHash($file)) -eq ($changeCache["$file"])) +} + +function MakeCache { + if(Test-Path "build/cache.json") { + Clear-Content "build/cache.json" + } + SetFileHash("CMakeLists.txt") + SetFileHash("src/main.cxx") + Set-Content -Path "build/cache.json" -Value ($changeCache | ConvertTo-Json) +} + +$firstTime = 0 + +# Create a build directory +if(-not(Test-Path ./build)) { + mkdir ./build > $null + $firstTime = 1 +} + +# If CMakeLists.txt or main.cxx is changed, rebuild the executable and copy it to the root directory +if($firstTime -or -not(CheckDiff("src/main.cxx") -and CheckDiff("CMakeLists.txt"))) { + Write-Output "Building exe file..." + if(buildExe -eq 0) { + Write-Output "Copying exe file..." + copyExe + MakeCache + } + Write-Output "Build script finished executing!" +} \ No newline at end of file diff --git a/demonstration/src/main.cxx b/demonstration/src/main.cxx index 0cf10fa..e82f98d 100644 --- a/demonstration/src/main.cxx +++ b/demonstration/src/main.cxx @@ -4,7 +4,6 @@ */ #include -#include #include #include #include