23# include <GLUT/glut.h>
34 static const int format = GL_LUMINANCE;
35 static const int type = GL_FLOAT;
40 static const int format = GL_LUMINANCE;
41 static const int type = GL_UNSIGNED_BYTE;
46 static const int format = GL_LUMINANCE;
47 static const int type = GL_UNSIGNED_SHORT;
52 static const int format = GL_RGBA;
53 static const int type = GL_UNSIGNED_BYTE;
58 static const int format = GL_RGB;
59 static const int type = GL_UNSIGNED_BYTE;
64 static const int format = GL_RGBA;
65 static const int type = GL_UNSIGNED_BYTE;
71void drawit(
const T* scene,
const Eigen::Vector2i& res)
73 const Eigen::Vector2i content_res(res);
76 if (glutGetWindow() == 0) {
78 char* argv = (
char*)
"supereight";
79 glutInit(&argc, &argv);
80 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
81 glutInitWindowSize(content_res.x(), content_res.y());
82 glutCreateWindow(
"supereight display");
84 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
85 glPixelStorei(GL_UNPACK_ROW_LENGTH, content_res.x());
88 glMatrixMode(GL_PROJECTION);
89 gluOrtho2D(0.0, 1.0, 0.0, 1.0);
90 glMatrixMode(GL_MODELVIEW);
95 const Eigen::Vector2i window_res =
96 Eigen::Vector2i(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
97 const float width_factor = (float) window_res.x() / content_res.x();
98 const float height_factor = (float) window_res.y() / content_res.y();
99 const float factor = std::min(width_factor, height_factor);
101 glViewport(0, 0, window_res.x(), window_res.y());
103 glClear(GL_COLOR_BUFFER_BIT);
105 if (scene !=
nullptr) {
109 glPixelZoom(factor, -factor);
110 glDrawPixels(res.x(), res.y(), gl<T>::format, gl<T>::type, scene);
119void drawit(
const T*,
const Eigen::Vector2i&)
void drawit(const T *, const Eigen::Vector2i &)
Definition draw.hpp:119
Helper wrapper to allocate and de-allocate octants in the octree.
Definition bounded_vector.hpp:14