本文整理汇总了C++中GLSLProgram::setUniformMatrix4fv方法的典型用法代码示例。如果您正苦于以下问题:C++ GLSLProgram::setUniformMatrix4fv方法的具体用法?C++ GLSLProgram::setUniformMatrix4fv怎么用?C++ GLSLProgram::setUniformMatrix4fv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLSLProgram
的用法示例。
在下文中一共展示了GLSLProgram::setUniformMatrix4fv方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void Renderer::init(GLSLProgram & shader)
{
setProjectionMatrix(30,1, 1, -100, projection);
shader.use();
shader.setUniformMatrix4fv("projectionMatrix", projection);
shader.unuse();
}
示例2: render
void Renderer::render(Entity& entity,GLSLProgram& shader)
{
mat4 rotMatrix;
mat4 translationMatrix;
mat4 transformMatrix;
prepare();
time += 0.0001f;
entity.increaseRotation(0.0, 0.0, 0.0);
entity.increasePosition(0, 0, 0);
translationMatrix = calcTranslationMatrix(entity.getPosition().x, entity.getPosition().y, entity.getPosition().z);
rotMatrix = calcRotationMatrix(entity.getRotX(), entity.getRotY(), entity.getRotZ());
transformMatrix = rotMatrix * translationMatrix;
shader.setUniformMatrix4fv("transformMatrix", transformMatrix);
TexturedModel texturedModel = entity.getTexturedModel();
RawModel model = texturedModel.getRawModel();
glBindBuffer(GL_ARRAY_BUFFER, model.getVboID());
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,model.getIndices());
glActiveTexture(GL_TEXTURE0);
texturedModel.getModelTexture().bind();
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glVertexAttribPointer(0, 3, GL_FLOAT, false, sizeof(Vertex), (void*)offsetof(Vertex, position));
glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Vertex), (void*)offsetof(Vertex, color));
glVertexAttribPointer(2, 2, GL_FLOAT, false, sizeof(Vertex), (void*)offsetof(Vertex, uv));
//glDrawArrays(GL_TRIANGLES, 0, model.getVertexCount());
//glDrawElements(GL_LINES, model.getVertexCount(), GL_UNSIGNED_INT, 0);
glDrawElements(GL_TRIANGLES,model.getVertexCount(), GL_UNSIGNED_INT,0);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(2);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);
texturedModel.getModelTexture().unbind();
}