source: trunk/src/engine/mesh_manager.cc @ 486

Last change on this file since 486 was 484, checked in by epyon, 10 years ago
  • resource manager updates
  • nv-image added
  • missing stl memory added
  • several other missing files
File size: 1.3 KB
Line 
1// Copyright (C) 2015-2015 ChaosForge Ltd
2// http://chaosforge.org/
3//
4// This file is part of Nova libraries.
5// For conditions of distribution and use, see copying.txt file in root folder.
6
7#include "nv/engine/mesh_manager.hh"
8
9using namespace nv;
10
11resource< gpu_mesh > gpu_mesh_manager::load_resource( resource< data_channel_set > mesh )
12{
13        resource< gpu_mesh > result = get( mesh.id().value() );
14        if ( result ) return result;
15        if ( auto lmesh = mesh.lock() )
16        {
17                gpu_mesh* gm = new gpu_mesh;
18                gm->va = m_context->create_vertex_array( &*lmesh, STATIC_DRAW );
19                gm->count = lmesh->get_channel_size( slot::INDEX );
20                gm->shader = lmesh->get_channel( slot::BONEINDEX ) != nullptr ? BONE : NORMAL;
21                return add( mesh.id(), gm );
22        }
23        return resource< gpu_mesh >();
24}
25
26bool nv::gpu_mesh_manager::load_resource( const string_view& id )
27{
28        if ( auto lmesh = m_mesh_manager->get( id ).lock() )
29        {
30                gpu_mesh* gm = new gpu_mesh;
31                gm->va = m_context->create_vertex_array( &*lmesh, STATIC_DRAW );
32                gm->count = lmesh->get_channel_size( slot::INDEX );
33                gm->shader = lmesh->get_channel( slot::BONEINDEX ) != nullptr ? BONE : NORMAL;
34                add( id, gm );
35                return true;
36        }
37        return false;
38}
39
40void gpu_mesh_manager::release( gpu_mesh* m )
41{
42        m_context->release( m->va );
43}
Note: See TracBrowser for help on using the repository browser.