- Timestamp:
- 06/01/13 00:24:07 (12 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/gl/gl_device.hh
r62 r70 26 26 virtual index_buffer* create_index_buffer( buffer_hint hint, int size, void* source = nullptr ); 27 27 virtual vertex_array* create_vertex_array(); 28 virtual texture2d* create_texture2d( ivec2 size, image_format aformat, etype adatatype, sampler asampler, void* data = nullptr );28 virtual texture2d* create_texture2d( ivec2 size, image_format aformat, datatype adatatype, sampler asampler, void* data = nullptr ); 29 29 virtual ~gl_device(); 30 30 private: -
trunk/nv/gl/gl_enum.hh
r62 r70 37 37 unsigned int primitive_to_enum( primitive p ); 38 38 39 unsigned int type_to_gl_enum( etype type );40 etype gl_enum_to_type( unsigned int gl_enum );39 unsigned int datatype_to_gl_enum( datatype type ); 40 datatype gl_enum_to_datatype( unsigned int gl_enum ); 41 41 42 42 } // namespace nv -
trunk/nv/gl/gl_texture2d.hh
r62 r70 22 22 { 23 23 public: 24 gl_texture2d( ivec2 size, image_format aformat, etype adatatype, sampler asampler, void* data = nullptr );24 gl_texture2d( ivec2 size, image_format aformat, datatype adatatype, sampler asampler, void* data = nullptr ); 25 25 virtual void assign( void* data ); 26 26 virtual void bind( int slot = 0 ); -
trunk/nv/interface/device.hh
r62 r70 31 31 virtual index_buffer* create_index_buffer( buffer_hint hint, int size, void* source = nullptr ) = 0; 32 32 virtual vertex_array* create_vertex_array() = 0; 33 virtual texture2d* create_texture2d( ivec2 size, image_format aformat, etype adatatype, sampler asampler, void* data = nullptr ) = 0;33 virtual texture2d* create_texture2d( ivec2 size, image_format aformat, datatype adatatype, sampler asampler, void* data = nullptr ) = 0; 34 34 }; 35 35 -
trunk/nv/interface/program.hh
r64 r70 25 25 { 26 26 public: 27 attribute( 28 const string& name, 29 int location, 30 etype type, 31 int length ) : 32 m_name( name ), 33 m_location( location ), 34 m_type( type ), 35 m_length( length ) 36 { 37 38 } 39 27 attribute( const string& name, int location, datatype type, int length ) : 28 m_name( name ), m_location( location ), m_type( type ), m_length( length ) {} 40 29 const string& get_name() const { return m_name; } 41 30 int get_location() const { return m_location; } 42 etype get_type() const { return m_type; }31 datatype get_type() const { return m_type; } 43 32 int get_length() const { return m_length; } 44 33 45 34 protected: 46 string m_name;47 int m_location;48 etypem_type;49 int m_length;35 string m_name; 36 int m_location; 37 datatype m_type; 38 int m_length; 50 39 }; 51 40 … … 53 42 { 54 43 public: 55 uniform_base( const string& name, etype type, int location, int length )44 uniform_base( const string& name, datatype type, int location, int length ) 56 45 : m_name( name ), m_type( type ), m_location(location), m_length( length ), m_dirty( true ) {} 57 etype get_type() const { return m_type; }46 datatype get_type() const { return m_type; } 58 47 int get_location() const { return m_location; } 59 48 int get_length() const { return m_length; } … … 61 50 void clean() { m_dirty = false; } 62 51 protected: 63 string m_name;64 etypem_type;65 int m_location;66 int m_length;67 bool m_dirty;52 string m_name; 53 datatype m_type; 54 int m_location; 55 int m_length; 56 bool m_dirty; 68 57 }; 69 58 … … 164 153 } 165 154 protected: 166 uniform_base* create_uniform( etype utype, const string& name, int location, int length )155 uniform_base* create_uniform( datatype utype, const string& name, int location, int length ) 167 156 { 168 157 switch( utype ) -
trunk/nv/interface/texture2d.hh
r62 r70 60 60 public: 61 61 62 texture2d( ivec2 size, image_format aformat, etype adatatype, sampler asampler ) :62 texture2d( ivec2 size, image_format aformat, datatype adatatype, sampler asampler ) : 63 63 m_size( size ), m_format( aformat ), m_datatype( adatatype ), m_sampler( asampler ) {} 64 64 virtual void assign( void* data ) = 0; … … 70 70 int get_height() const { return m_size.y; } 71 71 image_format get_format() const { return m_format; } 72 etype get_datatype() const { return m_datatype; }72 datatype get_datatype() const { return m_datatype; } 73 73 const sampler& get_sampler() const { return m_sampler; } 74 74 protected: 75 75 ivec2 m_size; 76 76 image_format m_format; 77 etypem_datatype;77 datatype m_datatype; 78 78 sampler m_sampler; 79 79 }; -
trunk/nv/interface/vertex_buffer.hh
r62 r70 58 58 { 59 59 public: 60 vertex_buffer_attribute( vertex_buffer* buffer, etype datatype, int components, int offset = 0, int stride = 0, bool owner = true )60 vertex_buffer_attribute( vertex_buffer* buffer, datatype datatype, int components, int offset = 0, int stride = 0, bool owner = true ) 61 61 : m_buffer( buffer ), m_datatype( datatype ), m_components( components ), m_offset( offset ), m_stride( stride ), m_owner( owner ) {} 62 62 63 63 vertex_buffer* get_buffer() const { return m_buffer; } 64 etype get_datatype() const { return m_datatype; }64 datatype get_datatype() const { return m_datatype; } 65 65 int get_components() const { return m_components; } 66 66 int get_offset() const { return m_offset; } … … 76 76 protected: 77 77 vertex_buffer* m_buffer; 78 etypem_datatype;78 datatype m_datatype; 79 79 int m_components; 80 80 int m_offset; … … 89 89 public: 90 90 vertex_array() : m_map(), m_index( nullptr ) {} 91 void add_vertex_buffer( int location, vertex_buffer* buffer, etype datatype, int components, int offset = 0, int stride = 0, bool owner = true )91 void add_vertex_buffer( int location, vertex_buffer* buffer, datatype datatype, int components, int offset = 0, int stride = 0, bool owner = true ) 92 92 { 93 93 m_map[ location ] = new vertex_buffer_attribute( buffer, datatype, components, offset, stride, owner ); -
trunk/nv/types.hh
r68 r70 20 20 { 21 21 22 enum etype22 enum datatype 23 23 { 24 24 INT, … … 44 44 }; 45 45 46 typedef glm::detail::tvec2<uint8> i8vec2; 47 typedef glm::detail::tvec3<uint8> i8vec3; 48 typedef glm::detail::tvec4<uint8> i8vec4; 46 template <typename T> 47 struct etype_traits 48 { 49 typedef T type; 50 typedef T base_type; 51 static const size_t size = 1; 52 }; 53 54 template <typename T> 55 struct etype_traits< glm::detail::tvec2<T> > 56 { 57 typedef glm::detail::tvec2<T> type; 58 typedef typename type::value_type base_type; 59 static const size_t size = 2; 60 }; 61 62 template <typename T> 63 struct etype_traits< glm::detail::tvec3<T> > 64 { 65 typedef glm::detail::tvec3<T> type; 66 typedef typename type::value_type base_type; 67 static const size_t size = 3; 68 }; 69 70 template <typename T> 71 struct etype_traits< glm::detail::tvec4<T> > 72 { 73 typedef glm::detail::tvec4<T> type; 74 typedef typename type::value_type base_type; 75 static const size_t size = 4; 76 }; 77 78 typedef glm::detail::tvec2<sint8> i8vec2; 79 typedef glm::detail::tvec3<sint8> i8vec3; 80 typedef glm::detail::tvec4<sint8> i8vec4; 49 81 50 82 typedef glm::vec2 vec2; … … 60 92 typedef glm::mat4 mat4; 61 93 62 template < etype EnumType > struct enum_to_type {};94 template < datatype EnumType > struct enum_to_type {}; 63 95 64 96 template <> struct enum_to_type< INT > { typedef int type; }; … … 88 120 template < typename TYPE > struct type_to_enum {}; 89 121 90 template <> struct type_to_enum< int > { static const etype type = INT; }; 91 template <> struct type_to_enum< unsigned int > { static const etype type = UINT; }; 92 template <> struct type_to_enum< short > { static const etype type = SHORT; }; 93 template <> struct type_to_enum< unsigned short >{ static const etype type = USHORT; }; 94 template <> struct type_to_enum< char > { static const etype type = BYTE; }; 95 template <> struct type_to_enum< unsigned char > { static const etype type = UBYTE; }; 96 template <> struct type_to_enum< f32 > { static const etype type = FLOAT; }; 97 98 template <> struct type_to_enum< vec2 > { static const etype type = FLOAT_VECTOR_2; }; 99 template <> struct type_to_enum< vec3 > { static const etype type = FLOAT_VECTOR_3; }; 100 template <> struct type_to_enum< vec4 > { static const etype type = FLOAT_VECTOR_4; }; 101 102 template <> struct type_to_enum< ivec2 > { static const etype type = INT_VECTOR_2; }; 103 template <> struct type_to_enum< ivec3 > { static const etype type = INT_VECTOR_3; }; 104 template <> struct type_to_enum< ivec4 > { static const etype type = INT_VECTOR_4; }; 105 106 template <> struct type_to_enum< i8vec2 > { static const etype type = BYTE_VECTOR_2; }; 107 template <> struct type_to_enum< i8vec3 > { static const etype type = BYTE_VECTOR_3; }; 108 template <> struct type_to_enum< i8vec4 > { static const etype type = BYTE_VECTOR_4; }; 109 110 template <> struct type_to_enum< mat2 > { static const etype type = FLOAT_MATRIX_2; }; 111 template <> struct type_to_enum< mat3 > { static const etype type = FLOAT_MATRIX_3; }; 112 template <> struct type_to_enum< mat4 > { static const etype type = FLOAT_MATRIX_4; }; 122 template <> struct type_to_enum< int > { static const datatype type = INT; }; 123 template <> struct type_to_enum< unsigned int > { static const datatype type = UINT; }; 124 template <> struct type_to_enum< short > { static const datatype type = SHORT; }; 125 template <> struct type_to_enum< unsigned short >{ static const datatype type = USHORT; }; 126 template <> struct type_to_enum< char > { static const datatype type = BYTE; }; 127 template <> struct type_to_enum< signed char > { static const datatype type = BYTE; }; 128 template <> struct type_to_enum< unsigned char > { static const datatype type = UBYTE; }; 129 template <> struct type_to_enum< f32 > { static const datatype type = FLOAT; }; 130 131 template <> struct type_to_enum< vec2 > { static const datatype type = FLOAT_VECTOR_2; }; 132 template <> struct type_to_enum< vec3 > { static const datatype type = FLOAT_VECTOR_3; }; 133 template <> struct type_to_enum< vec4 > { static const datatype type = FLOAT_VECTOR_4; }; 134 135 template <> struct type_to_enum< ivec2 > { static const datatype type = INT_VECTOR_2; }; 136 template <> struct type_to_enum< ivec3 > { static const datatype type = INT_VECTOR_3; }; 137 template <> struct type_to_enum< ivec4 > { static const datatype type = INT_VECTOR_4; }; 138 139 template <> struct type_to_enum< i8vec2 > { static const datatype type = BYTE_VECTOR_2; }; 140 template <> struct type_to_enum< i8vec3 > { static const datatype type = BYTE_VECTOR_3; }; 141 template <> struct type_to_enum< i8vec4 > { static const datatype type = BYTE_VECTOR_4; }; 142 143 template <> struct type_to_enum< mat2 > { static const datatype type = FLOAT_MATRIX_2; }; 144 template <> struct type_to_enum< mat3 > { static const datatype type = FLOAT_MATRIX_3; }; 145 template <> struct type_to_enum< mat4 > { static const datatype type = FLOAT_MATRIX_4; }; 113 146 114 147 template <typename TYPE> -
trunk/src/gl/gl_device.cc
r62 r70 67 67 } 68 68 69 texture2d* gl_device::create_texture2d( ivec2 size, image_format aformat, etype adatatype, sampler asampler, void* data /*= nullptr */ )69 texture2d* gl_device::create_texture2d( ivec2 size, image_format aformat, datatype adatatype, sampler asampler, void* data /*= nullptr */ ) 70 70 { 71 71 return new gl_texture2d( size, aformat, adatatype, asampler, data ); -
trunk/src/gl/gl_enum.cc
r68 r70 185 185 } 186 186 187 unsigned int nv:: type_to_gl_enum( etype type )187 unsigned int nv::datatype_to_gl_enum( datatype type ) 188 188 { 189 189 switch( type ) … … 213 213 } 214 214 215 nv:: etype nv::gl_enum_to_type( unsigned int gl_enum )215 nv::datatype nv::gl_enum_to_datatype( unsigned int gl_enum ) 216 216 { 217 217 switch( gl_enum ) … … 233 233 case GL_INT_VEC3 : return INT_VECTOR_3; 234 234 case GL_INT_VEC4 : return INT_VECTOR_4; 235 default : return etype(0); // TODO: throw!236 } 237 } 235 default : return datatype(0); // TODO: throw! 236 } 237 } -
trunk/src/gl/gl_program.cc
r62 r70 156 156 int attr_loc = glGetAttribLocation( m_name.get_value(), name.c_str() ); 157 157 158 m_attribute_map[ name ] = new attribute( name, attr_loc, gl_enum_to_ type( attr_type ), attr_len );158 m_attribute_map[ name ] = new attribute( name, attr_loc, gl_enum_to_datatype( attr_type ), attr_len ); 159 159 } 160 160 } … … 180 180 181 181 int uni_loc = glGetUniformLocation( m_name.get_value(), name.c_str() ); 182 etype utype = gl_enum_to_type( uni_type );182 datatype utype = gl_enum_to_datatype( uni_type ); 183 183 m_uniform_map[ name ] = create_uniform( utype, name, uni_loc, uni_len ); 184 184 } -
trunk/src/gl/gl_texture2d.cc
r62 r70 10 10 using namespace nv; 11 11 12 nv::gl_texture2d::gl_texture2d( ivec2 size, image_format aformat, etype adatatype, sampler asampler, void* data /*= nullptr */ )12 nv::gl_texture2d::gl_texture2d( ivec2 size, image_format aformat, datatype adatatype, sampler asampler, void* data /*= nullptr */ ) 13 13 : texture2d( size, aformat, adatatype, asampler ), m_name() 14 14 { … … 31 31 { 32 32 glBindTexture( GL_TEXTURE_2D, m_name.get_value() ); 33 glTexImage2D( GL_TEXTURE_2D, 0, nv::image_format_to_enum(m_format), m_size.x, m_size.y, 0, nv::image_format_to_enum(m_format), nv:: type_to_gl_enum(m_datatype), data );33 glTexImage2D( GL_TEXTURE_2D, 0, nv::image_format_to_enum(m_format), m_size.x, m_size.y, 0, nv::image_format_to_enum(m_format), nv::datatype_to_gl_enum(m_datatype), data ); 34 34 glBindTexture( GL_TEXTURE_2D, 0 ); 35 35 } -
trunk/src/gl/gl_vertex_buffer.cc
r44 r70 89 89 location, 90 90 va->get_components(), 91 nv:: type_to_gl_enum( va->get_datatype() ),91 nv::datatype_to_gl_enum( va->get_datatype() ), 92 92 GL_FALSE, 93 93 va->get_stride(),
Note: See TracChangeset
for help on using the changeset viewer.