14 #include <Eigen/Dense> 21 # include <GLUT/glut.h> 32 static const int format = GL_LUMINANCE;
33 static const int type = GL_FLOAT;
38 static const int format = GL_LUMINANCE;
39 static const int type = GL_UNSIGNED_BYTE;
44 static const int format = GL_LUMINANCE;
45 static const int type = GL_UNSIGNED_SHORT;
50 static const int format = GL_RGBA;
51 static const int type = GL_UNSIGNED_BYTE;
57 void drawit(
const T* scene,
const Eigen::Vector2i& res)
59 const Eigen::Vector2i content_res(res);
62 if (glutGetWindow() == 0) {
64 char* argv = (
char*)
"supereight";
65 glutInit(&argc, &argv);
66 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
67 glutInitWindowSize(content_res.x(), content_res.y());
68 glutCreateWindow(
"supereight display");
70 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
71 glPixelStorei(GL_UNPACK_ROW_LENGTH, content_res.x());
74 glMatrixMode(GL_PROJECTION);
75 gluOrtho2D(0.0, 1.0, 0.0, 1.0);
76 glMatrixMode(GL_MODELVIEW);
81 const Eigen::Vector2i window_res =
82 Eigen::Vector2i(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
83 const float width_factor = (float) window_res.x() / content_res.x();
84 const float height_factor = (float) window_res.y() / content_res.y();
85 const float factor = std::min(width_factor, height_factor);
87 glViewport(0, 0, window_res.x(), window_res.y());
89 glClear(GL_COLOR_BUFFER_BIT);
91 if (scene !=
nullptr) {
95 glPixelZoom(factor, -factor);
96 glDrawPixels(res.x(), res.y(), gl<T>::format, gl<T>::type, scene);
105 void drawit(
const T*,
const Eigen::Vector2i&)
112 #endif // SE_DRAW_HPP void drawit(const T *, const Eigen::Vector2i &)
Definition: draw.hpp:105