Changeset 70


Ignore:
Timestamp:
06/01/13 00:24:07 (12 years ago)
Author:
epyon
Message:
  • etype -> datatype
  • types clarifications, and datatype_traits
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/gl/gl_device.hh

    r62 r70  
    2626                virtual index_buffer* create_index_buffer( buffer_hint hint, int size, void* source = nullptr );
    2727                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 );
    2929                virtual ~gl_device();
    3030        private:
  • trunk/nv/gl/gl_enum.hh

    r62 r70  
    3737        unsigned int primitive_to_enum( primitive p );
    3838
    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 );
    4141
    4242} // namespace nv
  • trunk/nv/gl/gl_texture2d.hh

    r62 r70  
    2222        {
    2323        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 );
    2525                virtual void assign( void* data );
    2626                virtual void bind( int slot = 0 );
  • trunk/nv/interface/device.hh

    r62 r70  
    3131                virtual index_buffer* create_index_buffer( buffer_hint hint, int size, void* source = nullptr ) = 0;
    3232                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;
    3434        };
    3535
  • trunk/nv/interface/program.hh

    r64 r70  
    2525        {
    2626        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 ) {}
    4029                const string& get_name() const { return m_name; }
    4130                int get_location() const { return m_location; }
    42                 etype get_type() const { return m_type; }
     31                datatype get_type() const { return m_type; }
    4332                int get_length() const { return m_length; }
    4433
    4534        protected:
    46                 string m_name;
    47                 int    m_location;
    48                 etype m_type;
    49                 int    m_length;
     35                string   m_name;
     36                int      m_location;
     37                datatype m_type;
     38                int      m_length;
    5039        };
    5140
     
    5342        {
    5443        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 )
    5645                        : 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; }
    5847                int get_location() const { return m_location; }
    5948                int get_length() const { return m_length; }
     
    6150                void clean() { m_dirty = false; }
    6251        protected:
    63                 string m_name;
    64                 etype m_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;
    6857        };
    6958
     
    164153                }
    165154        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 )
    167156                {
    168157                        switch( utype )
  • trunk/nv/interface/texture2d.hh

    r62 r70  
    6060        public:
    6161
    62                 texture2d( ivec2 size, image_format aformat, etype adatatype, sampler asampler ) :
     62                texture2d( ivec2 size, image_format aformat, datatype adatatype, sampler asampler ) :
    6363                        m_size( size ), m_format( aformat ), m_datatype( adatatype ), m_sampler( asampler ) {}
    6464                virtual void assign( void* data ) = 0;
     
    7070                int get_height() const { return m_size.y; }
    7171                image_format get_format() const { return m_format; }
    72                 etype get_datatype() const { return m_datatype; }
     72                datatype get_datatype() const { return m_datatype; }
    7373                const sampler& get_sampler() const { return m_sampler; }
    7474        protected:
    7575                ivec2        m_size;
    7676                image_format m_format;
    77                 etype         m_datatype;
     77                datatype     m_datatype;
    7878                sampler      m_sampler;
    7979        };
  • trunk/nv/interface/vertex_buffer.hh

    r62 r70  
    5858        {
    5959        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 )
    6161                        : m_buffer( buffer ), m_datatype( datatype ), m_components( components ), m_offset( offset ), m_stride( stride ), m_owner( owner ) {}
    6262
    6363                vertex_buffer* get_buffer() const { return m_buffer; }
    64                 etype get_datatype() const { return m_datatype; }
     64                datatype get_datatype() const { return m_datatype; }
    6565                int get_components() const { return m_components; }
    6666                int get_offset() const { return m_offset; }
     
    7676        protected:
    7777                vertex_buffer* m_buffer;
    78                 etype           m_datatype;
     78                datatype       m_datatype;
    7979                int  m_components;
    8080                int  m_offset;
     
    8989        public:
    9090                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 )
    9292                {
    9393                        m_map[ location ] = new vertex_buffer_attribute( buffer, datatype, components, offset, stride, owner );
  • trunk/nv/types.hh

    r68 r70  
    2020{
    2121
    22         enum etype
     22        enum datatype
    2323        {
    2424                INT,
     
    4444        };
    4545
    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;
    4981
    5082        typedef glm::vec2 vec2;
     
    6092        typedef glm::mat4 mat4;
    6193
    62         template < etype EnumType > struct enum_to_type {};
     94        template < datatype EnumType > struct enum_to_type {};
    6395
    6496        template <> struct enum_to_type< INT >   { typedef int type; };
     
    88120        template < typename TYPE > struct type_to_enum {};
    89121
    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; };
    113146
    114147        template <typename TYPE>
  • trunk/src/gl/gl_device.cc

    r62 r70  
    6767}
    6868
    69 texture2d* gl_device::create_texture2d( ivec2 size, image_format aformat, etype adatatype, sampler asampler, void* data /*= nullptr */ )
     69texture2d* gl_device::create_texture2d( ivec2 size, image_format aformat, datatype adatatype, sampler asampler, void* data /*= nullptr */ )
    7070{
    7171        return new gl_texture2d( size, aformat, adatatype, asampler, data );
  • trunk/src/gl/gl_enum.cc

    r68 r70  
    185185}
    186186
    187 unsigned int nv::type_to_gl_enum( etype type )
     187unsigned int nv::datatype_to_gl_enum( datatype type )
    188188{
    189189        switch( type )
     
    213213}
    214214
    215 nv::etype nv::gl_enum_to_type( unsigned int gl_enum )
     215nv::datatype nv::gl_enum_to_datatype( unsigned int gl_enum )
    216216{
    217217        switch( gl_enum )
     
    233233        case GL_INT_VEC3       : return INT_VECTOR_3;
    234234        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  
    156156                int attr_loc = glGetAttribLocation( m_name.get_value(), name.c_str() );
    157157
    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 );
    159159        }
    160160}
     
    180180
    181181                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 );
    183183                m_uniform_map[ name ] = create_uniform( utype, name, uni_loc, uni_len );
    184184        }
  • trunk/src/gl/gl_texture2d.cc

    r62 r70  
    1010using namespace nv;
    1111
    12 nv::gl_texture2d::gl_texture2d( ivec2 size, image_format aformat, etype adatatype, sampler asampler, void* data /*= nullptr */ )
     12nv::gl_texture2d::gl_texture2d( ivec2 size, image_format aformat, datatype adatatype, sampler asampler, void* data /*= nullptr */ )
    1313        : texture2d( size, aformat, adatatype, asampler ), m_name()
    1414{
     
    3131{
    3232        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 );
    3434        glBindTexture( GL_TEXTURE_2D, 0 );
    3535}
  • trunk/src/gl/gl_vertex_buffer.cc

    r44 r70  
    8989                        location,
    9090                        va->get_components(),
    91                         nv::type_to_gl_enum( va->get_datatype() ),
     91                        nv::datatype_to_gl_enum( va->get_datatype() ),
    9292                        GL_FALSE,
    9393                        va->get_stride(),
Note: See TracChangeset for help on using the changeset viewer.