Ignore:
Timestamp:
08/25/14 02:43:30 (11 years ago)
Author:
epyon
Message:
  • updated all tests to new nova
  • cleaned up tests paths
  • general cleanup of tests and test data
File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/tests/md2_test/nv_md2_test.cc

    r239 r321  
    1 #include <nv/common.hh>
    21#include <nv/gfx/keyframed_mesh.hh>
    3 #include <nv/interface/vertex_buffer.hh>
    42#include <nv/gl/gl_device.hh>
    53#include <nv/gfx/image.hh>
    64#include <nv/interface/context.hh>
    75#include <nv/interface/window.hh>
    8 #include <nv/interface/program.hh>
    9 #include <nv/interface/texture2d.hh>
    106#include <nv/interface/mesh_loader.hh>
    117#include <nv/io/c_file_system.hh>
    128#include <nv/formats/md2_loader.hh>
    13 #include <nv/profiler.hh>
    14 #include <nv/logging.hh>
    15 #include <nv/logger.hh>
    16 #include <nv/math.hh>
    17 #include <nv/time.hh>
    18 #include <nv/string.hh>
     9#include <nv/core/profiler.hh>
     10#include <nv/core/logging.hh>
     11#include <nv/core/logger.hh>
     12#include <nv/core/math.hh>
     13#include <nv/core/time.hh>
     14#include <nv/core/string.hh>
    1915#include <glm/gtx/rotate_vector.hpp>
    2016
     
    2723        ~application();
    2824protected:
    29         nv::device*       m_device;
    30         nv::window*       m_window;
    31         nv::texture2d*    m_diffuse;
    32         nv::program*      m_program;
     25        nv::device*  m_device;
     26        nv::window*  m_window;
     27        nv::context* m_context;
     28        nv::texture  m_diffuse;
     29        nv::program  m_program;
    3330
    3431        nv::clear_state   m_clear_state;
     
    3633        nv::scene_state   m_scene_state;
    3734
    38         nv::mesh_data*      m_mesh_data;
    39         nv::keyframed_mesh* m_mesh;
     35        nv::mesh_data*       m_mesh_data;
     36        nv::keyframed_mesh*  m_mesh;
     37        nv::animation_entry* m_animation;
    4038};
    4139
     
    4341{
    4442        NV_PROFILE( "app_construct" );
    45         m_device = new nv::gl_device();
    46         m_window = m_device->create_window( 800, 600, false );
     43        m_device  = new nv::gl_device();
     44        m_window  = m_device->create_window( 800, 600, false );
     45        m_context = m_window->get_context();
    4746
    4847        nv::sampler sampler( nv::sampler::LINEAR, nv::sampler::REPEAT );
    4948        nv::image_data* data = m_device->create_image_data( "data/manc.png" );
    50         m_diffuse  = m_device->create_texture2d( data->get_size(), nv::RGB, nv::UBYTE, sampler, (void*)data->get_data() );
     49        m_diffuse  = m_device->create_texture( data, sampler );
    5150        delete data;
    5251
     
    6463{
    6564        NV_PROFILE( "app_initialize" );
    66         m_program = m_device->create_program( nv::slurp( "obj.vert" ), nv::slurp( "obj.frag" ) );
     65        m_program = m_device->create_program( nv::slurp( "md2.vert" ), nv::slurp( "md2.frag" ) );
    6766
    6867        nv::md2_loader* loader;
     
    8079        {
    8180                NV_PROFILE("create_mesh");
    82                 m_mesh      = new nv::keyframed_mesh_gpu( m_window->get_context(), m_mesh_data, nullptr, m_program );
     81                m_mesh      = new nv::keyframed_mesh_gpu( m_context, m_mesh_data, nullptr );
    8382        }
    8483
     
    9695        nv::fps_counter_class< nv::system_us_timer > fps_counter;
    9796
    98         m_mesh->setup_animation( 0, m_mesh->get_max_frames(), 2, true );
     97        m_animation = new nv::animation_entry( "", true, 5, 0.0f, m_mesh->get_max_frames()-1 );
     98        m_mesh->run_animation( m_animation );
    9999
    100100        while(!keypress)
     
    103103                ticks      = m_device->get_ticks();
    104104                nv::uint32 elapsed = ticks - last_ticks;
    105                 m_window->get_context()->clear( m_clear_state );
    106                 m_mesh->update( elapsed );
     105                m_context->clear( m_clear_state );
    107106                glm::vec3 eye = glm::rotate( glm::vec3( 100.0f, 25.0f, 0.0f ), (ticks / 20.f), glm::vec3( 0.0,1.0,0.0 ) );
    108107
     
    111110                m_scene_state.get_camera().set_perspective(60.0f, 1.0f*800.0f/600.0f, 0.1f, 1000.0f);
    112111
    113                 m_diffuse->bind( 0 );
    114                 m_program->set_opt_uniform( "light_position", glm::vec3(120.0, 120.0, 0) );
    115                 m_program->set_opt_uniform( "light_diffuse",  glm::vec4(1.0,1.0,1.0,1.0) );
    116                 m_program->set_opt_uniform( "light_specular", glm::vec4(1.0,1.0,1.0,1.0) );
     112                m_context->bind( m_diffuse, nv::TEX_DIFFUSE );
     113                m_device->set_opt_uniform( m_program, "light_position", glm::vec3(120.0, 120.0, 0) );
     114                m_device->set_opt_uniform( m_program, "light_diffuse",  glm::vec4(1.0,1.0,1.0,1.0) );
     115                m_device->set_opt_uniform( m_program, "light_specular", glm::vec4(1.0,1.0,1.0,1.0) );
     116                m_mesh->update_animation( m_animation, ticks );
    117117                m_mesh->update( m_program );
    118                 m_window->get_context()->draw( m_render_state, m_scene_state, m_program, m_mesh );
     118                m_context->draw( nv::TRIANGLES, m_render_state, m_scene_state, m_program, m_mesh->get_vertex_array(), m_mesh->get_index_count() );
    119119                m_window->swap_buffers();
    120120
     
    148148application::~application()
    149149{
    150         delete m_program;
     150        m_device->release( m_program );
    151151        delete m_mesh_data;
    152152        delete m_mesh;
    153         delete m_diffuse;
     153        delete m_animation;
     154        m_device->release( m_diffuse );
    154155        delete m_window;
    155156        delete m_device;
Note: See TracChangeset for help on using the changeset viewer.