Clean up
This commit is contained in:
parent
16d250a51d
commit
519d780b3c
@ -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 "$<IF:$<CONFIG:Debug>,${SDL2_INSTALL_DIR}/bin/SDL2d.dll,${SDL2_INSTALL_DIR}/bin/SDL2.dll>")
|
||||
set(SDL2_DLL_DST "$<IF:$<CONFIG:Debug>,$<TARGET_FILE_DIR:space-game001>/SDL2d.dll,$<TARGET_FILE_DIR:space-game001>/SDL2.dll>")
|
||||
set(SDL2_DLL_DST "$<IF:$<CONFIG:Debug>,$<TARGET_FILE_DIR:witcher001>/SDL2d.dll,$<TARGET_FILE_DIR:witcher001>/SDL2.dll>")
|
||||
|
||||
|
||||
set(LIBZIP_DLL_SRC "$<IF:$<CONFIG:Debug>,${LIBZIP_BASE_DIR}-Debug/bin/zip.dll,${LIBZIP_BASE_DIR}-Release/bin/zip.dll>")
|
||||
|
||||
set(ZLIB_DLL_SRC "$<IF:$<CONFIG:Debug>,${ZLIB_INSTALL_DIR}/bin/zd.dll,${ZLIB_INSTALL_DIR}/bin/z.dll>")
|
||||
set(ZLIB_DLL_DST "$<IF:$<CONFIG:Debug>,$<TARGET_FILE_DIR:space-game001>/zd.dll,$<TARGET_FILE_DIR:space-game001>/z.dll>")
|
||||
set(ZLIB_DLL_DST "$<IF:$<CONFIG:Debug>,$<TARGET_FILE_DIR:witcher001>/zd.dll,$<TARGET_FILE_DIR:witcher001>/z.dll>")
|
||||
|
||||
set(SDL2TTF_DLL_SRC "$<IF:$<CONFIG:Debug>,${SDL2TTF_BASE_DIR}-Debug/bin/SDL2_ttfd.dll,${SDL2TTF_BASE_DIR}-Release/bin/SDL2_ttf.dll>")
|
||||
|
||||
set(SDL2MIXER_DLL_SRC "$<IF:$<CONFIG:Debug>,${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}"
|
||||
"$<TARGET_FILE_DIR:space-game001>/zip.dll"
|
||||
"$<TARGET_FILE_DIR:witcher001>/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}"
|
||||
"$<TARGET_FILE_DIR:space-game001>"
|
||||
"$<TARGET_FILE_DIR:witcher001>"
|
||||
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty/SDL_mixer-release-2.8.0/install-$<CONFIG>/bin/SDL2_mixer$<$<CONFIG:Debug>:d>.dll"
|
||||
"$<TARGET_FILE_DIR:space-game001>/SDL2_mixer$<$<CONFIG:Debug>:d>.dll"
|
||||
"$<TARGET_FILE_DIR:witcher001>/SDL2_mixer$<$<CONFIG:Debug>: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}"
|
||||
"$<TARGET_FILE_DIR:space-game001>/${resdir}"
|
||||
"$<TARGET_FILE_DIR:witcher001>/${resdir}"
|
||||
# 2) в корень build, если захочешь запускать из этой папки
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"${CMAKE_SOURCE_DIR}/../${resdir}"
|
||||
|
||||
@ -127,15 +127,7 @@ void Character::setTexture(std::shared_ptr<ZL::Texture> texture)
|
||||
void Character::setTexture(const std::string& meshName, std::shared_ptr<Texture> tex) {
|
||||
meshTextures[meshName] = std::move(tex);
|
||||
}
|
||||
/*
|
||||
void Character::setTexture(std::shared_ptr<Texture> 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<int64_t>(static_cast<float>(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<float>(deltaMs) / 24.f;
|
||||
/*
|
||||
if (npcId == "ghost_01x")
|
||||
{
|
||||
std::cout << "Current animation frame: " << anim.currentFrame << " / " << anim.totalFrames << " -- " << anim.lastFrame << std::endl;
|
||||
}*/
|
||||
|
||||
if (static_cast<int>(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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -9,10 +9,9 @@ namespace ZL {
|
||||
GLuint fbo = 0;
|
||||
GLuint textureID = 0;
|
||||
int width, height;
|
||||
bool useMipmaps; // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD>
|
||||
bool useMipmaps;
|
||||
|
||||
public:
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> false
|
||||
FrameBuffer(int w, int h, bool useMipmaps = false);
|
||||
~FrameBuffer();
|
||||
|
||||
@ -22,7 +21,6 @@ namespace ZL {
|
||||
void Bind();
|
||||
void Unbind();
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void GenerateMipmaps();
|
||||
|
||||
GLuint getTextureID() const { return textureID; }
|
||||
|
||||
@ -14,8 +14,6 @@ namespace ZL {
|
||||
GLuint shaderProgram;
|
||||
|
||||
std::unordered_map<std::string, GLuint> uniformList;
|
||||
|
||||
//std::unordered_map<std::string, std::pair<bool, size_t>> UniformList;
|
||||
std::map<std::string, GLuint> attribList;
|
||||
|
||||
|
||||
|
||||
@ -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<Texture>(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);
|
||||
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
namespace ZL {
|
||||
|
||||
struct GlyphInfo {
|
||||
// std::shared_ptr<Texture> 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<uint32_t, GlyphInfo> glyphs;
|
||||
|
||||
// OpenGL objects for a dynamic quad
|
||||
//unsigned int vao = 0;
|
||||
//unsigned int vbo = 0;
|
||||
|
||||
// единый атлас для всех глифов
|
||||
std::shared_ptr<Texture> atlasTexture;
|
||||
size_t atlasWidth = 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user