Skip to content

Commit

Permalink
[ren.quad] quad renderer now has code setup to regenerate its project…
Browse files Browse the repository at this point in the history
…ion matrix if it detects that the window has been resized. however, as projection matrices are not yet implemented this code is not complete
  • Loading branch information
harrand committed Oct 31, 2024
1 parent 3b0e31d commit 0792364
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/tz/ren/quad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "tz/gpu/pass.hpp"
#include "tz/gpu/graph.hpp"
#include "tz/gpu/shader.hpp"
#include "tz/os/window.hpp"

#include ImportedShaderHeader(quad, vertex)
#include ImportedShaderHeader(quad, fragment)
Expand All @@ -20,6 +21,8 @@ namespace tz::ren
tz::gpu::graph_handle graph = tz::nullhand;
std::size_t quad_count = 0;
std::size_t texture_count = 0;
unsigned int window_width_cache;
unsigned int window_height_cache;
};

struct quad_data
Expand Down Expand Up @@ -98,6 +101,9 @@ namespace tz::ren
.add_pass(ren.main_pass)
.build());

ren.window_width_cache = tz::os::window_get_width();
ren.window_height_cache = tz::os::window_get_height();

return static_cast<tz::hanval>(id);
}

Expand Down Expand Up @@ -219,6 +225,16 @@ namespace tz::ren
void quad_renderer_update(quad_renderer_handle renh)
{
auto& ren = renderers[renh.peek()];
(void)ren;

auto w = tz::os::window_get_width();
auto h = tz::os::window_get_height();
if((w != 0 && h != 0) && (ren.window_width_cache != w || ren.window_height_cache != h))
{
// window has resized
ren.window_width_cache = w;
ren.window_height_cache = h;
// todo: regenerate projection matrix.

}
}
}

0 comments on commit 0792364

Please sign in to comment.