Skip to content

Commit

Permalink
[imgui] imgui render wip
Browse files Browse the repository at this point in the history
  • Loading branch information
harrand committed Nov 15, 2024
1 parent 8b4a197 commit 0ca0d04
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
7 changes: 7 additions & 0 deletions demo/tz/tz_triangle_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ int tz_main()
while(tz::os::window_is_open())
{
tz::os::window_update();
auto windims = static_cast<tz::v2f>(tz::v2u{tz::os::window_get_width(), tz::os::window_get_height()});
ImGui::GetIO().DisplaySize = {windims[0], windims[1]};
ImGui::NewFrame();
ImGui::Begin("123");
ImGui::Text("hello world");
ImGui::End();
ImGui::EndFrame();
tz::gpu::execute(graph);
}

Expand Down
9 changes: 9 additions & 0 deletions include/tz/core/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <concepts>
#include <array>
#include <type_traits>
#include <algorithm>

namespace tz
{
Expand Down Expand Up @@ -96,6 +97,14 @@ namespace tz
/// Divide one vector by another.
vector<T, N> operator/(const vector<T, N>& rhs) const{auto cpy = *this; return cpy /= rhs;}

template<typename C>
operator vector<C, N>() const requires(std::is_convertible_v<T, C>)
{
std::array<C, N> arr;
std::transform(this->arr.begin(), this->arr.end(), arr.begin(), [](const T& t)->C{return static_cast<C>(t);});
return {arr};
}

/// Retrieve the magnitude of the vector.
T length() const;
/// Retrieve the dot (scalar) product of two vectors.
Expand Down
8 changes: 7 additions & 1 deletion src/tz/imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,14 @@ namespace tz
{
(void)graph;
// we have a graph that could be completely wrong.
ImGui::Render();
ImDrawData* draws = ImGui::GetDrawData();
(void)draws;
if(draws == nullptr)
{
return;
}

impl_write_vertices_and_indices(draws);
}

void impl_write_vertices_and_indices(ImDrawData* draw)
Expand Down

0 comments on commit 0ca0d04

Please sign in to comment.