nux-1.14.0
GLShaderParameter.h
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef GLSHADERPARAMETER_H
00024 #define GLSHADERPARAMETER_H
00025 
00026 #include "GLError.h"
00027 #include "GLResource.h"
00028 
00029 namespace nux
00030 {
00031 
00033   enum eShaderParameterType
00034   {
00035     eVERTEXUNIFORMTYPE,
00036     eFRAGMENTUNIFORMTYPE,
00037     eSAMPLERUNIFORMTYPE,
00038   };
00039 
00041   enum eShaderType
00042   {
00043     eVERTEXSHADERTYPE,
00044     eFRAGMENTSHADERTYPE
00045   };
00046   class GLProgramObject;
00047   class IOpenGLShaderProgram;
00048 
00049   class GLShaderParameter
00050   {
00051   public:
00052     int                      m_Index;                  // Register m_Index / Attribute m_Index
00053     eShaderParameterType        m_ShaderParameterType;
00054     NString                     m_Name;
00055     bool                       m_bIsOptional;
00056     bool                       m_bIsStatic;
00057     bool                       bStaticSet;
00058     GLProgramObject            *m_ShaderProgram;
00059     IOpenGLShaderProgram       *m_ShaderProgram2;
00060     GLShaderParameter          *m_NextParameter;
00061     UINT                        m_Size;
00062     UINT                        m_Type;
00063 
00064     GLShaderParameter (GLProgramObject *Shader,
00065                        const TCHAR *ParamName,
00066                        eShaderParameterType InType,
00067                        bool InbIsOptional = FALSE,
00068                        bool InbIsStatic = FALSE);
00069 
00070     inline void SetUniform1f ( FLOAT FloatA )
00071     {
00072       NUX_RETURN_IF_TRUE(m_Index == -1);
00073       CHECKGL ( glUniform1fARB ( m_Index, FloatA ) );
00074     }
00075     inline void SetUniform1i ( INT i )
00076     {
00077       NUX_RETURN_IF_TRUE(m_Index == -1);
00078       CHECKGL ( glUniform1iARB ( m_Index, i ) );
00079     }
00080     inline void SetUniform2f ( FLOAT FloatA, FLOAT FloatB )
00081     {
00082       NUX_RETURN_IF_TRUE(m_Index == -1);
00083       CHECKGL ( glUniform2fARB ( m_Index, FloatA, FloatB ) );
00084     }
00085     inline void SetUniform3f ( FLOAT FloatA, FLOAT FloatB, FLOAT FloatC )
00086     {
00087       NUX_RETURN_IF_TRUE(m_Index == -1);
00088       CHECKGL ( glUniform3fARB ( m_Index, FloatA, FloatB, FloatC ) );
00089     }
00090     inline void SetUniform4f ( FLOAT FloatA, FLOAT FloatB, FLOAT FloatC, FLOAT FloatD )
00091     {
00092       NUX_RETURN_IF_TRUE(m_Index == -1);
00093       CHECKGL ( glUniform4fARB ( m_Index, FloatA, FloatB, FloatC, FloatD ) );
00094     }
00095 
00096     inline void SetUniform1fv ( GLsizei count, GLfloat *value )
00097     {
00098       NUX_RETURN_IF_TRUE(m_Index == -1);
00099       CHECKGL ( glUniform1fvARB ( m_Index, count, value ) );
00100     }
00101 
00102     inline void SetUniform2fv ( GLsizei count, GLfloat *value )
00103     {
00104       NUX_RETURN_IF_TRUE(m_Index == -1);
00105       CHECKGL ( glUniform2fvARB ( m_Index, count, value ) );
00106     }
00107 
00108     inline void SetUniform3fv ( GLsizei count, GLfloat *value )
00109     {
00110       NUX_RETURN_IF_TRUE(m_Index == -1);
00111       CHECKGL ( glUniform3fvARB ( m_Index, count, value ) );
00112     }
00113 
00114     inline void SetUniform4fv ( GLsizei count, GLfloat *value )
00115     {
00116       NUX_RETURN_IF_TRUE(m_Index == -1);
00117       CHECKGL ( glUniform4fvARB ( m_Index, count, value ) );
00118     }
00119 
00120     inline void SetUniformMatrix2fv ( GLsizei count, GLfloat *value, GLboolean transpose = GL_FALSE )
00121     {
00122       NUX_RETURN_IF_TRUE(m_Index == -1);
00123       CHECKGL ( glUniformMatrix2fvARB ( m_Index, count, transpose, value ) );
00124     }
00125 
00126     inline void SetUniformMatrix3fv ( GLsizei count, GLfloat *value, GLboolean transpose = GL_FALSE )
00127     {
00128       NUX_RETURN_IF_TRUE(m_Index == -1);
00129       CHECKGL ( glUniformMatrix3fvARB ( m_Index, count, transpose, value ) );
00130     }
00131 
00132     inline void SetUniformMatrix4fv ( GLsizei count, GLfloat *value, GLboolean transpose = GL_FALSE )
00133     {
00134       NUX_RETURN_IF_TRUE(m_Index == -1);
00135       CHECKGL ( glUniformMatrix4fvARB ( m_Index, count, transpose, value ) );
00136     }
00137 
00138 
00139     inline void SetTexture ( const GLuint textureId )
00140     {
00141       //CHECKGL( glUniform1iARB( m_Index, textureId ) );
00142       //CHECKGL( cgGLEnableTextureParameter( CgParameter ) );
00143     }
00144 
00145     void MapTo ( GLProgramObject *Shader );
00146 
00147   private:
00148 
00149   };
00150 }
00151 
00152 #endif // GLSHADERPARAMETER_H
00153 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends