本文整理汇总了C++中ShaderProgram::getUniformLocation方法的典型用法代码示例。如果您正苦于以下问题:C++ ShaderProgram::getUniformLocation方法的具体用法?C++ ShaderProgram::getUniformLocation怎么用?C++ ShaderProgram::getUniformLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShaderProgram
的用法示例。
在下文中一共展示了ShaderProgram::getUniformLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void GLText::Draw(ShaderProgram &program, GLCamera &camera) const {
program.Bind();
glUniformMatrix4fv(program.getUniformLocation("camera"), 1, GL_FALSE, glm::value_ptr(camera.PVMatrix()));
glm::mat4 model;
model = glm::translate(model, position);
model = glm::rotate(model, glm::radians(rotation.x), { 1,0,0 });
model = glm::rotate(model, glm::radians(rotation.y+180), { 0,1,0 });
model = glm::rotate(model, glm::radians(rotation.z), { 0,0,1 });
model = glm::scale(model, scale);
glUniformMatrix4fv(program.getUniformLocation("model"), 1, GL_FALSE, glm::value_ptr(model));
glDisable(GL_CULL_FACE);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureid);
glBindVertexArray(vao);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr); // Draw plane with 36 vertices
glBindVertexArray(0);
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(0);
glEnable(GL_CULL_FACE);
}
示例2: draw
// Draw the skybox using the skybox shader
void Skybox::draw(ShaderProgram& s){
GLint posAttrib = s.getAttribLocation( "position" );
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_CUBE_MAP,tex);
GLint cube = s.getUniformLocation("cubeMap");
glUniform1i(cube,0);
glEnableVertexAttribArray(posAttrib);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glVertexAttribPointer( posAttrib, 3, GL_FLOAT, GL_FALSE, 0, (void*)0 );
glDrawArrays (GL_TRIANGLES, 0, 36);
glBindBuffer(GL_ARRAY_BUFFER,0);
}