refactor(text_rendering): 优化文本渲染示例并更新窗口配置
- 删除冗余注释和临时文件note.txt - 更新窗口标题为中文并修改后端为SDL2 - 简化相机服务配置方式
This commit is contained in:
parent
b794221d49
commit
c32c2dd60d
|
|
@ -1,4 +0,0 @@
|
|||
请将 1.jpg 图片复制到此目录,并重命名为 demo.jpg
|
||||
|
||||
源文件位置: C:\Users\soulcoco\Desktop\Extra2D\1.jpg
|
||||
目标文件位置: C:\Users\soulcoco\Desktop\Extra2D\examples\image_display\assets\images\demo.jpg
|
||||
|
|
@ -57,7 +57,6 @@ public:
|
|||
float y = 100.0f;
|
||||
float x = 100.0f;
|
||||
|
||||
// 渲染标题(自动批处理,无需手动调用 begin/end)
|
||||
renderText(renderer, "Extra2D Text Rendering Demo", x, y,
|
||||
Color(1.0f, 0.8f, 0.2f, 1.0f));
|
||||
y += font_->getLineHeight() * 2;
|
||||
|
|
@ -91,8 +90,6 @@ public:
|
|||
// 渲染操作提示
|
||||
renderText(renderer, "Press ESC to exit", x, y,
|
||||
Color(0.5f, 0.5f, 0.5f, 1.0f));
|
||||
|
||||
// 注意:无需手动调用 renderer.endSpriteBatch(),帧结束时会自动刷新
|
||||
}
|
||||
|
||||
void setRenderer(RenderBackend *renderer) { renderer_ = renderer; }
|
||||
|
|
@ -120,9 +117,9 @@ int main(int argc, char *argv[]) {
|
|||
app.use<WindowModule>([](auto &cfg) {
|
||||
cfg.w = 1280;
|
||||
cfg.h = 720;
|
||||
cfg.title = "Extra2D Text Rendering Demo";
|
||||
cfg.title = "Extra2D 文字显示示例";
|
||||
cfg.priority = 0;
|
||||
cfg.backend = "glfw";
|
||||
cfg.backend = "sdl2";
|
||||
});
|
||||
|
||||
app.use<RenderModule>([](auto &cfg) { cfg.priority = 10; });
|
||||
|
|
@ -167,11 +164,11 @@ int main(int argc, char *argv[]) {
|
|||
// 配置相机
|
||||
auto cameraService = ServiceLocator::instance().getService<ICameraService>();
|
||||
if (cameraService && win) {
|
||||
ViewportConfig vpConfig;
|
||||
vpConfig.logicWidth = static_cast<float>(win->width());
|
||||
vpConfig.logicHeight = static_cast<float>(win->height());
|
||||
vpConfig.mode = ViewportMode::AspectRatio;
|
||||
cameraService->setViewportConfig(vpConfig);
|
||||
cameraService->setViewportConfig([&](auto &cfg) {
|
||||
cfg.logicWidth = static_cast<float>(win->width());
|
||||
cfg.logicHeight = static_cast<float>(win->height());
|
||||
cfg.mode = ViewportMode::AspectRatio;
|
||||
});
|
||||
cameraService->updateViewport(win->width(), win->height());
|
||||
cameraService->applyViewportAdapter();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue