- Timestamp:
- 07/15/13 02:48:06 (12 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/formats/md3_loader.cc
r156 r161 313 313 } 314 314 315 vertex_attribute< vec3 >* position = m->add_attribute<vec3>(" position");316 vertex_attribute< vec3 >* normal = m->add_attribute<vec3>("n ormal");317 vertex_attribute< vec2 >* texcoord = m->add_attribute<vec2>(" texcoord");315 vertex_attribute< vec3 >* position = m->add_attribute<vec3>("nv_position"); 316 vertex_attribute< vec3 >* normal = m->add_attribute<vec3>("nv_normal"); 317 vertex_attribute< vec2 >* texcoord = m->add_attribute<vec2>("nv_texcoord"); 318 318 vertex_attribute< uint16 >* indices = m->add_indices<uint16>(); 319 319 -
trunk/src/formats/obj_loader.cc
r148 r161 140 140 if ( m_position == nullptr ) 141 141 { 142 m_position = m_mesh->add_attribute< vec3 >( " position" );142 m_position = m_mesh->add_attribute< vec3 >( "nv_position" ); 143 143 } 144 144 if ( m_tex_coord == nullptr ) 145 145 { 146 m_tex_coord = m_mesh->add_attribute< vec2 >( " texcoord" );146 m_tex_coord = m_mesh->add_attribute< vec2 >( "nv_texcoord" ); 147 147 } 148 148 if ( m_normal == nullptr && ni != nullptr ) 149 149 { 150 m_normal = m_mesh->add_attribute< vec3 >( "n ormal" );150 m_normal = m_mesh->add_attribute< vec3 >( "nv_normal" ); 151 151 } 152 152 … … 174 174 void mesh_obj_reader::calculate_tangents() 175 175 { 176 m_tangent = m_mesh->add_attribute< vec4 >( " tangent" );176 m_tangent = m_mesh->add_attribute< vec4 >( "nv_tangent" ); 177 177 178 178 std::vector< vec3 >& vp = m_position->get(); -
trunk/src/gfx/keyframed_mesh.cc
r159 r161 21 21 , m_va( nullptr ) 22 22 , m_loc_next_position( 0 ) 23 , m_loc_last_position( 0 )24 23 , m_loc_next_normal( 0 ) 25 , m_loc_last_normal( 0 )26 24 , m_last_frame( 0 ) 27 25 , m_next_frame( 0 ) … … 37 35 38 36 nv::vertex_buffer* vb; 39 m_loc_next_position = m_program->get_attribute( "next_position" )->get_location(); 40 m_loc_last_position = m_program->get_attribute( "last_position" )->get_location(); 41 m_loc_next_normal = m_program->get_attribute( "next_normal" )->get_location(); 42 m_loc_last_normal = m_program->get_attribute( "last_normal" )->get_location(); 37 m_loc_next_position = m_program->get_attribute( "nv_next_position" )->get_location(); 38 m_loc_next_normal = m_program->get_attribute( "nv_next_normal" )->get_location(); 43 39 44 40 vb = m_context->get_device()->create_vertex_buffer( nv::STATIC_DRAW, m_data->get_vertex_count() * sizeof( nv::vec3 ) * m_data->get_frame_count(), (void*)m_data->get_positions().data() ); 45 41 m_va->add_vertex_buffer( m_loc_next_position, vb, nv::FLOAT, 3, 0, 0, false ); 46 m_va->add_vertex_buffer( m_loc_last_position, vb, nv::FLOAT, 3 );42 m_va->add_vertex_buffer( nv::POSITION, vb, nv::FLOAT, 3 ); 47 43 48 44 vb = m_context->get_device()->create_vertex_buffer( nv::STATIC_DRAW, m_data->get_vertex_count() * sizeof( nv::vec3 ) * m_data->get_frame_count(), (void*)m_data->get_normals().data() ); 49 45 m_va->add_vertex_buffer( m_loc_next_normal, vb, nv::FLOAT, 3, 0, 0, false ); 50 m_va->add_vertex_buffer( m_loc_last_normal, vb, nv::FLOAT, 3 );46 m_va->add_vertex_buffer( nv::NORMAL, vb, nv::FLOAT, 3 ); 51 47 52 48 vb = m_context->get_device()->create_vertex_buffer( nv::STATIC_DRAW, m_data->get_vertex_count() * sizeof( nv::vec2 ), (void*)m_data->get_texcoords().data() ); 53 m_va->add_vertex_buffer( m_program->get_attribute( "texcoord" )->get_location(), vb, nv::FLOAT, 2 );49 m_va->add_vertex_buffer( nv::slot::TEXCOORD, vb, nv::FLOAT, 2 ); 54 50 nv::index_buffer* ib = m_context->get_device()->create_index_buffer( nv::STATIC_DRAW, m_data->get_index_count() * sizeof( nv::uint16 ), (void*)m_data->get_indices().data() ); 55 51 m_va->set_index_buffer( ib, nv::USHORT, true ); … … 129 125 if ( m_gpu_last_frame != m_last_frame ) 130 126 { 131 m_va->update_vertex_buffer( m_loc_last_position, m_last_frame * vtx_count * sizeof( nv::vec3 ) );132 m_va->update_vertex_buffer( m_loc_last_normal, m_last_frame * vtx_count * sizeof( nv::vec3 ) );127 m_va->update_vertex_buffer( slot::POSITION, m_last_frame * vtx_count * sizeof( nv::vec3 ) ); 128 m_va->update_vertex_buffer( slot::NORMAL, m_last_frame * vtx_count * sizeof( nv::vec3 ) ); 133 129 m_gpu_last_frame = m_last_frame; 134 130 } … … 139 135 m_gpu_next_frame = m_next_frame; 140 136 } 141 m_program->set_uniform( " interpolate", m_interpolation );137 m_program->set_uniform( "nv_interpolate", m_interpolation ); 142 138 m_context->draw( nv::TRIANGLES, rstate, m_program, m_va, m_data->get_index_count() ); 143 139 } -
trunk/src/gl/gl_device.cc
r153 r161 44 44 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); 45 45 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); 46 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16);46 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); 47 47 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); 48 49 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); 50 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4 ); 51 48 52 } 49 53 -
trunk/src/gl/gl_program.cc
r121 r161 105 105 if (!vertex_shader.compile( vertex_program )) { return false; } 106 106 if (!fragment_shader.compile( fragment_program )) { return false; } 107 108 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::POSITION ), "nv_position" ); 109 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::TEXCOORD ), "nv_texcoord" ); 110 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::NORMAL ), "nv_normal" ); 111 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::COLOR ), "nv_color" ); 112 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::TANGENT ), "nv_tangent" ); 107 113 108 114 glAttachShader( m_name.get_value(), fragment_shader.get_id() ); -
trunk/src/gui/gui_renderer.cc
r152 r161 81 81 nv::program* shader; 82 82 nv::texture2d* texture; 83 84 int loc_coord;85 int loc_color;86 int loc_tcoord;87 83 }; 88 84 … … 116 112 sr->varray = m_window->get_device()->create_vertex_array(); 117 113 sr->shader = m_window->get_device()->create_program( nv::slurp( "gui.vert" ), nv::slurp( "gui.frag" ) ); 118 sr->loc_coord = sr->shader->get_attribute("coord")->get_location();119 sr->loc_tcoord = sr->shader->get_attribute("tcoord")->get_location();120 sr->loc_color = sr->shader->get_attribute("color")->get_location();121 114 sr->shader->set_uniform( "tex", 0 ); 122 115 glm::mat4 projection = glm::ortho( 0.0f, float( m_window->get_width() ), float( m_window->get_height() ), 0.0f, -1.0f, 1.0f ); 123 sr->shader->set_uniform( " projection", projection );116 sr->shader->set_uniform( "nv_projection", projection ); 124 117 125 118 vertex_buffer* vb = (vertex_buffer*)sr->buffer.get_buffer(); 126 sr->varray->add_vertex_buffer( s r->loc_coord,vb, nv::INT, 2, 0, sizeof( vertex ), false );127 sr->varray->add_vertex_buffer( s r->loc_tcoord, vb, nv::FLOAT, 2, offset_of( &vertex::tcoord ), sizeof( vertex ), false );128 sr->varray->add_vertex_buffer( s r->loc_color,vb, nv::FLOAT, 4, offset_of( &vertex::color ), sizeof( vertex ), false );119 sr->varray->add_vertex_buffer( slot::POSITION, vb, nv::INT, 2, 0, sizeof( vertex ), false ); 120 sr->varray->add_vertex_buffer( slot::TEXCOORD, vb, nv::FLOAT, 2, offset_of( &vertex::tcoord ), sizeof( vertex ), false ); 121 sr->varray->add_vertex_buffer( slot::COLOR, vb, nv::FLOAT, 4, offset_of( &vertex::color ), sizeof( vertex ), false ); 129 122 130 123 nv::sampler sampler( nv::sampler::LINEAR, nv::sampler::CLAMP_TO_EDGE ); … … 277 270 { 278 271 nv::vertex_buffer* vb = (nv::vertex_buffer*)sr->buffer.get_buffer(); 279 sr->varray->update_vertex_buffer( sr->loc_coord,vb, false );280 sr->varray->update_vertex_buffer( sr->loc_tcoord, vb, false );281 sr->varray->update_vertex_buffer( sr->loc_color,vb, false );272 sr->varray->update_vertex_buffer( nv::POSITION, vb, false ); 273 sr->varray->update_vertex_buffer( nv::TEXCOORD, vb, false ); 274 sr->varray->update_vertex_buffer( nv::COLOR, vb, false ); 282 275 } 283 276 sr->texture->bind( 0 );
Note: See TracChangeset
for help on using the changeset viewer.