Uranium
Application Framework
Loading...
Searching...
No Matches
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

 __init__ (self, shader, **kwargs)
 Init method.
 
 renderType (self)
 The RenderType for this batch.
 
 renderMode (self)
 The RenderMode for this batch.
 
 shader (self)
 The shader for this batch.
 
 backfaceCull (self)
 Whether backface culling is enabled or not.
 
 renderRange (self)
 The range of elements to render.
 
 items (self)
 The items to render.
 
 __lt__ (self, other)
 Less-than comparison method.
 
 addItem (self, transformation, mesh, uniforms=None)
 Add an item to render to this batch.
 
 render (self, camera)
 Render the batch.
 

Protected Member Functions

 _renderItem (self, item)
 

Protected Attributes

 _shader
 
 _render_type
 
 _render_mode
 
 _backface_cull
 
 _render_range
 
 _sort_weight
 
 _blend_mode
 
 _state_setup_callback
 
 _state_teardown_callback
 
 _items
 
 _view_matrix
 
 _projection_matrix
 
 _view_projection_matrix
 
 _gl
 

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

◆ __init__()

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

◆ __lt__()

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

Less-than comparison method.

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

◆ addItem()

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.

◆ items()

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

The items to render.

Returns
A list of tuples, where each item is (transform_matrix, mesh, extra_uniforms)

◆ render()

UM.View.RenderBatch.RenderBatch.render (   self,
  camera 
)

Render the batch.

Parameters
cameraThe camera to render from.

◆ renderRange()

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)

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