forked from marcan/blitzloop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphics.py
More file actions
69 lines (60 loc) · 2.22 KB
/
graphics.py
File metadata and controls
69 lines (60 loc) · 2.22 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2012-2017 Hector Martin "marcan" <hector@marcansoft.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 or version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from blitzloop import util
def Display(*args, **kwargs):
global _display
display = util.get_opts().display
if display == "glut":
from blitzloop.backend import glut
_display = glut.Display(*args, **kwargs)
elif display == "glfw":
from blitzloop.backend import glfw
_display = glfw.Display(*args, **kwargs)
elif display == "rpi":
from blitzloop.backend import rpi
_display = rpi.Display(*args, **kwargs)
elif display == "kms":
from blitzloop.backend import kms
_display = kms.Display(*args, **kwargs)
elif display == "surfaceless":
from blitzloop.backend import surfaceless
_display = surfaceless.Display(*args, **kwargs)
else:
raise Exception("Unknown display: %s" % display)
return _display
_renderer = None
def get_renderer():
global _renderer
if _renderer is None:
from blitzloop.renderer import gles as _renderer
return _renderer
_solid_renderer = None
def get_solid_renderer():
global _solid_renderer
if _solid_renderer is None:
_solid_renderer = get_renderer().SolidRenderer(_display)
return _solid_renderer
_texture_renderer = None
def get_texture_renderer():
global _texture_renderer
if _texture_renderer is None:
_texture_renderer = get_renderer().TextureRenderer(_display)
return _texture_renderer
def GL():
return get_renderer().gl
def arrays():
return get_renderer().arrays