No need to deactivate shaders or anything now.

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

View file

@ -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):
@ -131,7 +130,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):
@ -155,7 +153,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)
@ -173,7 +170,7 @@ class Sky(Entity):
shader.deactivate_all_attributes()
glBindBuffer(GL_ARRAY_BUFFER, 0)
self.world.activate_shader(None)
glActiveTexture(GL_TEXTURE0)
class Body(Entity):
@ -282,7 +279,6 @@ class Body(Entity):
if not solid:
glDisable(GL_BLEND)
self.world.activate_shader(None)
def draw(self, options):
self._draw(options)
@ -379,7 +375,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)
@ -425,7 +420,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):
@ -433,7 +427,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)
@ -447,7 +440,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':
@ -466,7 +458,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)
@ -480,7 +471,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)
@ -491,7 +481,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)
@ -507,7 +496,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):
@ -521,7 +509,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)
@ -535,7 +522,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)
@ -572,4 +558,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

@ -257,7 +257,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)
@ -269,8 +268,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)
@ -279,11 +278,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)