home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 March / ENTER.ISO / files / fwp-0.0.6-win32-installer.exe / Shader.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-12-06  |  3.0 KB  |  169 lines

  1. #ifndef __Shader_h__
  2. #define __Shader_h__
  3.  
  4. #include "File.h"
  5. #include "vectormath.h"
  6. #include "Texture.h"
  7. #include "Tokenizer.h"
  8.  
  9. #define SHADER_MAX_TEX_ANIM_FRAMES            16
  10. #define SHADER_ANIM_FUNCTION_MAX_SAMPLES    16
  11.  
  12. #define SHADER_FLAG_NONE            0x0000
  13. #define SHADER_FLAG_NO_LIGHTING        0x0001
  14. #define SHADER_FLAG_NO_DEPTH_TEST    0x0002
  15. #define SHADER_FLAG_ALPHA_TEST        0x0004
  16. #define SHADER_FLAG_BLEND            0x0008
  17. #define SHADER_FLAG_TWO_SIDED        0x0010
  18. #define SHADER_FLAG_NO_DEPTH_WRITE    0x0020
  19. #define SHADER_FLAG_POLYGON_OFFSET    0x0040
  20.  
  21. #define SHADER_COMBINE_MODE_ADD            0
  22. #define SHADER_COMBINE_MODE_MODULATE    1
  23. #define SHADER_COMBINE_MODE_REPLACE        2
  24.  
  25.  
  26. typedef struct animFunctionSamplePoint_s{
  27.     int time;
  28.     float value;
  29. }animFunctionSamplePoint_t;
  30.  
  31. class AnimFunction{
  32. public:
  33.     animFunctionSamplePoint_t samples[SHADER_ANIM_FUNCTION_MAX_SAMPLES];
  34.     int numSamples;
  35.  
  36.     AnimFunction(int numSamples, char** samples);
  37.     ~AnimFunction();
  38.  
  39.     float getValue(int time);
  40. };
  41.  
  42. class ColAnim{
  43. public:
  44.     AnimFunction* red;
  45.     AnimFunction* green;
  46.     AnimFunction* blue;
  47.     AnimFunction* alpha;
  48.     int combineMode;
  49.     int duration;
  50.  
  51.     ColAnim();
  52.     ~ColAnim();
  53.  
  54.     void setup(unsigned int time);
  55.     void setdown();
  56.  
  57.     bool readFromFile(File* f);
  58. };
  59.  
  60.  
  61.  
  62. class BaseOptions{
  63. public:
  64.     unsigned int flags;
  65.     unsigned int collisionFlags;
  66.     int surfaceType;
  67.     vec4_t color;
  68.     ColAnim* colAnim;
  69.     int alphaFunc_id;
  70.     float alphaFunc_val;
  71.     int depthFunc_id;
  72.     float depthFunc_val;
  73.     int blendFunc_srcFactor;
  74.     int blendFunc_dstFactor;
  75.     float polygonOffset;
  76.  
  77.     BaseOptions();
  78.     ~BaseOptions();
  79.  
  80.     void setup(unsigned int time);
  81.     void setdown();
  82.  
  83.     bool readFromFile(File* f);
  84. };
  85.  
  86.  
  87.  
  88.  
  89.  
  90. typedef struct texAnimFrame_s{
  91.     Texture* texture;
  92.     int delayTime;
  93.     int startTime;
  94. }texAnimFrame_t;
  95.  
  96. class TexAnim{
  97. public:
  98.     texAnimFrame_t frames[SHADER_MAX_TEX_ANIM_FRAMES];
  99.     int numFrames;
  100.     int duration;
  101.  
  102.     TexAnim();
  103.     ~TexAnim();
  104.  
  105.     void setup(unsigned int time);
  106.     void setdown();
  107.  
  108.     bool readFromFile(File* f);
  109.  
  110. protected:
  111.     bool readRange(Tokenizer* t, int delayTime);
  112. };
  113.  
  114. class TexCoordAnim{
  115. public:
  116.     AnimFunction* uModFunc;
  117.     AnimFunction* vModFunc;
  118.     AnimFunction* uAddFunc;
  119.     AnimFunction* vAddFunc;
  120. //    int combineMode;
  121.     int duration;
  122.  
  123.     TexCoordAnim();
  124.     ~TexCoordAnim();
  125.  
  126.     void setup(unsigned int time);
  127.     void setdown();
  128.  
  129.     bool readFromFile(File* f);
  130. };
  131.  
  132. class MapChannelOptions{
  133. public:
  134.     int texUnit;    // THINKABOUTME
  135.     Texture* map;
  136.     TexAnim* texAnim;
  137.     TexCoordAnim* texCoordAnim;
  138.     int texMode;
  139.  
  140.     MapChannelOptions();
  141.     ~MapChannelOptions();
  142.  
  143.     void setup(unsigned int time);
  144.     void setdown();
  145.  
  146.     bool readFromFile(File* f);
  147. };
  148.  
  149. class Shader{
  150. public:
  151.     char* name;
  152.     char* filename;
  153.     BaseOptions* base;
  154.     MapChannelOptions* mapChannel1;
  155.     MapChannelOptions* mapChannel2;
  156.  
  157.     Shader(const char* filename);
  158.     ~Shader();
  159.  
  160.     static char* findShaderForImageFile(const char* filename);
  161.  
  162.     void setup(unsigned int time);
  163.     void setdown();
  164.  
  165.     bool readFromFile(File* f);
  166. };
  167.  
  168. #endif    /* __Shader_h__ */
  169.