Engine
Frameworkcreatedbymeusableforthecreationofsimplegames.CurrentlysupportsOpenGL(Verysimple)andVulkan.
OpenGLMesh.cpp
Go to the documentation of this file.
2 #ifdef USING_OPENGL
4 #include <ThirdParty/glew-2.1.0/include/GL/glew.h>
5 
6 namespace Engine
7 {
8  OpenGLMesh::OpenGLMesh(eastl::vector<Vertex> vertices, eastl::vector<unsigned> indices) : Mesh(vertices, indices)
9  {
10  OpenGLMesh::SetUpMesh();
11  }
12 
13  void OpenGLMesh::SetUpMesh()
14  {
15  // Bind Vertices, texture coordinates and normals
16  // Allocate one buffer
17  unsigned int uVBO = unsigned int(vbo);
18  glGenBuffers(1, &uVBO);
19  glGetError();
20 
21  // Array buffer contains the attribute data
22  glBindBuffer(GL_ARRAY_BUFFER, uVBO);
23  glGetError();
24 
25  // Copy into VBO
26  glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex) * vertices.size(), &vertices[0], GL_STATIC_DRAW);
27  glGetError();
28  glBindBuffer(GL_ARRAY_BUFFER, 0); // Unbind buffer
29  glGetError();
30  //--
31 
32  vbo = uint64_t(uVBO);
33 
34  unsigned int uEBO = unsigned int(ebo);
35  // Allocate one buffer
36  glGenBuffers(1, &uEBO);
37  glGetError();
38 
39  // Element array buffer contains the indices.
40  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, uEBO);
41  glGetError();
42 
43  // Copy into VBO
44  glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * indices.size(), &indices[0], GL_STATIC_DRAW);
45  glGetError();
46  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 1); // Unbind buffer
47  glGetError();
48 
49  ebo = uint64_t(uEBO);
50 
51  //Could clear vertices & indices here
52  }
53 } // namespace Engine
54 #endif
eastl::vector< unsigned > indices
The indices of this mesh.
Definition: Mesh.hpp:24
uint64_t ebo
Definition: Mesh.hpp:110
eastl::vector< Vertex > vertices
The vertices of this mesh.
Definition: Mesh.hpp:20
uint64_t vbo
Definition: Mesh.hpp:110
This object is used to store general data for a vertex.
Definition: Vertex.hpp:6