Major speed up in rendering by only doing it when we move, but drawing the rendered 3d view texture constantly.
This commit is contained in:
parent
0260e3d345
commit
b43553a563
7 changed files with 39 additions and 17 deletions
10
main_ui.cpp
10
main_ui.cpp
|
@ -65,13 +65,15 @@ namespace gui {
|
|||
$rayview.init_shaders();
|
||||
$rayview.set_position(RAY_VIEW_X, RAY_VIEW_Y);
|
||||
$rayview.position_camera($player.x + 0.5, $player.y + 0.5);
|
||||
|
||||
$overlay_ui.render();
|
||||
}
|
||||
|
||||
void MainUI::draw() {
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
if($needs_render) $rayview.render();
|
||||
$rayview.draw($window);
|
||||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
auto elapsed = std::chrono::duration<double>(end - start);
|
||||
$stats.sample(1/elapsed.count());
|
||||
|
@ -85,16 +87,20 @@ namespace gui {
|
|||
}
|
||||
|
||||
bool MainUI::play_rotate() {
|
||||
return $camera.play_rotate($rayview);
|
||||
bool done = $camera.play_rotate($rayview);
|
||||
$needs_render = !done;
|
||||
return done;
|
||||
}
|
||||
|
||||
// this could be an optional that returs a Point
|
||||
std::optional<Point> MainUI::play_move() {
|
||||
if($camera.play_move($rayview)) {
|
||||
$needs_render = false;
|
||||
return std::make_optional<Point>({
|
||||
size_t($camera.target_x),
|
||||
size_t($camera.target_y)});
|
||||
} else {
|
||||
$needs_render = true;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue