diff --git a/friture/spectrumPlotWidget.py b/friture/spectrumPlotWidget.py index 2203bd84..837aed2b 100644 --- a/friture/spectrumPlotWidget.py +++ b/friture/spectrumPlotWidget.py @@ -356,37 +356,51 @@ def prepareQuadData(self, x, y, w, baseline, r, g, b): n = x.shape[0] - # 4 vertices per quad * (3 coordinates + 3 color coordinates) - if self.vertices_data.shape != (n*4, 6): - self.vertices_data = zeros((n*4, 6), dtype=np.float32) - - self.vertices_data[0::4, 0::6] = x[:,np.newaxis] - self.vertices_data[0::4, 1::6] = (y + h)[:,np.newaxis] - self.vertices_data[0::4, 2::6] = 0*x[:,np.newaxis] - self.vertices_data[0::4, 3::6] = r[:,np.newaxis] - self.vertices_data[0::4, 4::6] = g[:,np.newaxis] - self.vertices_data[0::4, 5::6] = b[:,np.newaxis] - - self.vertices_data[1::4, 0::6] = (x + w)[:,np.newaxis] - self.vertices_data[1::4, 1::6] = (y + h)[:,np.newaxis] - self.vertices_data[1::4, 2::6] = 0*x[:,np.newaxis] - self.vertices_data[1::4, 3::6] = r[:,np.newaxis] - self.vertices_data[1::4, 4::6] = g[:,np.newaxis] - self.vertices_data[1::4, 5::6] = b[:,np.newaxis] - - self.vertices_data[2::4, 0::6] = x[:,np.newaxis] - self.vertices_data[2::4, 1::6] = y[:,np.newaxis] - self.vertices_data[2::4, 2::6] = 0*x[:,np.newaxis] - self.vertices_data[2::4, 3::6] = r[:,np.newaxis] - self.vertices_data[2::4, 4::6] = g[:,np.newaxis] - self.vertices_data[2::4, 5::6] = b[:,np.newaxis] - - self.vertices_data[3::4, 0::6] = (x + w)[:,np.newaxis] - self.vertices_data[3::4, 1::6] = y[:,np.newaxis] - self.vertices_data[3::4, 2::6] = 0*x[:,np.newaxis] - self.vertices_data[3::4, 3::6] = r[:,np.newaxis] - self.vertices_data[3::4, 4::6] = g[:,np.newaxis] - self.vertices_data[3::4, 5::6] = b[:,np.newaxis] + # (1 quad = 2 triangles = 6 vertices) * (3 coordinates + 3 color coordinates) + if self.vertices_data.shape != (n*6, 6): + self.vertices_data = zeros((n*6, 6), dtype=np.float32) + + self.vertices_data[0::6, 0::6] = x[:,np.newaxis] + self.vertices_data[0::6, 1::6] = (y + h)[:,np.newaxis] + self.vertices_data[0::6, 2::6] = 0*x[:,np.newaxis] + self.vertices_data[0::6, 3::6] = r[:,np.newaxis] + self.vertices_data[0::6, 4::6] = g[:,np.newaxis] + self.vertices_data[0::6, 5::6] = b[:,np.newaxis] + + self.vertices_data[1::6, 0::6] = (x + w)[:,np.newaxis] + self.vertices_data[1::6, 1::6] = (y + h)[:,np.newaxis] + self.vertices_data[1::6, 2::6] = 0*x[:,np.newaxis] + self.vertices_data[1::6, 3::6] = r[:,np.newaxis] + self.vertices_data[1::6, 4::6] = g[:,np.newaxis] + self.vertices_data[1::6, 5::6] = b[:,np.newaxis] + + self.vertices_data[2::6, 0::6] = x[:,np.newaxis] + self.vertices_data[2::6, 1::6] = y[:,np.newaxis] + self.vertices_data[2::6, 2::6] = 0*x[:,np.newaxis] + self.vertices_data[2::6, 3::6] = r[:,np.newaxis] + self.vertices_data[2::6, 4::6] = g[:,np.newaxis] + self.vertices_data[2::6, 5::6] = b[:,np.newaxis] + + self.vertices_data[3::6, 0::6] = x[:,np.newaxis] + self.vertices_data[3::6, 1::6] = y[:,np.newaxis] + self.vertices_data[3::6, 2::6] = 0*x[:,np.newaxis] + self.vertices_data[3::6, 3::6] = r[:,np.newaxis] + self.vertices_data[3::6, 4::6] = g[:,np.newaxis] + self.vertices_data[3::6, 5::6] = b[:,np.newaxis] + + self.vertices_data[4::6, 0::6] = (x + w)[:,np.newaxis] + self.vertices_data[4::6, 1::6] = y[:,np.newaxis] + self.vertices_data[4::6, 2::6] = 0*x[:,np.newaxis] + self.vertices_data[4::6, 3::6] = r[:,np.newaxis] + self.vertices_data[4::6, 4::6] = g[:,np.newaxis] + self.vertices_data[4::6, 5::6] = b[:,np.newaxis] + + self.vertices_data[5::6, 0::6] = (x + w)[:,np.newaxis] + self.vertices_data[5::6, 1::6] = (y + h)[:,np.newaxis] + self.vertices_data[5::6, 2::6] = 0*x[:,np.newaxis] + self.vertices_data[5::6, 3::6] = r[:,np.newaxis] + self.vertices_data[5::6, 4::6] = g[:,np.newaxis] + self.vertices_data[5::6, 5::6] = b[:,np.newaxis] def transformUpdate(self): self.need_transform = True @@ -459,7 +473,7 @@ def glDraw(self, xMap, yMap, rect, vbo, shader_program): color_offset = c_void_p(3 * sizeof(c_float)) GL.glVertexAttribPointer(0, 3, GL.GL_FLOAT, GL.GL_FALSE, stride, vertex_offset) GL.glVertexAttribPointer(1, 3, GL.GL_FLOAT, GL.GL_FALSE, stride, color_offset) - GL.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, self.vertices_data.shape[0]) + GL.glDrawArrays(GL.GL_TRIANGLES, 0, self.vertices_data.shape[0]) GL.glDisableVertexAttribArray(0) GL.glDisableVertexAttribArray(1) finally: