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 |
|
19 |
#ifndef INVALID |
20 |
#define INVALID -1 |
21 |
#endif |
22 |
|
23 |
#ifndef LORES |
24 |
#define SFLOAT double |
25 |
#else |
26 |
#define SFLOAT float |
27 |
#endif |
28 |
|
29 |
typedef struct samp { |
30 |
SFLOAT (*wp)[3]; /* world intersection point array */ |
31 |
int4 *wd; /* world direction array */ |
32 |
TMbright *brt; /* encoded brightness array */ |
33 |
BYTE (*chr)[3]; /* encoded chrominance array */ |
34 |
BYTE (*rgb)[3]; /* tone-mapped color array */ |
35 |
int *info; /* Extra sample info */ |
36 |
int *info1; /* Extra sample info */ |
37 |
int max_samp; /* maximum number of samples */ |
38 |
int max_base_pt; /* maximum number of aux points */ |
39 |
int next_base_pt; /* next auxilliary point to add */ |
40 |
int replace_samp; /* next sample to free */ |
41 |
int num_samp; /* current number of samples */ |
42 |
int tone_map; /* pointer to next value(s)t tonemap*/ |
43 |
int free_samp; /* free sample-not available yet */ |
44 |
char *base; /* base of allocated memory */ |
45 |
} SAMP; |
46 |
|
47 |
/* Sample field access macros */ |
48 |
#define S_W_PT(s) ((s)->wp) |
49 |
#define S_W_DIR(s) ((s)->wd) |
50 |
#define S_BRT(s) ((s)->brt) |
51 |
#define S_CHR(s) ((s)->chr) |
52 |
#define S_RGB(s) ((s)->rgb) |
53 |
#define S_INFO(s) ((s)->info) |
54 |
#define S_INFO1(s) ((s)->info1) |
55 |
#define S_MAX_SAMP(s) ((s)->max_samp) |
56 |
#define S_MAX_BASE_PT(s) ((s)->max_base_pt) |
57 |
#define S_NEXT_BASE_PT(s) ((s)->next_base_pt) |
58 |
#define S_REPLACE_SAMP(s) ((s)->replace_samp) |
59 |
#define S_NUM_SAMP(s) ((s)->num_samp) |
60 |
#define S_TONE_MAP(s) ((s)->tone_map) |
61 |
#define S_FREE_SAMP(s) ((s)->free_samp) |
62 |
#define S_BASE(s) ((s)->base) |
63 |
|
64 |
#define S_MAX_POINTS(s) ((s)->max_base_pt) |
65 |
#define S_NTH_W_PT(s,n) (S_W_PT(s)[(n)]) |
66 |
#define S_NTH_W_DIR(s,n) (S_W_DIR(s)[(n)]) |
67 |
#define S_NTH_RGB(s,n) (S_RGB(s)[(n)]) |
68 |
#define S_NTH_CHR(s,n) (S_CHR(s)[(n)]) |
69 |
#define S_NTH_INFO(s,n) (S_INFO(s)[(n)]) |
70 |
#define S_NTH_INFO1(s,n) (S_INFO1(s)[(n)]) |
71 |
#define S_NTH_BRT(s,n) (S_BRT(s)[(n)]) |
72 |
|
73 |
/* Sample Flag macros */ |
74 |
#define S_IS_FLAG(s) IS_FLAG(samp_flag,s) |
75 |
#define S_SET_FLAG(s) SET_FLAG(samp_flag,s) |
76 |
#define S_CLR_FLAG(s) CLR_FLAG(samp_flag,s) |
77 |
|
78 |
#define S_NTH_NEXT(s,n) S_NTH_W_DIR(s,n) |
79 |
#define sUnalloc_samp(s,n) (S_NTH_NEXT(s,n)=S_FREE_SAMP(s),S_FREE_SAMP(s)=n) |
80 |
#define sClear_base_points(s) (S_NEXT_BASE_PT(s) = S_MAX_SAMP(s)) |
81 |
#define sClear(s) sInit(s) |
82 |
/* MAXDIFF2 Max allowed cos angle squared of sample dir from current view */ |
83 |
/* In terms of cos: if angle is 30: MAXDIFF2 = cos(30)^2, if difference |
84 |
is greater than this point not accepted on rebuild |
85 |
*/ |
86 |
#define MAXDIFF2 0.75 |
87 |
/* Max difference in direction for points at infinity: if over 45degrees |
88 |
not accepted on rebuild cos(45) |
89 |
*/ |
90 |
#define MAXDIR 0.70710678 |
91 |
#define MAXQUALITY 10000 /* Maximum quality for rendering rep */ |
92 |
|
93 |
extern SAMP rsL; |
94 |
extern double sDepthEps; /* epsilon to compare depths (z fraction) */ |
95 |
extern int4 encodedir(); /* Encodes FVECT direction */ |
96 |
extern void decodedir(); /* Decodes dir-> FVECT */ |
97 |
extern double fdir2diff(), dir2diff(); /* Compare dir and FVECT */ |
98 |
extern int4 *samp_flag; /* Per/sample flags s */ |
99 |
|
100 |
/* These values are set by the driver, and used in the OGL call for glFrustum*/ |
101 |
extern double dev_zmin,dev_zmax; |
102 |
|
103 |
extern SAMP *sAlloc(); |
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|