| 1 |
< |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
| 2 |
< |
|
| 3 |
< |
/* SCCSid "$SunId$ SGI" */ |
| 4 |
< |
|
| 1 |
> |
/* RCSid: $Id$ */ |
| 2 |
|
/* |
| 3 |
|
* Sample data structures for holodeck display drivers. |
| 4 |
|
*/ |
| 5 |
|
#include "color.h" |
| 6 |
|
#include "tonemap.h" |
| 7 |
|
#include "rhdriver.h" |
| 8 |
+ |
#include "object.h" |
| 9 |
|
|
| 10 |
|
#ifndef int2 |
| 11 |
|
#define int2 short |
| 18 |
|
#define INVALID -1 |
| 19 |
|
#endif |
| 20 |
|
|
| 23 |
– |
#ifndef LORES |
| 24 |
– |
#define SFLOAT double |
| 25 |
– |
#else |
| 21 |
|
#define SFLOAT float |
| 27 |
– |
#endif |
| 22 |
|
|
| 23 |
+ |
typedef OBJECT S_ID; |
| 24 |
+ |
|
| 25 |
+ |
#define S_ID_MAX ((1 << ((sizeof(S_ID)<<3)-1))-1) |
| 26 |
+ |
|
| 27 |
|
typedef struct samp { |
| 28 |
|
SFLOAT (*wp)[3]; /* world intersection point array */ |
| 29 |
|
int4 *wd; /* world direction array */ |
| 31 |
|
BYTE (*chr)[3]; /* encoded chrominance array */ |
| 32 |
|
BYTE (*rgb)[3]; /* tone-mapped color array */ |
| 33 |
|
int *info; /* Extra sample info */ |
| 34 |
< |
int *info1; /* Extra sample info */ |
| 34 |
> |
int *info1; /* Extra sample info */ |
| 35 |
|
int max_samp; /* maximum number of samples */ |
| 36 |
< |
int max_base_pt; /* maximum number of aux points */ |
| 37 |
< |
int next_base_pt; /* next auxilliary point to add */ |
| 38 |
< |
int replace_samp; /* next sample to free */ |
| 36 |
> |
int max_base_pt; /* maximum number of aux points */ |
| 37 |
> |
S_ID next_base_pt; /* next auxilliary point to add */ |
| 38 |
> |
S_ID replace_samp; /* next sample to free */ |
| 39 |
|
int num_samp; /* current number of samples */ |
| 40 |
< |
int tone_map; /* pointer to next value(s)t tonemap*/ |
| 41 |
< |
int free_samp; /* free sample-not available yet */ |
| 40 |
> |
S_ID tone_map; /* pointer to next value(s)t tonemap*/ |
| 41 |
> |
S_ID free_samp; /* next free sample */ |
| 42 |
|
char *base; /* base of allocated memory */ |
| 43 |
|
} SAMP; |
| 44 |
|
|
| 49 |
|
#define S_CHR(s) ((s)->chr) |
| 50 |
|
#define S_RGB(s) ((s)->rgb) |
| 51 |
|
#define S_INFO(s) ((s)->info) |
| 52 |
< |
#define S_INFO1(s) ((s)->info1) |
| 52 |
> |
#define S_INFO1(s) ((s)->info1) |
| 53 |
|
#define S_MAX_SAMP(s) ((s)->max_samp) |
| 54 |
|
#define S_MAX_BASE_PT(s) ((s)->max_base_pt) |
| 55 |
|
#define S_NEXT_BASE_PT(s) ((s)->next_base_pt) |
| 65 |
|
#define S_NTH_RGB(s,n) (S_RGB(s)[(n)]) |
| 66 |
|
#define S_NTH_CHR(s,n) (S_CHR(s)[(n)]) |
| 67 |
|
#define S_NTH_INFO(s,n) (S_INFO(s)[(n)]) |
| 68 |
< |
#define S_NTH_INFO1(s,n) (S_INFO1(s)[(n)]) |
| 68 |
> |
#define S_NTH_INFO1(s,n) (S_INFO1(s)[(n)]) |
| 69 |
|
#define S_NTH_BRT(s,n) (S_BRT(s)[(n)]) |
| 70 |
|
|
| 71 |
|
/* Sample Flag macros */ |
| 97 |
|
|
| 98 |
|
/* These values are set by the driver, and used in the OGL call for glFrustum*/ |
| 99 |
|
extern double dev_zmin,dev_zmax; |
| 100 |
< |
|
| 100 |
> |
extern S_ID sAdd_base_point(); |
| 101 |
|
extern SAMP *sAlloc(); |
| 102 |
< |
|
| 102 |
> |
extern S_ID sAlloc_samp(); |
| 103 |
> |
/* |
| 104 |
> |
* int |
| 105 |
> |
* smInit(n) : Initialize/clear data structures for n entries |
| 106 |
> |
* int n; |
| 107 |
> |
* |
| 108 |
> |
* Initialize sampL and other data structures for at least n samples. |
| 109 |
> |
* If n is 0, then free data structures. Return number actually allocated. |
| 110 |
> |
* |
| 111 |
> |
* |
| 112 |
> |
* int |
| 113 |
> |
* smNewSamp(c, p, v) : register new sample point and return index |
| 114 |
> |
* COLR c; : pixel color (RGBE) |
| 115 |
> |
* FVECT p; : world intersection point |
| 116 |
> |
* FVECT v; : ray direction vector |
| 117 |
> |
* |
| 118 |
> |
* Add new sample point to data structures, removing old values as necessary. |
| 119 |
> |
* New sample representation will be output in next call to smUpdate(). |
| 120 |
> |
* |
| 121 |
> |
* |
| 122 |
> |
* int |
| 123 |
> |
* smFindSamp(orig, dir): intersect ray with 3D rep. and find closest sample |
| 124 |
> |
* FVECT orig, dir; |
| 125 |
> |
* |
| 126 |
> |
* Find the closest sample to the given ray. Return -1 on failure. |
| 127 |
> |
* |
| 128 |
> |
* |
| 129 |
> |
* smClean() : display has been wiped clean |
| 130 |
> |
* |
| 131 |
> |
* Called after display has been effectively cleared, meaning that all |
| 132 |
> |
* geometry must be resent down the pipeline in the next call to smUpdate(). |
| 133 |
> |
* |
| 134 |
> |
* |
| 135 |
> |
* smUpdate(vp, qua) : update OpenGL output geometry for view vp |
| 136 |
> |
* VIEW *vp; : desired view |
| 137 |
> |
* int qua; : quality level (percentage on linear time scale) |
| 138 |
> |
* |
| 139 |
> |
* Draw new geometric representation using OpenGL calls. Assume that the |
| 140 |
> |
* view has already been set up and the correct frame buffer has been |
| 141 |
> |
* selected for drawing. The quality level is on a linear scale, where 100% |
| 142 |
> |
* is full (final) quality. It is not necessary to redraw geometry that has |
| 143 |
> |
* been output since the last call to smClean(). (The last view drawn will |
| 144 |
> |
* be vp==&odev.v each time.) |
| 145 |
> |
*/ |
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|