No need to deactivate shaders or anything now.

This commit is contained in:
Quantum 2018-08-28 23:20:49 -04:00
parent f70a725a58
commit b4c96ebf90
3 changed files with 3 additions and 23 deletions

View file

@ -59,7 +59,7 @@ class Asteroid(Entity):
def update(self):
super(Asteroid, self).update()
rx, ry, rz = self.rotation
# Increment all axis to 'spin'
# Increment all axis to 'spin'
self.rotation = rx + 1, ry + 1, rz + 1
def draw(self, options):
@ -68,7 +68,6 @@ class Asteroid(Entity):
shader.uniform_mat4('u_mvMatrix', self.mv_matrix)
shader.uniform_mat4('u_modelMatrix', self.model_matrix)
self.model.draw(shader)
self.world.activate_shader(None)
class AsteroidManager(object):
@ -137,7 +136,6 @@ class Belt(Entity):
glBindBuffer(GL_ARRAY_BUFFER, 0)
object.draw(shader, instances=count)
shader.deactivate_all_attributes()
self.world.activate_shader(None)
class Sky(Entity):
@ -161,7 +159,6 @@ class Sky(Entity):
Matrix4f.from_angles(rotation=(cam.pitch, cam.yaw, cam.roll)) *
Matrix4f.from_angles(rotation=self.rotation))
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_CUBE_MAP, self.texture)
shader.uniform_texture('u_skysphere', 0)
@ -179,7 +176,7 @@ class Sky(Entity):
shader.deactivate_all_attributes()
glBindBuffer(GL_ARRAY_BUFFER, 0)
self.world.activate_shader(None)
glActiveTexture(GL_TEXTURE0)
class Body(Entity):
@ -288,7 +285,6 @@ class Body(Entity):
if not solid:
glDisable(GL_BLEND)
self.world.activate_shader(None)
def draw(self, options):
self._draw(options)
@ -385,7 +381,6 @@ class SphericalBody(Body):
shader.uniform_mat4('u_mvMatrix', self.mv_matrix)
shader.uniform_mat4('u_mvpMatrix', self.mvp_matrix)
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_2D, self.texture)
shader.uniform_texture('u_planet.diffuseMap', 0)
@ -431,7 +426,6 @@ class SphericalBody(Body):
shader.deactivate_all_attributes()
glBindBuffer(GL_ARRAY_BUFFER, 0)
self.world.activate_shader(None)
glActiveTexture(GL_TEXTURE0)
def _draw_star(self):
@ -439,7 +433,6 @@ class SphericalBody(Body):
shader.uniform_float('u_radius', self.radius)
shader.uniform_mat4('u_mvpMatrix', self.mvp_matrix)
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_2D, self.texture)
shader.uniform_texture('u_emission', 0)
@ -453,7 +446,6 @@ class SphericalBody(Body):
shader.deactivate_all_attributes()
glBindBuffer(GL_ARRAY_BUFFER, 0)
self.world.activate_shader(None)
def _draw_sphere(self):
if self.type == 'planet':
@ -472,7 +464,6 @@ class SphericalBody(Body):
matrix = Matrix4f([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, mv[12], mv[13], mv[14], 1])
shader.uniform_mat4('u_mvpMatrix', self.world.projection_matrix() * matrix)
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_1D, self.atm_texture)
shader.uniform_texture('u_texture', 0)
@ -486,7 +477,6 @@ class SphericalBody(Body):
shader.deactivate_all_attributes()
glBindBuffer(GL_ARRAY_BUFFER, 0)
self.world.activate_shader(None)
glDisable(GL_BLEND)
glEnable(GL_CULL_FACE)
@ -497,7 +487,6 @@ class SphericalBody(Body):
shader.uniform_mat4('u_modelMatrix', self.model_matrix)
shader.uniform_mat4('u_mvpMatrix', self.mvp_matrix)
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_2D, self.cloud_transparency)
shader.uniform_texture('u_transparency', 0)
shader.uniform_vec3('u_diffuse', 1, 1, 1)
@ -513,7 +502,6 @@ class SphericalBody(Body):
shader.deactivate_all_attributes()
glBindBuffer(GL_ARRAY_BUFFER, 0)
self.world.activate_shader(None)
glDisable(GL_BLEND)
def _draw_rings(self):
@ -527,7 +515,6 @@ class SphericalBody(Body):
shader.uniform_float('u_planetRadius', self.radius)
shader.uniform_float('u_ambient', 0.1)
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_1D, self.ring_texture)
shader.uniform_texture('u_texture', 0)
@ -541,7 +528,6 @@ class SphericalBody(Body):
shader.deactivate_all_attributes()
glBindBuffer(GL_ARRAY_BUFFER, 0)
self.world.activate_shader(None)
glDisable(GL_BLEND)
glEnable(GL_CULL_FACE)
@ -578,4 +564,3 @@ class ModelBody(Body):
shader.uniform_mat4('u_mvMatrix', self.mv_matrix)
shader.uniform_mat4('u_modelMatrix', self.model_matrix)
self.vbo.draw(shader)
self.world.activate_shader(None)

View file

@ -247,7 +247,6 @@ class WavefrontVBO(object):
tex_id = self._tex_cache[mat.texture] if mat and mat.texture else 0
if tex_id:
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_2D, tex_id)
shader.uniform_bool('u_material.hasDiffuse', True)
shader.uniform_texture('u_material.diffuseMap', 0)

View file

@ -258,7 +258,6 @@ class Punyverse(pyglet.window.Window):
shader.uniform_mat4('u_projMatrix', projection)
self.info_engine.draw(info)
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_2D, self.world.font_tex)
shader.uniform_texture('u_alpha', 0)
shader.uniform_vec3('u_color', 1, 1, 1)
@ -270,8 +269,8 @@ class Punyverse(pyglet.window.Window):
self.info_engine.stride, self.info_engine.tex_offset)
glDrawArrays(GL_TRIANGLES, 0, self.info_engine.vertex_count)
self.info_engine.end()
glDisable(GL_BLEND)
glLineWidth(2)
@ -280,11 +279,8 @@ class Punyverse(pyglet.window.Window):
shader.uniform_vec4('u_color', 0, 1, 0, 1)
shader.uniform_mat4('u_mvpMatrix', mvp)
glBindBuffer(GL_ARRAY_BUFFER, self.circle.vbo)
shader.vertex_attribute('a_position', self.circle.position_size, self.circle.type, GL_FALSE,
self.circle.stride, self.circle.position_offset)
glDrawArrays(GL_LINE_LOOP, 0, self.circle.vertex_count)
glBindBuffer(GL_ARRAY_BUFFER, 0)
glLineWidth(1)
self.world.activate_shader(None)