Changeset 237 for trunk


Ignore:
Timestamp:
05/14/14 19:08:41 (11 years ago)
Author:
epyon
Message:
  • debug_draw module added
  • evil vertex descriptor and info added
  • fix for sampler objects
  • various fixes
Location:
trunk
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/common.hh

    r204 r237  
    101101
    102102#if NV_COMPILER == NV_MSVC
    103 #pragma warning(disable: 4201)
    104 #undef _SCL_SECURE_NO_WARNINGS // to prevent redefinig
     103#pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union
     104#pragma warning( disable : 4510 ) // default constructor could not be generated
     105#pragma warning( disable : 4610 ) // object 'class' can never be instantiated - user-defined constructor required
     106#undef _SCL_SECURE_NO_WARNINGS // to prevent redefining
    105107#define _SCL_SECURE_NO_WARNINGS
    106108#endif
     
    170172        typedef uint64 uid;
    171173
     174        struct empty_type {};
     175
    172176} // namespace nv
    173177
  • trunk/nv/interface/device.hh

    r236 r237  
    5555                        return result;
    5656                }
     57
     58                template < typename VTX, slot SLOT >
     59                void add_vertex_buffer_impl( vertex_array*, vertex_buffer*, const std::false_type& )
     60                {
     61                }
     62
     63                template < typename VTX, slot SLOT >
     64                void add_vertex_buffer_impl( vertex_array* va, vertex_buffer* vb, const std::true_type& )
     65                {
     66                        typedef vertex_slot_info< VTX, SLOT > vinfo;
     67                        typedef datatype_traits< typename vinfo::value_type > dt_traits;
     68                        va->add_vertex_buffer( SLOT, vb, type_to_enum< dt_traits::base_type >::type, dt_traits::size, vinfo::offset, sizeof( VTX ), false );
     69                }
     70
     71                template < typename VTX, slot SLOT >
     72                void add_vertex_buffer( vertex_array* va, vertex_buffer* vb )
     73                {
     74                        add_vertex_buffer_impl< VTX, SLOT >( va, vb, std::integral_constant< bool, vertex_has_slot< VTX, SLOT >::value >() );
     75                }
     76
     77
     78                template < typename VTX >
     79                vertex_array* create_vertex_array( const VTX* v, size_t count, buffer_hint hint )
     80                {
     81                        vertex_array*  va = create_vertex_array();
     82                        vertex_buffer* vb = create_vertex_buffer( hint, count * sizeof( VTX ), v );
     83                        add_vertex_buffer< VTX, slot::POSITION >  ( va, vb );
     84                        add_vertex_buffer< VTX, slot::TEXCOORD >  ( va, vb );
     85                        add_vertex_buffer< VTX, slot::NORMAL   >  ( va, vb );
     86                        add_vertex_buffer< VTX, slot::TANGENT >   ( va, vb );
     87                        add_vertex_buffer< VTX, slot::BONEINDEX > ( va, vb );
     88                        add_vertex_buffer< VTX, slot::BONEWEIGHT >( va, vb );
     89                        add_vertex_buffer< VTX, slot::COLOR >     ( va, vb );
     90                        return va;
     91                }
     92
     93                template < typename VTX >
     94                vertex_array* create_vertex_array( const std::vector< VTX >& data, buffer_hint hint )
     95                {
     96                        return create_vertex_array( data.data(), data.size(), hint );
     97                }
     98
     99                template < typename VTX, typename IDX >
     100                vertex_array* create_vertex_array( const VTX* v, size_t vcount, const IDX* i, size_t icount, buffer_hint hint )
     101                {
     102                        vertex_array* va = create_vertex_array( v, vcount, hint );
     103                        index_buffer* ib = create_index_buffer( hint, icount * sizeof( IDX ), i );
     104                        va->set_index_buffer( ib, type_to_enum< IDX >::type, true );
     105                        return va;
     106                }
     107
     108                template < typename VTX, typename IDX >
     109                vertex_array* create_vertex_array( const std::vector< VTX >& data, const std::vector< IDX >& idata, buffer_hint hint )
     110                {
     111                        return create_vertex_array( data.data(), data.size(), idata.data(), idata.size(), hint );
     112                }
     113
    57114                virtual ~device() {}
    58115        };
  • trunk/nv/interface/program.hh

    r235 r237  
    1515#include <unordered_map>
    1616#include <nv/interface/uniform.hh>
     17#include <nv/interface/vertex.hh>
    1718#include <nv/logging.hh>
    1819#include <nv/exception.hh>
     
    2425{
    2526        class camera;
    26 
    27         enum slot
    28         {
    29                 POSITION   = 0,
    30                 TEXCOORD   = 1,
    31                 NORMAL     = 2,
    32                 TANGENT    = 3,
    33                 BONEINDEX  = 4,
    34                 BONEWEIGHT = 5,
    35                 COLOR      = 6,
    36         };
    3727
    3828        enum texture_slot
  • trunk/nv/math.hh

    r235 r237  
    8383        enum datatype
    8484        {
     85                NONE,
    8586                INT,
    8687                BYTE,
     
    107108        template < datatype EnumType > struct enum_to_type {};
    108109
     110        template <> struct enum_to_type< NONE >  { typedef void type; };
    109111        template <> struct enum_to_type< INT >   { typedef int type; };
    110112        template <> struct enum_to_type< UINT >  { typedef unsigned int type; };
     
    160162        template <> struct type_to_enum< mat4 > { static const datatype type = FLOAT_MATRIX_4; };
    161163
     164        template < typename T >
     165        struct sizeof_type
     166        {
     167                static const int result = sizeof( T );
     168        };
     169
     170        template <>
     171        struct sizeof_type< void >
     172        {
     173                static const int result = 0;
     174        };
     175
     176        template < datatype T >
     177        struct sizeof_enum_type
     178        {
     179                static const int result = sizeof_type< typename enum_to_type<T>::type >::result;
     180        };
     181
    162182
    163183} // namespace nv
  • trunk/src/gfx/skeletal_mesh.cc

    r231 r237  
    5858        // Technically this is not needed, because the va is just a fake class,
    5959        // but if it's real it will be needed?
    60         m_va->update_vertex_buffer( nv::slot::POSITION, m_vb_position, false );
    61         m_va->update_vertex_buffer( nv::slot::NORMAL,   m_vb_normal,   false );
    62         m_va->update_vertex_buffer( nv::slot::TANGENT,  m_vb_tangent,  false );
     60//      m_va->update_vertex_buffer( nv::slot::POSITION, m_vb_position, false );
     61//      m_va->update_vertex_buffer( nv::slot::NORMAL,   m_vb_normal,   false );
     62//      m_va->update_vertex_buffer( nv::slot::TANGENT,  m_vb_tangent,  false );
     63        // TODO: answer is - probably not
    6364}
    6465
  • trunk/src/gl/gl_enum.cc

    r233 r237  
    246246        case GL_INT_VEC3       : return INT_VECTOR_3;
    247247        case GL_INT_VEC4       : return INT_VECTOR_4;
     248// TODO: separate types?
     249        case GL_SAMPLER_1D         : return INT;
     250        case GL_SAMPLER_2D         : return INT;
     251        case GL_SAMPLER_3D         : return INT;
     252        case GL_SAMPLER_CUBE       : return INT;
     253        case GL_SAMPLER_1D_SHADOW  : return INT;       
     254        case GL_SAMPLER_2D_SHADOW  : return INT;
     255// TODO: implement?
     256//      case GL_BOOL   
     257//      case GL_BOOL_VEC2
     258//      case GL_BOOL_VEC3
     259//      case GL_BOOL_VEC4
     260//      case GL_FLOAT_MAT2x3   
     261//      case GL_FLOAT_MAT2x4   
     262//      case GL_FLOAT_MAT3x2   
     263//      case GL_FLOAT_MAT3x4   
     264//      case GL_FLOAT_MAT4x2   
     265//      case GL_FLOAT_MAT4x3   
    248266        default : return datatype(0); // TODO: throw!
    249267        }
  • trunk/src/gl/gl_program.cc

    r235 r237  
    197197                }
    198198
    199                 m_uniform_map[ name ] = create_uniform( utype, name, uni_loc, uni_len );
     199                uniform_base* u = create_uniform( utype, name, uni_loc, uni_len );
     200                NV_ASSERT( u, "Unknown uniform type!" );
     201                m_uniform_map[ name ] = u;
    200202        }
    201203
  • trunk/tests/objload_test/objload_test.cc

    r224 r237  
    3232        nv::vertex_array* m_va;
    3333        nv::program*      m_program;
    34         nv::mesh_data*    m_mesh;
     34        nv::mesh_data_old* m_mesh;
    3535        nv::uint32        m_count;
    3636};
     
    3939{
    4040        m_device = new nv::gl_device();
    41         m_window = m_device->create_window( 800, 600 );
     41        m_window = m_device->create_window( 800, 600, false );
    4242        nv::sampler sampler( nv::sampler::LINEAR, nv::sampler::REPEAT );
    4343       
Note: See TracChangeset for help on using the changeset viewer.