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: rmprivat.h,v 1.23 2005/06/26 18:59:30 wes Exp $
27  * Version: $Name: OpenRM-1-6-0-2-RC2 $
28  * $Revision: 1.23 $
29  * $Log: rmprivat.h,v $
30  * Revision 1.23  2005/06/26 18:59:30  wes
31  * New routines for push/pop OpenGL attrib stack.
32  *
33  * Revision 1.22  2005/06/09 00:45:29  wes
34  * More compiler warning fixes turned up by Windows build.
35  *
36  * Revision 1.21  2005/06/06 02:04:29  wes
37  * Lots of small additions to clean up compiler warnings.
38  *
39  * Revision 1.20  2005/05/15 15:20:42  wes
40  * New internal routine to set the appropriate OpenGL texture coordinate function
41  * as a function of RMprimitive TC data characteristics.
42  *
43  * Revision 1.19  2005/03/19 17:19:00  wes
44  * Declarations for time init/deinit routines.
45  *
46  * Revision 1.18  2005/02/27 19:34:04  wes
47  * Added support for application supplied texture object IDs and display lists.
48  *
49  * Revision 1.17  2005/02/24 16:17:25  wes
50  * Added support for fbClears to be set at the RMpipe level. Apps can
51  * still set them at the RMnode level if desired for fine-grained control.
52  *
53  * Revision 1.16  2005/02/19 16:43:48  wes
54  * Distro sync and consolidation.
55  * Remove dead and test code.
56  *
57  * Revision 1.15  2005/02/12 00:57:07  wes
58  * Migration of private rmGL* declarations for use in rmdraw*.c files.
59  * Needed to support fast/slow path use in draw routines for many prims.
60  *
61  * Revision 1.14  2005/01/23 17:08:25  wes
62  * Copyright updated to 2005.
63  * Updates to support access and use of extensions; multitexturing on all
64  * platforms, use of 3d texture extension to realize implementation of
65  * volume rendering and related functions on Windows platforms.
66  *
67  * Revision 1.13  2004/09/28 00:48:57  wes
68  * Added render state cache as a parameter to routines that may modify
69  * lighting state to fix a lighting state tracking problem.
70  *
71  * Revision 1.12  2004/01/16 16:57:39  wes
72  * Added two private_rmPipe* declarations.
73  *
74  * Revision 1.11  2003/12/06 03:26:06  wes
75  * Documentation tweaks to RMtime routines, updates to RMtime routines for
76  * Windows.
77  *
78  * Revision 1.10  2003/12/01 02:13:05  wes
79  * Additions to support constant frame-rate rendering on both Unix and Win32.
80  *
81  * Revision 1.9  2003/11/22 00:53:41  wes
82  * Changes to support RMtextures being shared when assigned as scene parameters
83  * to properly implement instancing.
84  *
85  * Revision 1.8  2003/11/05 15:29:44  wes
86  * Updates for picking: now have 20 bits of node identifiers, and 8 of
87  * primitive identifiers.
88  *
89  * Revision 1.7  2003/07/23 13:32:28  wes
90  * Win32: problems with offscreen rendering appeared with new context
91  * initialization code sequence (1.5.0). Minor repairs needed to fix the bug.
92  *
93  * Revision 1.6  2003/04/05 14:13:26  wes
94  * Turn off all debugging, DEBUG_LEVEL = 0.
95  *
96  * Revision 1.5  2003/02/17 17:36:02  wes
97  * Mods to fix Win32 compile problems.
98  *
99  * Revision 1.4  2003/02/14 00:19:12  wes
100  * Add prototype for glCallList wrapper function.
101  *
102  * Revision 1.3  2003/02/02 17:50:57  wes
103  * Added bounding boxes to RMprimitives, as a supplement to node-level bboxes.
104  * The RMprimitive level bboxes are needed for the retained-mode CR work.
105  *
106  * Revision 1.2  2003/02/02 02:07:15  wes
107  * Updated copyright to 2003.
108  *
109  * Revision 1.1.1.1  2003/01/28 02:15:23  wes
110  * Manual rebuild of rm150 repository.
111  *
112  * Revision 1.26  2003/01/27 05:04:42  wes
113  * Changes to RMpipe API and initialization sequence to unify GLX, WGL and CR
114  * platforms w/o too much disruption to existing apps.
115  *
116  * Revision 1.25  2003/01/20 05:39:49  wes
117  * Rewrote texture state handling code.
118  *
119  * Revision 1.24  2002/12/31 00:55:22  wes
120  *
121  * Various enhancements to support Chromium - achitecture-specific sections
122  * of RMpipe were cleaned up, etc.
123  *
124  * Revision 1.23  2002/12/04 14:50:33  wes
125  * Cleanup SGI compiles.
126  *
127  * Revision 1.22  2002/11/14 15:34:51  wes
128  * Minor editing for beautification.
129  *
130  * Revision 1.21  2002/09/22 17:35:05  wes
131  * Turned off debug messages used during 143 development.
132  *
133  * Revision 1.20  2002/09/17 14:21:05  wes
134  * Added #define DEBUG_FINAL_MEMCHECK, which will cause rmComponentManagerPrintStatus
135  * to be called inside rmFinish().
136  *
137  * Revision 1.19  2002/08/29 22:20:32  wes
138  *
139  * Massive upgrade to accommodate dynamic object reallocation within
140  * the component manager, and within the context cache. Use the
141  * debug #define DEBUG_LEVEL DEBUG_REALLOC_TRACE to get a printf
142  * whenever a realloc occurs. With this upgrade, there are no
143  * OpenRM limits on the size of the scene graph. There will be external
144  * limits, such as the amount of RAM and the amount of space available
145  * to your OpenGL implementation.
146  *
147  * Revision 1.18  2002/08/19 00:28:27  wes
148  * Added declaration to private_rmAssert() so that it can be called
149  * via a DLL in Win32 (from other OpenRM libs).
150  *
151  * Revision 1.17  2002/06/17 01:04:45  wes
152  * Changed the number of bits available for node and primitive ID during
153  * picking. New limits provide for 8192 nodes and 128 prims per node.
154  *
155  * Revision 1.16  2002/06/02 15:17:03  wes
156  * Added RMstateCache code to help eliminate the number of state changes
157  * made during the render traversal. The RMstateCache tracks
158  * the actual OpenGL rendering state w/o the need for querying OpenGL
159  * directly, and  is queried by draw code that then decides if any
160  * real state changes are required given the configuration of data
161  * within an RMprimitive.
162  *
163  * Revision 1.15  2002/04/30 19:33:26  wes
164  * Updated copyright dates.
165  *
166  * Revision 1.14  2001/10/15 01:32:19  wes
167  * Minor mods to support 4-byte alignment of framebuffer reads on Win32.
168  * Problem showed up in demo "pdb."
169  *
170  * Revision 1.12  2001/07/15 17:14:24  wes
171  * Added prototypes for private routines that cleanse the context cache.
172  *
173  * Revision 1.11  2001/06/03 20:52:02  wes
174  * Added a few declarations for private routines.
175  *
176  * Revision 1.10  2001/05/26 14:37:49  wes
177  * Added RMnode parameter to serialization code used in picking - this
178  * will permit picking of scene graph subtrees that are disconnected
179  * from rmRootNode().
180  *
181  * Revision 1.9  2001/03/31 18:46:33  wes
182  * Turned off debugging for 1.4.0-alpha-2 release.
183  *
184  * Revision 1.8  2001/03/31 17:12:11  wes
185  * v1.4.0-alpha-2 checkin.
186  *
187  * Revision 1.7  2000/12/03 22:35:38  wes
188  * Mods for thread safety.
189  *
190  * Revision 1.6  2000/08/31 02:09:48  wes
191  * No significant changes.
192  *
193  * Revision 1.5  2000/08/23 23:24:21  wes
194  * DO_LISTS define moved from rmogl.c to rmprivat.h. All display
195  * list code removed from rmBitmap (will be reinserted later).
196  *
197  * Revision 1.4  2000/05/14 23:40:52  wes
198  * Single parm changes to internal routines to support new RMpipe
199  * control over matrix stack initialization during rendering.
200  *
201  * Revision 1.3  2000/04/27 03:13:45  wes
202  * Function prototype tweaks.
203  *
204  * Revision 1.2  2000/04/20 16:29:47  wes
205  * Documentation additions/enhancements, some code rearragement.
206  *
207  * Revision 1.1.1.1  2000/02/28 21:29:40  wes
208  * OpenRM 1.2 Checkin
209  *
210  * Revision 1.1.1.1  2000/02/28 17:18:48  wes
211  * Initial entry - pre-RM120 release, source base for OpenRM 1.2.
212  *
213  */
214 
215 
216 
217 #ifndef _rmprivat_h_
218 #define _rmprivat_h_
219 
220 #ifndef GL_EXT_texture3D
221 #define GL_TEXTURE_3D                           0x806F
222 #define GL_TEXTURE_WRAP_R                       0x8072
223 #define GL_TEXTURE_WRAP_R_EXT                   0x8072
224 #endif
225 
226 #ifndef GL_ARB_multitexture
227 #define GL_TEXTURE0_ARB                         0x84C0
228 #define GL_TEXTURE1_ARB                         0x84C1
229 #define GL_TEXTURE2_ARB                         0x84C2
230 #define GL_TEXTURE3_ARB                         0x84C3
231 #define GL_TEXTURE4_ARB                         0x84C4
232 #define GL_TEXTURE5_ARB                         0x84C5
233 #define GL_TEXTURE6_ARB                         0x84C6
234 #define GL_TEXTURE7_ARB                         0x84C7
235 #define GL_TEXTURE8_ARB                         0x84C8
236 #define GL_TEXTURE9_ARB                         0x84C9
237 #define GL_MAX_TEXTURE_UNITS_ARB                0x84E2
238 
239 #endif
240 
241 #define DEBUG_GLERRORCHECK 0x1
242 #define DEBUG_TRACE        0x2
243 #define DEBUG_RSTATECACHECHECK 0x4
244 #define DEBUG_REALLOC_TRACE 0x8
245 #define DEBUG_FINAL_MEMCHECK 0x010
246 #define DEBUG_CR_BBOX      0x020
247 #define DEBUG_PS_TRACE     0x0040
248 #define DEBUG_PS_TIMING    0x0080
249 #define DEBUG_GLSTATECHECK 0x0100
250 
251 #define DEBUG_LEVEL 0 		/* for production release */
252 
253 /*
254  * To obtain lots of debugging information related to attribute
255  * stack management, set DEBUG_LEVEL to include DEBUG_GLERRORCHECK
256  */
257 
258 int private_rmGLPushAttrib (RMpipe *p, const RMnode *r, GLuint imask);
259 int private_rmGLPopAttrib (RMpipe *p, RMstate *s, RMstateCache *rsc);
260 
261 /*
262  * when DO_LISTS is 1, display lists are enabled. when set to
263  * zero, no OpenGL display lists will be used anywhere. (this define
264  * was formerly in rmogl.c). some platforms are not happy with
265  * combinations of display lists and vertex arrays.
266  *
267  * Note that you have two "normal" mechanisms to control whether or
268  * not display lists are created:
269  * rmPipeSetDisplayListEnable() enables/disables display lists on a
270  *   given RMpipe;
271  * rmPrimitiveSetDisplayListEnable() enables/disables creation/use of
272  *   a display list on a single RMprimitive.
273  *
274  * The #define below is occasionally useful for RM dev debugging.
275  */
276 #define DO_LISTS 1
277 
278 /*
279  * set DO_TIME to 1, and  per-frame rendering timer will be enabled.
280  * it will spit out the render time in msec within rmFrame().
281  * it may cause compilation to fail on some systems due
282  * to the fact that some extra system includes are grabbed, all of
283  * which do not exist across all platforms.
284  */
285 #define DO_TIME 0
286 
287 
288 /* list of stuff that can be added to prims */
289 #define RM_PRIMITIVE_2DVERTICES			0
290 #define RM_PRIMITIVE_3DVERTICES			1
291 #define RM_PRIMITIVE_4DVERTICES			2
292 
293 #define RM_PRIMITIVE_NORMALS			3
294 #define RM_PRIMITIVE_4COLORS			4 /* RGBA */
295 #define RM_PRIMITIVE_3COLORS			5 /* RGB */
296 #define RM_PRIMITIVE_RADII			6
297 #define RM_PRIMITIVE_QMESHDIMS			7
298 #define RM_PRIMITIVE_OMESHDIMS			8
299 #define RM_PRIMITIVE_CONE_RADII			9
300 #define RM_PRIMITIVE_CYLINDER_RADII		10
301 #define RM_PRIMITIVE_RENDERFUNC			11
302 #define RM_PRIMITIVE_INDEXED_TEXT_BITMAPS	12
303 #define RM_PRIMITIVE_MARKERS2D_SCALE		13
304 #define RM_PRIMITIVE_MARKERS2D_PRIM		14
305 #define RM_PRIMITIVE_SPRITES			15
306 #define RM_PRIMITIVE_BITMAPS			16
307 #define RM_PRIMITIVE_BITMAP_INDICES		17
308 #define RM_PRIMITIVE_TEXTPRIM			18
309 #define RM_PRIMITIVE_OMESH_MINMAX_GRID		19
310 #define RM_PRIMITIVE_OMESH_RECT_GRID		20
311 #define RM_PRIMITIVE_INDICES			21
312 
313 #define RM_PRIMITIVE_1DTCOORDS                  22
314 #define RM_PRIMITIVE_2DTCOORDS			23
315 #define RM_PRIMITIVE_3DTCOORDS			24
316 
317 #define RM_PRIMITIVE_MULTI_1DTCOORDS            25
318 #define RM_PRIMITIVE_MULTI_2DTCOORDS            26
319 #define RM_PRIMITIVE_MULTI_3DTCOORDS            27
320 
321 #define RM_PRIMITIVE_DONT_COPY_DATA		0 /* app manages memory */
322 #define RM_PRIMITIVE_COPY_DATA			1 /* RM manages memory */
323 
324 #define C4COPY(a,b) 	(memcpy((void *)(a), (void *)(b), sizeof(RMcolor4D)))
325 
326 /*
327  * stuff for primitives. this structure provides configuration info
328  * about each type of primitive. there's one of these configuration
329  * things for each primitive
330  */
331 #define RM_MAXBLOBS_PER_PRIMITIVE	6
332 
333 /*
334  * mapping from fundamental RM primitive data types to blob positions.
335  * each primitive has an array of blobs. the following definitions map
336  * from an RM primitive type into the array of blobs.
337  */
338 #define BLOB_VERTEX_INDEX		0
339 #define BLOB_COLOR_INDEX		1
340 #define BLOB_NORMAL_INDEX		2
341 #define BLOB_TC_INDEX			3
342 #define BLOB_QMESHDIMS_INDEX		4
343 #define BLOB_SCALE_INDEX		5
344 #define BLOB_OMESHDIMS_INDEX		6
345 #define BLOB_OMESH_RECTGRID_INDEX	7
346 #define BLOB_INDEX_INDEX		8
347 
348 /*
349  * We encode information into a passthrough token.  The types of information
350  * encoded are:
351  * 1. object/primitive/atomic specific information.
352  * 2. more general information, such as the current object index, and the
353  *    current primitive index
354  *
355  * (others may be added in the future)
356  *
357  * Each passthrough token is treated as a signed 24bit integer quantity.
358  * The breakdown of those 24 bits depends upon the particular type of
359  * information being conveyed.
360  *
361  * (Currently) The one types of op's permitted are:
362  * 1. Identifier  (object index, prim index, lod index)
363  *
364  * The uppermost 4 bits of the passthrough token are used to hold
365  * the opcode.  Currently, these are:
366  *
367  * 0x00: Identifier
368  * 0x01: 2d circle radius.
369  * 0x02..0x05: 2d ellipse related stuff.
370  * 0x06  indexed bitmap/text index
371  * 0x07  change of render state.
372  *
373  * for the glPassThrough token, we can store in the glPassThrough
374  * token a single number.  in this number, we can encode and extract
375  * an object number (index), a primitive index, and the LOD used when
376  * that primitive was rendered.  for these, we allocate:
377  *
378  * Updated 10/10/2003.
379  * object index - 19 bits  (max 512K objects)
380  * prim index -   7 bits  (max 128 primitives per object)
381  *
382  * the following macros are used to encode and extract this information.
383  */
384 #define RM_PASSTHRU_OPCODE_IDENTIFIER		0x0
385 
386 /* opcode */
387 #define RMPASSTHRU_OPCODE_BITS     		4
388 #define RMPASSTHRU_OPCODE_SHIFT			26
389 #define RMPASSTHRU_ENCODE_OPCODE(a,b)		((a) = (a) | (((b) & 0x0f) << RMPASSTHRU_OPCODE_SHIFT))
390 #define RMPASSTHRU_GET_OPCODE(a)		(((a) >> RMPASSTHRU_OPCODE_SHIFT) & 0x0f)
391 
392 /* object ID */
393 #define RMPASSTHRU_OBJECT_ID_BITS		19
394 #define RMPASSTHRU_OBJECT_ID_SHIFT		0
395 #define RMPASSTHRU_ENCODE_OBJECT_ID(a,b)	((a) = (a) | (((b) & 0x07ffff) << RMPASSTHRU_OBJECT_ID_SHIFT))
396 #define RMPASSTHRU_GET_OBJECT_ID(a)		(((a) >> RMPASSTHRU_OBJECT_ID_SHIFT) & 0x07ffff)
397 
398 /* prim ID */
399 #define RMPASSTHRU_PRIM_ID_BITS			7
400 #define RMPASSTHRU_PRIM_ID_SHIFT		19
401 #define RMPASSTHRU_ENCODE_PRIM_ID(a,b)		((a) = (a) | (((b) & 0x07f) << RMPASSTHRU_PRIM_ID_SHIFT))
402 #define RMPASSTHRU_GET_PRIM_ID(a)		(((a) >> RMPASSTHRU_PRIM_ID_SHIFT) & 0x07f)
403 
404 
405 /* bitmap macro definitions [23] */
406 #define private_rmBitmapGetWidth(b)			((b)->w)
407 #define private_rmBitmapSetWidth(b,i)			((b)->w = (i))
408 #define private_rmBitmapGetHeight(b)			((b)->h)
409 #define private_rmBitmapSetHeight(b,i)			((b)->h = (i))
410 #define private_rmBitmapGetBytesPerScanline(b)		((b)->bytes_per_scanline)
411 #define private_rmBitmapSetBytesPerScanline(b,i)	((b)->bytes_per_scanline = (i))
412 #define private_rmBitmapGetPBSize(b)			((b)->pbsize)
413 #define private_rmBitmapSetPBSize(b,i)			((b)->pbsize = (i))
414 #define private_rmBitmapGetPixelData(b)			((b)->pixeldata)
415 
416 /* image macro definitions [21] */
417 #define private_rmImageSetNDims(t,ndims)	((t)->ndims = ndims)
418 #define private_rmImageGetNDims(t)		((t)->ndims)
419 #define private_rmImageSetWidth(t,i)		((t)->w = i)
420 #define private_rmImageGetWidth(t)		((t)->w)
421 #define private_rmImageSetHeight(t,i)		((t)->h = i)
422 #define private_rmImageGetHeight(t)		((t)->h)
423 #define private_rmImageSetDepth(t,i)		((t)->d = i)
424 #define private_rmImageGetDepth(t)		((t)->d)
425 #define private_rmImageSetElements(t,i)		((t)->elements = i)
426 #define private_rmImageGetElements(t)		((t)->elements)
427 #define private_rmImageSetFormat(t,f)		((t)->image_format = f)
428 #define private_rmImageGetFormat(t)		((t)->image_format)
429 #define private_rmImageSetType(t,f)		((t)->image_type = f)
430 #define private_rmImageGetType(t)		((t)->image_type)
431 #define private_rmImageSetCopyFlag(t,i)		((t)->copy_flag = i)
432 #define private_rmImageGetCopyFlag(t)		((t)->copy_flag)
433 #define private_rmImageGetPixelData(t)		((t)->pixeldata)
434 #define private_rmImageGetBytesPerScanline(t)	((t)->bytes_per_scanline)
435 #define private_rmImageSetBytesPerScanline(t,i)	((t)->bytes_per_scanline = i)
436 #define private_rmImageGetBytesPerComponent(t)  ((t)->bytes_per_component)
437 #define private_rmImageSetBytesPerComponent(t,i) ((t)->bytes_per_component = i)
438 #define private_rmImageGetCacheKey(t)           ((t)->cacheKey)
439 #define private_rmImageGetVismap(t)             ((t)->vismap)
440 
441 #define RM_MAKE_CACHEKEY(a) ((a) & 0xFFFFFFFF)
442 #if 0
443 /* these #defines were used when the cachekey was a function of time */
444 #define RM_MAKE_CACHEKEY(sec,usec) (((sec) << 20) | ((usec) & 0x0fffff)) /* 32bit */
445 #define RM_MAKE_CACHEKEY(sec,usec) (((sec) << 32) | ((usec) & 0x0ffffffff)) /* 64 bit */
446 #endif
447 
448 /* node macro definitions [12] */
449 #define   private_rmNodeSetRenderpassOpacity(n,i)	((n)->object_info.rpass_opacity = (i))
450 #define   private_rmNodeGetRenderpassOpacity(n)		((n)->object_info.rpass_opacity)
451 #define   private_rmNodeSetRenderpassDims(n,i)		((n)->object_info.rpass_vdims = (i))
452 #define   private_rmNodeGetRenderpassDims(n)		((n)->object_info.rpass_vdims)
453 #define   private_rmNodeGetNumChildren(n)		((n)->nchildren)
454 #define   private_rmNodeGetIthChild(a,j)		((a)->children[(j)])
455 #define   private_rmNodeSetTraversalMaskOpacity(n,i) ((n)->object_info.rpass_opacity = (i))
456 #define   private_rmNodeGetTraversalMaskOpacity(n)   ((n)->object_info.rpass_opacity)
457 #define   private_rmNodeSetTraversalMaskDims(n,i) ((n)->object_info.rpass_vdims = (i))
458 #define   private_rmNodeGetTraversalMaskDims(n)   ((n)->object_info.rpass_vdims)
459 #define   private_rmNodeSetTraversalMaskChannel(n,i) ((n)->object_info.channel = (i))
460 #define   private_rmNodeGetTraversalMaskChannel(n)   ((n)->object_info.channel)
461 
462 /* RMprimitive macros [7] */
463 #define   private_rmPrimitiveSetType(p,t)		((p)->type = (t))
464 #define   private_rmPrimitiveGetType(p)			((p)->type)
465 #define   private_rmNodeGetName(n)			((n)->object_info.name)
466 #define   private_rmPrimitiveSetDisplayListEnable(p,n)	((p)->display_list_enable = (n))
467 #define   private_rmPrimitiveGetDisplayListEnable(p)	((p)->display_list_enable)
468 #define   private_rmPrimitiveSetModelFlag(p,t)		((p)->model_flag = (t))
469 #define   private_rmPrimitiveGetModelFlag(p)		((p)->model_flag)
470 
471 /* texture macro definitions [4] */
472 #define    private_rmTextureGetDims(t)		((t)->dims)
473 #define    private_rmTextureGetNMipMaps(t)	((t)->nmipmaps)
474 #define    private_rmTextureSetNMipMaps(t,i)	((t)->nmipmaps = (i))
475 #define    private_rmTextureGetCacheKey(t)      ((t)->cacheKey)
476 
477 /* PRIVATE */
478 typedef struct RMtextPrim
479 {
480     char *string;	/* the string */
481     int   bw, bh;	/* width/height of bitmap */
482     int   ptag;		/* current font/style tag */
483 } RMtextPrim;
484 
485 /* PRIVATE */
486 typedef struct RMSerialNodeList
487 {
488     RMnode *node;	/* pointer to object */
489     int     index;	/* serialized node index */
490 } RMSerialNodeList;
491 
492 /* PRIVATE */
493 typedef struct RMLinestyleEnum
494 {
495     int            enum_value;	/* enumeration value */
496     int            ogl_factor;	/* stuff for OpenGL */
497     unsigned short ogl_pattern;
498 
499 
500 } RMLinestyleEnum;
501 
502 typedef struct RMLinewidthEnum /* PRIVATE */
503 {
504     int   enum_value;
505     float width;
506 } RMLinewidthEnum;
507 
508 
509 /* rmcamera.c: view computation [1] */
510 void private_rmComputeViewMatrix (const RMcamera3D *, RMmatrix *, RMmatrix *);
511 
512 /* rmcmpmgr.c: component manager init/manip routines [??] */
513 void           private_rmDeleteComponentManager(RMcompMgrHdr *);
514 RMcompMgrHdr * private_rmInitComponentManager(int objCount, int objSize);
515 RMimage      * private_rmImageNew(void);
516 RMenum         private_rmImageDelete(RMimage *);
517 RMnode       * private_rmNodeNew(void);
518 RMenum         private_rmNodeDelete(RMnode *);
519 RMprimitive  * private_rmPrimitiveNew(void);
520 RMenum         private_rmPrimitiveDelete(RMprimitive *);
521 RMtexture    * private_rmTextureNew(void);
522 RMenum         private_rmTextureDelete(RMtexture *);
523 void           private_rmPrimitiveSetCacheKey(RMprimitive *p);
524 void           private_rmTextureSetIDCacheKey(RMtexture *t);
525 void           private_rmTextureSetDataCacheKey(RMtexture *t);
526 RMtextProps *  private_rmTextPropsNew(void);
527 RMenum         private_rmTextPropsDelete(RMtextProps *r);
528 
529 /* rmcr.c: CR-specific routines */
530 #ifdef RM_CR
531 void           private_rmPipeCloseContextCR (RMpipe *);
532 void           private_rmPipeInitCR(RMpipe *p);
533 #endif
534 
535 /* rmdraw2.c: various rendering stuff [2] */
536 void private_rmStateGetTextJustify (const RMstate *s, RMenum *hjustify, RMenum *vjustify);
537 void private_initTrigTables (void);
538 
539 /* rmframe.c: assorted private functions [13] */
540 int private_collectAndApplyMatrices (RMstate *rState, RMnode *n, void (*perObjFunc)(const RMnode *), GLenum renderMode, int *pushedAttribsReturn, RMenum applyGL);
541 void private_rmSetChannelRenderFunc (RMpipe *p);
542 int  private_rmTrueFilterfunc (RMnode *r);
543 int  private_rmFalseFilterfunc (RMnode *r);
544 void private_rmSubTreeFrame (RMpipe *renderPipe, RMnode *user_root, GLenum rendermode, void (*perobj_func)(const RMnode *), void (*perprim_func)(RMnode *, int), int (*perchannel_func)(RMnode *), void (*perstate_func)(RMstate *, int), RMenum, RMenum, RMenum, RMenum);
545 void private_rmPostRender (int whichbuffer_enum, RMpipe *p);
546 void private_rmPostRenderDepthBuffer (GLenum whichbuffer_enum, RMpipe *p);
547 int  private_updateSceneParms (const RMnode *r, RMstate *rState, RMenum applyGL, int pushAttribEnable, RMpipe *renderPipe, RMstateCache *rsc);
548 void private_fbClear(internals_RMfbClear *fbClear, RMstate *local_state, RMenum applyGL, RMenum fbClearEnable);
549 void private_computeStereoOffset (RMcamera3D *c,  RMenum whichChannel, RMcamera3D *r);
550 void private_postRenderBarrierFunc (RMpipe *p);
551 void private_postRenderImageFuncs (RMpipe *p, GLenum whichBuffer);
552 void private_postRenderSwapBuffersFunc (RMpipe *p);
553 
554 /* rmglobal.c: text routines [2] */
555 int private_rmLinestyleToIndex (RMenum style_enum);
556 int private_rmLinewidthToIndex (RMenum style_enum);
557 
558 /* rmimage.c: private image functions [15] */
559 int    private_rmImageGetNumElements (RMenum image_format_enum);
560 int    private_rmImageNumComponentBytes (RMenum type_enum);
561 GLenum private_rmImageGetOGLFormat (const RMimage *img);
562 GLenum private_rmImageGetOGLType (const RMimage *img);
563 RMenum private_rmImageSetGLScaleAndBias (const RMimage *src);
564 RMenum private_rmImageUnsetGLScaleAndBias (const RMimage *src);
565 RMenum private_glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixeldata, const RMimage *src);
566 RMenum private_glReadPixels (int x, int y, int width, int height, GLenum format, GLenum type, GLvoid *pixels);
567 RMenum private_rmSetLuminancePixelScale (void);
568 RMenum private_rmUnsetLuminancePixelScale (void);
569 RMenum private_rmImage2DMirrorVertical (RMimage *src);
570 RMenum private_rmImage2DMirrorHorizontal (RMimage *src);
571 RMenum private_rmImage2DResize (const RMimage *src, RMimage *dst, RMenum hardware_or_software, RMpipe *hwPipe);
572 RMenum private_rmImage3DResize (const RMimage *src, RMimage *dst, RMenum hardware_enum, RMpipe *hwPipe);
573 int    private_rmImage2DBuildMipmaps (const RMimage *img, RMimage ***maps_return, int filter_method, RMpipe *hwPipe);
574 
575 /* rmmalloc.c: pointer checking [2] */
576 RM_EXPORT_API int  private_rmAssert (const void *a, const char *s);
577 #define RM_ASSERT(a,s)	private_rmAssert(a,s)
578 RM_EXPORT_API void *private_rmMemDup(void *src, int sizeOfInput);
579 
580 /* rmmatrix.c: coordinate conversions, deprecated private_rmPointMax [6] */
581 void   private_rmDCFromWC3 (RMvertex3D *a, RMvertex3D *ret, int n, RMstate *s);
582 void   private_rmDCFromWC2 (RMvertex3D *a, RMvertex3D *ret, int n, RMstate *s);
583 int    private_rmFixedFromFloat (float a);
584 float  private_rmFloatFromFixed (int a);
585 void   private_rmPointMax (float *input, int count, float *ret, int vnspace);
586 void   private_rmNewWCfromDCOffset(RMvertex3D *source, float xmove, float ymove, RMvertex3D *dest,  RMmatrix *vpm,  RMmatrix *vpm_inv,  RMmatrix *forward, RMmatrix *inv);
587 void   private_rmNewWCfromDC(RMvertex3D *source, RMvertex3D *dest, RMmatrix *vpm, RMmatrix *vpm_inv, RMmatrix *forward, RMmatrix *inv);
588 void   private_rmComputeViewportMatrix(float vp[4], float fw, float fh, RMmatrix *returnMatrix);
589 
590 /* rmnode.c: node routines [7] */
591 void   private_initObjectTree (void);
592 void   private_rmNodeIncrementRefcount (RMnode *);
593 int    private_rmNodeGetRefcount (RMnode *);
594 int    private_rmNodeDecrementRefcount (RMnode *);
595 void   private_rmNodeAttribMask(RMnode *, GLuint, RMenum);
596 GLuint private_rmNodeGetAttribMask(const RMnode *);
597 GLuint private_rmNodeComputeAttribMask(const RMnode *);
598 
599 /* rmogl.c: OpenGL stuff [13] */
600 void private_rmReadBytePixels (unsigned char *pixelbuf, int w, int h, int ncomponents, GLenum pixel_component, int bytesPerScanline);
601 void private_rmReadFloatPixels (float *pixelbuf, int w, int h, int ncomponents, GLenum pixel_component);
602 void private_rmOglSurfPropFunc (RMprimitive *p, RMnode *r, int has_norms, int has_color, RMstate *s);
603 void private_rmEndOglSurfPropFunc (void);
604 void private_rmOglLinesPropFunc (RMstate *s, RMprimitive *p, RMnode *r, int has_color, int has_tcoords);
605 void private_rmEndOglLinesPropFunc (void);
606 void private_rmOglImgPropFunc (RMprimitive *p, RMnode *r, RMstate *s);
607 void private_rmSetBackBuffer (RMpipe *p);
608 int  private_rmPrimitiveDisplayListBegin (RMpipe *pipe, RMprimitive *p);
609 int  private_rmPrimitiveDisplayListEnd (RMpipe *pipe, RMprimitive *p, int needFinalize);
610 void private_rmOGLTextureDelete(RMtexture *toDelete, RMpipe *p);
611 void private_glCallList(RMpipe *pipe, RMprimitive *prim, GLuint listIndx);
612 void (*private_rmGLGetProcAddr(const char *));
613 
614 void private_lightingStateManip(RMprimitive *p, RMstate *s, RMstateCache *rsc, RMenum forceNormals);
615 void private_colorMaterialStateManip(RMprimitive *p, RMstate *s, RMstateCache *rsc);
616 void private_rmColorMaterial(RMstate *s,RMstateCache *rsc,RMenum newVal);
617 void private_textureStateManip(RMprimitive *p, RMstate *s, RMstateCache *rsc);
618 int  private_glStateCheck(RMstate *s);
619 
620 /* rmomesh.c: octmesh-specific stuff [1] */
621 void   private_rmOctmeshPrimitiveFree(RMprimitive *p);
622 
623 /* rmpick.c: prims picking stuff [1] */
624 void private_rmComputePickMatrix (RMstate *s, RMmatrix *pickReturn);
625 
626 /* rmpipe.c: pipe routines [9] */
627 void    private_rmPipeCopy (RMpipe *source_pipe, RMpipe *dest_pipe);
628 int     private_rmComparePipes (RMpipe *p1, RMpipe *p2);
629 RMenum  private_rmPipeIsOffscreenFormat (const RMpipe *p);
630 #define private_rmPipeSetPlatform(p, a) ((p)->targetPlatform = (a))
631 #define private_rmPipeGetPlatform(p)    ((p)->targetPlatform)
632 void    private_rmPipeFPSStart(RMpipe *p);
633 void    private_rmPipeFPSEnd(RMpipe *p);
634 void    private_rmPipeSetTimeSyncFunc(RMpipe *t,void (*newFunc)(RMpipe *));
635 void    private_rmPipeTimeSyncFunc(RMpipe *t);
636 
637 /* rmprim.c: data blob & bbox routines [26] */
638 void                 private_rmGetBlobData (int tag, RMprimitive *p, int *stride, int *nverts, void **data, int *veclen);
639 void                 private_rmBlobSetFreefunc (RMprimitiveDataBlob *b, void (*freefunc)(void *));
640 void                 private_rmBlobSetData (RMprimitiveDataBlob *b, int num, int stride, void *stuff, RMenum copy_flag);
641 void                 private_rmBlobSetStride (RMprimitiveDataBlob *b, int stride);
642 void                 private_rmBlobSetNthings (RMprimitiveDataBlob *b, int num);
643 int                  private_rmBlobGetStride (RMprimitiveDataBlob *);
644 void                *private_rmBlobGetData (RMprimitiveDataBlob *b);	/* this will go away */
645 int                  private_rmBlobGetNthings (RMprimitiveDataBlob *b);
646 RMprimitiveDataBlob *private_rmBlobFromIndex (RMprimitive *p, int tag);
647 void                 private_rmBlobSetType (RMprimitiveDataBlob *b, int newtype);
648 int                  private_rmBlobGetType (RMprimitiveDataBlob *b);
649 void                 private_rmBlobSetVeclen (RMprimitiveDataBlob *b, int veclen);
650 int                  private_rmBlobGetVeclen (RMprimitiveDataBlob *b);
651 int                  private_rmBlobIndexFromPrimAtom (int tag);
652 RMenum               private_rmPrimitiveGetItem (RMprimitive *p, int tag, int *num,  void **stuff);
653 RMenum               private_rmPrimSetAssert (RMprimitive *t, int n, void *dataptr, RMenum copyEnum, void (*freefunc)(), const char *rname);
654 RMenum               rmPrimitiveSetItem (RMprimitive *p, int tag, int n, int stride, void *stuff, int copy_flag, void (*freefunc)(void *) );
655 RMenum               rmPrimitiveGetItem (RMprimitive *p, int tag, int *n, void **stuff);
656 /* RMprimitive bbox methods */
657 RMenum    private_rmPrimitiveComputeGenericBoundingBox(RMprimitive *p);
658 RMenum    private_rmPrimitiveComputeSpheresBoundingBox(RMprimitive *p);
659 RMenum    private_rmPrimitiveComputeCylindersBoundingBox(RMprimitive *p);
660 RMenum    private_rmPrimitiveComputeConesBoundingBox(RMprimitive *p);
661 RMenum    private_rmPrimitiveComputeOctmeshBoundingBox(RMprimitive *p);
662 RMenum    private_rmPrimitiveComputeOctmeshBoundingBox(RMprimitive *p);
663 RMenum    private_rmPrimitiveCompute2DCircleBoundingBox(RMprimitive *p);
664 RMenum    private_rmPrimitiveCompute2DEllipseBoundingBox(RMprimitive *p);
665 RMenum    private_rmPrimitiveNullBoxFunc(RMprimitive *p);
666 
667 
668 
669 /* cache key macros for RMprimitives, RMtextures */
670 #define              private_rmPrimitiveGetCacheKey(p)   ((p)->cacheKey)
671 #define              private_rmTextureGetIDCacheKey(p)   ((p)->cacheKeyID)
672 #define              private_rmTextureGetDataCacheKey(p) ((p)->cacheKeyData)
673 
674 /* rmqdrix.c: init for quadric prims, sphere routines [4] */
675 void private_rmInitQuadrics (RMcontextCache *c);
676 void private_rmCacheDeleteQuadrics (RMcontextCache *c);
677 void private_rmSphereTesselator (int subdivisions, RMvertex3D **sphere_verts, RMvertex3D **sphere_norms, int *face_count_return);
678 int  private_rmGetTrianglesPerSphere (void);
679 
680 /* rmrstate.c: RM state routines [5] */
681 void          private_rmStateInit (const RMpipe *p, RMstate *s, RMenum rendermode, RMmatrix *initModel, RMmatrix *initView, RMmatrix *initProj, RMmatrix *initTexture);
682 RMstateCache *private_rmStateCacheNew (void);
683 void          private_rmStateCacheDelete(RMstateCache *);
684 void          private_rmStateCacheSync(const RMstate *s, RMstateCache *rsc);
685 void          private_rmSyncStateToCache(RMstateCache *rsc, RMstate *s);
686 
687 /* rmscene.c: scene routines [3] */
688 RMtextProps *private_rmDefaultTextProps (RMpipe *p);
689 void         private_rmNodeSetSceneParms (RMnode *r, RMenum tag, void *stuff, int n);
690 internals_RMfbClear *private_rmFBClearNew (void);
691 
692 /* rmserial.c: serialized scene graph for picking [8] */
693 void     private_rmSerialStateInit(void);
694 int      private_rmBuildSerializedList (RMnode *r, int *totalNodesReturn, int *totalPrimsReturn);
695 int      private_rmIndexFromSerial (const RMnode *r);
696 RMnode  *private_rmNodeFromSerial (int index);
697 RMstate *private_rmStateFromSerial (int indx);
698 int      private_pushSerialState (RMstate *s);
699 int      private_rmBuildSerialState (RMpipe *p, RMnode *r, RMstate *last, int init);
700 int      private_rmDeleteSerialState (void);
701 
702 /* rmtext.c: internal RM font registry functions [5] */
703 void            private_rmFontRegistryDelete(RMpipe *p, RMfontRegistry *);
704 RMfontRegistry *private_rmFontRegistryNew(void);
705 int             private_rmFontRegistryIndex (int font_face, int font_size, int font_italic, int font_embolden);
706 RMfontRegistry *private_rmFontRegistryEntry (int font_face, int font_size, int font_italic, int font_embolden, RMfontRegistry *toQuery);
707 void   private_rmTextPropsCopy(const RMtextProps *s,RMtextProps *d);
708 
709 /* rmtxture.c: texture routines [5] */
710 void private_rmSetPixelTransferMode (const RMvisMap *vmap);
711 void private_rmUnsetPixelTransferMode (void);
712 void private_rmTextureToOGL (RMpipe *p, RMtexture *t, int isnew);
713 void private_rmTextureSetRefCount(RMtexture *t,int newVal);
714 int  private_rmTextureGetRefCount(const RMtexture *t);
715 
716 
717 /* rmutil.c: GL imaging pipeline stuff, context init & cache keys [11] */
718 void       private_rmInitInternalImagingPipeline (RMpipe *hwPipe);
719 void       private_rmCacheFlush(RMcontextCache *toDelete);
720 RMenum     private_rmCacheInit(RMcontextCache **toCreate);
721 RMenum     private_rmCacheDelete(RMpipe *p, RMcontextCache *toDelete);
722 RMcacheKey private_rmGetNewCacheKey(void);
723 RMenum     private_rmInitCacheKeyMutex(void);
724 RMenum     private_rmDestroyCacheKeyMutex(void);
725 RMenum     private_rmCacheDeleteAllPrimitiveDisplayLists(RMcontextCache *c);
726 RMenum     private_rmCacheDeleteAllTextures(RMcontextCache *c);
727 RMenum     private_rmCacheDeleteAllImageDisplayLists(RMcontextCache *c);
728 int        private_rmCacheComputeNumberNewPages(int oldNItems,int numItemsPerPage,int newIndx);
729 
730 /* rmversion.c: copyright notice [1] */
731 int private_rmHello (void);
732 
733 /* rmx.c: X11 context stuff [3] */
734 RMenum private_rmxPipeCreateContext (RMpipe *pipe);
735 #ifdef RM_X
736 XVisualInfo *private_rmxCreateVisual(RMpipe *p);
737 void    private_rmPipeCloseContextX11(RMpipe *toClose);
738 #endif
739 
740 /* rmwtext.c, rmxtext.c: text stuff [3] */
741 RMenum private_rmPrepareBitmapFont (RMtextProps *t, RMpipe *p);
742 RMenum private_rmPrimitiveGetText (RMprimitive *t, int *nstringsReturn, RMtextPrim **primsReturn);
743 int    private_rmTextPrimComputeCW (RMtextPrim *, RMfontRegistry *, const RMpipe *p);
744 
745 /* this is referenced in ifdef'ed out code in rmscene.c [318] */
746 void private_rmCompute2DProjectionInverse (const RMcamera2D *c, RMmatrix *m);
747 
748 /* rmwin.c, win32-specific stuff [2] */
749 #ifdef RM_WIN
750 void   private_rmPipeCloseContextW32(RMpipe *toClose);
751 RMenum private_rmwCheckAndDisplayLastError(const char *callerMsg);
752 #endif
753 
754 
755 /* Win32 only: generate human-readable message from system error code */
756 #ifdef RM_WIN
757 private_rmW32Error(void);
758 #endif
759 
760 /* scene parms  */
761 int private_setViewport (const RMnode *r, RMstate *s, int push_attrib_enable,  RMenum applyGL);
762 int process_scene_lights (const RMnode *r, int push_attrib_enable, RMstate *s,RMenum applyGL, RMstateCache *rsc);
763 int private_setClipPlanes (const RMnode *r,int push_attrib_enable, RMstate *rState, RMenum applyGL);
764 int private_setFog (const RMnode *r, int push_attrib_enable, RMstate *rState,RMenum applyGL);
765 int private_manageTextureState(RMtexture *t, RMstate *rState, RMpipe *p, int applyGL, int textureUnitIndex);
766 int private_setSurfaceProps (const RMnode *r, int push_attrib_enable,RMstate *s,RMenum applyGL);
767 int private_setRenderProps (const RMnode *r, int push_attrib_enable, RMstate *s,  RMenum applyGL, RMstateCache *rsc);
768 int private_setBackgroundDepthValue (const internals_RMfbClear *r, RMstate *rState, RMenum applyGL);
769 int private_setBackgroundColor (const internals_RMfbClear *r, RMstate *s, int push_attrib_enable, RMenum applyGL);
770 int private_setBackgroundTile (const internals_RMfbClear *r, RMstate *s,int push_attrib_enable, RMenum applyGL);
771 int private_setBackgroundDepthImage (const internals_RMfbClear *r,RMstate *s,int push_attrib_enable, RMenum applyGL);
772 
773 int fake_gluScaleImage(GLenum format, GLsizei widthin, GLsizei heightin, GLenum typein, const void *datain, GLsizei widthout, GLsizei heightout, GLenum typeout, void *dataout);
774 
775 /* rmdraw1.c [2] */
776 void private_rmEnableVertexArrays (int verts, int colors, int normals, int textureCoords, int indices, int edgeFlags);
777 void private_dispatchMTCs(RMpipe *pipe, RMprimitive *prim, int i);
778 
779 /* from rmwin.c, win-32 stuff */
780 #ifdef RM_WIN
781 RM_EXPORT_API void private_rmwSetupDIB(HDC hDC, int width, int height, int depth);
782 RM_EXPORT_API void private_rmwSetupPalette(HDC hDC);
783 RM_EXPORT_API void private_rmwSetupPixelFormat(HDC hDC, int depth, int offscreenBool, RMenum stereoFormatBool);
784 #endif
785 
786 /* rmmtdraw.c - access to the component manager, maybe should be in rmcmpmgr.c */
787 RMnode *GETNODE(RMcompMgrHdr *a, int indx);
788 void    private_rmLightStateConsistencyCheck(char *buf, RMstate *s, RMstateCache *rsc);
789 
790 /* from rmdraw2.c  */
791 #ifdef RM_WIN
792 void rmglVertex3fv (const GLfloat *v);
793 void rmglVertex2fv (const GLfloat *v);
794 void rmglNormal3fv (const GLfloat *v);
795 void rmglColor3fv (const GLfloat *a);
796 void rmglColor4fv (const GLfloat *a);
797 void rmglRasterPos2fv (const GLfloat *v);
798 void rmglRasterPos3fv (const GLfloat *v);
799 void rmglTexCoord1fv (const GLfloat *v);
800 void rmglTexCoord2fv (const GLfloat *v);
801 void rmglTexCoord3fv (const GLfloat *v);
802 
803 #else  /* RM_X */
804 #define rmglVertex3fv    glVertex3fv
805 #define rmglVertex2fv    glVertex2fv
806 #define rmglNormal3fv    glNormal3fv
807 #define rmglColor3fv     glColor3fv
808 #define rmglColor4fv     glColor4fv
809 #define rmglRasterPos2fv glRasterPos2fv
810 #define rmglRasterPos3fv glRasterPos3fv
811 #define rmglTexCoord3fv  glTexCoord3fv
812 #define rmglTexCoord2fv  glTexCoord2fv
813 #define rmglTexCoord1fv  glTexCoord1fv
814 #endif
815 
816 void glNoOp (const float *f);
817 void private_rmSetGLColorFunc (int cvecsize, int ncolors, void (**cfuncptr)(const float *)) ;
818 void private_rmSetGLTexCoordFunc (int tcvecsize, int ntc, void (**tcfuncptr)(const float *)) ;
819 
820 /* rmtime.c [2] */
821 RMenum  private_initTimer(void);
822 void    private_deInitTimer(void);
823 
824 #endif /* _rmprivat_h */
825 /* EOF */
826