~ubuntu-branches/ubuntu/warty/aqsis/warty

« back to all changes in this revision

Viewing changes to libslparse/ivardef.h

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:25:04 UTC
  • Revision ID: james.westby@ubuntu.com-20040824072504-zf993vnevvisdsvb
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Aqsis
 
2
// Copyright ļæ½ 1997 - 2001, Paul C. Gregory
 
3
//
 
4
// Contact: pgregory@aqsis.com
 
5
//
 
6
// This library is free software; you can redistribute it and/or
 
7
// modify it under the terms of the GNU General Public
 
8
// License as published by the Free Software Foundation; either
 
9
// version 2 of the License, or (at your option) any later version.
 
10
//
 
11
// This library is distributed in the hope that it will be useful,
 
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
// General Public License for more details.
 
15
//
 
16
// You should have received a copy of the GNU General Public
 
17
// License along with this library; if not, write to the Free Software
 
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
 
 
20
 
 
21
/** \file
 
22
                \brief Interface classes for variable definitions
 
23
                \author Paul C. Gregory (pgregory@aqsis.com)
 
24
*/
 
25
 
 
26
//? Is .h included already?
 
27
#ifndef IVARDEF_H_INCLUDED
 
28
#define IVARDEF_H_INCLUDED 1
 
29
 
 
30
#include        "aqsis.h"
 
31
 
 
32
START_NAMESPACE( Aqsis )
 
33
 
 
34
struct IqParseNode;
 
35
 
 
36
enum EqVariableType
 
37
{
 
38
    Type_Nil = 0,
 
39
 
 
40
    Type_Float = 1,
 
41
    Type_Integer,
 
42
    Type_Point,
 
43
    Type_String,
 
44
    Type_Color,
 
45
    Type_Triple,
 
46
    Type_hPoint,
 
47
    Type_Normal,
 
48
    Type_Vector,
 
49
    Type_Void,
 
50
    Type_Matrix,
 
51
    Type_HexTuple,
 
52
    Type_Last,
 
53
 
 
54
    Type_Uniform = 0x8000,
 
55
    Type_Varying = 0x4000,
 
56
    Type_Vertex = 0x2000,
 
57
 
 
58
    Type_Output = 0x0800,
 
59
    Type_Variable = 0x0400,
 
60
    Type_Param = 0x0200,
 
61
    Type_Array = 0x0100,
 
62
 
 
63
    Type_VaryingFloat = Type_Float | Type_Varying,
 
64
    Type_VaryingInteger = Type_Integer | Type_Varying,
 
65
    Type_VaryingPoint = Type_Point | Type_Varying,
 
66
    Type_VaryingString = Type_String | Type_Varying,
 
67
    Type_VaryingColor = Type_Color | Type_Varying,
 
68
    Type_VaryinghPoint = Type_hPoint | Type_Varying,
 
69
    Type_VaryingNormal = Type_Normal | Type_Varying,
 
70
    Type_VaryingVector = Type_Vector | Type_Varying,
 
71
    Type_VaryingMatrix = Type_Matrix | Type_Varying,
 
72
 
 
73
    Type_UniformFloat = Type_Float | Type_Uniform,
 
74
    Type_UniformInteger = Type_Integer | Type_Uniform,
 
75
    Type_UniformPoint = Type_Point | Type_Uniform,
 
76
    Type_UniformString = Type_String | Type_Uniform,
 
77
    Type_UniformColor = Type_Color | Type_Uniform,
 
78
    Type_UniformhPoint = Type_hPoint | Type_Uniform,
 
79
    Type_UniformNormal = Type_Normal | Type_Uniform,
 
80
    Type_UniformVector = Type_Vector | Type_Uniform,
 
81
    Type_UniformMatrix = Type_Matrix | Type_Uniform,
 
82
 
 
83
    Type_VertexFloat = Type_Float | Type_Vertex,
 
84
    Type_VertexInteger = Type_Integer | Type_Vertex,
 
85
    Type_VertexPoint = Type_Point | Type_Vertex,
 
86
    Type_VertexString = Type_String | Type_Vertex,
 
87
    Type_VertexColor = Type_Color | Type_Vertex,
 
88
    Type_VertexhPoint = Type_hPoint | Type_Vertex,
 
89
    Type_VertexNormal = Type_hPoint | Type_Vertex,
 
90
    Type_VertexVector = Type_hPoint | Type_Vertex,
 
91
    Type_VertexMatrix = Type_Matrix | Type_Vertex,
 
92
 
 
93
    Type_UniformFloatVariable = Type_Float | Type_Variable | Type_Uniform,
 
94
    Type_UniformPointVariable = Type_Point | Type_Variable | Type_Uniform,
 
95
    Type_UniformStringVariable = Type_String | Type_Variable | Type_Uniform,
 
96
    Type_UniformColorVariable = Type_Color | Type_Variable | Type_Uniform,
 
97
    Type_UniformNormalVariable = Type_Normal | Type_Variable | Type_Uniform,
 
98
    Type_UniformVectorVariable = Type_Vector | Type_Variable | Type_Uniform,
 
99
    Type_UniformMatrixVariable = Type_Matrix | Type_Variable | Type_Uniform,
 
100
 
 
101
    Type_VaryingFloatVariable = Type_Float | Type_Variable | Type_Varying,
 
102
    Type_VaryingPointVariable = Type_Point | Type_Variable | Type_Varying,
 
103
    Type_VaryingStringVariable = Type_String | Type_Variable | Type_Varying,
 
104
    Type_VaryingColorVariable = Type_Color | Type_Variable | Type_Varying,
 
105
    Type_VaryingNormalVariable = Type_Normal | Type_Variable | Type_Varying,
 
106
    Type_VaryingVectorVariable = Type_Vector | Type_Variable | Type_Varying,
 
107
    Type_VaryingMatrixVariable = Type_Matrix | Type_Variable | Type_Varying,
 
108
 
 
109
    Type_VertexFloatVariable = Type_Float | Type_Variable | Type_Vertex,
 
110
    Type_VertexPointVariable = Type_Point | Type_Variable | Type_Vertex,
 
111
    Type_VertexStringVariable = Type_String | Type_Variable | Type_Vertex,
 
112
    Type_VertexColorVariable = Type_Color | Type_Variable | Type_Vertex,
 
113
    Type_VertexNormalVariable = Type_Normal | Type_Variable | Type_Vertex,
 
114
    Type_VertexVectorVariable = Type_Vector | Type_Variable | Type_Vertex,
 
115
    Type_VertexMatrixVariable = Type_Matrix | Type_Variable | Type_Vertex,
 
116
 
 
117
    Type_VaryingFloatArray = Type_Float | Type_Varying | Type_Array,
 
118
    Type_VaryingIntegerArray = Type_Integer | Type_Varying | Type_Array,
 
119
    Type_VaryingPointArray = Type_Point | Type_Varying | Type_Array,
 
120
    Type_VaryingStringArray = Type_String | Type_Varying | Type_Array,
 
121
    Type_VaryingColorArray = Type_Color | Type_Varying | Type_Array,
 
122
    Type_VaryinghPointArray = Type_hPoint | Type_Varying | Type_Array,
 
123
    Type_VaryingNormalArray = Type_Normal | Type_Varying | Type_Array,
 
124
    Type_VaryingVectorArray = Type_Vector | Type_Varying | Type_Array,
 
125
    Type_VaryingMatrixArray = Type_Matrix | Type_Varying | Type_Array,
 
126
 
 
127
    Type_UniformFloatArray = Type_Float | Type_Uniform | Type_Array,
 
128
    Type_UniformIntegerArray = Type_Integer | Type_Uniform | Type_Array,
 
129
    Type_UniformPointArray = Type_Point | Type_Uniform | Type_Array,
 
130
    Type_UniformStringArray = Type_String | Type_Uniform | Type_Array,
 
131
    Type_UniformColorArray = Type_Color | Type_Uniform | Type_Array,
 
132
    Type_UniformhPointArray = Type_hPoint | Type_Uniform | Type_Array,
 
133
    Type_UniformNormalArray = Type_Normal | Type_Uniform | Type_Array,
 
134
    Type_UniformVectorArray = Type_Vector | Type_Uniform | Type_Array,
 
135
    Type_UniformMatrixArray = Type_Matrix | Type_Uniform | Type_Array,
 
136
 
 
137
    Type_VertexFloatArray = Type_Float | Type_Vertex | Type_Array,
 
138
    Type_VertexIntegerArray = Type_Integer | Type_Vertex | Type_Array,
 
139
    Type_VertexPointArray = Type_Point | Type_Vertex | Type_Array,
 
140
    Type_VertexStringArray = Type_String | Type_Vertex | Type_Array,
 
141
    Type_VertexColorArray = Type_Color | Type_Vertex | Type_Array,
 
142
    Type_VertexhPointArray = Type_hPoint | Type_Vertex | Type_Array,
 
143
    Type_VertexNormalArray = Type_hPoint | Type_Vertex | Type_Array,
 
144
    Type_VertexVectorArray = Type_hPoint | Type_Vertex | Type_Array,
 
145
    Type_VertexMatrixArray = Type_Matrix | Type_Vertex | Type_Array,
 
146
 
 
147
    Type_Mask = 0x00FF,
 
148
    Storage_Mask = 0xF000,
 
149
    Usage_Mask = 0x0F00,
 
150
 
 
151
    Storage_Shift = 12,
 
152
    Usage_Shift = 8,
 
153
};
 
154
 
 
155
 
 
156
enum EqShaderType
 
157
{
 
158
    Type_Surface,                       ///< Surface shader
 
159
    Type_Lightsource,                   ///< Lightsource shader.
 
160
    Type_Volume,                        ///< Volume shader.
 
161
    Type_Displacement,                  ///< Displacement shader.
 
162
    Type_Transformation,        ///< Transformation shader.
 
163
    Type_Imager,                        ///< Image shader.
 
164
};
 
165
 
 
166
 
 
167
enum EqEnvVars
 
168
{
 
169
    EnvVars_Cs,                 ///< Surface color.
 
170
    EnvVars_Os,                 ///< Surface opacity.
 
171
    EnvVars_Ng,                 ///< Geometric normal.
 
172
    EnvVars_du,                 ///< First derivative in u.
 
173
    EnvVars_dv,                 ///< First derivative in v.
 
174
    EnvVars_L,                  ///< Incoming light direction.
 
175
    EnvVars_Cl,                 ///< Light color.
 
176
    EnvVars_Ol,                 ///< Light opacity.
 
177
    EnvVars_P,                  ///< Point being shaded.
 
178
    EnvVars_dPdu,       ///< Change in P with respect to change in u.
 
179
    EnvVars_dPdv,       ///< Change in P with respect to change in v.
 
180
    EnvVars_N,                  ///< Surface normal.
 
181
    EnvVars_u,                  ///< Surface u coordinate.
 
182
    EnvVars_v,                  ///< Surface v coordinate.
 
183
    EnvVars_s,                  ///< Texture s coordinate.
 
184
    EnvVars_t,                  ///< Texture t coordinate.
 
185
    EnvVars_I,                  ///< Incident ray direction.
 
186
    EnvVars_Ci,                 ///< Incident color.
 
187
    EnvVars_Oi,                 ///< Incident opacity.
 
188
    EnvVars_Ps,                 ///< Point being lit.
 
189
    EnvVars_E,                  ///< Viewpoint position.
 
190
    EnvVars_ncomps,     ///< Number of color components.
 
191
    EnvVars_time,       ///< Frame time.
 
192
    EnvVars_alpha,      ///< Fractional pixel coverage.
 
193
 
 
194
    EnvVars_Ns,                 ///< Normal at point being lit.
 
195
 
 
196
    EnvVars_Last
 
197
};
 
198
 
 
199
 
 
200
///----------------------------------------------------------------------
 
201
/// EqVarType
 
202
/// Type of variable
 
203
 
 
204
enum EqVarType
 
205
{
 
206
    VarTypeStandard = 0,
 
207
    VarTypeLocal,
 
208
};
 
209
 
 
210
 
 
211
///----------------------------------------------------------------------
 
212
/// SqVarRef
 
213
/// Structure storing a variable reference.
 
214
 
 
215
struct SqVarRef
 
216
{
 
217
    EqVarType   m_Type;
 
218
    TqUint      m_Index;
 
219
 
 
220
    TqBool      operator==( const SqVarRef& From ) const
 
221
    {
 
222
        return ( From.m_Type == m_Type && From.m_Index == m_Index );
 
223
    }
 
224
};
 
225
 
 
226
 
 
227
struct IqVarDef
 
228
{
 
229
    virtual     const IqParseNode*      pInitialiser() const = 0;
 
230
    virtual     IqParseNode*    pInitialiser() = 0;
 
231
    virtual     TqInt   Type() const = 0;
 
232
    virtual const char* strName() const = 0;
 
233
    virtual     void    IncUseCount() = 0;
 
234
    virtual     TqInt   UseCount() const = 0;
 
235
    virtual     TqInt   ArrayLength() const = 0;
 
236
    virtual     TqBool  fExtern() const = 0;
 
237
    virtual     SqVarRef        vrExtern() const = 0;
 
238
    virtual     void    SetParam( TqBool fParam = TqTrue ) = 0;
 
239
    virtual     void    SetOutput( TqBool fOutput = TqTrue ) = 0;
 
240
    virtual     void    SetDefaultStorage( TqInt Storage ) = 0;
 
241
 
 
242
    static      IqVarDef*       GetVariablePtr( const SqVarRef& Ref );
 
243
};
 
244
 
 
245
//-----------------------------------------------------------------------
 
246
 
 
247
END_NAMESPACE( Aqsis )
 
248
 
 
249
#endif  // !IVARDEF_H_INCLUDED