| 1 |
gwlarson |
3.1 |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
| 2 |
|
|
|
| 3 |
|
|
/* SCCSid "$SunId$ SGI" */ |
| 4 |
|
|
|
| 5 |
|
|
/* |
| 6 |
|
|
* Sample data structures for holodeck display drivers. |
| 7 |
|
|
*/ |
| 8 |
|
|
#include "color.h" |
| 9 |
|
|
#include "tonemap.h" |
| 10 |
|
|
#include "rhdriver.h" |
| 11 |
|
|
|
| 12 |
|
|
#ifndef int2 |
| 13 |
|
|
#define int2 short |
| 14 |
|
|
#endif |
| 15 |
|
|
#ifndef int4 |
| 16 |
|
|
#define int4 int |
| 17 |
|
|
#endif |
| 18 |
|
|
/* child ordering */ |
| 19 |
|
|
typedef struct rsamp { |
| 20 |
|
|
float (*wp)[3]; /* world intersection point array */ |
| 21 |
|
|
int4 *wd; /* world direction array */ |
| 22 |
|
|
TMbright *brt; /* encoded brightness array */ |
| 23 |
|
|
BYTE (*chr)[3]; /* encoded chrominance array */ |
| 24 |
|
|
BYTE (*rgb)[3]; /* tone-mapped color array */ |
| 25 |
|
|
int max_samp; /* maximum number of samples */ |
| 26 |
|
|
int max_aux_pt; /* maximum number of aux points */ |
| 27 |
|
|
int next_aux_pt; /* next auxilliary point to add */ |
| 28 |
|
|
int replace_samp; /* next sample to free */ |
| 29 |
|
|
int num_samp; /* reached end of list? */ |
| 30 |
|
|
int tone_map; /* pointer to next value(s) to tonemap*/ |
| 31 |
|
|
int free_samp; /* list of freed samples */ |
| 32 |
|
|
char *base; /* base of allocated memory */ |
| 33 |
|
|
} RSAMP; |
| 34 |
|
|
|
| 35 |
|
|
#define RS_W_PT(s) ((s)->wp) |
| 36 |
|
|
#define RS_W_DIR(s) ((s)->wd) |
| 37 |
|
|
#define RS_BRT(s) ((s)->brt) |
| 38 |
|
|
#define RS_CHR(s) ((s)->chr) |
| 39 |
|
|
#define RS_RGB(s) ((s)->rgb) |
| 40 |
|
|
#define RS_MAX_SAMP(s) ((s)->max_samp) |
| 41 |
|
|
#define RS_TONE_MAP(s) ((s)->tone_map) |
| 42 |
|
|
#define RS_MAX_POINTS(s) ((s)->max_aux_pt) |
| 43 |
|
|
#define RS_REPLACE_SAMP(s) ((s)->replace_samp) |
| 44 |
|
|
#define RS_NEXT_AUX_PT(s) ((s)->next_aux_pt) |
| 45 |
|
|
#define RS_MAX_AUX_PT(s) ((s)->max_aux_pt) |
| 46 |
|
|
#define RS_BASE(s) ((s)->base) |
| 47 |
|
|
#define RS_NUM_SAMP(s) ((s)->num_samp) |
| 48 |
|
|
#define RS_FREE_SAMP(s) ((s)->free_samp) |
| 49 |
|
|
#define RS_NTH_W_PT(s,n) (RS_W_PT(s)[(n)]) |
| 50 |
|
|
#define RS_NTH_W_DIR(s,n) (RS_W_DIR(s)[(n)]) |
| 51 |
|
|
#define RS_NTH_RGB(s,n) (RS_RGB(s)[(n)]) |
| 52 |
|
|
#define RS_NTH_CHR(s,n) (RS_CHR(s)[(n)]) |
| 53 |
|
|
#define RS_NTH_BRT(s,n) (RS_BRT(s)[(n)]) |
| 54 |
|
|
#define RS_EOL(s) (RS_NUM_SAMP(s) >= RS_MAX_SAMP(s)) |
| 55 |
|
|
extern RSAMP rsL; |
| 56 |
|
|
|
| 57 |
|
|
extern double rsDepthEps; /* epsilon to compare depths (z fraction) */ |
| 58 |
|
|
|
| 59 |
|
|
extern int4 encodedir(); |
| 60 |
|
|
extern double fdir2diff(), dir2diff(); |
| 61 |
|
|
extern void decodedir(); |
| 62 |
|
|
/* |
| 63 |
|
|
* int |
| 64 |
|
|
* smInit(n) : Initialize/clear data structures for n entries |
| 65 |
|
|
* int n; |
| 66 |
|
|
* |
| 67 |
|
|
* Initialize sampL and other data structures for at least n samples. |
| 68 |
|
|
* If n is 0, then free data structures. Return number actually allocated. |
| 69 |
|
|
* |
| 70 |
|
|
* |
| 71 |
|
|
* int |
| 72 |
|
|
* smNewSamp(c, p, v) : register new sample point and return index |
| 73 |
|
|
* COLR c; : pixel color (RGBE) |
| 74 |
|
|
* FVECT p; : world intersection point |
| 75 |
|
|
* FVECT v; : ray direction vector |
| 76 |
|
|
* |
| 77 |
|
|
* Add new sample point to data structures, removing old values as necessary. |
| 78 |
|
|
* New sample representation will be output in next call to smUpdate(). |
| 79 |
|
|
* |
| 80 |
|
|
* |
| 81 |
|
|
* int |
| 82 |
|
|
* smFindSamp(orig, dir): intersect ray with 3D rep. and find closest sample |
| 83 |
|
|
* FVECT orig, dir; |
| 84 |
|
|
* |
| 85 |
|
|
* Find the closest sample to the given ray. Return -1 on failure. |
| 86 |
|
|
* |
| 87 |
|
|
* |
| 88 |
|
|
* smClean() : display has been wiped clean |
| 89 |
|
|
* |
| 90 |
|
|
* Called after display has been effectively cleared, meaning that all |
| 91 |
|
|
* geometry must be resent down the pipeline in the next call to smUpdate(). |
| 92 |
|
|
* |
| 93 |
|
|
* |
| 94 |
|
|
* smUpdate(vp, qua) : update OpenGL output geometry for view vp |
| 95 |
|
|
* VIEW *vp; : desired view |
| 96 |
|
|
* int qua; : quality level (percentage on linear time scale) |
| 97 |
|
|
* |
| 98 |
|
|
* Draw new geometric representation using OpenGL calls. Assume that the |
| 99 |
|
|
* view has already been set up and the correct frame buffer has been |
| 100 |
|
|
* selected for drawing. The quality level is on a linear scale, where 100% |
| 101 |
|
|
* is full (final) quality. It is not necessary to redraw geometry that has |
| 102 |
gwlarson |
3.2 |
* been output since the last call to smClean(). (The last view drawn will |
| 103 |
|
|
* be vp==&odev.v each time.) |
| 104 |
gwlarson |
3.1 |
*/ |
| 105 |
|
|
|
| 106 |
|
|
/* These values are set by the driver, and used in the OGL call for glFrustum*/ |
| 107 |
|
|
extern double dev_zmin,dev_zmax; |
| 108 |
|
|
|
| 109 |
|
|
|
| 110 |
|
|
|
| 111 |
|
|
|
| 112 |
|
|
|
| 113 |
|
|
|
| 114 |
|
|
|