#include #include #include using namespace std; namespace AMPS { class AMPS { public: AMPS() { } ~AMPS() { } }; class Window; static unordered_map windows; class Window { protected: int window; int width; int height; private: // This static member does not work for some reason. // static unordered_map windows; static void display_static() { int window = glutGetWindow(); windows[window]->display(); } public: Window(const char *title = "app", int width_ = 0, int height_ = 0, bool fullscreen = 0) : width(width_), height(height_) { if (width && height) { glutInitWindowSize(width, height); } window = glutCreateWindow(title); windows[window] = this; if (fullscreen) glutFullScreen(); glutDisplayFunc(&display_static); width = glutGet(GLUT_WINDOW_WIDTH); height = glutGet(GLUT_WINDOW_HEIGHT); cerr << "width " << width << ", height " << height << endl; } virtual ~Window() { glutDestroyWindow(window); } virtual void display() { glClear(GL_COLOR_BUFFER_BIT); glutSwapBuffers(); } }; class Editor : Window { public: Editor() : Window("AMPS", glutGet(GLUT_SCREEN_WIDTH), glutGet(GLUT_SCREEN_HEIGHT), 0) { } private: virtual void display() { cerr << width << " " << height << endl; cerr << (double) width / height << endl; gluPerspective(30, (double)width / height, 0.1, 10); glTranslated(0, 0, -2); glRotated(30, 4, 5, 6); glClear(GL_COLOR_BUFFER_BIT); glutWireTeapot(0.5); glutSwapBuffers(); } }; class Compiler { }; class Shape { }; class Graph { }; class Proc { }; class Node { }; class Port { }; class Arc { }; } void glut_init(int argc, char *argv[]) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); } int main(int argc, char *argv[]) { glut_init(argc, argv); AMPS::Editor e; glutMainLoop(); return 0; }