/** The most basic renderer — a stupid glut application */ #pragma once #include "../Mesh.hpp" #include "../Implicit.hpp" #include class GlutRender { public: static GlutRender& get_instance(); GlutRender(GlutRender const&) = delete; void operator=(GlutRender const&) = delete; void init(int* argc, char** argv, int wid, int hei, const char* win_name); void cleanup(); void add_mesh(Mesh* mesh); void remove_mesh(Mesh* mesh); void add_surface(ImplicitSurface* surf, const Cuboid& box); void remove_surface(ImplicitSurface* surf); void run(); void set_idle_func(void (*func)(void)); private: struct SurfaceDetails { SurfaceDetails(ImplicitSurface* surf, const Cuboid& box): surface(surf), box(box) {} ImplicitSurface* surface; Cuboid box; bool operator<(const SurfaceDetails& oth) const { return surface < oth.surface; } }; private: //meth GlutRender(); void display_mesh(Mesh& mesh) const; protected: void reshape(int wid, int hei); void display(); static void reshape_handle(int wid, int hei); static void display_handle(); private: //attr std::function rand_color; std::set meshes; std::set surfaces; };