Fix sky so that it works properly.

This commit is contained in:
Quantum 2018-08-22 00:35:15 -04:00
parent 6d1e52ae76
commit 0fea259382
3 changed files with 29 additions and 19 deletions

View file

@ -47,9 +47,9 @@ class Applet(pyglet.window.Window):
texture.init() texture.init()
if hasattr(self.config, '_attribute_names'): if hasattr(self.config, '_attribute_names'):
info = [' %-17s %s' % (key + ':', getattr(self.config, key)) info = [' %-22s %s' % (key + ':', getattr(self.config, key))
for key in self.config._attribute_names] for key in self.config._attribute_names]
info = ['%-25s %-25s' % group for group in info = ['%-30s %-30s' % group for group in
izip_longest(info[::2], info[1::2], fillvalue='')] izip_longest(info[::2], info[1::2], fillvalue='')]
info = 'OpenGL configuration:\n' + '\n'.join(info) info = 'OpenGL configuration:\n' + '\n'.join(info)
else: else:
@ -57,15 +57,21 @@ class Applet(pyglet.window.Window):
self.loaded = False self.loaded = False
self.__load_started = False self.__load_started = False
self._loading_phase = pyglet.text.Label(font_name='Consolas', font_size=20, x=10, y=self.height - 100, self._loading_phase = pyglet.text.Label(
color=(255, 255, 255, 255), width=self.width - 20, halign='center', font_name='Consolas', font_size=20, x=10, y=self.height - 80,
multiline=True, text='Punyverse is starting...') color=(255, 255, 255, 255), width=self.width - 20, align='center',
self._loading_label = pyglet.text.Label(font_name='Consolas', font_size=16, x=10, y=self.height - 200, multiline=True, text='Punyverse is starting...'
color=(255, 255, 255, 255), width=self.width - 20, halign='center', )
multiline=True) self._loading_label = pyglet.text.Label(
self._info_label = pyglet.text.Label(font_name='Consolas', font_size=13, x=10, y=self.height - 320, font_name='Consolas', font_size=16, x=10, y=self.height - 150,
color=(255, 255, 255, 255), width=self.width - 20, color=(255, 255, 255, 255), width=self.width - 20, align='center',
multiline=True, text=info) multiline=True
)
self._info_label = pyglet.text.Label(
font_name='Consolas', font_size=13, x=10, y=self.height - 250,
color=(255, 255, 255, 255), width=self.width - 20,
multiline=True, text=info
)
pyglet.clock.schedule_once(self.load, 0) pyglet.clock.schedule_once(self.load, 0)
def load(self, *args, **kwargs): def load(self, *args, **kwargs):
@ -368,7 +374,7 @@ class Applet(pyglet.window.Window):
self._loading_phase.draw() self._loading_phase.draw()
self._loading_label.draw() self._loading_label.draw()
if progress is not None: if progress is not None:
progress_bar(10, self.height - 240, self.width - 20, 50, progress) progress_bar(10, self.height - 170, self.width - 20, 50, progress)
self._info_label.draw() self._info_label.draw()
def on_draw(self, glMatrixBuffer=GLfloat * 16): def on_draw(self, glMatrixBuffer=GLfloat * 16):
@ -399,7 +405,10 @@ class Applet(pyglet.window.Window):
pitch, yaw, roll = entity.rotation pitch, yaw, roll = entity.rotation
with glMatrix(), glRestore(GL_CURRENT_BIT): with glMatrix(), glRestore(GL_CURRENT_BIT):
glTranslatef(x, y, z) if entity.background:
glTranslatef(c.x, c.y, c.z)
else:
glTranslatef(x, y, z)
glRotatef(pitch, 1, 0, 0) glRotatef(pitch, 1, 0, 0)
glRotatef(yaw, 0, 1, 0) glRotatef(yaw, 0, 1, 0)
glRotatef(roll, 0, 0, 1) glRotatef(roll, 0, 0, 1)
@ -482,5 +491,4 @@ class Applet(pyglet.window.Window):
cx, cy = width / 2, height / 2 cx, cy = width / 2, height / 2
glColor4f(0, 1, 0, 1) glColor4f(0, 1, 0, 1)
circle(10, 20, (cx, cy)) circle(10, 20, (cx, cy))
glPopAttrib()
frustrum() frustrum()

View file

@ -140,7 +140,7 @@ def flare(rinner, router, res, prob, tex):
last_y = y last_y = y
def sphere(r, lats, longs, tex, lighting=True, fv4=GLfloat * 4): def sphere(r, lats, longs, tex, lighting=True, fv4=GLfloat * 4, inside=False):
""" """
Sphere function from the OpenGL red book. Sphere function from the OpenGL red book.
""" """
@ -152,7 +152,7 @@ def sphere(r, lats, longs, tex, lighting=True, fv4=GLfloat * 4):
gluQuadricNormals(sphere, GLU_SMOOTH) gluQuadricNormals(sphere, GLU_SMOOTH)
glEnable(GL_CULL_FACE) glEnable(GL_CULL_FACE)
glCullFace(GL_BACK) glCullFace(GL_FRONT if inside else GL_BACK)
glEnable(GL_TEXTURE_2D) glEnable(GL_TEXTURE_2D)
if lighting: if lighting:
glDisable(GL_BLEND) glDisable(GL_BLEND)

View file

@ -179,9 +179,11 @@ class World(object):
object_id = compile(colourball, radius, division, division, texture) object_id = compile(colourball, radius, division, division, texture)
else: else:
if self.options.get('normal', False) and 'normal' in info: if self.options.get('normal', False) and 'normal' in info:
object_id = compile(normal_sphere, radius, division, texture, info['normal'], lighting=lighting) object_id = compile(normal_sphere, radius, division, texture,
info['normal'], lighting=lighting, inside=background)
else: else:
object_id = compile(sphere, radius, division, division, texture, lighting=lighting) object_id = compile(sphere, radius, division, division, texture,
lighting=lighting, inside=background)
elif 'model' in info: elif 'model' in info:
scale = info.get('scale', 1) scale = info.get('scale', 1)
object_id = model_list(load_model(info['model']), info.get('sx', scale), info.get('sy', scale), object_id = model_list(load_model(info['model']), info.get('sx', scale), info.get('sy', scale),
@ -268,4 +270,4 @@ class World(object):
self.callback('Loading objects (%d of %d)...' % (self._current_object, self._objects), self.callback('Loading objects (%d of %d)...' % (self._current_object, self._objects),
message, float(self._current_object) / self._objects) message, float(self._current_object) / self._objects)
self._body(satellite, info, object) self._body(satellite, info, object)
self._current_object += 1 self._current_object += 1