| 61 | } |
| 62 | |
| 63 | bool 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 | |
| 110 | Sound::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 |
nothing calls this directly
no outgoing calls
no test coverage detected