--- /dev/null
+// Copyright (C) 2006 Erik Dahlberg
+//
+// This file is part of LSystem3d.
+//
+// LSystem3D is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// LSystem3D is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with LSystem3D; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+
+
+#include <unistd.h>
+
+#include <GL/freeglut.h>
+
+#include "callbacks.h"
+#include "openglwindow.h"
+
+extern OpenGLWindow *openglWindow;
+
+
+
+// GLUT callback functions
+// -----------------------
+
+/**
+ * Key press
+ * @param key the key
+ * @param x mouse x-coordinate
+ * @param y mouse y-coordinate
+ */
+void glutKeyboardCB(unsigned char key, int x, int y)
+{
+ switch (key)
+ {
+ // quit
+ case 27: // escape key
+ glutLeaveMainLoop();
+ break;
+
+ // zoom in
+ case '+':
+ openglWindow->zoomIn();
+ break;
+
+ // zoom out
+ case '-':
+ openglWindow->zoomOut();
+ break;
+
+ // rotate around the y-axis
+ case 'y':
+ case 'Y':
+ openglWindow->rotateY();
+
+ default:
+ break;
+ }
+}
+
+
+
+/**
+ * Special key press
+ * @param key the key
+ * @param x mouse x-coordinate
+ * @param y mouse y-coordinate
+ */
+void glutSpecialCB(int key, int x, int y)
+{
+ switch (key)
+ {
+ // move camera left
+ case GLUT_KEY_LEFT:
+ openglWindow->left();
+ break;
+
+ // move camera right
+ case GLUT_KEY_RIGHT:
+ openglWindow->right();
+ break;
+
+ // move camera up
+ case GLUT_KEY_UP:
+ openglWindow->up();
+ break;
+
+ // move camera down
+ case GLUT_KEY_DOWN:
+ openglWindow->down();
+ break;
+
+ // move camera forth
+ case GLUT_KEY_PAGE_UP:
+ openglWindow->forth();
+ break;
+
+ // move camera back
+ case GLUT_KEY_PAGE_DOWN:
+ openglWindow->back();
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+
+/**
+ * Redraw of screen
+ */
+void glutDisplayCB()
+{
+ openglWindow->draw();
+}
+
+
+
+/**
+ * Idling
+ */
+void glutIdleCB()
+{
+ // spare some cpu cycles
+ usleep(1);
+}
+
+
+
+// GLUI callback functions
+// -----------------------
+
+/**
+ * Angle changes
+ * @param id not used
+ */
+void gluiSpinnerAngleCB(int id)
+{
+ // regenerate and draw l-system only if "live mode" is enabled
+
+ if (openglWindow->liveActivated())
+ {
+ openglWindow->generate();
+ glutPostRedisplay();
+ }
+}
+
+
+
+/**
+ * Reset button pressed
+ * @param id not used
+ */
+void gluiButtonResetCB(int id)
+{
+ // place camera at initial position
+ openglWindow->defaultView();
+}
+
+
+
+/**
+ * Generate button pressed
+ * @param id not used
+ */
+void gluiButtonGenerateCB(int id)
+{
+ openglWindow->generate();
+}