linux编译修复
This commit is contained in:
+4
-4
@@ -10,8 +10,8 @@
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "cl.exe",
|
||||
"CMAKE_CXX_COMPILER": "cl.exe",
|
||||
"BUILD_EXTRAS": false, //bullet3
|
||||
"BUILD_UNIT_TESTS": false //bullet3
|
||||
"BUILD_EXTRAS": false,
|
||||
"BUILD_UNIT_TESTS": false
|
||||
},
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
@@ -49,8 +49,8 @@
|
||||
"CMAKE_C_COMPILER": "/usr/bin/clang",
|
||||
"CMAKE_CXX_COMPILER": "/usr/bin/clang++",
|
||||
"CMAKE_BUILD_TYPE": "Debug",
|
||||
"BUILD_EXTRAS": false, //bullet3
|
||||
"BUILD_UNIT_TESTS": false //bullet3
|
||||
"BUILD_EXTRAS": false,
|
||||
"BUILD_UNIT_TESTS": false
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -44,7 +44,9 @@ endif()
|
||||
# freetype
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE freetype)
|
||||
# openal
|
||||
if (CMAKE_HOST_WIN32)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE OpenAL)
|
||||
endif()
|
||||
# bullet3
|
||||
# 3实际上没有教程,似乎已经弃坑(这里使用2的版本)
|
||||
# https://github.com/bulletphysics/bullet3/issues/4002
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include "dl_align.h"
|
||||
|
||||
#include "base\dl_type_convert.h"
|
||||
#include "base/dl_type_convert.h"
|
||||
|
||||
|
||||
namespace dl::Align
|
||||
|
||||
+5
-4
@@ -1,14 +1,15 @@
|
||||
#include "dl_engine.h"
|
||||
|
||||
#include "dl_platform.h"
|
||||
#if (DL_PLATFORM == DL_PLATFORM_WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
#include "render\dl_free_type.h"
|
||||
#include "render\dl_factory.h"
|
||||
#include "render\dl_physics.h"
|
||||
#include "render/dl_free_type.h"
|
||||
#include "render/dl_factory.h"
|
||||
#include "render/dl_physics.h"
|
||||
#include "dl_time.h"
|
||||
#include "io\dl_input.h"
|
||||
#include "io/dl_input.h"
|
||||
#include "dl_system.h"
|
||||
|
||||
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
namespace dl
|
||||
{
|
||||
std::string to_string(std::error_code code)
|
||||
@@ -88,7 +89,7 @@ bool GetPathAndRes(std::string_view path_root, std::string_view path_name, std::
|
||||
{
|
||||
path_real = path_name;
|
||||
res_name = "error";
|
||||
log_err("绝对路径加载,必须设定资源名字!");
|
||||
log_err0("绝对路径加载,必须设定资源名字!");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
||||
+2
-2
@@ -34,13 +34,13 @@ namespace dl
|
||||
{
|
||||
|
||||
//-----------------------------字符串连接-------------------
|
||||
inline std::string& operator+=(std::string a, std::string_view b)
|
||||
inline std::string& operator+=(std::string& a, std::string_view b)
|
||||
{
|
||||
a.append(b);
|
||||
return a;
|
||||
}
|
||||
|
||||
inline std::string operator+(std::string a, std::string_view b)
|
||||
inline std::string operator+(const std::string& a, std::string_view b)
|
||||
{
|
||||
std::string ret = a;
|
||||
return ret += b;
|
||||
|
||||
@@ -242,6 +242,16 @@ void log(std::string_view str)
|
||||
{
|
||||
std::cout << str << std::endl;
|
||||
}
|
||||
|
||||
void log_err0(const std::exception& e)
|
||||
{
|
||||
if (g_log->IsLevelLimit(LogSystem::Level::ERR))
|
||||
return;
|
||||
g_log->PushLevel(LogSystem::Level::ERR);
|
||||
log("捕获到C++异常:" + CodeCvt::MultiByteToUtf8(e.what()));
|
||||
g_log->Pop();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -169,6 +169,9 @@ void log(std::string_view str);
|
||||
#define log_err0(str) log(str)
|
||||
#define log_damage0(str) log(str)
|
||||
|
||||
void log_err0(const std::exception& e);
|
||||
|
||||
#define log_(str, ...) log(fmt::format(str, __VA_ARGS__))
|
||||
#define log_pause(str, ...) log_pause0(fmt::format(str, __VA_ARGS__))
|
||||
#define log_test(str, ...) log_test0(fmt::format(str, __VA_ARGS__))
|
||||
#define log_info(str, ...) log_info0(fmt::format(str, __VA_ARGS__))
|
||||
|
||||
@@ -143,12 +143,14 @@ public:
|
||||
std::multimap<unsigned, RectU> map_remain;
|
||||
//初始空间
|
||||
map_remain.insert( { _size[1], createRectU(_size) });
|
||||
//按面积大小排序
|
||||
stable_sort(all_box.begin(), all_box.end(), [&](const T& box0, const T& box1)
|
||||
|
||||
//按面积大小排序(list的sort本身就是稳定的)
|
||||
all_box.sort([get_size](const T& box0, const T& box1)
|
||||
{
|
||||
return Accumulate::Mul(get_size(box0))
|
||||
> Accumulate::Mul(get_size(box1));
|
||||
});
|
||||
|
||||
for (auto iter = all_box.begin(); iter != all_box.end();)
|
||||
{
|
||||
//获取大小
|
||||
|
||||
@@ -34,7 +34,7 @@ struct GcRefInfo
|
||||
template<typename T>
|
||||
class GC
|
||||
{
|
||||
template<typename T>
|
||||
template<typename TT>
|
||||
friend class PoolList;
|
||||
public:
|
||||
GC() :_p(nullptr), _ref(nullptr) {}
|
||||
|
||||
@@ -107,7 +107,7 @@ void Factory::LoadModel(std::string_view path_name, std::string_view name)
|
||||
for (ModelObject* model_object : mul_model_object)
|
||||
{//资源名+id
|
||||
//文件名
|
||||
std::string file_name = format("{}#{}", res_name, i);
|
||||
std::string file_name = fmt::format("{}#{}", res_name, i);
|
||||
//model文件
|
||||
const std::string PATH_CACHE = GetPathBinary3D();
|
||||
std::string path_child = PATH_CACHE + file_name + ".model";
|
||||
@@ -257,7 +257,7 @@ Size Factory::GetSpriteTexSize(gcSprite& spr)
|
||||
FactoryImp::SpriteInfo* spr_info = _imp->_get_sprite_info(spr_id);
|
||||
if (!spr_info)
|
||||
{
|
||||
log_err("返回精灵信息失败!");
|
||||
log_err0("返回精灵信息失败!");
|
||||
return Math::CastU(SIZE_DEFAULT_SPRITE);
|
||||
}
|
||||
return Align::GetSize(spr_info->_rect);
|
||||
@@ -669,7 +669,7 @@ bool FactoryImp::_reg_image(Image* image, size_t& id_tex, RectU& rect)
|
||||
tex_pack.Reset({ SIZE_TEXTURE_2D, SIZE_TEXTURE_2D });
|
||||
if (!tex_pack.Add(image->GetSize(), rect))
|
||||
{
|
||||
log_err("注册图像失败!可能是图像太大。需要小于SIZE_TEXTURE_2D。");
|
||||
log_err0("注册图像失败!可能是图像太大。需要小于SIZE_TEXTURE_2D。");
|
||||
return false;
|
||||
}
|
||||
id_tex = _numTexStatic + _allTexPack.size();
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
#include <optional>
|
||||
|
||||
#include "dl_type.h"
|
||||
#include "io/dl_log.h"
|
||||
@@ -22,7 +23,8 @@
|
||||
#include "render/dl_text.h"
|
||||
#include "base/dl_color.h"
|
||||
|
||||
namespace dl␍{
|
||||
namespace dl
|
||||
{
|
||||
|
||||
constexpr Size SIZE_SPRITE_DEFAULT = { 32, 32 };
|
||||
constexpr std::string_view STR_PATH_2D = "2d/";
|
||||
|
||||
@@ -153,13 +153,13 @@ void AddImageRect(Image* img_tar, const Image* img_src, const RectU& rect, const
|
||||
assert(img_tar && img_src);
|
||||
if (!img_src || !img_src->IsEmpty())
|
||||
{
|
||||
log_err("传入img无效!");
|
||||
log_err0("传入img无效!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Math::IsRectInSize(rect, img_src->GetSize()))
|
||||
{
|
||||
log_err("源图像区域无效!");
|
||||
log_err0("源图像区域无效!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ void AddImageRect(Image* img_tar, const Image* img_src, const RectU& rect, const
|
||||
if ((tar_xy[0] + s_size[0] > img_tar->GetWidth())
|
||||
|| (tar_xy[1] + s_size[1] > img_tar->GetHeight()))
|
||||
{
|
||||
log_err("目标图像过小!");
|
||||
log_err0("目标图像过小!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
{
|
||||
if (shape_id >= _allShape.size())
|
||||
{
|
||||
log_err("shape id越界!");
|
||||
log_err0("shape id越界!");
|
||||
return nullptr;
|
||||
}
|
||||
RigidBody* ret = new RigidBody;
|
||||
|
||||
+11
-11
@@ -132,7 +132,7 @@ void Text::_set_string(const std::string* str, const std::u32string* p_str_utf)
|
||||
if (str == nullptr
|
||||
&& p_str_utf == nullptr)
|
||||
{
|
||||
log_err("参数不能同时为空!");
|
||||
log_err0("参数不能同时为空!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ void Text::_set_string(const std::string* str, const std::u32string* p_str_utf)
|
||||
{
|
||||
if (CodeCvt::Utf8::Check(_str.c_str()) == 0)
|
||||
{
|
||||
log_err("字符串不是u8编码!");
|
||||
log_err0("字符串不是u8编码!");
|
||||
|
||||
std::string str_u8 = CodeCvt::MultiByteToUtf8(_str.c_str());
|
||||
str_utf = CodeCvt::Utf8ToUtf32(str_u8);
|
||||
@@ -244,7 +244,7 @@ void Text::_set_string(const std::string* str, const std::u32string* p_str_utf)
|
||||
if (iter == 0)
|
||||
{
|
||||
if (iter != str_utf.back())
|
||||
log_warn("空字符出现在非尾部!");
|
||||
log_warn0("空字符出现在非尾部!");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ void Text::_set_string(const std::string* str, const std::u32string* p_str_utf)
|
||||
//分长度处理
|
||||
if (str_flag.empty())
|
||||
{
|
||||
log_err("空标签");
|
||||
log_err0("空标签");
|
||||
}
|
||||
else if (str_flag.size() == 1)
|
||||
{
|
||||
@@ -368,7 +368,7 @@ void Text::_set_string(const std::string* str, const std::u32string* p_str_utf)
|
||||
str_flag.push_back(ch);//TODO utf_char转wchar_t
|
||||
break;
|
||||
default:
|
||||
log_err("错误的标签!");
|
||||
log_err0("错误的标签!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -381,7 +381,7 @@ void Text::_set_string(const std::string* str, const std::u32string* p_str_utf)
|
||||
if (iter == 0)
|
||||
{
|
||||
if (iter != str_utf.back())
|
||||
log_warn("空字符出现在非尾部!");
|
||||
log_warn0("空字符出现在非尾部!");
|
||||
break;;
|
||||
}
|
||||
|
||||
@@ -571,15 +571,15 @@ void Text::_update_layout()
|
||||
|
||||
bool Text::_is_char_can_first(char ch)
|
||||
{
|
||||
// && ch != ','
|
||||
// && ch != '。'
|
||||
// && ch != '!'
|
||||
// && ch != '?'
|
||||
return !ispunct(ch)
|
||||
|| (ch != ','
|
||||
&& ch != '.'
|
||||
&& ch != '!'
|
||||
&& ch != '?'
|
||||
&& ch != ','
|
||||
&& ch != '。'
|
||||
&& ch != '!'
|
||||
&& ch != '?');
|
||||
&& ch != '?');
|
||||
}
|
||||
|
||||
void Text::Render()
|
||||
|
||||
Reference in New Issue
Block a user