Changeset 319 for trunk/tests


Ignore:
Timestamp:
08/21/14 04:02:01 (11 years ago)
Author:
epyon
Message:
  • created core module and moved all free source files there
  • took the opportunity to update all copyright lines and minor cleanup
  • minor fixes
  • not all examples are up to date
Location:
trunk/tests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/cachebuf_test/nv_cachebuf_test.cc

    r214 r319  
    1 #include <nv/interface/vertex_buffer.hh>
    21#include <nv/gl/gl_device.hh>
    32#include <nv/gfx/image.hh>
    43#include <nv/interface/context.hh>
    54#include <nv/interface/window.hh>
    6 #include <nv/interface/program.hh>
    7 #include <nv/interface/texture2d.hh>
    8 #include <nv/logging.hh>
    9 #include <nv/logger.hh>
     5#include <nv/core/logging.hh>
     6#include <nv/core/logger.hh>
    107#include <glm/glm.hpp>
    118#include <glm/gtc/matrix_transform.hpp>
    129#include <glm/gtc/type_ptr.hpp>
    13 #include <nv/string.hh>
    14 #include <nv/interface/mesh.hh>
     10#include <nv/core/string.hh>
    1511#include <cstdlib> // rand
    1612#include <ctime> // time
     
    222218        ~application();
    223219protected:
    224         nv::device* m_device;
    225         nv::window* m_window;
     220        nv::device*  m_device;
     221        nv::context* m_context;
     222        nv::window*  m_window;
    226223        nv::clear_state m_clear_state;
    227224        nv::render_state m_render_state;
     
    230227        std::vector<app_window>  m_windows;
    231228
    232         nv::program* m_program;
    233         nv::vertex_array* m_va;
     229        nv::program      m_program;
     230        nv::vertex_array  m_va;
    234231        unsigned int m_count;
    235232};
     
    237234application::application()
    238235{
    239         m_device = new nv::gl_device();
    240         m_window = m_device->create_window( 800, 600 );
     236        m_device  = new nv::gl_device();
     237        m_window  = m_device->create_window( 800, 600, false );
     238        m_context = m_window->get_context();
    241239
    242240        m_clear_state.buffers = nv::clear_state::COLOR_AND_DEPTH_BUFFER;
     
    254252        {
    255253                m_program   = m_device->create_program( nv::slurp( "cachebuf.vert" ), nv::slurp( "cachebuf.frag" ) );
    256                 m_va        = m_device->create_vertex_array();
    257 
    258                 #ifdef INDEXED_TEST
    259                 m_quad_cache = new gcache( m_device, nv::DYNAMIC_DRAW, 200, 200 );
    260                 m_va->set_index_buffer( m_quad_cache->get_index_buffer(), nv::USHORT, false );
    261                 nv::vertex_buffer* buffer = m_quad_cache->get_vertex_buffer();
    262                 #else
    263                 m_quad_cache = new gcache( m_device, nv::DYNAMIC_DRAW, 20, true );
    264                 nv::vertex_buffer* buffer = (nv::vertex_buffer*)m_quad_cache->get_buffer();
    265                 #endif
    266 
    267                 m_va->add_vertex_buffer( nv::slot::POSITION, buffer, nv::INT,   2, 0, sizeof( vertex ), false );
    268                 m_va->add_vertex_buffer( nv::slot::COLOR,    buffer, nv::FLOAT, 4, offset_of( &vertex::color ), sizeof( vertex ), false );
     254                m_va        = m_context->create_vertex_array();
     255
     256                #ifdef INDEXED_TEST
     257                m_quad_cache = new gcache( m_context, nv::DYNAMIC_DRAW, 200, 200 );
     258                m_context->set_index_buffer( m_va, m_quad_cache->get_index_buffer(), nv::USHORT, false );
     259                nv::buffer buffer = m_quad_cache->get_vertex_buffer();
     260                #else
     261                m_quad_cache = new gcache( m_context, nv::DYNAMIC_DRAW, 20, true );
     262                nv::buffer buffer = m_quad_cache->get_buffer();
     263                #endif
     264
     265                m_context->add_vertex_buffer( m_va, nv::slot::POSITION, buffer, nv::INT,   2, 0, sizeof( vertex ), false );
     266                m_context->add_vertex_buffer( m_va, nv::slot::COLOR,    buffer, nv::FLOAT, 4, offset_of( &vertex::color ), sizeof( vertex ), false );
    269267        }
    270268        return true;
     
    274272{
    275273        int keypress = 0;
    276         m_program->bind();
    277274        glm::mat4 projection = glm::ortho( 0.0f, 800.0f, 600.0f, 0.0f, -1.0f, 1.0f );
    278         m_program->set_uniform( "nv_projection", glm::mat4(projection) );
     275        m_device->set_uniform( m_program, "nv_projection", glm::mat4(projection) );
    279276
    280277        while(!keypress)
     
    287284                {
    288285                        #ifdef INDEXED_TEST
    289                         m_va->set_index_buffer( m_quad_cache->get_index_buffer() );
    290                         nv::vertex_buffer* buffer = m_quad_cache->get_vertex_buffer();
     286                        m_context->set_index_buffer( m_va, m_quad_cache->get_index_buffer(), nv::USHORT, false );
     287                        nv::buffer buffer = m_quad_cache->get_vertex_buffer();
    291288                        #else
    292                         nv::vertex_buffer* buffer = (nv::vertex_buffer*)m_quad_cache->get_buffer();
     289                        nv::buffer buffer = m_quad_cache->get_buffer();
    293290                        #endif
    294                         m_va->update_vertex_buffer( nv::slot::POSITION, buffer, false );
    295                         m_va->update_vertex_buffer( nv::slot::COLOR,    buffer, false );
    296291                }
    297292
    298293                m_window->get_context()->clear( m_clear_state );
    299                 m_program->bind();
    300294//              m_program->set_uniform( "tex", 0 );
    301295                #ifdef INDEXED_TEST
     
    369363        delete m_quad_cache;
    370364
    371         delete m_program;
    372         delete m_va;
     365        m_device->release( m_program );
     366        m_context->release( m_va );
    373367        delete m_window;
    374368        delete m_device;
  • trunk/tests/gui_test/nv_gui_test.cc

    r269 r319  
    22#include <nv/gui/gui_environment.hh>
    33#include <nv/interface/context.hh>
    4 #include <nv/logging.hh>
    5 #include <nv/logger.hh>
     4#include <nv/core/logging.hh>
     5#include <nv/core/logger.hh>
    66#include <cstdlib> // rand
    77#include <ctime> // time
  • trunk/tests/md3_test/md3_test.cc

    r304 r319  
    1 #include <nv/common.hh>
     1#include <nv/core/common.hh>
    22#include <iomanip>
    33#include <nv/gfx/keyframed_mesh.hh>
    4 #include <nv/interface/vertex_buffer.hh>
    54#include <nv/gl/gl_device.hh>
    65#include <nv/gfx/image.hh>
     
    109#include <nv/io/c_file_system.hh>
    1110#include <nv/formats/md3_loader.hh>
    12 #include <nv/profiler.hh>
    13 #include <nv/logging.hh>
    14 #include <nv/logger.hh>
    15 #include <nv/math.hh>
    16 #include <nv/time.hh>
    17 #include <nv/string.hh>
     11#include <nv/core/profiler.hh>
     12#include <nv/core/logging.hh>
     13#include <nv/core/logger.hh>
     14#include <nv/core/math.hh>
     15#include <nv/core/time.hh>
     16#include <nv/core/string.hh>
    1817#include <glm/gtx/rotate_vector.hpp>
    1918#include <glm/gtc/matrix_access.hpp>
     
    6867        void update( nv::uint32 ms, nv::program program )
    6968        {
    70                 m_mesh->update( ms );
    7169                m_mesh->update_animation( m_entry, ms );
    7270                m_mesh->update( program );
     
    206204
    207205                        m_scene_state.set_model( model );
    208                         m_window->get_context()->draw( m_render_state, m_scene_state, m_program, m_legs->get_mesh() );
     206                        m_window->get_context()->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_program, m_legs->get_mesh()->get_vertex_array(), m_legs->get_mesh()->get_index_count() );
    209207
    210208                        //model = m_legs->get_transform( "tag_torso", last_legs_frame, legs_frame, legs_interpolate );
    211209                        model = m_legs->get_transform( 0 );
    212210                        m_scene_state.set_model( model );
    213                         m_window->get_context()->draw( m_render_state, m_scene_state, m_program, m_torso->get_mesh() );
     211                        m_window->get_context()->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_program, m_torso->get_mesh()->get_vertex_array(), m_torso->get_mesh()->get_index_count() );
    214212
    215213                        glm::mat4 head = model * m_torso->get_transform( 0 ); //, last_torso_frame, torso_frame, torso_interpolate );
    216214                        m_scene_state.set_model( head );
    217                         m_window->get_context()->draw( m_render_state, m_scene_state, m_program, m_head->get_mesh() );
     215                        m_window->get_context()->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_program, m_head->get_mesh()->get_vertex_array(), m_head->get_mesh()->get_index_count() );
    218216
    219217                        glm::mat4 weapon = model * m_torso->get_transform( 2 ); //, last_torso_frame, torso_frame, torso_interpolate );
    220218                        m_scene_state.set_model( weapon );
    221219                        m_context->bind( m_diffuse_weapon, nv::TEX_DIFFUSE );
    222                         m_context->draw( m_render_state, m_scene_state, m_program, m_weapon->get_mesh() );
     220                        m_context->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_program, m_weapon->get_mesh()->get_vertex_array(), m_weapon->get_mesh()->get_index_count() );
    223221
    224222                }
Note: See TracChangeset for help on using the changeset viewer.