forked from adamlwgriffiths/PyGLy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender_callback_node.py
More file actions
executable file
·47 lines (36 loc) · 1.6 KB
/
render_callback_node.py
File metadata and controls
executable file
·47 lines (36 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from .render_node import RenderNode
class RenderCallbackNode( RenderNode ):
"""A RenderNode that takes an initialisation and a
render function as callbacks to perform rendering.
"""
def __init__( self, name, initialise_callback, render_callback ):
"""Initialises the node with the specified callbacks.
Args:
name: The name to give the node.
initialise_callback: The function to call when the
node is to be initialised.
The function must accept a pointer to this object.
render_callback: The function to call when the
node is to be rendered.
The function must accept a pointer to this object.
It must also accept a **kwargs parameter which will
be passed from the render() method.
Raises:
ValueError: Raised if the render callback == None.
"""
super( RenderCallbackNode, self ).__init__( name )
if render_callback == None:
raise ValueError(
"RenderNode render_callback cannot be None"
)
self.initialise_callback = initialise_callback
self.render_callback = render_callback
# initialise the mesh now
if self.initialise_callback != None:
self.initialise_callback( self )
def on_context_lost( self ):
# re-create any data for the mesh
if self.initialise_callback != None:
self.initialise_callback( self )
def render( self, **kwargs ):
self.render_callback( self, **kwargs )