*** empty log message ***
[lsystem3d.git] / src / renderingsurface.h
1 // Copyright (C) 2006 Erik Dahlberg
2 //
3 // This file is part of LSystem3D.
4 //
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.
9 //
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.
14 //
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
18
19
20
21
22 #ifndef RENDERINGSURFACE_H
23 #define RENDERINGSURFACE_H
24
25 #include "fx.h"
26 #include "fx3d.h"
27
28 #include "lindenmayersystem.h"
29
30
31
32 /**
33 * The OpenGL rendering surface
34 */
35 class RenderingSurface : public FXMainWindow
36 {
37 // macro to set up class declaration
38 FXDECLARE(RenderingSurface)
39
40 public:
41
42 // message ID's
43 enum
44 {
45 ID_CANVAS = FXMainWindow::ID_LAST,
46 ID_LAST
47 };
48
49 /**
50 * Constructor
51 * @param application the FOX application object
52 * @param lsystem the Lindenmayer-system
53 */
54 RenderingSurface(FXApp *application, LindenmayerSystem *lsystem);
55
56 /**
57 * Create and initialize the window
58 */
59 void create();
60
61 /**
62 * Initialize OpenGL
63 */
64 void initOpenGL();
65
66 /**
67 * Force an update of the rendering surface
68 */
69 void draw();
70
71 /**
72 * Called by the system when the left mouse button is pressed
73 * @param sender the sender object
74 * @param selector message type and id
75 * @param data event related data
76 * @return
77 */
78 long onLeftMouseDown(FXObject *sender, FXSelector selector, void *data);
79
80 /**
81 * Called by the system when the left mouse button is released
82 * @param sender the sender object
83 * @param selector message type and id
84 * @param data event related data
85 * @return
86 */
87 long onLeftMouseUp(FXObject *sender, FXSelector selector, void *data);
88
89 /**
90 * Called by the system when the middle mouse button is pressed
91 * @param sender the sender object
92 * @param selector message type and id
93 * @param data event related data
94 * @return
95 */
96 long onMiddleMouseDown(FXObject *sender, FXSelector selector, void *data);
97
98 /**
99 * Called by the system when the middle mouse button is released
100 * @param sender the sender object
101 * @param selector message type and id
102 * @param data event related data
103 * @return
104 */
105 long onMiddleMouseUp(FXObject *sender, FXSelector selector, void *data);
106
107 /**
108 * Called by the system when the right mouse button is pressed
109 * @param sender the sender object
110 * @param selector message type and id
111 * @param data event related data
112 * @return
113 */
114 long onRightMouseDown(FXObject *sender, FXSelector selector, void *data);
115
116 /**
117 * Called by the system when the right mouse button is released
118 * @param sender the sender object
119 * @param selector message type and id
120 * @param data event related data
121 * @return
122 */
123 long onRightMouseUp(FXObject *sender, FXSelector selector, void *data);
124
125 /**
126 * Called by the system when the mouse is moved
127 * @param sender the sender object
128 * @param selector message type and id
129 * @param data event related data
130 * @return
131 */
132 long onMouseMove(FXObject *sender, FXSelector selector, void *data);
133
134 /**
135 * Called by the system when the rendering surface needs a repaint
136 * @param sender the sender object
137 * @param selector message type and id
138 * @param data event related data
139 * @return
140 */
141 long onRepaint(FXObject *sender, FXSelector selector, void *data);
142
143 protected:
144
145 /**
146 * Constructor
147 */
148 RenderingSurface() {}
149
150 private:
151
152 FXGLVisual *_visual; // Pixel format info
153 FXGLCanvas *_canvas; // OpenGL-capable drawing area
154
155 LindenmayerSystem *_lsystem; // The Lindenmayer System
156
157 // Model position
158 double _modelX,
159 _modelY,
160 _modelZ;
161
162 // Model rotation
163 double _modelRotationY;
164
165 // Mouse button status
166 bool _leftMouseDown,
167 _middleMouseDown,
168 _rightMouseDown;
169 };
170
171
172
173 #endif