12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #include "Caisse.h"
- Caisse::Caisse(float taille, std::string const vertexShader, std::string const fragmentShader, std::string fichierImage)
- : Cube(taille, vertexShader, fragmentShader)
- {
-
- m_texture.charger(fichierImage);
-
- float coordTextureTmp[] = {0, 0, 1, 0, 1, 1,
- 0, 0, 0, 1, 1, 1,
- 0, 0, 1, 0, 1, 1,
- 0, 0, 0, 1, 1, 1,
- 0, 0, 1, 0, 1, 1,
- 0, 0, 0, 1, 1, 1,
- 0, 0, 1, 0, 1, 1,
- 0, 0, 0, 1, 1, 1,
- 0, 0, 1, 0, 1, 1,
- 0, 0, 0, 1, 1, 1,
- 0, 0, 1, 0, 1, 1,
- 0, 0, 0, 1, 1, 1};
- for(int i (0); i < 72; i++)
- m_coordTexture[i] = coordTextureTmp[i];
- }
- Caisse::~Caisse()
- {}
- void Caisse::afficher(glm::mat4 &projection, glm::mat4 &modelview)
- {
-
- glUseProgram(m_shader.getProgramID());
-
- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, m_vertices);
- glEnableVertexAttribArray(0);
-
- glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 0, m_coordTexture);
- glEnableVertexAttribArray(2);
-
- glUniformMatrix4fv(glGetUniformLocation(m_shader.getProgramID(), "projection"), 1, GL_FALSE, glm::value_ptr(projection));
- glUniformMatrix4fv(glGetUniformLocation(m_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(modelview));
-
- glBindTexture(GL_TEXTURE_2D, m_texture.getID());
-
- glDrawArrays(GL_TRIANGLES, 0, 36);
-
- glBindTexture(GL_TEXTURE_2D, 0);
-
- glDisableVertexAttribArray(2);
- glDisableVertexAttribArray(0);
-
- glUseProgram(0);
- }
|