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


C++ TextureManager::unbindAllTextures方法代码示例

本文整理汇总了C++中TextureManager::unbindAllTextures方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureManager::unbindAllTextures方法的具体用法?C++ TextureManager::unbindAllTextures怎么用?C++ TextureManager::unbindAllTextures使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextureManager的用法示例。


在下文中一共展示了TextureManager::unbindAllTextures方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: render

//function to render stuff
void Object::render(const GLuint& program, TextureManager& textureManager){

	//Note to self : very very important!!! Otherwise you won't see anything! 
	glUseProgram(program);

	//bind the current object's texture

	for (auto iter = m_textureHandles.begin(); iter != m_textureHandles.end(); iter++)
	{
		if (cubemap)
		{
			textureManager.BindTextureCubeMap(iter->first, iter->second, program);
		}
		else
		{
			textureManager.BindTexture2D(iter->first, iter->second, program);
		}
	}

	//set the uniforms
	glUniform1i(glGetUniformLocation(program, "lightSwitch"), lightSwitch);
	glUniform4fv(glGetUniformLocation(program, "diffuseColor"), 1, diffuse);

	glm::mat4 scaleMatrix = glm::scale(glm::mat4(1.0f), glm::vec3(scale[0], scale[1], scale[2]));
	glm::mat4 translateMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(translate[0], translate[1], translate[2]));
	glm::mat4 rotationMatrix_X = glm::rotate(glm::mat4(1.0f), angle[0], glm::vec3(1.0f, 0.0f, 0.0f));
	glm::mat4 rotationMatrix_Y = glm::rotate(glm::mat4(1.0f), angle[1], glm::vec3(0.0f, 1.0f, 0.0f));
	glm::mat4 rotationMatrix_Z = glm::rotate(glm::mat4(1.0f), angle[2], glm::vec3(0.0f, 0.0f, 1.0f));

	glm::mat4 modelMatrix = scaleMatrix * translateMatrix * rotationMatrix_X * rotationMatrix_Y * rotationMatrix_Z;

	glUniformMatrix4fv(glGetUniformLocation(program, "model"), 1, false, glm::value_ptr(modelMatrix));

	//bind the vao and draw the triangles
	glBindVertexArray(vao);
	glDrawArrays(GL_TRIANGLES, 0, faces.size() * 3 * 3);

	textureManager.unbindAllTextures();

	glUseProgram(0);
}
开发者ID:theomission,项目名称:Amospheric-Scattering,代码行数:42,代码来源:Object.cpp


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