1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#ifndef __glsmapint_h__
#define __glsmapint_h__
/* Copyright (c) Mark J. Kilgard, 1998. */
/* This program is freely distributable without licensing fees
and is provided without guarantee or warrantee expressed or
implied. This program is -not- in the public domain. */
#include "glsmap.h"
enum { X = 0, Y = 1, Z = 2 };
#define INITFACE(mesh) \
int steps = mesh->steps; \
int sqsteps = mesh->steps * mesh->steps
#define FACE(side,y,x) \
mesh->face[(side)*sqsteps + (y)*steps + (x)]
#define FACExy(side,i,j) \
(&FACE(side,i,j).x)
#define FACEst(side,i,j) \
(&FACE(side,i,j).s)
#define INITBACK(mesh) \
int allrings = mesh->rings + mesh->edgeExtend; \
int ringedspokes = allrings * mesh->steps
#define BACK(edge,ring,spoke) \
mesh->back[(edge)*ringedspokes + (ring)*mesh->steps + (spoke)]
#define BACKxy(edge,ring,spoke) \
(&BACK(edge,ring,spoke).x)
#define BACKst(edge,ring,spoke) \
(&BACK(edge,ring,spoke).s)
typedef struct _STXY {
GLfloat s, t;
GLfloat x, y;
} STXY;
typedef struct _SphereMapMesh {
int refcnt;
int steps;
int rings;
int edgeExtend;
STXY *face;
STXY *back;
} SphereMapMesh;
struct _SphereMap {
/* Shared sphere map mesh vertex data. */
SphereMapMesh *mesh;
/* Texture object ids. */
GLuint smapTexObj;
GLuint viewTexObjs[6];
GLuint viewTexObj;
/* Flags */
SphereMapFlags flags;
/* Texture dimensions must be a power of two. */
int viewTexDim; /* view texture dimension */
int smapTexDim; /* sphere map texture dimension */
/* Viewport origins for view and sphere map rendering. */
int viewOrigin[2];
int smapOrigin[2];
/* Viewing vectors. */
GLfloat eye[3];
GLfloat up[3];
GLfloat obj[3];
/* Projection parameters. */
GLfloat viewNear;
GLfloat viewFar;
/* Rendering callbacks. */
void (*positionLights)(int view, void *context);
void (*drawView)(int view, void *context);
/* Application specified callback data. */
void *context;
};
/* Library internal routines. */
extern void __smapDrawSphereMapMeshSide(SphereMapMesh *mesh, int side);
extern void __smapDrawSphereMapMeshBack(SphereMapMesh *mesh);
extern void __smapValidateSphereMapMesh(SphereMapMesh *mesh);
#endif /* __glsmapint_h__ */
|