SquareMesh.cpp
Go to the documentation of this file.
1 #include "SquareMesh.hpp"
2 
3 namespace iv
4 {
5 
6 //-------------- UniversalShader_Subprovider ---------------------------------------------------------------------
8  cm( inst, this, "SquareMesh_Subprovider" ),
9  inst( inst )
10 {
11 }
12 
14 {
15  return this->inst;
16 }
17 
18 void SquareMesh_Subprovider::each_resource( std::function< void( ResourcePath const & ) > const & f ) const
19 {
21 }
22 
24 {
25  return path == SquareMesh::VirtualPath;
26 }
27 
28 
29 //-------------- SquareMesh ---------------------------------------------------------------------
31  Mesh( inst ),
32  GlListener( inst ),
33  cm( inst, this, "SquareMesh" )
34 {
35  if( this->GlIsEnabled() )
36  this->GlEnable();
37 }
38 
40 {
41  this->gl_mesh()->DestroyMesh( &this->cm );
42 }
43 
44 void SquareMesh::GlEnable()
45 {
46  auto * mesh = this->gl_mesh();
47 
48  mesh->CreateMesh( &this->cm );
49  static const float positions[] = { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f };
50  mesh->Load_Positions( &this->cm, positions, 12 );
51  static const float texcoords[] = { 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f };
52  mesh->Load_TexCoords( &this->cm, texcoords, 8 );
53  static const unsigned indices[] = { 0, 1, 2, 3 };
54  mesh->Load_Indices( &this->cm, indices, 4, GL_TRIANGLE_STRIP );
55 }
56 
57 void SquareMesh::GlDisable()
58 {
59  this->gl_mesh()->DestroyMesh( &this->cm );
60 }
61 
62 void SquareMesh::GlDrop()
63 {
64  this->gl_mesh()->DropMesh( &this->cm );
65 }
66 
67 }