mpri-graphics-project/render/GlutRender.hpp
Théophile Bastian eaa730f5dc Integrate Perlin noise switch
Also make Perlin noise ground wider and less ugly
2018-02-14 13:16:01 +01:00

62 lines
1.6 KiB
C++

/** The most basic renderer — a stupid glut application */
#pragma once
#include "../Mesh.hpp"
#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();
void add_mesh(Mesh* mesh);
void remove_mesh(Mesh* mesh);
void add_surface(ImplicitSurface* surf, const Cuboid& box,
double resolution=0.1);
void remove_surface(ImplicitSurface* surf);
void run();
void set_idle_func(void (*func)(void));
private:
struct SurfaceDetails {
SurfaceDetails(ImplicitSurface* surf, const Cuboid& box,
double resolution):
surface(surf), box(box), resolution(resolution) {}
ImplicitSurface* surface;
Cuboid box;
double resolution;
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<double()> rand_color;
std::set<Mesh*> meshes;
std::set<SurfaceDetails> surfaces;
};