MCPcopy Create free account
hub / github.com/OpenNFS/OpenNFS / genBuffers

Method genBuffers

src/Scene/Sound.cpp:63–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63bool Sound::genBuffers() {
64 glGenVertexArrays(1, &VertexArrayID);
65 glBindVertexArray(VertexArrayID);
66 // Verts
67 glGenBuffers(1, &vertexbuffer);
68 glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
69 glBufferData(GL_ARRAY_BUFFER, m_vertices.size() * sizeof(glm::vec3), &m_vertices[0], GL_STATIC_DRAW);
70 glVertexAttribPointer(
71 0, // attribute
72 3, // size
73 GL_FLOAT, // type
74 GL_FALSE, // normalized?
75 0, // stride
76 (void *) 0 // array buffer offset
77 );
78 // 1st attribute buffer : Vertices
79 glEnableVertexAttribArray(0);
80 // UVs
81 glGenBuffers(1, &uvbuffer);
82 glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
83 glBufferData(GL_ARRAY_BUFFER, m_uvs.size() * sizeof(glm::vec2), &m_uvs[0], GL_STATIC_DRAW);
84 glVertexAttribPointer(
85 1, // attribute
86 2, // size
87 GL_FLOAT, // type
88 GL_FALSE, // normalized?
89 0, // stride
90 (void *) 0 // array buffer offset
91 );
92 // 2nd attribute buffer : normals
93 glEnableVertexAttribArray(1);
94 // Normals
95 glGenBuffers(1, &normalBuffer);
96 glBindBuffer(GL_ARRAY_BUFFER, normalBuffer);
97 glBufferData(GL_ARRAY_BUFFER, m_normals.size() * sizeof(glm::vec3), &m_normals[0], GL_STATIC_DRAW);
98 glVertexAttribPointer(
99 4, // attribute
100 3, // size
101 GL_FLOAT, // type
102 GL_FALSE, // normalized?
103 0, // stride
104 (void *) 0 // array buffer offset
105 );
106 glBindVertexArray(0);
107 return true;
108}
109
110Sound::Sound() : super("Sound", std::vector<glm::vec3>(), std::vector<glm::vec2>(), std::vector<glm::vec3>(), std::vector<unsigned int>(), false, glm::vec3(0,0,0)){}
111

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected