Uranium
Application Framework
 All Classes Namespaces Files Functions Variables Pages
UM.View.RenderBatch.RenderBatch Class Reference

The RenderBatch class represent a batch of objects that should be rendered. More...

Classes

class  BlendMode
 Blending mode. More...
 
class  RenderMode
 The mode to render objects in. More...
 
class  RenderType
 The type of render batch. More...
 

Public Member Functions

def __init__
 Init method. More...
 
def renderType
 The RenderType for this batch. More...
 
def renderMode
 The RenderMode for this batch. More...
 
def shader
 The shader for this batch. More...
 
def backfaceCull
 Whether backface culling is enabled or not. More...
 
def renderRange
 The range of elements to render. More...
 
def items
 The items to render. More...
 
def __lt__
 Less-than comparison method. More...
 
def addItem
 Add an item to render to this batch. More...
 
def render
 Render the batch. More...
 

Detailed Description

The RenderBatch class represent a batch of objects that should be rendered.

Each RenderBatch contains a list of objects to render and all state related to those objects. It tries to minimize changes to state between render the individual objects. This means that for example the ShaderProgram used is only bound once, at the start of rendering. There are a few values, like the model-view-projection matrix that are updated for each object.

Currently RenderBatch objects are created each frame including the VertexArrayObject (VAO). This is done to greatly simplify managing RenderBatch-changes. Whenever (sets of) RenderBatches are managed throughout the lifetime of a session, crossing multiple frames, the usage of VAO's can improve performance by reusing them.

Constructor & Destructor Documentation

def UM.View.RenderBatch.RenderBatch.__init__ (   self,
  shader,
  kwargs 
)

Init method.

Parameters
shaderThe shader to use for this batch.
kwargsKeyword arguments. Possible values:
  • type: The RenderType to use for this batch. Defaults to RenderType.Solid.
  • mode: The RenderMode to use for this batch. Defaults to RenderMode.Triangles.
  • backface_cull: Whether to enable or disable backface culling. Defaults to True.
  • range: A tuple indicating the start and end of a range of triangles to render. Defaults to None.
  • sort: A modifier to influence object sorting. Lower values will cause the object to be rendered before others. Mostly relevant to Transparent mode.
  • blend_mode: The BlendMode to use to render this batch. Defaults to NoBlending when type is Solid, Normal when type is Transparent or Overlay.
  • state_setup_callback: A callback function to be called just after the state has been set up but before rendering. This can be used to do additional alterations to the state that can not be done otherwise. The callback is passed the OpenGL bindings object as first and only parameter.
  • state_teardown_callback: A callback similar to state_setup_callback, but called after everything was rendered, to handle cleaning up state changes made in state_setup_callback.

Member Function Documentation

def UM.View.RenderBatch.RenderBatch.__lt__ (   self,
  other 
)

Less-than comparison method.

This sorts RenderType.Solid before RenderType.Transparent and RenderType.Transparent before RenderType.Overlay.

def UM.View.RenderBatch.RenderBatch.addItem (   self,
  transformation,
  mesh,
  uniforms = None 
)

Add an item to render to this batch.

Parameters
transformationThe transformation matrix to use for rendering the item.
meshThe mesh to render with the transform matrix.
uniformsA dict of additional uniform bindings to set when rendering the item. Note these are set specifically for this item.
def UM.View.RenderBatch.RenderBatch.backfaceCull (   self)

Whether backface culling is enabled or not.

def UM.View.RenderBatch.RenderBatch.items (   self)

The items to render.

Returns
A list of tuples, where each item is (transform_matrix, mesh, extra_uniforms)
def UM.View.RenderBatch.RenderBatch.render (   self,
  camera 
)

Render the batch.

Parameters
cameraThe camera to render from.
def UM.View.RenderBatch.RenderBatch.renderMode (   self)

The RenderMode for this batch.

def UM.View.RenderBatch.RenderBatch.renderRange (   self)

The range of elements to render.

Returns
The range of elements to render, as a tuple of (start, end)
def UM.View.RenderBatch.RenderBatch.renderType (   self)

The RenderType for this batch.

def UM.View.RenderBatch.RenderBatch.shader (   self)

The shader for this batch.


The documentation for this class was generated from the following file: