00001
00016 #ifndef __UNIFORM_H_INCLUDED__
00017 #define __UNIFORM_H_INCLUDED__
00018
00019 #include <QtCore/QString>
00020 #include <QtOpenGL/QGLContext>
00021
00022
00023
00024
00025
00026
00048 class CUniform
00049 {
00050 public:
00051 CUniform( const QString & name=QString(), int type=0, int location=-1 );
00052 CUniform( const CUniform & u, int location );
00053 virtual ~CUniform( void );
00054
00059 enum baseType_e
00060 {
00061 BASE_TYPE_BAD = 0,
00062 BASE_TYPE_BOOL,
00063 BASE_TYPE_INT,
00064 BASE_TYPE_FLOAT,
00065 BASE_TYPE_SAMPLER,
00066 };
00067
00069 const QString & getName( void ) const { return m_name; }
00070
00072 int getType( void ) const { return m_type; }
00073
00075 QString getTypeName( void ) const { return getTypeNameString( m_type ); }
00076
00078 int getLocation( void ) const { return m_location; }
00079
00080
00081 int getComponentCount( void ) const;
00082 baseType_e getBaseType( void ) const;
00083
00084
00085 bool isMatrix( void ) const;
00086 int getColumnCount( void ) const;
00087 CUniform getColumnVector( int column ) const;
00088 void setColumnVector( int column, const CUniform & u );
00089
00090
00091
00092 bool getValueAsBool ( int component ) const;
00093 int getValueAsInt ( int component ) const;
00094 double getValueAsFloat( int component ) const;
00095 void setValueAsBool ( int component, bool value );
00096 void setValueAsInt ( int component, int value );
00097 void setValueAsFloat( int component, double value );
00098
00099
00100 void applyToGL( void );
00101
00102
00103 static QString getTypeNameString( int type );
00104
00105 private:
00106
00111 typedef union dataUnit_u {
00112 GLfloat _float [ 16 ];
00113 GLint _int [ 4 ];
00114 } dataUnit_t;
00115
00116 QString m_name;
00117 int m_type;
00118 int m_location;
00119 dataUnit_t m_data;
00120 };
00121
00122
00123
00124
00125
00126
00131 class IUniformState
00132 {
00133 public:
00134 virtual ~IUniformState( void ) {}
00135
00140 virtual int getActiveUniforms( void ) = 0;
00141
00149 virtual CUniform getUniform( int index ) = 0;
00150
00160 virtual void setUniform( int index, const CUniform & u ) = 0;
00161 };
00162
00163
00164
00165 #endif // __UNIFORM_H_INCLUDED__