mirror of
https://github.com/quantum5/punyverse.git
synced 2025-04-24 13:11:57 -04:00
No need to deactivate shaders or anything now.
This commit is contained in:
parent
f70a725a58
commit
b4c96ebf90
|
@ -68,7 +68,6 @@ class Asteroid(Entity):
|
||||||
shader.uniform_mat4('u_mvMatrix', self.mv_matrix)
|
shader.uniform_mat4('u_mvMatrix', self.mv_matrix)
|
||||||
shader.uniform_mat4('u_modelMatrix', self.model_matrix)
|
shader.uniform_mat4('u_modelMatrix', self.model_matrix)
|
||||||
self.model.draw(shader)
|
self.model.draw(shader)
|
||||||
self.world.activate_shader(None)
|
|
||||||
|
|
||||||
|
|
||||||
class AsteroidManager(object):
|
class AsteroidManager(object):
|
||||||
|
@ -137,7 +136,6 @@ class Belt(Entity):
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
object.draw(shader, instances=count)
|
object.draw(shader, instances=count)
|
||||||
shader.deactivate_all_attributes()
|
shader.deactivate_all_attributes()
|
||||||
self.world.activate_shader(None)
|
|
||||||
|
|
||||||
|
|
||||||
class Sky(Entity):
|
class Sky(Entity):
|
||||||
|
@ -161,7 +159,6 @@ class Sky(Entity):
|
||||||
Matrix4f.from_angles(rotation=(cam.pitch, cam.yaw, cam.roll)) *
|
Matrix4f.from_angles(rotation=(cam.pitch, cam.yaw, cam.roll)) *
|
||||||
Matrix4f.from_angles(rotation=self.rotation))
|
Matrix4f.from_angles(rotation=self.rotation))
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0)
|
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, self.texture)
|
glBindTexture(GL_TEXTURE_CUBE_MAP, self.texture)
|
||||||
shader.uniform_texture('u_skysphere', 0)
|
shader.uniform_texture('u_skysphere', 0)
|
||||||
|
|
||||||
|
@ -179,7 +176,7 @@ class Sky(Entity):
|
||||||
|
|
||||||
shader.deactivate_all_attributes()
|
shader.deactivate_all_attributes()
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
self.world.activate_shader(None)
|
glActiveTexture(GL_TEXTURE0)
|
||||||
|
|
||||||
|
|
||||||
class Body(Entity):
|
class Body(Entity):
|
||||||
|
@ -288,7 +285,6 @@ class Body(Entity):
|
||||||
|
|
||||||
if not solid:
|
if not solid:
|
||||||
glDisable(GL_BLEND)
|
glDisable(GL_BLEND)
|
||||||
self.world.activate_shader(None)
|
|
||||||
|
|
||||||
def draw(self, options):
|
def draw(self, options):
|
||||||
self._draw(options)
|
self._draw(options)
|
||||||
|
@ -385,7 +381,6 @@ class SphericalBody(Body):
|
||||||
shader.uniform_mat4('u_mvMatrix', self.mv_matrix)
|
shader.uniform_mat4('u_mvMatrix', self.mv_matrix)
|
||||||
shader.uniform_mat4('u_mvpMatrix', self.mvp_matrix)
|
shader.uniform_mat4('u_mvpMatrix', self.mvp_matrix)
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0)
|
|
||||||
glBindTexture(GL_TEXTURE_2D, self.texture)
|
glBindTexture(GL_TEXTURE_2D, self.texture)
|
||||||
shader.uniform_texture('u_planet.diffuseMap', 0)
|
shader.uniform_texture('u_planet.diffuseMap', 0)
|
||||||
|
|
||||||
|
@ -431,7 +426,6 @@ class SphericalBody(Body):
|
||||||
|
|
||||||
shader.deactivate_all_attributes()
|
shader.deactivate_all_attributes()
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
self.world.activate_shader(None)
|
|
||||||
glActiveTexture(GL_TEXTURE0)
|
glActiveTexture(GL_TEXTURE0)
|
||||||
|
|
||||||
def _draw_star(self):
|
def _draw_star(self):
|
||||||
|
@ -439,7 +433,6 @@ class SphericalBody(Body):
|
||||||
shader.uniform_float('u_radius', self.radius)
|
shader.uniform_float('u_radius', self.radius)
|
||||||
shader.uniform_mat4('u_mvpMatrix', self.mvp_matrix)
|
shader.uniform_mat4('u_mvpMatrix', self.mvp_matrix)
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0)
|
|
||||||
glBindTexture(GL_TEXTURE_2D, self.texture)
|
glBindTexture(GL_TEXTURE_2D, self.texture)
|
||||||
shader.uniform_texture('u_emission', 0)
|
shader.uniform_texture('u_emission', 0)
|
||||||
|
|
||||||
|
@ -453,7 +446,6 @@ class SphericalBody(Body):
|
||||||
|
|
||||||
shader.deactivate_all_attributes()
|
shader.deactivate_all_attributes()
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
self.world.activate_shader(None)
|
|
||||||
|
|
||||||
def _draw_sphere(self):
|
def _draw_sphere(self):
|
||||||
if self.type == 'planet':
|
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])
|
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)
|
shader.uniform_mat4('u_mvpMatrix', self.world.projection_matrix() * matrix)
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0)
|
|
||||||
glBindTexture(GL_TEXTURE_1D, self.atm_texture)
|
glBindTexture(GL_TEXTURE_1D, self.atm_texture)
|
||||||
shader.uniform_texture('u_texture', 0)
|
shader.uniform_texture('u_texture', 0)
|
||||||
|
|
||||||
|
@ -486,7 +477,6 @@ class SphericalBody(Body):
|
||||||
|
|
||||||
shader.deactivate_all_attributes()
|
shader.deactivate_all_attributes()
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
self.world.activate_shader(None)
|
|
||||||
glDisable(GL_BLEND)
|
glDisable(GL_BLEND)
|
||||||
glEnable(GL_CULL_FACE)
|
glEnable(GL_CULL_FACE)
|
||||||
|
|
||||||
|
@ -497,7 +487,6 @@ class SphericalBody(Body):
|
||||||
shader.uniform_mat4('u_modelMatrix', self.model_matrix)
|
shader.uniform_mat4('u_modelMatrix', self.model_matrix)
|
||||||
shader.uniform_mat4('u_mvpMatrix', self.mvp_matrix)
|
shader.uniform_mat4('u_mvpMatrix', self.mvp_matrix)
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0)
|
|
||||||
glBindTexture(GL_TEXTURE_2D, self.cloud_transparency)
|
glBindTexture(GL_TEXTURE_2D, self.cloud_transparency)
|
||||||
shader.uniform_texture('u_transparency', 0)
|
shader.uniform_texture('u_transparency', 0)
|
||||||
shader.uniform_vec3('u_diffuse', 1, 1, 1)
|
shader.uniform_vec3('u_diffuse', 1, 1, 1)
|
||||||
|
@ -513,7 +502,6 @@ class SphericalBody(Body):
|
||||||
|
|
||||||
shader.deactivate_all_attributes()
|
shader.deactivate_all_attributes()
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
self.world.activate_shader(None)
|
|
||||||
glDisable(GL_BLEND)
|
glDisable(GL_BLEND)
|
||||||
|
|
||||||
def _draw_rings(self):
|
def _draw_rings(self):
|
||||||
|
@ -527,7 +515,6 @@ class SphericalBody(Body):
|
||||||
shader.uniform_float('u_planetRadius', self.radius)
|
shader.uniform_float('u_planetRadius', self.radius)
|
||||||
shader.uniform_float('u_ambient', 0.1)
|
shader.uniform_float('u_ambient', 0.1)
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0)
|
|
||||||
glBindTexture(GL_TEXTURE_1D, self.ring_texture)
|
glBindTexture(GL_TEXTURE_1D, self.ring_texture)
|
||||||
shader.uniform_texture('u_texture', 0)
|
shader.uniform_texture('u_texture', 0)
|
||||||
|
|
||||||
|
@ -541,7 +528,6 @@ class SphericalBody(Body):
|
||||||
|
|
||||||
shader.deactivate_all_attributes()
|
shader.deactivate_all_attributes()
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
self.world.activate_shader(None)
|
|
||||||
glDisable(GL_BLEND)
|
glDisable(GL_BLEND)
|
||||||
glEnable(GL_CULL_FACE)
|
glEnable(GL_CULL_FACE)
|
||||||
|
|
||||||
|
@ -578,4 +564,3 @@ class ModelBody(Body):
|
||||||
shader.uniform_mat4('u_mvMatrix', self.mv_matrix)
|
shader.uniform_mat4('u_mvMatrix', self.mv_matrix)
|
||||||
shader.uniform_mat4('u_modelMatrix', self.model_matrix)
|
shader.uniform_mat4('u_modelMatrix', self.model_matrix)
|
||||||
self.vbo.draw(shader)
|
self.vbo.draw(shader)
|
||||||
self.world.activate_shader(None)
|
|
||||||
|
|
|
@ -247,7 +247,6 @@ class WavefrontVBO(object):
|
||||||
tex_id = self._tex_cache[mat.texture] if mat and mat.texture else 0
|
tex_id = self._tex_cache[mat.texture] if mat and mat.texture else 0
|
||||||
|
|
||||||
if tex_id:
|
if tex_id:
|
||||||
glActiveTexture(GL_TEXTURE0)
|
|
||||||
glBindTexture(GL_TEXTURE_2D, tex_id)
|
glBindTexture(GL_TEXTURE_2D, tex_id)
|
||||||
shader.uniform_bool('u_material.hasDiffuse', True)
|
shader.uniform_bool('u_material.hasDiffuse', True)
|
||||||
shader.uniform_texture('u_material.diffuseMap', 0)
|
shader.uniform_texture('u_material.diffuseMap', 0)
|
||||||
|
|
|
@ -258,7 +258,6 @@ class Punyverse(pyglet.window.Window):
|
||||||
shader.uniform_mat4('u_projMatrix', projection)
|
shader.uniform_mat4('u_projMatrix', projection)
|
||||||
self.info_engine.draw(info)
|
self.info_engine.draw(info)
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0)
|
|
||||||
glBindTexture(GL_TEXTURE_2D, self.world.font_tex)
|
glBindTexture(GL_TEXTURE_2D, self.world.font_tex)
|
||||||
shader.uniform_texture('u_alpha', 0)
|
shader.uniform_texture('u_alpha', 0)
|
||||||
shader.uniform_vec3('u_color', 1, 1, 1)
|
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)
|
self.info_engine.stride, self.info_engine.tex_offset)
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLES, 0, self.info_engine.vertex_count)
|
glDrawArrays(GL_TRIANGLES, 0, self.info_engine.vertex_count)
|
||||||
|
|
||||||
self.info_engine.end()
|
self.info_engine.end()
|
||||||
|
|
||||||
glDisable(GL_BLEND)
|
glDisable(GL_BLEND)
|
||||||
|
|
||||||
glLineWidth(2)
|
glLineWidth(2)
|
||||||
|
@ -280,11 +279,8 @@ class Punyverse(pyglet.window.Window):
|
||||||
shader.uniform_vec4('u_color', 0, 1, 0, 1)
|
shader.uniform_vec4('u_color', 0, 1, 0, 1)
|
||||||
shader.uniform_mat4('u_mvpMatrix', mvp)
|
shader.uniform_mat4('u_mvpMatrix', mvp)
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, self.circle.vbo)
|
glBindBuffer(GL_ARRAY_BUFFER, self.circle.vbo)
|
||||||
|
|
||||||
shader.vertex_attribute('a_position', self.circle.position_size, self.circle.type, GL_FALSE,
|
shader.vertex_attribute('a_position', self.circle.position_size, self.circle.type, GL_FALSE,
|
||||||
self.circle.stride, self.circle.position_offset)
|
self.circle.stride, self.circle.position_offset)
|
||||||
glDrawArrays(GL_LINE_LOOP, 0, self.circle.vertex_count)
|
glDrawArrays(GL_LINE_LOOP, 0, self.circle.vertex_count)
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||||
glLineWidth(1)
|
glLineWidth(1)
|
||||||
self.world.activate_shader(None)
|
|
||||||
|
|
Loading…
Reference in a new issue