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


Python Texture.getNullTexture方法代码示例

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


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

示例1: toCompiled

# 需要导入模块: from texture import Texture [as 别名]
# 或者: from texture.Texture import getNullTexture [as 别名]
	def toCompiled(self, shader=None):

		if shader is None:
			shader = self.getShader()

		assert(shader)

		code = ""

		# items made up of 3 floats
		for what in ("diffuse_color","specular_color","ambient_color"):
			loc = shader.getUniformPos(what)
			if loc!=-1:
				code += "\tglUniform3fv(%s, 1, mat._%s)\n"%(loc,what)

		# items made up of 1 float
		for what in ("specular_exp","alpha"):
			loc = shader.getUniformPos(what)
			if loc!=-1:
				code += "\tglUniform1f(%s, mat._%s)\n"%(loc,what)

		# textures
		for i in xrange(3):
			loc = shader.getUniformPos("texture%s"%i)
			if loc!=-1:
				try: # see if the texture is already loaded
					self._texture[i].id()
				except:
					if self._texture[i] is None:
						self._texture[i] = Texture.getNullTexture()
					else:
						self._texture[i] = R.loadTexture(self._texture[i])

				code += "\tmat._texture[%s].bind(%s,%s)\n"%(i,i,loc)

		if not code:
			code = "def binder(): pass"
		else:
			code = "def binder():\n"+code


		c = compile(code, "<compiled material>", "exec")

		ns = dict(mat = self, glUniform3fv=glUniform3fv, glUniform1f=glUniform1f)
	
		exec c in ns

		return ns['binder']
开发者ID:Gato-X,项目名称:sPyGlass,代码行数:50,代码来源:materials.py


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