Exemplo n.º 1
0
    def _post_draw(self):
        GLArray._post_draw(self)

        if self._sprite_texture == None:
            return

        self._sprite_texture.unbind()

        glDisable(GL_BLEND)
        glDisable(GL_POINT_SPRITE)
Exemplo n.º 2
0
   def _update(self, x, y, nx, ny):
      print ' Grid: updating cache...'
      self.x = x
      self.y = y
      self.nx = nx
      self.ny = ny

      dx = self.x / self.nx
      dy = self.y / self.ny

      points = [ ]
      for i in range(nx):
         points.append([i*dx, 0.0, 0.0])
         points.append([i*dx,   y, 0.0])
      points.append([x, 0.0, 0.0])
      points.append([x, y,   0.0])

      for i in range(ny):
         points.append([0.0, i*dy, 0.0])
         points.append([x,   i*dy, 0.0])
      points.append([0, y, 0.0])
      points.append([x, y, 0.0])

      self.buffer = GLArray(points)
      self.buffer.renderMode(GL_LINES)
Exemplo n.º 3
0
    def _pre_draw(self):
        GLArray._pre_draw(self)

        if self._sprite_texture == None:
            return

        glDepthMask(GL_FALSE)

        glEnable(GL_POINT_SMOOTH)
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE)

        self._sprite_texture.bind()

        glTexEnvf(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE)
        glEnable(GL_POINT_SPRITE)

        glPointSize(15.0)
Exemplo n.º 4
0
class Grid:
   def __init__(self):
      self.x = None
      self.y = None
      self.nx = None
      self.ny = None

   def __call__(self, x, y, nx, ny):
      checks = [ 
            self.x != x, 
            self.y != y, 
            self.nx != nx, 
            self.ny != ny ]
      if any(checks):
         self._update(x, y, nx, ny)

      self.buffer.draw()

   def _update(self, x, y, nx, ny):
      print ' Grid: updating cache...'
      self.x = x
      self.y = y
      self.nx = nx
      self.ny = ny

      dx = self.x / self.nx
      dy = self.y / self.ny

      points = [ ]
      for i in range(nx):
         points.append([i*dx, 0.0, 0.0])
         points.append([i*dx,   y, 0.0])
      points.append([x, 0.0, 0.0])
      points.append([x, y,   0.0])

      for i in range(ny):
         points.append([0.0, i*dy, 0.0])
         points.append([x,   i*dy, 0.0])
      points.append([0, y, 0.0])
      points.append([x, y, 0.0])

      self.buffer = GLArray(points)
      self.buffer.renderMode(GL_LINES)
Exemplo n.º 5
0
 def __init__(self, vertex_data=None, color_data=None):
     GLArray.__init__(self, vertex_data, color_data)
     self._sprite_texture = None