diff --git a/src/renderer/backend/dx/dx_window.cpp b/src/renderer/backend/dx/dx_window.cpp index 2570231..6b4fb47 100644 --- a/src/renderer/backend/dx/dx_window.cpp +++ b/src/renderer/backend/dx/dx_window.cpp @@ -87,9 +87,9 @@ void dx_window::begin_frame() { context.draw_rounded_rectangle({ 100, 100 }, { 200, 200 }, { 1, 0, 0, 1 }, radius); auto height = sin(get_total_time().count()) * 100; - context.draw_line({ 600, 600 - height }, { 700, 600 + height }, { 0, 0, 1, 1 }, 0.1); + context.draw_line({ 600, 600 - height }, { 700, 600 + height }, { 0, 0, 1, 1 }, 0.5); - context.draw_texture({0, 0}, test_texture->size(), test_texture); + if (test_texture) context.draw_texture({ 0, 0 }, test_texture->size(), test_texture); context.flush(); diff --git a/src/renderer/core/renderer/renderer.cpp b/src/renderer/core/renderer/renderer.cpp index bf65593..e957018 100644 --- a/src/renderer/core/renderer/renderer.cpp +++ b/src/renderer/core/renderer/renderer.cpp @@ -5,6 +5,7 @@ #include "renderer_texture.h" #include "core/window/renderer_window.h" #define STB_IMAGE_IMPLEMENTATION +#define STBI_FAILURE_USERMSG #include "stb_image.h" #if DX_BACKEND @@ -24,12 +25,12 @@ void renderer::destroy_texture(renderer_texture* texture) { delete texture; } renderer_texture* renderer::load_image(const std::string& file_path, texture_format in_format) { int width, height, channels; - auto result = stbi_load(file_path.c_str(), &width, &height, &channels, 0); + const auto result = stbi_load(file_path.c_str(), &width, &height, &channels, 0); if (!result) { - spdlog::critical("Failed to load image: {0}", file_path); + const char* reason = stbi_failure_reason(); + spdlog::critical("加载图片 {0} 失败: {1}", file_path, reason); return nullptr; } - int target_channel_count = get_format_channel_count(in_format); unsigned int row_pitch = 0;