00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef LS_COMPUTE_SLAB_H_
00019 #define LS_COMPUTE_SLAB_H_
00020
00021 #include <iostream.h>
00022
00023 #include <glew.h>
00024 #include <command.h>
00025 #include <vec2.h>
00026
00027 #include <basicTexture.h>
00028 #include <multiTexture.h>
00029 #include <pixelShaderATI.h>
00030 #include <shader.h>
00031
00032 #include <planarQuad.h>
00033 #include <shadedPrim.h>
00034
00035 #include <renderPass.h>
00036
00037 #include <vector>
00038 typedef std::vector<Vec2f> VecVec2f;
00039
00040 class ComputeSlab
00041 {
00042 public:
00043 ComputeSlab( const ComputeSlab& rhs );
00044 ComputeSlab& operator=( const ComputeSlab& rhs );
00045 virtual ~ComputeSlab();
00046
00047 void render();
00048 void resetShader();
00049
00050 protected:
00051
00052 ComputeSlab() {}
00053 ComputeSlab( const VecTexPtr& vecInTex, GlewShadeLang lang, const Vec2i& dimen, GLfloat z=0.0f );
00054 ComputeSlab( const VecTexPtr& vecInTex, GlewShadeLang lang, PBuffer* pbuffDest, const Vec2i& dimen, GLfloat z=0.0f );
00055 ComputeSlab( const VecTexPtr& vecInTex, GlewShadeLang lang, BasicTexture* texDest, const Vec2i& dimen, GLfloat z=0.0f );
00056
00057
00058 virtual uint numTexUnits() const = 0;
00059 virtual void pixShaderATI();
00060 virtual void pixShaderNV20();
00061 virtual void pixShaderNV30();
00062 virtual void pixShaderCG();
00063 virtual TexCoordPerturb* getTexPerturbs( const Vec2i& dimen );
00064
00065 private:
00066
00067 MultiTexture* m_texInput;
00068 GlewShadeLang m_lang;
00069 PBuffer* m_pbuffDest;
00070 BasicTexture* m_texDest;
00071 Vec2i m_dimen;
00072 GLfloat m_z;
00073
00074
00075 RenderPass* m_pass;
00076 PixelShader* m_pixShader;
00077
00078
00079
00080
00081 TexCoordPerturb* m_texPerturb;
00082 ProgShader* m_progShader;
00083 Shader* m_shader;
00084 RawPrim* m_quad;
00085 ShadedPrim* m_shadedPrim;
00086
00087
00088 void create( PixelShader* pixShader );
00089 void initInputMembers( const VecTexPtr& vecInTex, GlewShadeLang lang,
00090 PBuffer* pbuffDest, BasicTexture* texDest,
00091 const Vec2i& dimen, GLfloat z);
00092
00093
00094 void reset();
00095 void copyMembers( const ComputeSlab& rhs );
00096 void copyMembers( RenderPass* pass, const Vec2i& m_dimen, GLfloat z, PBuffer* pbuffDest,
00097 BasicTexture* texDest, GlewShadeLang lang,
00098 MultiTexture* texInput, PixelShader* pixShader, ShadedPrim* shadedPrim,
00099 ProgShader* progShader, RawPrim* quad, Shader* shader, TexCoordPerturb* texPerturb );
00100
00101
00102
00103 template <class CallType>
00104 PixelShader* makePixShader( const CallType* obj )
00105 {
00106 PixelShader* pixShader = NULL;
00107 switch(m_lang) {
00108 case GSL_ATI8K: pixShader = new PixelShaderATI( new MemberCommand0<CallType>(obj, &CallType::pixShaderATI), m_pbuffDest );
00109 break;
00110 case GSL_NV20:
00111 case GSL_NV30:
00112 case GSL_CG:
00113 default: err() << "pixelShader(...) Error:\n"
00114 << "\tUnsupported shading language (" << m_lang << ")\n";
00115 exit(1);
00116 }
00117
00118 return pixShader;
00119 }
00120 };
00121
00122 #endif