Changeset 235 for trunk/nv/interface/uniform.hh
- Timestamp:
- 05/12/14 16:52:16 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/interface/uniform.hh
r232 r235 32 32 bool is_dirty() const { return m_dirty; } 33 33 void clean() { m_dirty = false; } 34 virtual ~uniform_base() {} 34 35 protected: 35 36 string m_name; … … 47 48 48 49 uniform( const string& name, int location, int length ) 49 : uniform_base( name, type_to_enum< T >::type, location, length ), m_value() 50 {} 50 : uniform_base( name, type_to_enum< T >::type, location, length ), m_value( nullptr ) 51 { 52 m_value = new T[ m_length ]; 53 } 51 54 52 55 void set_value( const T& value ) 53 56 { 54 if ( value != m_value ) 57 NV_ASSERT( m_length == 1, "set_value on array uniform!" ); 58 if ( value != m_value[0] ) 55 59 { 56 m_value = value;60 m_value[0] = value; 57 61 m_dirty = true; 58 62 } 59 63 } 60 64 61 const T& get_value() { return m_value; } 65 void set_value( const T* value, uint32 count ) 66 { 67 // TODO: memcmp? 68 std::copy( value, value + count, m_value ); 69 m_dirty = true; 70 } 71 72 const T* get_value() { return m_value; } 73 virtual ~uniform() 74 { 75 delete[] m_value; 76 } 62 77 protected: 63 T m_value;78 T* m_value; 64 79 }; 65 80 … … 145 160 }; 146 161 162 class engine_uniform_m_model_inv : public engine_uniform< mat4 > 163 { 164 public: 165 engine_uniform_m_model_inv( uniform_base* u ) : engine_uniform( u ) {} 166 virtual void set( const context* , const scene_state* s ) { m_uniform->set_value( s->get_model_inv() ); } 167 }; 168 147 169 class engine_uniform_m_modelview : public engine_uniform< mat4 > 148 170 { … … 173 195 }; 174 196 197 class engine_uniform_v_camera_position : public engine_uniform< vec3 > 198 { 199 public: 200 engine_uniform_v_camera_position( uniform_base* u ) : engine_uniform( u ) {} 201 virtual void set( const context* , const scene_state* s ) { m_uniform->set_value( s->get_camera().get_position() ); } 202 }; 203 204 class engine_uniform_v_camera_direction : public engine_uniform< vec3 > 205 { 206 public: 207 engine_uniform_v_camera_direction( uniform_base* u ) : engine_uniform( u ) {} 208 virtual void set( const context* , const scene_state* s ) { m_uniform->set_value( s->get_camera().get_direction() ); } 209 }; 210 175 211 template< int VALUE > 176 212 class engine_link_uniform_int : public engine_link_uniform< int >
Note: See TracChangeset
for help on using the changeset viewer.