00001 ////////////////////////////////////////////////////////////////////// 00002 // 6/6/02 Aaron Lefohn Scientific Computing and Imaging Institute 00003 // School of Computing University of Utah 00004 // 00005 // This library is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // This library is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with this library; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 00020 #if !defined(AFX_ATIPIXELSHADER_H__FC907450_D5EC_4CF6_B230_3EEDD8897081__INCLUDED_) 00021 #define AFX_ATIPIXELSHADER_H__FC907450_D5EC_4CF6_B230_3EEDD8897081__INCLUDED_ 00022 00023 #if _MSC_VER > 1000 00024 #pragma once 00025 #endif // _MSC_VER > 1000 00026 00027 #include "stateGLI.h" 00028 #include "pbuffGlift.h" 00029 #include <GL/glew.h> 00030 #include "../util/command.h" 00031 00032 namespace glift { 00033 00034 ///////////////////////////////////////////////////////////////////////// 00035 /// 00036 /// pixelShaderATI.h: interface for the PixelShaderATI class. 00037 /// 00038 /// - Class for an ATI fragment shader. 00039 /// 00040 /// - The constructor takes either a callback to a "void name()" routine 00041 /// or a MemberCommand0 callback object that encapsulates a calling class 00042 /// instance and a "void name()" method. The "void name()" function/method 00043 /// contains the code that actually defines the shader. 00044 /// 00045 /// Examples: 1) PixelShaderATI shader0 = new PixelShaderATI( shaderDefFunc ); 00046 /// 00047 // AClass a; 00048 // 2) PixelShaderATI shader3 = new PixelShaderATI( new MemberCommand0(&a, &a::shaderDefFunc) ); 00049 // **Note: ~PixelShaderATI() destroys the command (callback) object. 00050 // 00051 /// - The class constructor takes care of all state except the actual 00052 /// shader (eg. the first instruction in the callback should be 00053 /// 'glSampleMapATI(...)' or glPassTexCoordATI. The last instruction 00054 /// should be a write to R0. 00055 /// 00056 /// - Note that the bind/release methods do NOT ensure that 'm_pbuff' 00057 /// is enabled. If the shader is created inside a pbuffer context, 00058 /// it is up to you to make sure that the context is current before 00059 /// using the shader. This is for efficiency reasons. 00060 /// 00061 /// - The 'm_pbuff' context IS enabled/disabled for initialization and 00062 /// destruction of the shader. 00063 /////////////////////////////////////////////////////////////////////// 00064 class _export_ PixelShaderATI8K : public PixelShader 00065 { 00066 public: 00067 PixelShaderATI8K( VoidFuncPtr defineShader, PBuffGlift* pbuff=NULL ); 00068 PixelShaderATI8K( Command* defineShader, PBuffGlift* pbuff=NULL ); 00069 00070 PixelShaderATI8K( const PixelShaderATI8K& rhs ); 00071 PixelShaderATI8K& operator=( const PixelShaderATI8K& rhs ); 00072 virtual ~PixelShaderATI8K(); 00073 00074 virtual void reset(); //Destroy OpenGL shader object and re-initialize shader. 00075 virtual void setLocalConstf( unsigned int constNum, const gutz::vec4f& val ); 00076 00077 protected: 00078 virtual void bindDef(); 00079 virtual void releaseDef(); 00080 00081 private: 00082 Command* m_defineShader; /// Callback to function or method that defines shader of type 'void Name()' 00083 GLuint m_shaderNum; /// OpenGL shader object number 00084 PBuffGlift* m_pbuff; /// The pbuffer context in which this shader exists (optional) 00085 00086 void init(); 00087 void destroy(); 00088 void initMembers( const PixelShaderATI8K& rhs ); 00089 void initMembers( Command* defineShader, GLuint shaderNum, PBuffGlift* pbuff ); 00090 }; 00091 00092 } /// End of namespace glift 00093 00094 #endif /// !defined(AFX_ATIPIXELSHADER_H__FC907450_D5EC_4CF6_B230_3EEDD8897081__INCLUDED_)