From 4f99fc6d612e97eecc11f11c1e0a2a8347fd7ec7 Mon Sep 17 00:00:00 2001 From: Lukas Rusak Date: Fri, 21 Apr 2023 10:21:46 -0700 Subject: [PATCH] CVisualizationMatrix: use vao Signed-off-by: Lukas Rusak --- src/main.cpp | 11 +++++++++++ src/main.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 29f80b5..509592a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -188,7 +188,11 @@ void CVisualizationMatrix::Render() { if (m_initialized) { + glBindVertexArray(m_state.vao); + RenderTo(m_matrixShader.ProgramHandle(), 0); + + glBindVertexArray(0); } } @@ -205,11 +209,16 @@ bool CVisualizationMatrix::Start(int iChannels, int iSamplesPerSec, int iBitsPer -1.0,-1.0, 1.0, 1.0, }; + glGenVertexArrays(1, &m_state.vao); + glBindVertexArray(m_state.vao); + // Upload vertex data to a buffer glGenBuffers(1, &m_state.vertex_buffer); glBindBuffer(GL_ARRAY_BUFFER, m_state.vertex_buffer); glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW); + glBindVertexArray(0); + m_samplesPerSec = iSamplesPerSec; Launch(m_currentPreset); m_initialized = true; @@ -226,6 +235,8 @@ void CVisualizationMatrix::Stop() UnloadTextures(); glDeleteBuffers(1, &m_state.vertex_buffer); + + glDeleteVertexArrays(1, &m_state.vao); } diff --git a/src/main.h b/src/main.h index 0556116..a9e45eb 100644 --- a/src/main.h +++ b/src/main.h @@ -107,6 +107,7 @@ class ATTR_DLL_LOCAL CVisualizationMatrix struct { + GLuint vao; GLuint vertex_buffer; GLuint attr_vertex_e; GLuint attr_vertex_r, uTexture;