arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

computeSlab.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 // 6/18/02      Aaron Lefohn    Scientific Computing and Imaging Institute
00003 // School of Computing          University of Utah
00004 //////////////////////////////////////////////////////////////////////
00005 //
00006 // Construction/Initialization: You MUST call 'init()' after construction
00007 //                                                              or the object will not be valid.
00008 //
00009 // ComputeSlab: The base class for using a 2D, texture-mapped quad
00010 //                              as a grid-based computation primitive. It can only
00011 //                              be constructed by a sub-class.
00012 //
00013 //////////////////////////////////////////////////////////////////////
00014 
00015 // Note: When OOGL gets reference counting, the "House-cleaning"
00016 //       pointers be removed and simply left in the constructor.
00017 
00018 #ifndef LS_COMPUTE_SLAB_H_
00019 #define LS_COMPUTE_SLAB_H_
00020 
00021 #include <iostream.h>
00022 
00023 #include <glew.h>                       //Util/Glew files
00024 #include <command.h>
00025 #include <vec2.h>
00026 
00027 #include <basicTexture.h>       //Attributes
00028 #include <multiTexture.h>
00029 #include <pixelShaderATI.h>
00030 #include <shader.h>
00031 
00032 #include <planarQuad.h>         //Drawables
00033 #include <shadedPrim.h>
00034 
00035 #include <renderPass.h>         //RenderPass
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         // Constructors
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         // Inherited virtual functions
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 ); //Default is to return NULL;
00064 
00065 private:
00066         // Input Data
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         // Generated pointers that MUST be kept around
00075         RenderPass*      m_pass;
00076         PixelShader*     m_pixShader;
00077  
00078         // "House-cleaning" Pointers
00079         // - If OOGL had reference counting, these would not need to be here
00080         // - They are only here so that memory can be freed upon destruction
00081         TexCoordPerturb* m_texPerturb;
00082         ProgShader*              m_progShader;
00083         Shader*                  m_shader;
00084         RawPrim*                 m_quad;
00085         ShadedPrim*              m_shadedPrim;
00086 
00087         // Constructor/Init Helper
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         // Copy Constructor/Assig. Helpers
00094         void reset();   // Delete all instance-allocated memory.
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         // Used to create a shader with the correct callback
00102         // - This is defined here so that VS 6.0 can compile it.
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

Send questions, comments, and bug reports to:
jmk