Skip to content
Snippets Groups Projects
Commit 4fc0e018 authored by Philip Trettner's avatar Philip Trettner
Browse files

started plotting

parent 58c42b9d
No related branches found
No related tags found
No related merge requests found
Pipeline #11635 failed
glow-extras @ 8b505f71
Subproject commit 65a7989156d719fb592c3291d08b8b6f2c657763
Subproject commit 8b505f71cef3869610898612b995ea1334437514
typed-geometry @ e8102273
Subproject commit d00bebc1b4e0428a22c89c9c73403e29ed687ae7
Subproject commit e8102273eda0db9b0323a93473bdc1d2a6168c23
cmake_minimum_required(VERSION 3.0)
project(Plotting)
file(GLOB_RECURSE SHADER_FILES "shaders/*.*")
file(GLOB_RECURSE SOURCES "*.cc" "*.hh" "*.*sh")
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} PUBLIC glow glow-extras glfw polymesh)
target_compile_options(${PROJECT_NAME} PUBLIC ${GLOW_SAMPLES_DEF_OPTIONS})
set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER "Samples/WIP")
if (GLOW_EXTRAS_EMBED_SHADERS)
target_compile_definitions(${PROJECT_NAME} PUBLIC GLOW_SAMPLES_VIEWER_EMBED_SHADERS)
endif()
#include <glow-extras/glfw/GlfwContext.hh>
#include <glow-extras/plotting/plot.hh>
#include <glow-extras/viewer/view.hh>
int main()
{
// Create a context
glow::glfw::GlfwContext ctx;
// some example data
std::vector<tg::pos2> xy_data;
for (auto i = 0; i < 100; ++i)
xy_data.emplace_back(i, tg::sin(5_deg * i));
// grid view of example plots
{
auto v = glow::viewer::grid();
// simple cases
view_plot(xy_data);
view_scatter_plot(xy_data);
view_line_plot(xy_data);
// manual setup
{
auto f = glow::plotting::Figure();
view(f);
}
}
}
#include <random>
#include <imgui/imgui.h>
#include <glow/common/str_utils.hh>
......@@ -25,9 +23,6 @@ int main()
// Create a context
glow::glfw::GlfwContext ctx;
std::uniform_real_distribution<float> dis(0.0f, 1.0f);
std::default_random_engine rng;
// Load a polymesh mesh
pm::Mesh m;
auto pos = m.vertices().make_attribute<tg::pos3>();
......@@ -35,14 +30,15 @@ int main()
normalize(pos); // make it -1..1
// prepare some data
tg::rng rng;
pm::vertex_attribute<glm::vec2> uv = pos.map([](tg::pos3 v) { return glm::vec2(v.x, v.y); });
pm::vertex_attribute<float> vdata = pos.map([](tg::pos3 v) { return v.y; });
pm::vertex_attribute<tg::vec3> vnormals = vertex_normals_by_area(m, pos);
pm::face_attribute<float> fdata = m.faces().map([&](pm::face_handle f) { return f.vertices().avg(pos).z; });
glow::SharedTexture2D tex = glow::Texture2D::createFromFile(dataPath + "textures/tiles.color.png", glow::ColorSpace::sRGB);
glow::AsyncTexture2D atex = glow::AsyncTextureLoader::load2D(dataPath + "textures/tiles.color.png", glow::ColorSpace::sRGB);
pm::face_attribute<glow::colors::color> fcolors = m.faces().map([&](pm::face_handle) { return glow::colors::color(dis(rng), dis(rng), dis(rng)); });
pm::vertex_attribute<glow::colors::color> vcolors = attribute(m.vertices(), glow::colors::color(1, 0, 0));
pm::face_attribute<tg::color3> fcolors = m.faces().map([&](pm::face_handle) { return tg::uniform<tg::color3>(rng); });
pm::vertex_attribute<tg::color3> vcolors = attribute(m.vertices(), tg::color3::red);
pm::edge_attribute<float> edge_lengths = m.edges().map([&](pm::edge_handle e) { return edge_length(e, pos); });
pm::vertex_attribute<float> ptsize = m.vertices().map([&](pm::vertex_handle v) { return v.edges().avg(edge_lengths); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment