ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rhd_odraw.h
Revision: 3.13
Committed: Fri Jan 7 20:33:02 2005 UTC (19 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R7P2, rad3R7P1, rad4R0, rad3R8, rad3R9
Changes since 3.12: +3 -1 lines
Log Message:
Modernized tone-mapping routines with structure pointer r.t. stack

File Contents

# User Rev Content
1 greg 3.13 /* RCSid $Id: rhd_odraw.h,v 3.12 2004/01/01 11:21:55 schorsch Exp $ */
2 gwlarson 3.1 /*
3     * Header for OpenGL cone drawing routines with depth buffer checks.
4 greg 3.9 *
5     * Include after "standard.h"
6 gwlarson 3.1 */
7 schorsch 3.11 #ifndef _RAD_RHD_ODRAW_H_
8     #define _RAD_RHD_ODRAW_H_
9 gwlarson 3.1
10     #include "color.h"
11     #include "tonemap.h"
12     #include "rhdriver.h"
13    
14 schorsch 3.11 #ifdef __cplusplus
15     extern "C" {
16     #endif
17    
18 gwlarson 3.1 extern struct ODview {
19 gwlarson 3.4 int sfirst, snext; /* first sample and first in next view */
20 gwlarson 3.1 short hhi, vhi; /* screen image resolution */
21     short hlow, vlow; /* block resolution */
22 gwlarson 3.6 int n2redraw; /* approx. number of samples needing redraw */
23 gwlarson 3.1 struct ODblock {
24     short nsamp; /* number of samples in block */
25     short nused; /* number actually allocated */
26     int first; /* first sample in this block */
27     int free; /* index for block free list */
28 gwlarson 3.2 float pthresh; /* proximity threshold */
29 gwlarson 3.1 } *bmap; /* low resolution image map */
30 greg 3.9 int32 *emap; /* low resolution edge presence map */
31     int32 *pmap; /* high resolution presence map */
32 gwlarson 3.1 GLfloat *dmap; /* high resolution depth map */
33     } *odView; /* our view list */
34    
35     extern int odNViews; /* number of views in our list */
36    
37 greg 3.13 extern TMstruct *tmGlobal; /* global tone-mapping structure */
38    
39 gwlarson 3.1 extern struct ODsamp {
40     union ODfunion {
41     float prox; /* viewpoint proximity */
42 greg 3.9 int32 next; /* next in free list */
43 gwlarson 3.1
44     } *f; /* free list next or proximity */
45     short (*ip)[2]; /* image position array */
46     TMbright *brt; /* encoded brightness array */
47     BYTE (*chr)[3]; /* encoded chrominance array */
48     BYTE (*rgb)[3]; /* tone-mapped color array */
49 greg 3.9 int32 *redraw; /* redraw flags */
50 gwlarson 3.1 int nsamp; /* total number of samples */
51     char *base; /* base of allocated memory */
52     } odS; /* sample values */
53    
54     #ifndef FL4OP
55     #define FL4OP(f,i,op) ((f)[(i)>>5] op (1L<<((i)&0x1f)))
56     #define CHK4(f,i) FL4OP(f,i,&)
57     #define SET4(f,i) FL4OP(f,i,|=)
58     #define CLR4(f,i) FL4OP(f,i,&=~)
59     #define TGL4(f,i) FL4OP(f,i,^=)
60     #define FL4NELS(n) (((n)+0x1f)>>5)
61 schorsch 3.10 #define CLR4ALL(f,n) memset((char *)(f),'\0',FL4NELS(n)*sizeof(int32))
62 gwlarson 3.1 #endif
63    
64     #define OMAXDEPTH 32000 /* maximum depth value */
65    
66     #define nextfree(i) f[i].next /* free pointers */
67     #define closeness(i) f[i].prox /* viewpoint proximity */
68     #define ENDFREE (-1) /* free list terminator */
69    
70     #define odClean() odInit(odS.nsamp) /* clear samples */
71     #define odDone() odInit(0) /* free samples */
72    
73    
74     /*****************************************************************************
75     * Interface routines:
76    
77    
78     int
79     odInit(nsamps) : allocate and initialize memory
80     int nsamps; : number of samples to make available
81    
82     If nsamps is zero, then this becomes a deallocation routine. If nsamps
83     is the same as last time, then this merely clears all data. The dev_auxview()
84     function may be called to determine the current view(s). The odAlloc()
85     function returns the number of samples actually allocated.
86    
87    
88     void
89     odSample(c, d, p) : register new sample value
90     COLR c; : pixel color (RGBE)
91     FVECT d; : ray direction vector
92     FVECT p; : world intersection point
93    
94     If p is NULL, then the point is at infinity.
95    
96    
97     void
98     odDepthMap(vn, dm) : set depth map for the given view
99     int vn; : view number
100     GLfloat *dm; : depth map
101    
102     Assign the depth map associated with view number vn. The map has
103     been preallocated, and won't be freed until it is no longer needed
104     (after an odAlloc() call). All depth values are the projected
105     distance along the view direction from the view origin. If dm
106     is NULL, then there is no depth map associated with this view.
107    
108    
109     void
110     odRedraw(vn, x0, y0, x1, y1) : region needs to be redrawn
111     int vn; : view number
112     int x0, y0, x1, y1; : rectangle to redraw
113    
114     This call indicates that the given rectangular region in view vn
115     needs to be redrawn in the next call to odUpdate().
116    
117    
118     void
119 gwlarson 3.5 odRedrawAll() : everything needs to be redrawn
120    
121     Redraw everything in all views on the next call to odUpdate().
122     Unless odRemap() is called, no new tone mapping will be done.
123    
124    
125     void
126 gwlarson 3.1 odUpdate(vn) : update the current view
127     int vn; : view number
128    
129     Draw all new and undrawn sample values since last call for this view.
130    
131    
132     void
133 gwlarson 3.2 odRemap(newhist) : recompute tone mapping
134     int newhist; : flag whether to clear history
135 gwlarson 3.1
136     Recompute the tone mapping for all the samples in all the views
137 gwlarson 3.2 and redraw them on the next call(s) to odUpdate(). If newhist
138     is non-zero, then clear the previous sample history.
139 gwlarson 3.1
140     **********************************************************************/
141 schorsch 3.12
142     /* rhd_geom.c */
143     void gmNewGeom( char *file);
144     extern void gmEndGeom(void);
145     extern int gmDrawGeom(void);
146     extern void gmDrawPortals(int r, int g, int b, int a);
147     extern void gmDepthLimit( double dl[2], FVECT vorg, FVECT vdir);
148     extern void gmNewPortal(char *pflist);
149     extern int gmEndPortal(void);
150     /* rhd_odraw.c */
151     extern int odInit(int n);
152     extern void odSample(COLR c, FVECT d, FVECT p);
153     extern void odRemap(int newhist);
154     extern void odRedrawAll(void);
155     extern void odRedraw(int vn, int hmin, int vmin, int hmax, int vmax);
156     extern void odDepthMap(int vn, GLfloat *dm);
157     extern void odUpdate(int vn);
158    
159 schorsch 3.11
160     #ifdef __cplusplus
161     }
162     #endif
163     #endif /* _RAD_RHD_ODRAW_H_ */
164