Allowed depth buffer to be adjusted and multisample be enabled.

This commit is contained in:
Quantum 2014-01-05 19:23:31 -05:00
parent 54d9841d02
commit f961b43675

View file

@ -6,17 +6,42 @@ WIN_TITLE = 'Punyverse'
def main(): def main():
import argparse 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', parser.add_argument('-v', '--no-vsync', help='Disables vsync',
action='store_false', dest='vsync') action='store_false', dest='vsync')
args = parser.parse_args() args = parser.parse_args()
import pyglet import pyglet
from punyverse import game
pyglet.options['shadow_window'] = False 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, 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() pyglet.app.run()