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 |
gwlarson |
3.3 |
|
19 |
|
|
#ifndef INVALID |
20 |
|
|
#define INVALID -1 |
21 |
|
|
#endif |
22 |
|
|
|
23 |
|
|
typedef struct samp { |
24 |
gwlarson |
3.1 |
float (*wp)[3]; /* world intersection point array */ |
25 |
|
|
int4 *wd; /* world direction array */ |
26 |
gwlarson |
3.3 |
#ifndef HP_VERSION |
27 |
gwlarson |
3.1 |
TMbright *brt; /* encoded brightness array */ |
28 |
gwlarson |
3.3 |
#endif |
29 |
gwlarson |
3.1 |
BYTE (*chr)[3]; /* encoded chrominance array */ |
30 |
|
|
BYTE (*rgb)[3]; /* tone-mapped color array */ |
31 |
|
|
int max_samp; /* maximum number of samples */ |
32 |
gwlarson |
3.3 |
int max_base_pt; /* maximum number of aux points */ |
33 |
|
|
int next_base_pt; /* next auxilliary point to add */ |
34 |
|
|
int replace_samp; /* next sample to free */ |
35 |
|
|
int num_samp; /* current number of samples */ |
36 |
|
|
int tone_map; /* pointer to next value(s)t tonemap*/ |
37 |
|
|
int free_samp; /* Available sample */ |
38 |
gwlarson |
3.1 |
char *base; /* base of allocated memory */ |
39 |
gwlarson |
3.3 |
} SAMP; |
40 |
gwlarson |
3.1 |
|
41 |
gwlarson |
3.3 |
/* Sample field access macros */ |
42 |
|
|
#define S_W_PT(s) ((s)->wp) |
43 |
|
|
#define S_W_DIR(s) ((s)->wd) |
44 |
|
|
#define S_BRT(s) ((s)->brt) |
45 |
|
|
#define S_CHR(s) ((s)->chr) |
46 |
|
|
#define S_RGB(s) ((s)->rgb) |
47 |
|
|
#define S_MAX_SAMP(s) ((s)->max_samp) |
48 |
|
|
#define S_MAX_BASE_PT(s) ((s)->max_base_pt) |
49 |
|
|
#define S_NEXT_BASE_PT(s) ((s)->next_base_pt) |
50 |
|
|
#define S_REPLACE_SAMP(s) ((s)->replace_samp) |
51 |
|
|
#define S_NUM_SAMP(s) ((s)->num_samp) |
52 |
|
|
#define S_TONE_MAP(s) ((s)->tone_map) |
53 |
|
|
#define S_FREE_SAMP(s) ((s)->free_samp) |
54 |
|
|
#define S_BASE(s) ((s)->base) |
55 |
gwlarson |
3.1 |
|
56 |
gwlarson |
3.3 |
#define S_MAX_POINTS(s) ((s)->max_base_pt) |
57 |
|
|
#define S_NTH_W_PT(s,n) (S_W_PT(s)[(n)]) |
58 |
|
|
#define S_NTH_W_DIR(s,n) (S_W_DIR(s)[(n)]) |
59 |
|
|
#define S_NTH_RGB(s,n) (S_RGB(s)[(n)]) |
60 |
|
|
#define S_NTH_CHR(s,n) (S_CHR(s)[(n)]) |
61 |
|
|
#ifndef HP_VERSION |
62 |
|
|
#define S_NTH_BRT(s,n) (S_BRT(s)[(n)]) |
63 |
|
|
#endif |
64 |
|
|
/* Sample Flag macros */ |
65 |
|
|
#define S_IS_FLAG(s) IS_FLAG(samp_flag,s) |
66 |
|
|
#define S_SET_FLAG(s) SET_FLAG(samp_flag,s) |
67 |
|
|
#define S_CLR_FLAG(s) CLR_FLAG(samp_flag,s) |
68 |
gwlarson |
3.1 |
|
69 |
gwlarson |
3.4 |
#define S_NTH_NEXT(s,n) S_NTH_W_DIR(s,n) |
70 |
|
|
#define sUnalloc_samp(s,n) (S_NTH_NEXT(s,n) = S_FREE_SAMP(s),S_FREE_SAMP(s)=n) |
71 |
gwlarson |
3.3 |
#define sClear_base_points(s) (S_NEXT_BASE_PT(s) = S_MAX_SAMP(s)) |
72 |
|
|
#define sClear(s) sInit(s) |
73 |
|
|
/* Max allowed angle of sample dir from current view */ |
74 |
|
|
#define MAXANG 20 |
75 |
|
|
#define MAXDIFF2 ( MAXANG*MAXANG * (PI*PI/180./180.)) |
76 |
gwlarson |
3.1 |
|
77 |
gwlarson |
3.3 |
extern SAMP rsL; |
78 |
|
|
extern double sDepthEps; /* epsilon to compare depths (z fraction) */ |
79 |
|
|
extern int4 encodedir(); /* Encodes FVECT direction */ |
80 |
|
|
extern void decodedir(); /* Decodes dir-> FVECT */ |
81 |
|
|
extern double fdir2diff(), dir2diff(); /* Compare dir and FVECT */ |
82 |
|
|
extern int4 *samp_flag; /* Per/sample flags s */ |
83 |
|
|
|
84 |
gwlarson |
3.1 |
/* These values are set by the driver, and used in the OGL call for glFrustum*/ |
85 |
|
|
extern double dev_zmin,dev_zmax; |
86 |
gwlarson |
3.3 |
|
87 |
|
|
extern SAMP *sAlloc(); |
88 |
gwlarson |
3.1 |
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
|