Compare commits

...

2 Commits

Author SHA1 Message Date
Till Wübbers
93bb1553be wip 2025-03-16 21:03:41 +01:00
Till Wübbers
ebf29b058a release build setup 2025-03-16 02:00:33 +01:00
13 changed files with 66 additions and 64 deletions

1
src/.gitignore vendored
View File

@@ -33,5 +33,6 @@
# build dirs
cmake-build/
cmake-build-release/
out/
.vs/

View File

@@ -2,17 +2,17 @@ cmake_minimum_required(VERSION 3.10)
project(PuzGameProj)
if (MSVC)
else()
add_compile_options(-g -gcodeview)
add_link_options(-fuse-ld=lld -g -Wl,--pdb=)
endif()
add_compile_definitions("$<$<CONFIG:DEBUG>:DEBUG>")
# 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}/$<CONFIGURATION>")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$<CONFIGURATION>")
set(PROFILE ON)
# Imgui
file(GLOB imgui_sources dependency/imgui/*.h dependency/imgui/*.cpp)
@@ -27,7 +27,6 @@ file(GLOB_RECURSE sources_engine engine/*.cpp engine/*.h)
add_executable(PuzGameEngine ${sources_engine})
target_compile_definitions(PuzGameEngine PUBLIC "_AMD64_")
set_property(TARGET PuzGameEngine PROPERTY CXX_STANDARD 17)
target_include_directories(PuzGameEngine PUBLIC dependency/tracy/public/)
# Game
add_custom_command(
@@ -42,10 +41,11 @@ file(GLOB source_singleheader dependency/tinygltf/stb_image.h dependency/tinyglt
add_library(PuzGame SHARED ${sources_game} ${source_singleheader} ${imgui_sources} ${imgui_backend_sdl})
set_property(TARGET PuzGame PROPERTY CXX_STANDARD 17)
target_include_directories(PuzGame PUBLIC dependency/imgui)
target_include_directories(PuzGame PUBLIC dependency/tracy/public/)
# Profiling
if (PROFILE)
option(TRACY_ENABLE "" ON)
option(TRACY_ENABLE "" OFF)
if (TRACY_ENABLE)
option(TRACY_ON_DEMAND "" ON)
set(TRACY_DELAYED_INIT ON)
set(TRACY_MANUAL_LIFETIME ON)
@@ -61,6 +61,11 @@ SET(BGFX_BUILD_EXAMPLES OFF)
add_subdirectory("${CMAKE_SOURCE_DIR}/dependency/bgfx.cmake")
# Link
if (TRACY_ENABLE)
target_link_libraries(PuzGame bx bimg bgfx SDL3::SDL3 Tracy::TracyClient)
target_link_libraries(PuzGameEngine bx SDL3::SDL3 Tracy::TracyClient)
else()
target_link_libraries(PuzGame bx bimg bgfx SDL3::SDL3)
target_link_libraries(PuzGameEngine bx SDL3::SDL3)
endif()
set_target_properties(PuzGame PROPERTIES OUTPUT_NAME "PuzGame2")

1
src/build-release.bat Normal file
View File

@@ -0,0 +1 @@
cmake --build cmake-build-release

View File

@@ -1,4 +1,6 @@
cd dependency/bgfx.cmake
cmake -G "Ninja" -S . -B cmake-build -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_COMPILER="clang++.exe" -DBGFX_BUILD_TOOLS=OFF -DBGFX_BUILD_EXAMPLES=OFF
cmake -G "Ninja" -S . -B cmake-build-release -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_COMPILER="clang++.exe" -DBGFX_BUILD_TOOLS=OFF -DBGFX_BUILD_EXAMPLES=OFF
cd ..\..
cmake -G "Ninja" -S . -B cmake-build -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_COMPILER="clang++.exe" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake -G "Ninja" -S . -B cmake-build-release -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_COMPILER="clang++.exe" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

View File

@@ -15,7 +15,7 @@
#include <SDL3/SDL.h>
#include <bx/math.h>
#include <cstdint>
#include <tracy/tracy.hpp>
#include <tracy/Tracy.hpp>
namespace Game
{
@@ -76,6 +76,10 @@ namespace Game
needReset |= PuzzleTiles.Setup(storagePtr, needReset);
needReset |= UIQuads.Setup(storagePtr, needReset);
UIQuads.IsEnabled = false;
Tests.IsEnabled = false;
Cubes.IsEnabled = false;
Puzzle::Setup();
bx::Error err;
@@ -148,14 +152,13 @@ namespace Game
{
Tests.Get(Tests.New()).Setup();
}
if (PuzzleTiles.Count == 0)
for (int32_t i = 0; i < BX_COUNTOF(Puzzles); ++i)
{
for (uint32_t puzI = 0; puzI < BX_COUNTOF(Puzzles); ++puzI)
if (Puzzles[i].Data.ID != UINT16_MAX && !Puzzles[i].IsSetup)
{
Puzzles[puzI].Setup();
Puzzles[i].Setup();
}
}
UpdatePlayerInputMode();
}
@@ -301,32 +304,11 @@ namespace Game
void WorldPuzzle::Setup()
{
Data.PlacedCardCount = 16;
for (int32_t i = 0; i < 16; ++i)
auto& level = GetInstance().GameLevel;
for (int32_t i = 0; i < Puzzle::Config::MaxCardsInPuzzle; ++i)
{
Data.PlacedCards[i].RefCard = {0};
Data.PlacedCards[i].Position = {int8_t(i % 4), int8_t(i / 4)};
}
for (uint32_t cardI = 0; cardI < Data.PlacedCardCount; ++cardI)
{
const Generated::PlacedPuzzleCard& card = Data.PlacedCards[cardI];
Level& level = GetInstance().GameLevel;
TileHandles[cardI] = level.PuzzleTiles.New();
UIPlacedCards[cardI] = level.UIQuads.New();
bx::Vec3 Pos = {
WorldPosition.x + card.Position.X * WorldCardSize.x,
WorldPosition.y,
WorldPosition.z + card.Position.Y * WorldCardSize.y,
};
PuzzleTileEntity& tile = level.PuzzleTiles.Get(TileHandles[cardI]);
tile.EData.Transform.Position = Pos;
tile.EData.MaterialHandle = 0;
UIQuadEntity& quad = level.UIQuads.Get(UIPlacedCards[cardI]);
quad.EData.MaterialHandle = 0;
quad.EData.ModelHandle = GameRendering::Get().GetModelHandleFromPath("models/plane.glb");
TileHandles[i] = level.PuzzleTiles.New();
UIPlacedCards[i] = level.UIQuads.New();
}
}
@@ -336,18 +318,23 @@ namespace Game
Vec3 cameraPos = camTransform.GetPosition() * -1;
Level& level = GetInstance().GameLevel;
for (int32_t cardI = 0; cardI < Data.PlacedCardCount; ++cardI)
for (int8_t y = 0; y < Data.WidthTiles / Puzzle::Config::CardSize; ++y)
{
Generated::PlacedPuzzleCard& card = Data.PlacedCards[cardI];
if (!Puzzle::IsValid(card.RefCard)) continue;
for (int8_t x = 0; x < Data.WidthTiles / Puzzle::Config::CardSize; ++x)
{
Generated::PlacedPuzzleCard& card = Data.PlacedCards[y * Puzzle::Config::MaxPuzzleSizeCards + x];
if (!Puzzle::IsValid(card.RefCard))
const Generated::StaticPuzzleCard& cData = Puzzle::GetCard(card.RefCard);
level.PuzzleTiles.Get(TileHandles[cardI]).EData.ModelHandle = cData.ModelHandle;
auto& tile = level.PuzzleTiles.Get(TileHandles[y * Puzzle::Config::MaxPuzzleSizeCards + x]);
tile.EData.ModelHandle = Puzzle::GetStaticPuzzleData().Cards[card.RefCard.Idx].ModelHandle;
tile.EData.Transform.SetPosition({(float)card.Position.X, (float)card.Position.Y, 0.0f});
auto& quad = level.UIQuads.Get(UIPlacedCards[cardI]);
auto& quad = level.UIQuads.Get(UIPlacedCards[y * Puzzle::Config::MaxPuzzleSizeCards + x]);
Vec3 fw = {0, -1, 0};
// quad.EData.Transform.SetPosition(cameraPos + Vec3{0, -2, 0});
quad.EData.Transform.SetPosition({});
quad.EData.Transform.Rotation = camTransform.Rotation;
}
}
}
} // namespace Game

View File

@@ -135,6 +135,7 @@ namespace Game
Vec3 WorldPosition;
PuzzleTileEntityHandle TileHandles[Puzzle::Config::MaxCardsInPuzzle];
UIQuadEntityHandle UIPlacedCards[Puzzle::Config::MaxCardsInPuzzle];
bool IsSetup = false;
void Setup();
void Update();

View File

@@ -7,8 +7,10 @@
#include "bx/bx.h"
#include "bx/timer.h"
#ifdef TRACY_ENABLE
#include <client/TracyProfiler.hpp>
#include <tracy/tracy.hpp>
#endif
#include <tracy/Tracy.hpp>
namespace Game
{
@@ -26,7 +28,10 @@ namespace Game
void Setup(SharedData& shared)
{
LOG("Game Setup Start!");
#ifdef TRACY_ENABLE
LOG("Tracy is enabled");
tracy::StartupProfiler();
#endif
if (shared.Game.PermanentStorage == nullptr)
{
@@ -89,6 +94,8 @@ namespace Game
{
LOG("Shutdown");
SetupInstance.Rendering.Shutdown();
#ifdef TRACY_ENABLE
tracy::ShutdownProfiler();
#endif
}
} // namespace Game

View File

@@ -95,7 +95,6 @@ type PuzzleData
u8 HeightTiles
u32 AvailableCardCount
PuzzleCardStack AvailableCards Arr(16)
u32 PlacedCardCount
PlacedPuzzleCard PlacedCards Arr(256)
PuzzleElementType BackgroundTiles Arr(1024)
u32 GoalPositionCount

View File

@@ -342,7 +342,9 @@ namespace Game
bgfx::Init init;
init.type = bgfx::RendererType::Direct3D12;
init.debug = true;
#ifdef _DEBUG
// init.debug = true;
#endif
init.platformData.nwh = shared.Window.Handle;
init.platformData.ndt = nullptr;
init.platformData.type = bgfx::NativeWindowHandleType::Default;

View File

@@ -105,7 +105,7 @@ namespace Game
Model Models[MaxModels];
int32_t LastWidth = 0;
int32_t LastHeight = 0;
uint32_t ResetFlags = 0; // BGFX_RESET_VSYNC;
uint32_t ResetFlags = BGFX_RESET_NONE;
uint16_t MainViewID = 10;
float LastShaderLoadTime = 0.0f;
int32_t DitherRecursion = 1;

View File

@@ -257,7 +257,6 @@ namespace Generated
isOk = Save(&obj[i].HeightTiles, 1, serializer) && isOk;
isOk = Save(&obj[i].AvailableCardCount, 1, serializer) && isOk;
isOk = Save(obj[i].AvailableCards, 16, serializer) && isOk;
isOk = Save(&obj[i].PlacedCardCount, 1, serializer) && isOk;
isOk = Save(obj[i].PlacedCards, 256, serializer) && isOk;
isOk = Save(obj[i].BackgroundTiles, 1024, serializer) && isOk;
isOk = Save(&obj[i].GoalPositionCount, 1, serializer) && isOk;
@@ -276,7 +275,6 @@ namespace Generated
isOk = Load(&obj[i].HeightTiles, 1, serializer) && isOk;
isOk = Load(&obj[i].AvailableCardCount, 1, serializer) && isOk;
isOk = Load(obj[i].AvailableCards, 16, serializer) && isOk;
isOk = Load(&obj[i].PlacedCardCount, 1, serializer) && isOk;
isOk = Load(obj[i].PlacedCards, 256, serializer) && isOk;
isOk = Load(obj[i].BackgroundTiles, 1024, serializer) && isOk;
isOk = Load(&obj[i].GoalPositionCount, 1, serializer) && isOk;

View File

@@ -131,14 +131,13 @@ namespace Generated
};
struct PuzzleData
{
static constexpr uint32_t Hash = 2775382112;
static constexpr uint32_t Hash = 657000000;
uint16_t ID = {};
char PuzzleName[64] = {};
uint8_t WidthTiles = {};
uint8_t HeightTiles = {};
uint32_t AvailableCardCount = {};
PuzzleCardStack AvailableCards[16] = {};
uint32_t PlacedCardCount = {};
PlacedPuzzleCard PlacedCards[256] = {};
PuzzleElementType::Enum BackgroundTiles[1024] = {};
uint32_t GoalPositionCount = {};