parameters: (self, node, shader)
docstring: Main recursive rendering method.
docstring_summary: Main recursive rendering method.
docstring_tokens: Main recursive rendering method .
function: def recursive_render(self, node, shader):
          """ Main recursive rendering method.
          """
  
          # save model matrix and apply node transformation
          glPushMatrix()
          m = node.transformation.transpose() # OpenGL row major
          glMultMatrixf(m)
  
          for mesh in node.meshes:
  
              stride = 24 # 6 * 4 bytes
  
              diffuse = mesh.material.properties["diffuse"]
              if len(diffuse) == 3: diffuse.append(1.0)
              ambient = mesh.material.properties["ambient"]
              if len(ambient) == 3: ambient.append(1.0)
  
              glUniform4f( shader.Material_diffuse, *diffuse )
              glUniform4f( shader.Material_ambient, *ambient )
  
              vbo = mesh.gl["vbo"]
              vbo.bind()
  
              glEnableVertexAttribArray( shader.Vertex_position )
              glEnableVertexAttribArray( shader.Vertex_normal )
  
              glVertexAttribPointer(
                  shader.Vertex_position,
                  3, GL_FLOAT,False, stride, vbo
              )
  
              glVertexAttribPointer(
                  shader.Vertex_normal,
                  3, GL_FLOAT,False, stride, vbo+12
              )
  
              glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh.gl["faces"])
              glDrawElements(GL_TRIANGLES, len(mesh.faces) * 3, GL_UNSIGNED_INT, None)
  
  
              vbo.unbind()
              glDisableVertexAttribArray( shader.Vertex_position )
  
              glDisableVertexAttribArray( shader.Vertex_normal )
  
  
              glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)
  
          for child in node.children:
              self.recursive_render(child, shader)
  
          glPopMatrix()
function_tokens: def recursive_render ( self , node , shader ) : # save model matrix and apply node transformation glPushMatrix ( ) m = node . transformation . transpose ( ) # OpenGL row major glMultMatrixf ( m ) for mesh in node . meshes : stride = 24 # 6 * 4 bytes diffuse = mesh . material . properties [ "diffuse" ] if len ( diffuse ) == 3 : diffuse . append ( 1.0 ) ambient = mesh . material . properties [ "ambient" ] if len ( ambient ) == 3 : ambient . append ( 1.0 ) glUniform4f ( shader . Material_diffuse , * diffuse ) glUniform4f ( shader . Material_ambient , * ambient ) vbo = mesh . gl [ "vbo" ] vbo . bind ( ) glEnableVertexAttribArray ( shader . Vertex_position ) glEnableVertexAttribArray ( shader . Vertex_normal ) glVertexAttribPointer ( shader . Vertex_position , 3 , GL_FLOAT , False , stride , vbo ) glVertexAttribPointer ( shader . Vertex_normal , 3 , GL_FLOAT , False , stride , vbo + 12 ) glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , mesh . gl [ "faces" ] ) glDrawElements ( GL_TRIANGLES , len ( mesh . faces ) * 3 , GL_UNSIGNED_INT , None ) vbo . unbind ( ) glDisableVertexAttribArray ( shader . Vertex_position ) glDisableVertexAttribArray ( shader . Vertex_normal ) glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , 0 ) for child in node . children : self . recursive_render ( child , shader ) glPopMatrix ( )