1 """Tools for managing render contexts.
2
3 @author: Stephan Wenger
4 @date: 2012-03-08
5 """
8 _bound_context = None
9
10 - def __get__(self, obj, cls=None):
11 return self._bound_context
12
13 - def __set__(self, obj, context=None):
19
21 return "proxy for context binding"
22
23 -class ContextManager(object):
24 current_context = ContextBindingProxy()
25 """The currently active context."""
26
29
30 - def push(self, context):
33
35 self.current_context = self._stack.pop()
36
37 @staticmethod
39 """Create a default offscreen rendering context.
40
41 @todo: This is window system dependent; create an appropriate context
42 dynamically.
43 @todo: When no context exists, create a raw offscreen context instead of a
44 hidden GLUT window so that rendering is possible without an X connection.
45 """
46
47 from glitter.contexts.glut import GlutWindow
48 return GlutWindow(shape=(1, 1), hide=True)
49
50 context_manager = ContextManager()
51
52 __all__ = ["context_manager"]
53