1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
ItemToDraw::ItemToDraw(){
Vertex_VBO = 0;
Normal_VBO = 0;
UV_VBO = 0;
Index_VBO = 0;
Material_VBO = 0;
Pointer_VAO = 0;
ElementCount = 0;
Offset = 0;
for (int i = 0; i < 4; i++) {
ObjectColor[i] = 0.0f;
AmbientColor[i] = 0.0f;
EmissiveColor[i] = 0.0f;
DiffuseColor[i] = 0.0f;
SpecularColor[i] = 0.0f;
}
Shininess = 0.0f;
float initializer[16];
for (int i = 0; i < 16; i++) {
initializer[i] = 0.0f;
}
ModelMatrix = glm::make_mat4x4(initializer);
}
ItemToDraw::~ItemToDraw() {
}
void ItemToDraw::DrawMe(GlManagerClass* CurrentOpenGLController) {
glm::mat4 ModelViewMatrix = CurrentOpenGLController->GetViewMatrix() * ModelMatrix;
glm::mat3 NormalMatrix = glm::transpose(glm::inverse(glm::mat3(ModelViewMatrix)));
glm::mat4 ModelViewProjectionMatrix = CurrentOpenGLController->GetProjectionViewMatrix() * ModelMatrix;
glBindVertexArray(Pointer_VAO);
glUniformMatrix3fv(CurrentOpenGLController->GetObjectOffsetPositionID(), 1, GL_FALSE,
glm::value_ptr(NormalMatrix));
glUniformMatrix4fv(CurrentOpenGLController->GetUniformGlobalPositionID(), 1, GL_FALSE, glm::value_ptr(ModelViewProjectionMatrix));
glUniform4fv(CurrentOpenGLController->GetEmmissiveMeshColorID(), 1, EmissiveColor);
glUniform4fv(CurrentOpenGLController->GetAmbientMeshColorID(), 1, AmbientColor);
glUniform4fv(CurrentOpenGLController->GetDiffuseMeshColorID(), 1, DiffuseColor);
glUniform4fv(CurrentOpenGLController->GetSpecularMeshColorID(), 1, SpecularColor);
glUniform4fv(CurrentOpenGLController->GetMaterialColorID(), 1, ObjectColor);
glUniform1f(CurrentOpenGLController->GetMeshShininessID(), Shininess);
glDrawElements(GL_TRIANGLES, ElementCount, GL_UNSIGNED_INT, reinterpret_cast<const GLvoid *>(Offset));
}
|