From f961b4367579c223a0ac46a92d4c754618eb3182 Mon Sep 17 00:00:00 2001 From: Quantum Date: Sun, 5 Jan 2014 19:23:31 -0500 Subject: [PATCH] Allowed depth buffer to be adjusted and multisample be enabled. --- punyverse/__main__.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/punyverse/__main__.py b/punyverse/__main__.py index c3c3a5d..26ac613 100644 --- a/punyverse/__main__.py +++ b/punyverse/__main__.py @@ -6,17 +6,42 @@ WIN_TITLE = 'Punyverse' def main(): import argparse - parser = argparse.ArgumentParser(prog='punyverse', description='Python simulator of a puny universe.') + parser = argparse.ArgumentParser(prog='punyverse', description=''' + Python simulator of a puny universe. + ''') + parser.add_argument('-d', '--high-depth', help='Use a larger depth buffer', + const=32, default=24, dest='depth', nargs='?', type=int) + parser.add_argument('-m', '--multisample', help='Use multisampled image, ' + 'optional samples', const=2, default=0, nargs='?', + type=int) parser.add_argument('-v', '--no-vsync', help='Disables vsync', action='store_false', dest='vsync') args = parser.parse_args() import pyglet - from punyverse import game pyglet.options['shadow_window'] = False + template = pyglet.gl.Config(depth_size=args.depth, double_buffer=True, + sample_buffers=args.multisample > 1, + samples=args.multisample) + + platform = pyglet.window.get_platform() + display = platform.get_default_display() + screen = display.get_default_screen() + try: + config = screen.get_best_config(template) + except pyglet.window.NoSuchConfigException: + raise SystemExit('Graphics configuration not supported.') + else: + if hasattr(config, '_attribute_names'): + print 'OpenGL configuration:' + for key in config._attribute_names: + print ' %-17s %s' % (key + ':', getattr(config, key)) + + from punyverse import game game.Applet(width=INITIAL_WIN_WIDTH, height=INITIAL_WIN_HEIGHT, - caption=WIN_TITLE, resizable=True, vsync=args.vsync) + caption=WIN_TITLE, resizable=True, vsync=args.vsync, + config=config) pyglet.app.run()