当前位置: 首页>>代码示例>>C++>>正文


C++ ShaderProgram::getUniformLocation方法代码示例

本文整理汇总了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);

	}
开发者ID:SerraPlo,项目名称:JocsEnXarxa,代码行数:24,代码来源:GLText.cpp

示例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);




}
开发者ID:11Alex11,项目名称:CS488-A5,代码行数:23,代码来源:Skybox.cpp


注:本文中的ShaderProgram::getUniformLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。