|
|
@ -151,7 +151,25 @@ void Model::createVertexBuffer() |
|
|
|
} |
|
|
|
|
|
|
|
void Model::Draw(glm::mat4 & viewMatrix, glm::mat4 projectionMatrix, float x, float y, float z) { |
|
|
|
//TODO
|
|
|
|
mShader->SetVec4("U_CameraPos", x, y, z, 1.0); |
|
|
|
glEnable(GL_DEPTH_TEST); |
|
|
|
mVertexBuffer->Bind(); |
|
|
|
if (mShader->mProgram > 0) { |
|
|
|
mShader->Bind(glm::value_ptr(mModelMatrix), glm::value_ptr(viewMatrix), glm::value_ptr(projectionMatrix)); |
|
|
|
glm::mat4 it = glm::inverseTranspose(mModelMatrix); |
|
|
|
GLint itLocation = glGetUniformLocation(mShader->mProgram, "IT_ModelMatrix"); |
|
|
|
glUniformMatrix4fv(itLocation, 1, GL_FALSE, glm::value_ptr(it)); |
|
|
|
itLocation = glGetUniformLocation(mShader->mProgram, "LightViewMatrix"); |
|
|
|
if (itLocation >= 0 && mLightViewMatrix != nullptr) { |
|
|
|
glUniformMatrix4fv(itLocation, 1, GL_FALSE, mLightViewMatrix); |
|
|
|
} |
|
|
|
itLocation = glGetUniformLocation(mShader->mProgram, "LightProjectionMatrix"); |
|
|
|
if (itLocation >= 0 && mLightProjectionMatrix != nullptr) { |
|
|
|
glUniformMatrix4fv(itLocation, 1, GL_FALSE, mLightProjectionMatrix); |
|
|
|
} |
|
|
|
} |
|
|
|
glDrawArrays(GL_TRIANGLES, 0, mVertexBuffer->mVertexCount); |
|
|
|
mVertexBuffer->Unbind(); |
|
|
|
} |
|
|
|
|
|
|
|
void Model::SetPosition(float x, float y, float z) { |
|
|
|