From 519d780b3c360c452116e83e56965452c40fa67c Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Fri, 1 May 2026 20:01:06 +0300 Subject: [PATCH] Clean up --- proj-windows/CMakeLists.txt | 42 ++++++++++++++-------------- src/Character.cpp | 28 +------------------ src/Game.h | 3 -- src/dialogue/DialogueOverlay.cpp | 12 +------- src/items/GameObjectLoader.h | 7 +---- src/render/FrameBuffer.h | 4 +-- src/render/ShaderManager.h | 2 -- src/render/TextRenderer.cpp | 48 -------------------------------- src/render/TextRenderer.h | 5 ---- 9 files changed, 25 insertions(+), 126 deletions(-) diff --git a/proj-windows/CMakeLists.txt b/proj-windows/CMakeLists.txt index 0543c46..ea66beb 100644 --- a/proj-windows/CMakeLists.txt +++ b/proj-windows/CMakeLists.txt @@ -1,20 +1,20 @@ cmake_minimum_required(VERSION 3.16) -project(space-game001 LANGUAGES C CXX) +project(witcher001 LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) # Build option (Windows-only): when ON, the game launches in fullscreen. # When OFF (default), it launches in a 1280x720 window like before. -option(FULLSCREEN "Launch the game in fullscreen mode" ON) +option(FULLSCREEN "Launch the game in fullscreen mode" OFF) include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/ThirdParty.cmake) # =========================================== -# Основной проект space-game001 +# Основной проект witcher001 # =========================================== -add_executable(space-game001 +add_executable(witcher001 ../src/main.cpp ../src/Game.cpp ../src/Game.h @@ -85,21 +85,21 @@ add_executable(space-game001 ) # Установка проекта по умолчанию для Visual Studio -set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT space-game001) +set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT witcher001) # include-пути проекта -target_include_directories(space-game001 PRIVATE +target_include_directories(witcher001 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../src" ) -set_target_properties(space-game001 PROPERTIES - OUTPUT_NAME "space-game001" +set_target_properties(witcher001 PROPERTIES + OUTPUT_NAME "witcher001" ) # Определения препроцессора: # PNG_ENABLED – включает код PNG в TextureManager # SDL_MAIN_HANDLED – отключает переопределение main -> SDL_main -target_compile_definitions(space-game001 PRIVATE +target_compile_definitions(witcher001 PRIVATE WIN32_LEAN_AND_MEAN PNG_ENABLED SDL_MAIN_HANDLED @@ -108,14 +108,14 @@ target_compile_definitions(space-game001 PRIVATE ) if(FULLSCREEN) - target_compile_definitions(space-game001 PRIVATE FULLSCREEN) + target_compile_definitions(witcher001 PRIVATE FULLSCREEN) endif() # Линкуем с SDL2main, если он вообще установлен -target_link_libraries(space-game001 PRIVATE SDL2main_external_lib) +target_link_libraries(witcher001 PRIVATE SDL2main_external_lib) # Линкуем сторонние библиотеки -target_link_libraries(space-game001 PRIVATE +target_link_libraries(witcher001 PRIVATE SDL2_external_lib libpng_external_lib zlib_external_lib @@ -130,7 +130,7 @@ target_link_libraries(space-game001 PRIVATE # Линкуем OpenGL (Windows) if(WIN32) - target_link_libraries(space-game001 PRIVATE opengl32) + target_link_libraries(witcher001 PRIVATE opengl32) endif() # =========================================== @@ -140,19 +140,19 @@ if (WIN32) # SDL2: в Debug - SDL2d.dll, в Release - SDL2.dll set(SDL2_DLL_SRC "$,${SDL2_INSTALL_DIR}/bin/SDL2d.dll,${SDL2_INSTALL_DIR}/bin/SDL2.dll>") - set(SDL2_DLL_DST "$,$/SDL2d.dll,$/SDL2.dll>") + set(SDL2_DLL_DST "$,$/SDL2d.dll,$/SDL2.dll>") set(LIBZIP_DLL_SRC "$,${LIBZIP_BASE_DIR}-Debug/bin/zip.dll,${LIBZIP_BASE_DIR}-Release/bin/zip.dll>") set(ZLIB_DLL_SRC "$,${ZLIB_INSTALL_DIR}/bin/zd.dll,${ZLIB_INSTALL_DIR}/bin/z.dll>") - set(ZLIB_DLL_DST "$,$/zd.dll,$/z.dll>") + set(ZLIB_DLL_DST "$,$/zd.dll,$/z.dll>") set(SDL2TTF_DLL_SRC "$,${SDL2TTF_BASE_DIR}-Debug/bin/SDL2_ttfd.dll,${SDL2TTF_BASE_DIR}-Release/bin/SDL2_ttf.dll>") set(SDL2MIXER_DLL_SRC "$,${SDL2MIXER_BASE_DIR}-Debug/bin/SDL2_mixerd.dll,${SDL2MIXER_BASE_DIR}-Release/bin/SDL2_mixer.dll>") - add_custom_command(TARGET space-game001 POST_BUILD + add_custom_command(TARGET witcher001 POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "Copying DLLs to output folder..." # Копируем SDL2 (целевое имя всегда SDL2.dll) @@ -163,7 +163,7 @@ if (WIN32) # Копируем LIBZIP (целевое имя всегда zip.dll) COMMAND ${CMAKE_COMMAND} -E copy_if_different "${LIBZIP_DLL_SRC}" - "$/zip.dll" + "$/zip.dll" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${ZLIB_DLL_SRC}" @@ -171,11 +171,11 @@ if (WIN32) COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SDL2TTF_DLL_SRC}" - "$" + "$" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty/SDL_mixer-release-2.8.0/install-$/bin/SDL2_mixer$<$:d>.dll" - "$/SDL2_mixer$<$:d>.dll" + "$/SDL2_mixer$<$:d>.dll" ) endif() @@ -191,12 +191,12 @@ set(RUNTIME_RESOURCE_DIRS # Копируем ресурсы и шейдеры в папку exe и в корень build/ foreach(resdir IN LISTS RUNTIME_RESOURCE_DIRS) - add_custom_command(TARGET space-game001 POST_BUILD + add_custom_command(TARGET witcher001 POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "Copying ${resdir} to runtime folders..." # 1) туда, где лежит exe (build/Debug, build/Release и т.п.) COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/../${resdir}" - "$/${resdir}" + "$/${resdir}" # 2) в корень build, если захочешь запускать из этой папки COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/../${resdir}" diff --git a/src/Character.cpp b/src/Character.cpp index 2d37873..cc45b2d 100644 --- a/src/Character.cpp +++ b/src/Character.cpp @@ -127,15 +127,7 @@ void Character::setTexture(std::shared_ptr texture) void Character::setTexture(const std::string& meshName, std::shared_ptr tex) { meshTextures[meshName] = std::move(tex); } -/* -void Character::setTexture(std::shared_ptr tex) { - for (auto& animEntry : animations) { - for (const auto& name : animEntry.second.model.meshNamesOrdered) { - meshTextures[name] = tex; - } - } -} -*/ + AnimationState Character::resolveActiveState() const { if (animations.count(currentState)) return currentState; @@ -174,14 +166,6 @@ void Character::update(int64_t deltaMs) { deltaMs = static_cast(static_cast(deltaMs) * speedMultiplier); } - - //weaponInitialRotation = Eigen::AngleAxisf(x/180.0, Eigen::Vector3f::UnitZ()).toRotationMatrix(); - //weaponInitialRotation = Eigen::AngleAxisf(-M_PI*0.5, Eigen::Vector3f::UnitZ()).toRotationMatrix(); - //weaponInitialPosition = Eigen::Vector3f(0, 0.09, 0.016); - /*if (deltaMs > 200) - { - deltaMs = 200; - }*/ Eigen::Vector3f activeTarget; Eigen::Vector3f lookTarget; @@ -373,14 +357,8 @@ void Character::update(int64_t deltaMs) { resetAnim = false; anim.currentFrame = 0; } - //19 int prevFrame = anim.currentFrame; anim.currentFrame += static_cast(deltaMs) / 24.f; - /* - if (npcId == "ghost_01x") - { - std::cout << "Current animation frame: " << anim.currentFrame << " / " << anim.totalFrames << " -- " << anim.lastFrame << std::endl; - }*/ if (static_cast(anim.currentFrame) >= 20 && currentState == AnimationState::STAND_TO_ACTION) { @@ -436,25 +414,21 @@ void Character::update(int64_t deltaMs) { if (currentState == AnimationState::STAND_TO_ACTION) { currentState = AnimationState::ACTION_IDLE; - //resetAnim = true; } if (currentState == AnimationState::ACTION_TO_STAND) { currentState = AnimationState::STAND; - //resetAnim = true; } if (currentState == AnimationState::ACTION_ATTACK) { currentState = AnimationState::ACTION_IDLE; - //resetAnim = true; attack = 0; } if (currentState == AnimationState::ACTION_TO_DEATH) { currentState = AnimationState::DEATH_IDLE; - //resetAnim = true; } } diff --git a/src/Game.h b/src/Game.h index a35fb96..81dac78 100644 --- a/src/Game.h +++ b/src/Game.h @@ -107,9 +107,6 @@ namespace ZL { void updatePinchZoom(); void endPinch(); int countNonUiPointers() const; - void handleDown(int64_t fingerId, int mx, int my); - void handleUp(int64_t fingerId, int mx, int my); - void handleMotion(int64_t fingerId, int mx, int my); void setupQuestJournalUi(); void toggleQuestJournal(); diff --git a/src/dialogue/DialogueOverlay.cpp b/src/dialogue/DialogueOverlay.cpp index 203c123..8f5e87a 100644 --- a/src/dialogue/DialogueOverlay.cpp +++ b/src/dialogue/DialogueOverlay.cpp @@ -205,22 +205,12 @@ void DialogueOverlay::drawDialogue(Renderer& renderer, const PresentationModel& nameRenderer->drawText(model.speaker, nameX, nameY, 1.0f, false, { 1.0f, 0.88f, 0.45f, 1.0f }); } -/*<<<<<<< HEAD - //const std::string wrappedBody = wrapText(model.visibleText, 90); - const std::string wrappedBody = wrapText(model.visibleText, 56); - bodyRenderer->drawText(wrappedBody, bodyX, bodyY, 1.0f, false, { 1.0f, 1.0f, 1.0f, 1.0f }); -=======*/ - // const std::string wrappedBody = wrapText(model.visibleText, 90); - // bodyRenderer->drawText(wrappedBody, bodyX, bodyY, 1.0f, false, { 1.0f, 1.0f, 1.0f, 1.0f }); - // const std::string wrappedBody = wrapText(model.visibleText, 56); - // bodyRenderer->drawText(wrappedBody, bodyX, bodyY, 1.0f, false, { 1.0f, 1.0f, 1.0f, 1.0f }); - + const float bodyTextScale = 1.0f; const float bodyMaxWidthPx = textboxRect.w - 48.0f; const std::string wrappedBody = wrapTextToWidth(model.visibleText, *bodyRenderer, bodyMaxWidthPx, bodyTextScale); bodyRenderer->drawText(wrappedBody, bodyX, bodyY, bodyTextScale, false, { 1.0f, 1.0f, 1.0f, 1.0f }); -//>>>>>>> 4de8f78ecad8b7e2139d593b95aaf9ef01b25ece lastChoiceRects.clear(); if (model.mode == PresentationMode::Choice) { diff --git a/src/items/GameObjectLoader.h b/src/items/GameObjectLoader.h index 15cdecb..1614167 100644 --- a/src/items/GameObjectLoader.h +++ b/src/items/GameObjectLoader.h @@ -7,14 +7,9 @@ #include "external/nlohmann/json.hpp" #include "TextModel.h" #include "InteractiveObject.h" -//#include "Character.h" -//#include "render/TextureManager.h" namespace ZL { - - //struct Texture; - //struct VertexRenderStruct; - //class Renderer; + class Character; struct GameObjectData { diff --git a/src/render/FrameBuffer.h b/src/render/FrameBuffer.h index 2c35f4d..3d53d27 100644 --- a/src/render/FrameBuffer.h +++ b/src/render/FrameBuffer.h @@ -9,10 +9,9 @@ namespace ZL { GLuint fbo = 0; GLuint textureID = 0; int width, height; - bool useMipmaps; // ���� ������������� ���-����� + bool useMipmaps; public: - // ��������� �������� � ����������� �� ��������� false FrameBuffer(int w, int h, bool useMipmaps = false); ~FrameBuffer(); @@ -22,7 +21,6 @@ namespace ZL { void Bind(); void Unbind(); - // ����� ��� �������������� ��������� ���-����� ����� ������� void GenerateMipmaps(); GLuint getTextureID() const { return textureID; } diff --git a/src/render/ShaderManager.h b/src/render/ShaderManager.h index c27f8c9..1b6c695 100644 --- a/src/render/ShaderManager.h +++ b/src/render/ShaderManager.h @@ -14,8 +14,6 @@ namespace ZL { GLuint shaderProgram; std::unordered_map uniformList; - - //std::unordered_map> UniformList; std::map attribList; diff --git a/src/render/TextRenderer.cpp b/src/render/TextRenderer.cpp index b3abb1b..e5758e7 100644 --- a/src/render/TextRenderer.cpp +++ b/src/render/TextRenderer.cpp @@ -298,34 +298,6 @@ bool TextRenderer::loadGlyphs(const std::string& ttfPath, int pixelSize, const s rowHeight = max(rowHeight, gb.height); } - // // Проходим по стандартным ASCII символам - // for (unsigned char c = 32; c < 128; ++c) { - // - // FT_Load_Char(face, c, FT_LOAD_RENDER); - - // TextureDataStruct glyphData; - // glyphData.width = face->glyph->bitmap.width; - // glyphData.height = face->glyph->bitmap.rows; - // glyphData.format = TextureDataStruct::R8; - // glyphData.mipmap = TextureDataStruct::NONE; - - // // Копируем буфер FreeType в вектор данных - // size_t dataSize = glyphData.width * glyphData.height; - // glyphData.data.assign(face->glyph->bitmap.buffer, face->glyph->bitmap.buffer + dataSize); - - // // Теперь создание текстуры — это одна строка! - // auto tex = std::make_shared(glyphData); - - //GlyphInfo g; - // g.texture = tex; - // g.size = Eigen::Vector2f((float)face->glyph->bitmap.width, (float)face->glyph->bitmap.rows); - // g.bearing = Eigen::Vector2f((float)face->glyph->bitmap_left, (float)face->glyph->bitmap_top); - // // Advance во FreeType измеряется в 1/64 пикселя - // g.advance = (unsigned int)face->glyph->advance.x; - - // glyphs.emplace((char)c, g); - // } - // Создаём Texture из atlasData (R8) TextureDataStruct atlasTex; atlasTex.width = atlasWidth; @@ -466,12 +438,9 @@ void TextRenderer::drawText(const std::string& text, float x, float y, float sca // Примечание: для текста лучше использовать GL_DYNAMIC_DRAW, // но RefreshVBO сейчас жестко зашит на GL_STATIC_DRAW. // Для UI это обычно не критично, если строк не тысячи. - // textMesh.AssignFrom(textData); // 4. Рендеринг r->shaderManager.PushShader(shaderName); - //r->PushMatrix(); - //r->LoadIdentity(); // Матрица проекции — используем виртуальные проекционные размеры, // чтобы координаты текста были независимы от физического разрешения экрана. @@ -498,24 +467,7 @@ void TextRenderer::drawText(const std::string& text, float x, float y, float sca glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - //for (size_t i = 0; i < text.length(); ++i) { - // auto it = glyphs.find(text[i]); - // if (it == glyphs.end()) continue; - - // glBindTexture(GL_TEXTURE_2D, it->second.texture->getTexID()); - - // // Отрисовываем по 6 вершин за раз - // // Нам нужно вручную биндить VBO, так как DrawVertexRenderStruct рисует всё сразу - // glBindBuffer(GL_ARRAY_BUFFER, textMesh.positionVBO->getBuffer()); - // r->VertexAttribPointer3fv("vPosition", 0, (const char*)(i * 6 * sizeof(Vector3f))); - - // glBindBuffer(GL_ARRAY_BUFFER, textMesh.texCoordVBO->getBuffer()); - // r->VertexAttribPointer2fv("vTexCoord", 0, (const char*)(i * 6 * sizeof(Vector2f))); - - // glDrawArrays(GL_TRIANGLES, 0, 6); - //} r->DrawVertexRenderStruct(cached.mesh); - //r->PopMatrix(); glDisable(GL_BLEND); diff --git a/src/render/TextRenderer.h b/src/render/TextRenderer.h index 0dd3075..7e9422c 100644 --- a/src/render/TextRenderer.h +++ b/src/render/TextRenderer.h @@ -12,7 +12,6 @@ namespace ZL { struct GlyphInfo { - // std::shared_ptr texture; // Texture for glyph Eigen::Vector2f uv; // u,v координата левого верхнего угла в атласе (0..1) Eigen::Vector2f uvSize; // ширина/высота в UV (0..1) @@ -42,10 +41,6 @@ private: std::unordered_map glyphs; - // OpenGL objects for a dynamic quad - //unsigned int vao = 0; - //unsigned int vbo = 0; - // единый атлас для всех глифов std::shared_ptr atlasTexture; size_t atlasWidth = 0;