本文整理匯總了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()