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


Python GameObject.render方法代码示例

本文整理汇总了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)
开发者ID:davidejones,项目名称:spaceinvaders,代码行数:42,代码来源:mesh.py

示例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()
开发者ID:davidejones,项目名称:spaceinvaders,代码行数:7,代码来源:swarm.py


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