1 // Copyright (C) 2006 Erik Dahlberg
3 // This file is part of LSystem3d.
5 // LSystem3D is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // LSystem3D is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with LSystem3D; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <GL/freeglut.h>
26 #include "callbacks.h"
27 #include "openglwindow.h"
29 extern OpenGLWindow
*openglWindow
;
33 // GLUT callback functions
34 // -----------------------
39 * @param x mouse x-coordinate
40 * @param y mouse y-coordinate
42 void glutKeyboardCB(unsigned char key
, int x
, int y
)
47 case 27: // escape key
53 openglWindow
->zoomIn();
58 openglWindow
->zoomOut();
61 // rotate around the y-axis
64 openglWindow
->rotateY();
76 * @param x mouse x-coordinate
77 * @param y mouse y-coordinate
79 void glutSpecialCB(int key
, int x
, int y
)
90 openglWindow
->right();
100 openglWindow
->down();
104 case GLUT_KEY_PAGE_UP
:
105 openglWindow
->forth();
109 case GLUT_KEY_PAGE_DOWN
:
110 openglWindow
->back();
125 openglWindow
->draw();
135 // spare some cpu cycles
141 // GLUI callback functions
142 // -----------------------
148 void gluiSpinnerAngleCB(int id
)
150 // regenerate and draw l-system only if "live mode" is enabled
152 if (openglWindow
->liveActivated())
154 openglWindow
->generate();
162 * Reset button pressed
165 void gluiButtonResetCB(int id
)
167 // place camera at initial position
168 openglWindow
->defaultView();
174 * Generate button pressed
177 void gluiButtonGenerateCB(int id
)
179 openglWindow
->generate();