ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rhd_odraw.h
Revision: 3.10
Committed: Mon Jun 30 14:59:11 2003 UTC (20 years, 9 months ago) by schorsch
Content type: text/plain
Branch: MAIN
Changes since 3.9: +2 -2 lines
Log Message:
Replaced most outdated BSD function calls with their posix equivalents, and cleaned up a few other platform dependencies.

File Contents

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