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