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