ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rhd_odraw.h
Revision: 3.2
Committed: Sun Dec 20 20:37:54 1998 UTC (25 years, 4 months ago) by gwlarson
Content type: text/plain
Branch: MAIN
Changes since 3.1: +5 -2 lines
Log Message:
improved sample insertion to take better samples
fixed and improved tone mapping

File Contents

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