From f8c2c26cdc477852c1af05d693e438ef5eeb425e Mon Sep 17 00:00:00 2001 From: Lenheart <947330670@qq.com> Date: Thu, 26 Feb 2026 13:19:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=BB=A3=E7=A0=81=E5=B9=B6=E7=AE=80=E5=8C=96=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除application.cpp中的测试绘制代码 简化main.cpp中的初始化逻辑,移除相机相关代码 调整窗口大小和渲染器视口配置 --- .../src/frostbite2D/core/application.cpp | 22 ---------- Frostbite2D/src/main.cpp | 40 ++++--------------- 2 files changed, 8 insertions(+), 54 deletions(-) diff --git a/Frostbite2D/src/frostbite2D/core/application.cpp b/Frostbite2D/src/frostbite2D/core/application.cpp index c2080f5..0a8c9df 100644 --- a/Frostbite2D/src/frostbite2D/core/application.cpp +++ b/Frostbite2D/src/frostbite2D/core/application.cpp @@ -250,28 +250,6 @@ void Application::render() { } } - // 简单的测试代码 - 绘制彩色方块 - if (renderer_) { - static float angle = 0.0f; - angle += 0.02f; - - renderer_->beginFrame(); - - // 绘制橙色方块 - renderer_->drawQuad(Vec2(0, 0), Size(200, 150), 1.0f, 0.5f, 0.2f); - - // 绘制蓝色移动方块 - float x = 1920.0 / 2 + cosf(angle) * 100.0f; - float y = 1080.0 / 2 + sinf(angle) * 100.0f; - renderer_->drawQuad(Vec2(x, y), Size(100, 100), 0.3f, 0.5f, 1.0f); - - renderer_->drawQuad(Vec2(1920 - 100, 1080 - 150), Size(100, 150), 1.0f, - 0.5f, 0.2f); - - renderer_->endFrame(); - renderer_->flush(); - } - if (window_) { window_->swap(); } diff --git a/Frostbite2D/src/main.cpp b/Frostbite2D/src/main.cpp index 92c54cb..78f8dc5 100644 --- a/Frostbite2D/src/main.cpp +++ b/Frostbite2D/src/main.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include @@ -14,48 +13,25 @@ int main(int argc, char **argv) { AppConfig config = AppConfig::createDefault(); config.appName = "Frostbite2D Test App"; config.appVersion = "1.0.0"; - config.windowConfig.width = 1920; - config.windowConfig.height = 1080; + config.windowConfig.width = 800; + config.windowConfig.height = 600; config.windowConfig.title = "Frostbite2D - Renderer Test"; - Application &app = Application::get(); + Application& app = Application::get(); if (!app.init(config)) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to initialize application!"); return -1; } - auto &renderer = Renderer::get(); - renderer.setClearColor(0.1f, 0.1f, 0.15f); + auto& renderer = Renderer::get(); + renderer.setClearColor(0.2f, 0.3f, 1.0f); + renderer.setViewport(0, 0, 800, 600); - // 获取屏幕实际大小 - auto *window = app.getWindow(); - int screenWidth = window ? window->width() : config.windowConfig.width; - int screenHeight = window ? window->height() : config.windowConfig.height; - - // 设置 Renderer 的视口到屏幕大小 - renderer.setViewport(0, 0, screenWidth, screenHeight); - - // 相机使用游戏逻辑分辨率 (1280x720) - static Camera camera; - camera.setViewport(config.windowConfig.width, config.windowConfig.height); - renderer.setCamera(&camera); - - auto &asset = Asset::get(); -#ifdef __SWITCH__ - asset.setWorkingDirectory("/switch/testgame"); -#else - asset.setWorkingDirectory("."); -#endif - - // 初始化着色器管理器 - auto &shaderManager = renderer.getShaderManager(); - shaderManager.init("shaders"); + auto& asset = Asset::get(); + asset.setWorkingDirectory("assets"); SDL_Log("Application initialized successfully"); - SDL_Log("Screen size: %dx%d", screenWidth, screenHeight); - SDL_Log("Render size: %dx%d", config.windowConfig.width, - config.windowConfig.height); SDL_Log("Starting main loop..."); app.run();