1 /*
2 * Copyright (C) 1997-2005, R3vis Corporation.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17 * USA, or visit http://www.gnu.org/copyleft/lgpl.html.
18 *
19 * Original Contributor:
20 * Wes Bethel, R3vis Corporation, Marin County, California
21 * Additional Contributor(s):
22 *
23 * The OpenRM project is located at http://openrm.sourceforge.net/.
24 */
25 /*
26 * $Id: rmglobal.c,v 1.9 2005/09/12 04:04:11 wes Exp $
27 * Version: $Name: OpenRM-1-6-0-2-RC2 $
28 * $Revision: 1.9 $
29 * $Log: rmglobal.c,v $
30 * Revision 1.9 2005/09/12 04:04:11 wes
31 * No significant changes.
32 *
33 * Revision 1.8 2005/03/16 16:44:12 wes
34 * Code merge activities.
35 *
36 * Revision 1.7 2005/02/19 16:37:34 wes
37 * Distro sync and consolidation.
38 *
39 * Revision 1.6 2005/01/23 17:00:22 wes
40 * Copyright updated to 2005.
41 *
42 * Revision 1.5 2004/03/10 01:46:20 wes
43 * Set default spotlight exponent to be 2.0.
44 *
45 * Revision 1.4 2004/01/16 16:45:12 wes
46 * Updated copyright line for 2004.
47 *
48 * Revision 1.3 2003/12/06 03:26:06 wes
49 * Documentation tweaks to RMtime routines, updates to RMtime routines for
50 * Windows.
51 *
52 * Revision 1.2 2003/02/02 02:07:15 wes
53 * Updated copyright to 2003.
54 *
55 * Revision 1.1.1.1 2003/01/28 02:15:23 wes
56 * Manual rebuild of rm150 repository.
57 *
58 * Revision 1.13 2003/01/16 22:21:17 wes
59 * Updated all source files to reflect new organization of header files:
60 * all header files formerly located in include/rmaux, include/rmi, include/rmv
61 * are now located in include/rm.
62 *
63 * Revision 1.12 2003/01/11 18:44:22 wes
64 * Added global control over whether or not display lists are used during
65 * rendering by adding the new RMpipe controls rmPipeSetDisplayListEnable()
66 * and rmPipeGetDisplayListEnable().
67 *
68 * Revision 1.11 2002/12/02 16:24:56 wes
69 * Bug fixes:
70 * (1) fixed memory leak in rmPrimitiveSetText;
71 * (2) fixed problem with textProps not being applied to 2nd and later
72 * strings in an RM_TEXT text primitive.
73 *
74 * Revision 1.10 2002/08/29 22:20:32 wes
75 *
76 * Massive upgrade to accommodate dynamic object reallocation within
77 * the component manager, and within the context cache. Use the
78 * debug #define DEBUG_LEVEL DEBUG_REALLOC_TRACE to get a printf
79 * whenever a realloc occurs. With this upgrade, there are no
80 * OpenRM limits on the size of the scene graph. There will be external
81 * limits, such as the amount of RAM and the amount of space available
82 * to your OpenGL implementation.
83 *
84 * Revision 1.9 2002/08/17 15:09:15 wes
85 * Changed RM_COMPONENT_POOL_SIZE to be a global variable in rmglobal.c.
86 * It was previously a #define. As a global variable, it can be set prior
87 * to rmInit() to control the size of the component manager's object pool.
88 * This will be helpful for apps that consume lots of scene graph resources.
89 *
90 * Revision 1.8 2002/04/30 19:31:59 wes
91 * Updated copyright dates.
92 *
93 * Revision 1.7 2001/05/26 14:34:34 wes
94 * Changed spotlight cutoff angle default value from 90.0 to 60.0.
95 *
96 * Revision 1.6 2001/03/31 17:12:38 wes
97 * v1.4.0-alpha-2 checkin.
98 *
99 * Revision 1.5 2000/12/03 22:35:38 wes
100 * Mods for thread safety.
101 *
102 * Revision 1.4 2000/05/17 14:23:14 wes
103 * Fixed compile warnings on RM_DEFAULT_FONT_FAMILY and RM_DEFAULT_FONT_SIZE.
104 *
105 * Revision 1.3 2000/05/14 23:37:50 wes
106 * Added constants for default font family, size, etc. used
107 * for initializing RMtextProps objects upon creation.
108 *
109 * Revision 1.2 2000/04/20 16:29:47 wes
110 * Documentation additions/enhancements, some code rearragement.
111 *
112 * Revision 1.1.1.1 2000/02/28 21:29:40 wes
113 * OpenRM 1.2 Checkin
114 *
115 * Revision 1.1.1.1 2000/02/28 17:18:48 wes
116 * Initial entry - pre-RM120 release, source base for OpenRM 1.2.
117 *
118 */
119
120 /*
121 * this file contains global variables...this is a good place to
122 * set default values for the system. we use global variables rather
123 * than #define's to avoid compile warnings.
124 */
125
126 #include <rm/rm.h>
127 #include "rmprivat.h"
128
129 RMcolor4D RM_DEFAULT_BACKGROUND_COLOR = {0.19, 0.19, 0.3, 1.0};
130 float RM_DEFAULT_DEPTH_VALUE = 1.0F;
131
132 /* default light values: these are assigned to a new RMlight object when created with rmLightNew() */
133 RM_EXPORT_VAR RMenum RM_DEFAULT_LIGHT_TYPE = RM_LIGHT_DIRECTIONAL;
134 RM_EXPORT_VAR RMvertex3D RM_DEFAULT_LIGHT_XYZ = {0.0F, 0.0F, 1.0F};
135 RM_EXPORT_VAR RMcolor4D RM_DEFAULT_LIGHT_AMBIENT_COLOR = {0.0F, 0.0F, 0.0F, 1.0F};
136 RM_EXPORT_VAR RMcolor4D RM_DEFAULT_LIGHT_DIFFUSE_COLOR = {0.75F, 0.75F, 0.75F, 1.0F};
137 RM_EXPORT_VAR RMcolor4D RM_DEFAULT_LIGHT_SPECULAR_COLOR = {0.1F, 0.1F, 0.1F, 1.0F};
138 RM_EXPORT_VAR RMvertex3D RM_DEFAULT_LIGHT_SPOT_DIRECTION = {0.0F, 0.0F, -1.0F};
139 RM_EXPORT_VAR float RM_DEFAULT_LIGHT_SPOT_EXPONENT = 2.0F;
140 RM_EXPORT_VAR float RM_DEFAULT_LIGHT_SPOT_CUTOFF = 60.0F;
141 RM_EXPORT_VAR float RM_DEFAULT_LIGHT_CONSTANT_ATTENUATION = 1.0F;
142 RM_EXPORT_VAR float RM_DEFAULT_LIGHT_LINEAR_ATTENUATION = 0.0F;
143 RM_EXPORT_VAR float RM_DEFAULT_LIGHT_QUADRATIC_ATTENUATION = 0.0F;
144 RM_EXPORT_VAR RMenum RM_DEFAULT_LIGHT_ENABLE = RM_TRUE;
145
146 /* default 2D camera parameters */
147 RM_EXPORT_VAR float RM_DEFAULT_2DCAMERA_XMIN = -1.0;
148 RM_EXPORT_VAR float RM_DEFAULT_2DCAMERA_YMIN = -1.0;
149 RM_EXPORT_VAR float RM_DEFAULT_2DCAMERA_XMAX = 1.0;
150 RM_EXPORT_VAR float RM_DEFAULT_2DCAMERA_YMAX = 1.0;
151 RM_EXPORT_VAR float RM_DEFAULT_2DCAMERA_ASPECT = 1.0;
152
153 /* default 3D camera parameters */
154 RM_EXPORT_VAR RMvertex3D RM_DEFAULT_3DCAMERA_EYE = {10.0, 10.0, 50.0};
155 RM_EXPORT_VAR RMvertex3D RM_DEFAULT_3DCAMERA_LOOKAT = {0.0, 0.0, 0.0};
156 RM_EXPORT_VAR RMvertex3D RM_DEFAULT_3DCAMERA_UP = {0.0, 1.0, 0.0};
157 RM_EXPORT_VAR float RM_DEFAULT_3DCAMERA_HITHER = 2.0;
158 RM_EXPORT_VAR float RM_DEFAULT_3DCAMERA_YON = 40.0;
159 RM_EXPORT_VAR float RM_DEFAULT_3DCAMERA_ASPECT = 1.0;
160 RM_EXPORT_VAR float RM_DEFAULT_3DCAMERA_FOV = 45.0;
161 RM_EXPORT_VAR RMenum RM_DEFAULT_3DCAMERA_PROJECTION = RM_PROJECTION_PERSPECTIVE;
162
163 /* default color values assigned a node by rmNodeNew() */
164 RM_EXPORT_VAR RMcolor4D RM_DEFAULT_AMBIENT_COLOR = {0.5F, 0.5F, 0.5F, 1.0F};
165 RM_EXPORT_VAR RMcolor4D RM_DEFAULT_DIFFUSE_COLOR = {0.6F, 0.6F, 0.6F, 1.0F};
166 RM_EXPORT_VAR RMcolor4D RM_DEFAULT_SPECULAR_COLOR = {0.7F, 0.7F, 0.7F, 1.0F};
167 RM_EXPORT_VAR RMcolor4D RM_DEFAULT_UNLIT_COLOR = {1.0F, 1.0F, 1.0F, 1.0F};
168 RM_EXPORT_VAR float RM_DEFAULT_SPECULAR_EXPONENT = 10.0F;
169 RM_EXPORT_VAR float RM_DEFAULT_OPACITY = 1.0F;
170
171 /* default text rendering parameters */
172 RM_EXPORT_VAR RMenum RM_DEFAULT_HJUSTIFY = RM_LEFT;
173 RM_EXPORT_VAR RMenum RM_DEFAULT_VJUSTIFY = RM_BOTTOM;
174 RM_EXPORT_VAR int RM_DEFAULT_FONT_FAMILY = RM_FONT_SANS;
175 RM_EXPORT_VAR int RM_DEFAULT_FONT_SIZE = RM_FONT_M;
176 RM_EXPORT_VAR RMenum RM_DEFAULT_FONT_BOLD = RM_FALSE;
177 RM_EXPORT_VAR RMenum RM_DEFAULT_FONT_ITALIC = RM_FALSE;
178
179 /* default policy on use of display lists */
180 RM_EXPORT_VAR RMenum RM_DEFAULT_PRIMITIVE_DISPLAY_LIST_ENABLE = RM_TRUE;
181 RM_EXPORT_VAR RMenum RM_DEFAULT_PIPE_DISPLAY_LIST_ENABLE = RM_TRUE;
182
183 /* component manager headers */
184 RMcompMgrHdr *global_RMimagePool = NULL;
185 RMcompMgrHdr *global_RMprimitivePool = NULL;
186 RMcompMgrHdr *global_RMnodePool = NULL;
187 RMcompMgrHdr *global_RMtexturePool = NULL;
188 RMcompMgrHdr *global_RMtextPropsPool = NULL;
189
190 #ifdef RM_WIN
191 /* on Win32, we need to obtain some information about the platform's
192 capabilities prior to using any timing stuff. the following variable
193 is set from a routine called by rmInit(). */
194 double static_Win32ClockFrequency=0.0F;
195 #endif
196
197
198 /*
199 * this controls how finely spheres are tesselated. increasing the number
200 * (10 is a good number) will produce nice pictures but will take a long
201 * time to render. at a future date, this value will be computed dynamically
202 * as a function of pixel coverage, so don't count on it for too long.
203 * (04/16/97)
204 */
205 RM_EXPORT_VAR int RM_SPHERE_SUBDIVISIONS = 4;
206
207 /* default clipping plane parameters */
208 RM_EXPORT_VAR RMvertex3D RM_DEFAULT_CLIP_PLANE_POINT = {0.0, 0.0, 0.0};
209 RM_EXPORT_VAR RMvertex3D RM_DEFAULT_CLIP_PLANE_NORMAL = {0.0, 0.0, -1.0};
210
211 /* line styles - private*/
212 RMLinestyleEnum rmlinestyles[RM_MAX_LINESTYLES] =
213 {
214 { /* this one is for solid lines. this is
215 the default everywhere, so we don't need
216 to put anything in this enum entry. */
217 0, /* the enumeration value */
218 0, 0, /* opengl values */
219 },
220 {
221 /* RM_LINES_DASHED */
222 /* this one is for dashed lines */
223 1, /* the enumeration value */
224 1, 0x00ff, /* values for OpenGL - this will create
225 dashes and blank spaces that are 8/72
226 inches long (assuming 72dpi on the monitor) */
227 },
228 {
229 /* RM_LINES_DOTTED */
230 /* this one is for dashed lines */
231 2, /* the enumeration value */
232 1, 0x1111, /* values for OpenGL - this will create
233 dots and blank spaces that are 1/72
234 inches long (assuming 72dpi on the monitor) */
235 },
236 {
237 /* RM_LINES_DOT_DASH */
238 /* this one is for dashed lines */
239 1, /* the enumeration value */
240 2, 0x07C1, /* values for OpenGL - this will create
241 dots and blank spaces that are 1/72
242 inches long (assuming 72dpi on the monitor) */
243 },
244 {
245 /* RM_LINES_DASH_DASH_DOT */
246 /* this one is for dashed lines */
247 2, /* the enumeration value */
248 2, 0x1C71, /* values for OpenGL - this will create
249 dots and blank spaces that are 1/72
250 inches long (assuming 72dpi on the monitor) */
251 }
252 };
253
254
255 /* line width */
256 RMLinewidthEnum rmlinewidths[RM_MAX_LINEWEIGHTS]=
257 {
258 {0, 1.0}, /* RM_LINEWIDTH_1, RM_LINEWIDTH_NARROW */
259 {1, 2.0}, /* RM_LINEWIDTH_2, RM_LINEWIDTH_MEDIUM */
260 {2, 3.0}, /* RM_LINEWIDTH_3 */
261 {3, 4.0}, /* RM_LINEWIDTH_4, RM_LINEWIDTH_HEAVY */
262 {4, 5.0}, /* RM_LINEWIDTH_5 */
263 {5, 6.0}, /* RM_LINEWIDTH_6 */
264 {6, 7.0}, /* RM_LINEWIDTH_7 */
265 {7, 8.0} /* RM_LINEWIDTH_8 */
266 };
267
268
269 /* PRIVATE */
270 int
private_rmLinestyleToIndex(RMenum style_enum)271 private_rmLinestyleToIndex(RMenum style_enum)
272 {
273 int rstat;
274
275 /* convert a line style enumerator to an index into rmlinestyles array */
276 switch(style_enum)
277 {
278 case RM_LINES_DASHED:
279 rstat = 1;
280 break;
281
282 case RM_LINES_DOTTED:
283 rstat = 2;
284 break;
285
286 case RM_LINES_DOT_DASH:
287 rstat = 3;
288 break;
289
290 case RM_LINES_DASH_DASH_DOT:
291 rstat = 4;
292 break;
293
294 default: /* bogus line style enum - default to solid */
295 case RM_LINES_SOLID:
296 rstat = 0;
297 break;
298 }
299 return(rstat);
300 }
301
302
303 /* PRIVATE */
304 int
private_rmLinewidthToIndex(RMenum style_enum)305 private_rmLinewidthToIndex(RMenum style_enum)
306 {
307 int rstat;
308
309 /* convert from line width enumerator to an index into rmlinewidths array */
310 switch(style_enum)
311 {
312 case RM_LINEWIDTH_1:
313 case RM_LINEWIDTH_NARROW:
314 rstat = 0;
315 break;
316
317 case RM_LINEWIDTH_2:
318 case RM_LINEWIDTH_MEDIUM:
319 rstat = 1;
320 break;
321
322 case RM_LINEWIDTH_3:
323 rstat = 2;
324 break;
325
326 case RM_LINEWIDTH_HEAVY:
327 case RM_LINEWIDTH_4:
328 rstat = 3;
329 break;
330
331 case RM_LINEWIDTH_5:
332 rstat = 4;
333 break;
334
335 case RM_LINEWIDTH_6:
336 rstat = 5;
337 break;
338
339 case RM_LINEWIDTH_7:
340 rstat = 6;
341 break;
342
343 case RM_LINEWIDTH_8:
344 rstat = 7;
345 break;
346
347 default: /* bogus line width enum */
348 rstat = 0;
349 break;
350 }
351 return(rstat);
352 }
353 /* EOF */
354