00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00033
00034
#ifndef SH_SHVECTOR_HPP
00035
#define SH_SHVECTOR_HPP
00036
00037
#include "ShAttrib.hpp"
00038
namespace SH {
00039
00047
template<
int N, ShBindingType Binding,
typename T=
float,
bool Swizzled=false>
00048 class ShVector :
public ShAttrib<N, Binding, T, Swizzled> {
00049
public:
00050
ShVector();
00051
ShVector(
const ShGeneric<N, T>& other);
00052
ShVector(
const ShVector<N, Binding, T, Swizzled>& other);
00053
ShVector(
const ShVariableNodePtr& node,
const ShSwizzle& swizzle,
bool neg);
00054
explicit ShVector(T data[N]);
00055
00056 ~
ShVector();
00057
00058
ShVector& operator=(
const ShGeneric<N, T>& other);
00059
ShVector& operator=(
const ShVector<N, Binding, T, Swizzled>& other);
00060
00061
ShVector& operator=(
const ShProgram& prg);
00062
00063
ShVector& operator+=(
const ShGeneric<N, T>& right);
00064
ShVector& operator-=(
const ShGeneric<N, T>& right);
00065
ShVector& operator*=(
const ShGeneric<N, T>& right);
00066
ShVector& operator/=(
const ShGeneric<N, T>& right);
00067
ShVector& operator%=(
const ShGeneric<N, T>& right);
00068
ShVector& operator*=(T);
00069
ShVector& operator/=(T);
00070
ShVector& operator%=(T);
00071
ShVector& operator+=(T);
00072
ShVector& operator-=(T);
00073
ShVector& operator+=(
const ShGeneric<1, T>&);
00074
ShVector& operator-=(
const ShGeneric<1, T>&);
00075
ShVector& operator*=(
const ShGeneric<1, T>&);
00076
ShVector& operator/=(
const ShGeneric<1, T>&);
00077
ShVector& operator%=(
const ShGeneric<1, T>&);
00078
ShVector<1, Binding, T, true> operator()(
int)
const;
00079
ShVector<2, Binding, T, true> operator()(
int,
int)
const;
00080
ShVector<3, Binding, T, true> operator()(
int,
int,
int)
const;
00081
ShVector<4, Binding, T, true> operator()(
int,
int,
int,
int)
const;
00082
ShVector<1, Binding, T, true> operator[](
int)
const;
00083
00084
template<
int N2>
00085
ShVector<N2, Binding, T, true> swiz(
int indices[])
const;
00086
00087
ShVector operator-()
const;
00088
typedef T ValueType;
00089
static const int typesize = N;
00090
static const ShBindingType binding_type = Binding;
00091
static const ShSemanticType semantic_type = SH_VECTOR;
00092
00093
typedef ShVector<N, SH_INPUT, T> InputType;
00094
typedef ShVector<N, SH_OUTPUT, T> OutputType;
00095
typedef ShVector<N, SH_INOUT, T> InOutType;
00096
typedef ShVector<N, SH_TEMP, T> TempType;
00097
typedef ShVector<N, SH_CONST, T> ConstType;
00098
private:
00099
typedef ShAttrib<N, Binding, T, Swizzled> ParentType;
00100 };
00101
00102
template<ShBindingType Binding,
typename T,
bool Swizzled>
00103
class ShVector<1, Binding, T, Swizzled> :
public ShAttrib<1, Binding, T, Swizzled> {
00104
public:
00105
ShVector();
00106
ShVector(
const ShGeneric<1, T>& other);
00107
ShVector(
const ShVector<1, Binding, T, Swizzled>& other);
00108
ShVector(
const ShVariableNodePtr& node,
const ShSwizzle& swizzle,
bool neg);
00109
explicit ShVector(T data[1]);
00110
00111
ShVector(T);
00112
00113 ~
ShVector();
00114
00115
ShVector& operator=(
const ShGeneric<1, T>& other);
00116
ShVector& operator=(
const ShVector<1, Binding, T, Swizzled>& other);
00117
00118
ShVector& operator=(T other);
00119
00120
ShVector& operator=(
const ShProgram& prg);
00121
00122
ShVector& operator+=(
const ShGeneric<1, T>& right);
00123
ShVector& operator-=(
const ShGeneric<1, T>& right);
00124
ShVector& operator*=(
const ShGeneric<1, T>& right);
00125
ShVector& operator/=(
const ShGeneric<1, T>& right);
00126
ShVector& operator%=(
const ShGeneric<1, T>& right);
00127
ShVector& operator*=(T);
00128
ShVector& operator/=(T);
00129
ShVector& operator%=(T);
00130
ShVector& operator+=(T);
00131
ShVector& operator-=(T);
00132
ShVector<1, Binding, T, true> operator()(
int) const;
00133
ShVector<2, Binding, T, true> operator()(
int,
int) const;
00134
ShVector<3, Binding, T, true> operator()(
int,
int,
int) const;
00135
ShVector<4, Binding, T, true> operator()(
int,
int,
int,
int) const;
00136
ShVector<1, Binding, T, true> operator[](
int) const;
00137
00138 template<
int N2>
00139
ShVector<N2, Binding, T, true> swiz(
int indices[]) const;
00140
00141
ShVector operator-() const;
00142 typedef T ValueType;
00143 static const
int typesize = 1;
00144 static const ShBindingType binding_type = Binding;
00145 static const ShSemanticType semantic_type = SH_VECTOR;
00146
00147 typedef
ShVector<1, SH_INPUT, T> InputType;
00148 typedef ShVector<1, SH_OUTPUT, T> OutputType;
00149 typedef ShVector<1, SH_INOUT, T> InOutType;
00150 typedef ShVector<1, SH_TEMP, T> TempType;
00151 typedef ShVector<1, SH_CONST, T> ConstType;
00152 private:
00153 typedef
ShAttrib<1, Binding, T, Swizzled> ParentType;
00154 };
00155
00156 template<ShBindingType Binding, typename T,
bool Swizzled>
00157 class ShVector<2, Binding, T, Swizzled> : public ShAttrib<2, Binding, T, Swizzled> {
00158
public:
00159 ShVector();
00160 ShVector(
const ShGeneric<2, T>& other);
00161 ShVector(
const ShVector<2, Binding, T, Swizzled>& other);
00162 ShVector(
const ShVariableNodePtr& node,
const ShSwizzle& swizzle,
bool neg);
00163
explicit ShVector(T data[2]);
00164
00165 ShVector(T, T);
00166 ShVector(
const ShGeneric<1, T>&,
const ShGeneric<1, T>&);
00167
00168 ~ShVector();
00169
00170 ShVector& operator=(
const ShGeneric<2, T>& other);
00171 ShVector& operator=(
const ShVector<2, Binding, T, Swizzled>& other);
00172
00173 ShVector& operator=(
const ShProgram& prg);
00174
00175 ShVector& operator+=(
const ShGeneric<2, T>& right);
00176 ShVector& operator-=(
const ShGeneric<2, T>& right);
00177 ShVector& operator*=(
const ShGeneric<2, T>& right);
00178 ShVector& operator/=(
const ShGeneric<2, T>& right);
00179 ShVector& operator%=(
const ShGeneric<2, T>& right);
00180 ShVector& operator*=(T);
00181 ShVector& operator/=(T);
00182 ShVector& operator%=(T);
00183 ShVector& operator+=(T);
00184 ShVector& operator-=(T);
00185 ShVector& operator+=(
const ShGeneric<1, T>&);
00186 ShVector& operator-=(
const ShGeneric<1, T>&);
00187 ShVector& operator*=(
const ShGeneric<1, T>&);
00188 ShVector& operator/=(
const ShGeneric<1, T>&);
00189 ShVector& operator%=(
const ShGeneric<1, T>&);
00190
ShVector<1, Binding, T, true> operator()(
int) const;
00191 ShVector<2, Binding, T, true> operator()(
int,
int) const;
00192 ShVector<3, Binding, T, true> operator()(
int,
int,
int) const;
00193 ShVector<4, Binding, T, true> operator()(
int,
int,
int,
int) const;
00194 ShVector<1, Binding, T, true> operator[](
int) const;
00195
00196 template<
int N2>
00197 ShVector<N2, Binding, T, true> swiz(
int indices[]) const;
00198
00199 ShVector operator-() const;
00200 typedef T ValueType;
00201 static const
int typesize = 2;
00202 static const ShBindingType binding_type = Binding;
00203 static const ShSemanticType semantic_type = SH_VECTOR;
00204
00205 typedef ShVector<2, SH_INPUT, T> InputType;
00206 typedef ShVector<2, SH_OUTPUT, T> OutputType;
00207 typedef ShVector<2, SH_INOUT, T> InOutType;
00208 typedef ShVector<2, SH_TEMP, T> TempType;
00209 typedef ShVector<2, SH_CONST, T> ConstType;
00210 private:
00211 typedef ShAttrib<2, Binding, T, Swizzled> ParentType;
00212 };
00213
00214 template<ShBindingType Binding, typename T,
bool Swizzled>
00215 class ShVector<3, Binding, T, Swizzled> : public ShAttrib<3, Binding, T, Swizzled> {
00216
public:
00217 ShVector();
00218 ShVector(
const ShGeneric<3, T>& other);
00219 ShVector(
const ShVector<3, Binding, T, Swizzled>& other);
00220 ShVector(
const ShVariableNodePtr& node,
const ShSwizzle& swizzle,
bool neg);
00221
explicit ShVector(T data[3]);
00222
00223 ShVector(T, T, T);
00224 ShVector(
const ShGeneric<1, T>&,
const ShGeneric<1, T>&,
const ShGeneric<1, T>&);
00225
00226 ~ShVector();
00227
00228 ShVector& operator=(
const ShGeneric<3, T>& other);
00229 ShVector& operator=(
const ShVector<3, Binding, T, Swizzled>& other);
00230
00231 ShVector& operator=(
const ShProgram& prg);
00232
00233 ShVector& operator+=(
const ShGeneric<3, T>& right);
00234 ShVector& operator-=(
const ShGeneric<3, T>& right);
00235 ShVector& operator*=(
const ShGeneric<3, T>& right);
00236 ShVector& operator/=(
const ShGeneric<3, T>& right);
00237 ShVector& operator%=(
const ShGeneric<3, T>& right);
00238 ShVector& operator*=(T);
00239 ShVector& operator/=(T);
00240 ShVector& operator%=(T);
00241 ShVector& operator+=(T);
00242 ShVector& operator-=(T);
00243 ShVector& operator+=(
const ShGeneric<1, T>&);
00244 ShVector& operator-=(
const ShGeneric<1, T>&);
00245 ShVector& operator*=(
const ShGeneric<1, T>&);
00246 ShVector& operator/=(
const ShGeneric<1, T>&);
00247 ShVector& operator%=(
const ShGeneric<1, T>&);
00248
ShVector<1, Binding, T, true> operator()(
int) const;
00249 ShVector<2, Binding, T, true> operator()(
int,
int) const;
00250 ShVector<3, Binding, T, true> operator()(
int,
int,
int) const;
00251 ShVector<4, Binding, T, true> operator()(
int,
int,
int,
int) const;
00252 ShVector<1, Binding, T, true> operator[](
int) const;
00253
00254 template<
int N2>
00255 ShVector<N2, Binding, T, true> swiz(
int indices[]) const;
00256
00257 ShVector operator-() const;
00258 typedef T ValueType;
00259 static const
int typesize = 3;
00260 static const ShBindingType binding_type = Binding;
00261 static const ShSemanticType semantic_type = SH_VECTOR;
00262
00263 typedef ShVector<3, SH_INPUT, T> InputType;
00264 typedef ShVector<3, SH_OUTPUT, T> OutputType;
00265 typedef ShVector<3, SH_INOUT, T> InOutType;
00266 typedef ShVector<3, SH_TEMP, T> TempType;
00267 typedef ShVector<3, SH_CONST, T> ConstType;
00268 private:
00269 typedef ShAttrib<3, Binding, T, Swizzled> ParentType;
00270 };
00271
00272 template<ShBindingType Binding, typename T,
bool Swizzled>
00273 class ShVector<4, Binding, T, Swizzled> : public ShAttrib<4, Binding, T, Swizzled> {
00274
public:
00275 ShVector();
00276 ShVector(
const ShGeneric<4, T>& other);
00277 ShVector(
const ShVector<4, Binding, T, Swizzled>& other);
00278 ShVector(
const ShVariableNodePtr& node,
const ShSwizzle& swizzle,
bool neg);
00279
explicit ShVector(T data[4]);
00280
00281 ShVector(T, T, T, T);
00282 ShVector(
const ShGeneric<1, T>&,
const ShGeneric<1, T>&,
const ShGeneric<1, T>&,
const ShGeneric<1, T>&);
00283
00284 ~ShVector();
00285
00286 ShVector& operator=(
const ShGeneric<4, T>& other);
00287 ShVector& operator=(
const ShVector<4, Binding, T, Swizzled>& other);
00288
00289 ShVector& operator=(
const ShProgram& prg);
00290
00291 ShVector& operator+=(
const ShGeneric<4, T>& right);
00292 ShVector& operator-=(
const ShGeneric<4, T>& right);
00293 ShVector& operator*=(
const ShGeneric<4, T>& right);
00294 ShVector& operator/=(
const ShGeneric<4, T>& right);
00295 ShVector& operator%=(
const ShGeneric<4, T>& right);
00296 ShVector& operator*=(T);
00297 ShVector& operator/=(T);
00298 ShVector& operator%=(T);
00299 ShVector& operator+=(T);
00300 ShVector& operator-=(T);
00301 ShVector& operator+=(
const ShGeneric<1, T>&);
00302 ShVector& operator-=(
const ShGeneric<1, T>&);
00303 ShVector& operator*=(
const ShGeneric<1, T>&);
00304 ShVector& operator/=(
const ShGeneric<1, T>&);
00305 ShVector& operator%=(
const ShGeneric<1, T>&);
00306
ShVector<1, Binding, T, true> operator()(
int) const;
00307 ShVector<2, Binding, T, true> operator()(
int,
int) const;
00308 ShVector<3, Binding, T, true> operator()(
int,
int,
int) const;
00309 ShVector<4, Binding, T, true> operator()(
int,
int,
int,
int) const;
00310 ShVector<1, Binding, T, true> operator[](
int) const;
00311
00312 template<
int N2>
00313 ShVector<N2, Binding, T, true> swiz(
int indices[]) const;
00314
00315 ShVector operator-() const;
00316 typedef T ValueType;
00317 static const
int typesize = 4;
00318 static const ShBindingType binding_type = Binding;
00319 static const ShSemanticType semantic_type = SH_VECTOR;
00320
00321 typedef ShVector<4, SH_INPUT, T> InputType;
00322 typedef ShVector<4, SH_OUTPUT, T> OutputType;
00323 typedef ShVector<4, SH_INOUT, T> InOutType;
00324 typedef ShVector<4, SH_TEMP, T> TempType;
00325 typedef ShVector<4, SH_CONST, T> ConstType;
00326 private:
00327 typedef ShAttrib<4, Binding, T, Swizzled> ParentType;
00328 };
00329
00330 typedef ShVector<1, SH_INPUT,
float>
ShInputVector1f;
00331 typedef ShVector<1, SH_OUTPUT,
float>
ShOutputVector1f;
00332 typedef ShVector<1, SH_INOUT,
float>
ShInOutVector1f;
00333 typedef ShVector<1, SH_TEMP,
float>
ShVector1f;
00334 typedef ShVector<1, SH_CONST,
float>
ShConstVector1f;
00335 typedef ShVector<2, SH_INPUT,
float>
ShInputVector2f;
00336 typedef ShVector<2, SH_OUTPUT,
float>
ShOutputVector2f;
00337 typedef ShVector<2, SH_INOUT,
float>
ShInOutVector2f;
00338 typedef ShVector<2, SH_TEMP,
float>
ShVector2f;
00339 typedef ShVector<2, SH_CONST,
float>
ShConstVector2f;
00340 typedef ShVector<3, SH_INPUT,
float>
ShInputVector3f;
00341 typedef ShVector<3, SH_OUTPUT,
float>
ShOutputVector3f;
00342 typedef ShVector<3, SH_INOUT,
float>
ShInOutVector3f;
00343 typedef ShVector<3, SH_TEMP,
float>
ShVector3f;
00344 typedef ShVector<3, SH_CONST,
float>
ShConstVector3f;
00345 typedef ShVector<4, SH_INPUT,
float>
ShInputVector4f;
00346 typedef ShVector<4, SH_OUTPUT,
float>
ShOutputVector4f;
00347 typedef ShVector<4, SH_INOUT,
float>
ShInOutVector4f;
00348 typedef ShVector<4, SH_TEMP,
float>
ShVector4f;
00349 typedef ShVector<4, SH_CONST,
float>
ShConstVector4f;
00350
00351 }
00352 #include "ShVectorImpl.hpp"
00353
00354 #endif