本文整理汇总了Python中gameobject.GameObject.render方法的典型用法代码示例。如果您正苦于以下问题:Python GameObject.render方法的具体用法?Python GameObject.render怎么用?Python GameObject.render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gameobject.GameObject
的用法示例。
在下文中一共展示了GameObject.render方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from gameobject import GameObject [as 别名]
# 或者: from gameobject.GameObject import render [as 别名]
def render(self):
GameObject.render(self)
self.program.bind()
view_location = glGetUniformLocation(self.program.get_handle(), "view")
if view_location > -1:
v = self.camera.view
v = v[:]
v_ctype = (GLfloat * len(v))(*v)
glUniformMatrix4fv(view_location, 1, GL_FALSE, v_ctype)
proj_location = glGetUniformLocation(self.program.get_handle(), "proj")
if proj_location > -1:
p = self.camera.projection
p = p[:]
p_ctype = (GLfloat * len(p))(*p)
glUniformMatrix4fv(proj_location, 1, GL_FALSE, p_ctype)
model_location = glGetUniformLocation(self.program.get_handle(), "model")
if model_location > -1:
self.matrix = Matrix4.new_translate(self.position.x, self.position.y, self.position.z)
if self.parent:
m = Matrix4().identity()
m = self.parent.matrix * self.matrix
m = m[:]
else:
m = self.matrix[:]
m_ctype = (GLfloat * len(m))(*m)
glUniformMatrix4fv(model_location, 1, GL_FALSE, m_ctype)
# bind vao for use
glBindVertexArray(self.vao)
# Draw a rectangle from the 2 triangles using 6 indices
if self.indices:
glDrawElements(GL_TRIANGLES, len(self.indices), GL_UNSIGNED_INT, 0)
elif self.vertices:
pass #gldrawarray?
# stop the vao
glBindVertexArray(0)
示例2: render
# 需要导入模块: from gameobject import GameObject [as 别名]
# 或者: from gameobject.GameObject import render [as 别名]
def render(self):
GameObject.render(self)
for row in self.enemies:
for enemy in row:
enemy.render()