mpri-graphics-project/render/GlutRender.hpp

56 lines
1.4 KiB
C++
Raw Normal View History

/** The most basic renderer — a stupid glut application */
2018-02-06 19:07:07 +01:00
#pragma once
#include "../Mesh.hpp"
2018-02-12 18:40:05 +01:00
#include "../Implicit.hpp"
#include <set>
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();
2018-02-06 21:05:45 +01:00
void add_mesh(Mesh* mesh);
void remove_mesh(Mesh* mesh);
2018-02-12 18:40:05 +01:00
void add_surface(ImplicitSurface* surf, const Cuboid& box);
void remove_surface(ImplicitSurface* surf);
void run();
2018-02-12 18:40:05 +01:00
void set_idle_func(void (*func)(void));
private: //meth
GlutRender();
2018-02-12 18:40:05 +01:00
void display_mesh(const 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:
2018-02-12 18:40:05 +01:00
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;
}
};
std::function<double()> rand_color;
2018-02-06 21:05:45 +01:00
std::set<Mesh*> meshes;
2018-02-12 18:40:05 +01:00
std::set<SurfaceDetails> surfaces;
};