Esempio n. 1
0
    def render(self):
        if self.buffer:
            self.enable_blending()
            self.set_default_uniforms()
            # Set texture
            gl.glActiveTexture(self.textureUnit.glenum)
            gl.glBindTexture(gl.GL_TEXTURE_2D, self.texture.glId)
            gl.glUniform1i(self.get_uniform_loc('textureSampler'), self.textureUnit.id)

            self.set_buffer('xyuv', self.buffer)
            super().draw(gl.GL_TRIANGLES, len(self.buffer))
Esempio n. 2
0
    def render(self):
        if self.buffer:
            self.enable_blending()
            self.set_default_uniforms()
            # Set texture
            gl.glActiveTexture(self.textureUnit.glenum)
            gl.glBindTexture(gl.GL_TEXTURE_2D, self.texture.glId)
            gl.glUniform1i(self.get_uniform_loc('textureSampler'),
                           self.textureUnit.id)

            self.set_buffer('xyuv', self.buffer)
            super().draw(gl.GL_TRIANGLES, len(self.buffer))
Esempio n. 3
0
 def draw_textboxs(self, textboxes):
     if not textboxes:
         # Nothing to draw, exit to avoid np.vstack exception.
         return
     fontTexture = self.fontTexture
     for textbox in textboxes:
         state = self._make_state(textbox)
         if textbox._renderState != state:
             textbox._buffer = self._make_buffer(textbox)
             textbox._renderState = state
     buffer = np.vstack([textbox._buffer for textbox in textboxes])
     # Set buffers
     self.pcsBuffer.set_data(buffer[:, 0:4])
     self.colorBuffer.set_data(buffer[:, 4:8])
     self.set_buffer('pos_char_scale', self.pcsBuffer)
     self.set_buffer('color', self.colorBuffer)
     # Set uniforms
     self.set_texture(self.fontTexture)
     config = fontTexture.config
     for name in ('rowsize', 'gridwidth', 'gridheight', 'fontsize'):
         gl.glUniform1i(self.get_uniform_loc(name), config[name])
     self.set_matrix_uniform()
     # Start draw
     self.draw(gl.GL_POINTS, len(buffer))
Esempio n. 4
0
 def set_texture(self, texture):
     gl.glActiveTexture(self.textureUnit.glenum)
     gl.glBindTexture(gl.GL_TEXTURE_2D, texture.glId)
     gl.glUniform1i(self.get_uniform_loc('fontSampler'), self.textureUnit.id)