1616
1717#include < renderer.h>
1818
19- #include < chrono>
2019#include < cstdint>
2120#include < iostream>
2221#include < span>
2322#include < string>
24- #include < thread>
2523#include < vector>
2624
2725#include " buffer.hpp"
@@ -83,7 +81,7 @@ int main(int argc, char **argv) {
8381 simple_renderer::Camera camera (simple_renderer::Vector3f (0 .0f , 0 .0f , 1 .0f ));
8482
8583 // 设置渲染模式(可选:TRADITIONAL、TILE_BASED 或 DEFERRED)
86- simple_renderer.SetRenderingMode (simple_renderer::RenderingMode::TRADITIONAL );
84+ simple_renderer.SetRenderingMode (simple_renderer::RenderingMode::TILE_BASED );
8785
8886 // 输出当前渲染模式
8987 std::string current_mode_name;
@@ -103,11 +101,9 @@ int main(int argc, char **argv) {
103101 auto display = Display (kWidth , kHeight );
104102 display.loopBegin ();
105103
106- // 调试模式:固定相机状态,只渲染一帧
107- bool debug_mode = true ;
108-
109- if (debug_mode) {
110- // 固定相机参数进行调试
104+ while (!display.loopShouldClose ()) {
105+ display.handleEvents (camera);
106+
111107 shader.SetUniform (" cameraPos" , camera.GetPosition ());
112108 shader.SetUniform (" viewMatrix" , camera.GetViewMatrix ());
113109 shader.SetUniform (" projectionMatrix" ,
@@ -119,29 +115,8 @@ int main(int argc, char **argv) {
119115 }
120116
121117 buffer.SwapBuffer ();
118+
122119 display.fill (buffer.GetDisplayBuffer ());
123-
124- // 调试模式下等待几秒让我们看到结果
125- std::this_thread::sleep_for (std::chrono::seconds (3 ));
126- } else {
127- // 正常渲染循环
128- while (!display.loopShouldClose ()) {
129- display.handleEvents (camera);
130-
131- shader.SetUniform (" cameraPos" , camera.GetPosition ());
132- shader.SetUniform (" viewMatrix" , camera.GetViewMatrix ());
133- shader.SetUniform (" projectionMatrix" ,
134- camera.GetProjectionMatrix (60 .0f , static_cast <float >(kWidth ) / static_cast <float >(kHeight ), 0 .1f , 100 .0f ));
135-
136- buffer.ClearDrawBuffer (simple_renderer::Color::kBlack );
137- for (auto &model : models) {
138- simple_renderer.DrawModel (model, shader, buffer.GetDrawBuffer ());
139- }
140-
141- buffer.SwapBuffer ();
142-
143- display.fill (buffer.GetDisplayBuffer ());
144- }
145120 }
146121
147122 return 0 ;
0 commit comments