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