本文整理汇总了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']