home *** CD-ROM | disk | FTP | other *** search
- #ifndef __Shader_h__
- #define __Shader_h__
-
- #include "File.h"
- #include "vectormath.h"
- #include "Texture.h"
- #include "Tokenizer.h"
-
- #define SHADER_MAX_TEX_ANIM_FRAMES 16
- #define SHADER_ANIM_FUNCTION_MAX_SAMPLES 16
-
- #define SHADER_FLAG_NONE 0x0000
- #define SHADER_FLAG_NO_LIGHTING 0x0001
- #define SHADER_FLAG_NO_DEPTH_TEST 0x0002
- #define SHADER_FLAG_ALPHA_TEST 0x0004
- #define SHADER_FLAG_BLEND 0x0008
- #define SHADER_FLAG_TWO_SIDED 0x0010
- #define SHADER_FLAG_NO_DEPTH_WRITE 0x0020
- #define SHADER_FLAG_POLYGON_OFFSET 0x0040
-
- #define SHADER_COMBINE_MODE_ADD 0
- #define SHADER_COMBINE_MODE_MODULATE 1
- #define SHADER_COMBINE_MODE_REPLACE 2
-
-
- typedef struct animFunctionSamplePoint_s{
- int time;
- float value;
- }animFunctionSamplePoint_t;
-
- class AnimFunction{
- public:
- animFunctionSamplePoint_t samples[SHADER_ANIM_FUNCTION_MAX_SAMPLES];
- int numSamples;
-
- AnimFunction(int numSamples, char** samples);
- ~AnimFunction();
-
- float getValue(int time);
- };
-
- class ColAnim{
- public:
- AnimFunction* red;
- AnimFunction* green;
- AnimFunction* blue;
- AnimFunction* alpha;
- int combineMode;
- int duration;
-
- ColAnim();
- ~ColAnim();
-
- void setup(unsigned int time);
- void setdown();
-
- bool readFromFile(File* f);
- };
-
-
-
- class BaseOptions{
- public:
- unsigned int flags;
- unsigned int collisionFlags;
- int surfaceType;
- vec4_t color;
- ColAnim* colAnim;
- int alphaFunc_id;
- float alphaFunc_val;
- int depthFunc_id;
- float depthFunc_val;
- int blendFunc_srcFactor;
- int blendFunc_dstFactor;
- float polygonOffset;
-
- BaseOptions();
- ~BaseOptions();
-
- void setup(unsigned int time);
- void setdown();
-
- bool readFromFile(File* f);
- };
-
-
-
-
-
- typedef struct texAnimFrame_s{
- Texture* texture;
- int delayTime;
- int startTime;
- }texAnimFrame_t;
-
- class TexAnim{
- public:
- texAnimFrame_t frames[SHADER_MAX_TEX_ANIM_FRAMES];
- int numFrames;
- int duration;
-
- TexAnim();
- ~TexAnim();
-
- void setup(unsigned int time);
- void setdown();
-
- bool readFromFile(File* f);
-
- protected:
- bool readRange(Tokenizer* t, int delayTime);
- };
-
- class TexCoordAnim{
- public:
- AnimFunction* uModFunc;
- AnimFunction* vModFunc;
- AnimFunction* uAddFunc;
- AnimFunction* vAddFunc;
- // int combineMode;
- int duration;
-
- TexCoordAnim();
- ~TexCoordAnim();
-
- void setup(unsigned int time);
- void setdown();
-
- bool readFromFile(File* f);
- };
-
- class MapChannelOptions{
- public:
- int texUnit; // THINKABOUTME
- Texture* map;
- TexAnim* texAnim;
- TexCoordAnim* texCoordAnim;
- int texMode;
-
- MapChannelOptions();
- ~MapChannelOptions();
-
- void setup(unsigned int time);
- void setdown();
-
- bool readFromFile(File* f);
- };
-
- class Shader{
- public:
- char* name;
- char* filename;
- BaseOptions* base;
- MapChannelOptions* mapChannel1;
- MapChannelOptions* mapChannel2;
-
- Shader(const char* filename);
- ~Shader();
-
- static char* findShaderForImageFile(const char* filename);
-
- void setup(unsigned int time);
- void setdown();
-
- bool readFromFile(File* f);
- };
-
- #endif /* __Shader_h__ */
-