| 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 |
gwlarson |
3.4 |
int sfirst, snext; /* first sample and first in next view */
|
| 21 |
gwlarson |
3.1 |
short hhi, vhi; /* screen image resolution */
|
| 22 |
|
|
short hlow, vlow; /* block resolution */
|
| 23 |
|
|
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 |
|
|
int4 *emap; /* low resolution edge presence map */
|
| 31 |
gwlarson |
3.3 |
int4 *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 |
|
|
int4 next; /* next in free list */
|
| 41 |
|
|
|
| 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 |
|
|
int4 *redraw; /* redraw flags */
|
| 48 |
|
|
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 |
|
|
#define CLR4ALL(f,n) bzero((char *)(f),FL4NELS(n)*sizeof(int4))
|
| 60 |
|
|
#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 |
|
|
odUpdate(vn) : update the current view
|
| 118 |
|
|
int vn; : view number
|
| 119 |
|
|
|
| 120 |
|
|
Draw all new and undrawn sample values since last call for this view.
|
| 121 |
|
|
|
| 122 |
|
|
|
| 123 |
|
|
void
|
| 124 |
gwlarson |
3.2 |
odRemap(newhist) : recompute tone mapping
|
| 125 |
|
|
int newhist; : flag whether to clear history
|
| 126 |
gwlarson |
3.1 |
|
| 127 |
|
|
Recompute the tone mapping for all the samples in all the views
|
| 128 |
gwlarson |
3.2 |
and redraw them on the next call(s) to odUpdate(). If newhist
|
| 129 |
|
|
is non-zero, then clear the previous sample history.
|
| 130 |
gwlarson |
3.1 |
|
| 131 |
|
|
**********************************************************************/
|