當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。