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