mirror of
https://github.com/quantum5/punyverse.git
synced 2025-04-24 13:11:57 -04:00
Make sky disablable, and disable by default on macOS
This commit is contained in:
parent
9cdf3b8513
commit
e72a3bc623
|
@ -134,10 +134,10 @@ class LoaderWindow(pyglet.window.Window):
|
||||||
self.flip()
|
self.flip()
|
||||||
self.dispatch_events()
|
self.dispatch_events()
|
||||||
|
|
||||||
def load(self):
|
def load(self, **kwargs):
|
||||||
start = time.clock()
|
start = time.clock()
|
||||||
with glContext(self._main_context):
|
with glContext(self._main_context):
|
||||||
world = World('world.json', self._load_callback)
|
world = World('world.json', self._load_callback, **kwargs)
|
||||||
print('Loaded in %s seconds.' % (time.clock() - start))
|
print('Loaded in %s seconds.' % (time.clock() - start))
|
||||||
return world
|
return world
|
||||||
|
|
||||||
|
@ -167,10 +167,10 @@ class LoaderConsole(object):
|
||||||
def _load_callback(self, phase, message, progress):
|
def _load_callback(self, phase, message, progress):
|
||||||
print(message, file=self._output)
|
print(message, file=self._output)
|
||||||
|
|
||||||
def load(self):
|
def load(self, **kwargs):
|
||||||
start = time.clock()
|
start = time.clock()
|
||||||
with glContext(self._main_context):
|
with glContext(self._main_context):
|
||||||
world = World('world.json', self._load_callback)
|
world = World('world.json', self._load_callback, **kwargs)
|
||||||
print('Loaded in %s seconds.' % (time.clock() - start), file=self._output)
|
print('Loaded in %s seconds.' % (time.clock() - start), file=self._output)
|
||||||
return world
|
return world
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ def main():
|
||||||
parser = argparse.ArgumentParser(prog='punyverse', description='''
|
parser = argparse.ArgumentParser(prog='punyverse', description='''
|
||||||
Python simulator of a puny universe.
|
Python simulator of a puny universe.
|
||||||
''')
|
''')
|
||||||
|
parser.set_defaults(sky=not macos)
|
||||||
parser.add_argument('-D', '--debug', help='Enable pyglet OpenGL debugging', action='store_true')
|
parser.add_argument('-D', '--debug', help='Enable pyglet OpenGL debugging', action='store_true')
|
||||||
parser.add_argument('-d', '--high-depth', help='Use a larger depth buffer',
|
parser.add_argument('-d', '--high-depth', help='Use a larger depth buffer',
|
||||||
const=32, default=24, dest='depth', nargs='?', type=int)
|
const=32, default=24, dest='depth', nargs='?', type=int)
|
||||||
|
@ -23,6 +24,10 @@ def main():
|
||||||
action='store_false', dest='vsync')
|
action='store_false', dest='vsync')
|
||||||
parser.add_argument('-n', '--normal', help='Enables the use of normal maps',
|
parser.add_argument('-n', '--normal', help='Enables the use of normal maps',
|
||||||
action='store_true')
|
action='store_true')
|
||||||
|
parser.add_argument('-s', '--sky', help='Enables the sky', dest='sky',
|
||||||
|
action='store_true')
|
||||||
|
parser.add_argument('-S', '--no-sky', help='Disables the sky', dest='sky',
|
||||||
|
action='store_false')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
versioning = dict(major_version=3, minor_version=3)
|
versioning = dict(major_version=3, minor_version=3)
|
||||||
|
@ -70,7 +75,7 @@ def main():
|
||||||
loader.context.set_current()
|
loader.context.set_current()
|
||||||
|
|
||||||
loader.set_main_context(punyverse.context)
|
loader.set_main_context(punyverse.context)
|
||||||
world = loader.load()
|
world = loader.load(sky=args.sky)
|
||||||
punyverse.context.set_current()
|
punyverse.context.set_current()
|
||||||
punyverse.initialize(world)
|
punyverse.initialize(world)
|
||||||
loader.close()
|
loader.close()
|
||||||
|
|
|
@ -30,7 +30,7 @@ class World(object):
|
||||||
'belt': ('belt.vertex.glsl', 'model.fragment.glsl'),
|
'belt': ('belt.vertex.glsl', 'model.fragment.glsl'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, file, callback):
|
def __init__(self, file, callback, sky=True):
|
||||||
self.tracker = []
|
self.tracker = []
|
||||||
self.x = None
|
self.x = None
|
||||||
self.y = None
|
self.y = None
|
||||||
|
@ -40,6 +40,8 @@ class World(object):
|
||||||
self.asteroids = AsteroidManager(self)
|
self.asteroids = AsteroidManager(self)
|
||||||
self.cam = Camera()
|
self.cam = Camera()
|
||||||
|
|
||||||
|
self._sky = sky
|
||||||
|
|
||||||
self._program = None
|
self._program = None
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
self.programs = self._load_programs()
|
self.programs = self._load_programs()
|
||||||
|
@ -127,7 +129,7 @@ class World(object):
|
||||||
'Loading %s.' % name, i / belt_count)
|
'Loading %s.' % name, i / belt_count)
|
||||||
self.tracker.append(Belt(name, self, info))
|
self.tracker.append(Belt(name, self, info))
|
||||||
|
|
||||||
if 'sky' in root:
|
if 'sky' in root and self._sky:
|
||||||
def callback(index, file):
|
def callback(index, file):
|
||||||
self.callback('Loading sky...', 'Loading %s.' % file, index / 6)
|
self.callback('Loading sky...', 'Loading %s.' % file, index / 6)
|
||||||
self.tracker.append(Sky(self, root['sky'], callback))
|
self.tracker.append(Sky(self, root['sky'], callback))
|
||||||
|
|
Loading…
Reference in a new issue