Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/opengl_spectrum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class ATTR_DLL_LOCAL CVisualizationSpectrum
std::vector<glm::vec3> m_vertex_buffer_data;
std::vector<glm::vec3> m_color_buffer_data;

GLuint m_vao = 0;

#ifdef HAS_GL
GLuint m_vertexVBO[2] = {0};
#endif
Expand Down Expand Up @@ -150,6 +152,8 @@ bool CVisualizationSpectrum::Start(int channels, int samplesPerSec, int bitsPerS

m_projMat = glm::frustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.5f, 10.0f);

glGenVertexArrays(1, &m_vao);

#ifdef HAS_GL
glGenBuffers(2, m_vertexVBO);
#endif
Expand All @@ -166,11 +170,12 @@ void CVisualizationSpectrum::Stop()
m_startOK = false;

#ifdef HAS_GL
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDeleteBuffers(2, m_vertexVBO);
m_vertexVBO[0] = 0;
m_vertexVBO[1] = 0;
#endif

glDeleteVertexArrays(1, &m_vao);
}

//-- Render -------------------------------------------------------------------
Expand All @@ -181,6 +186,8 @@ void CVisualizationSpectrum::Render()
if (!m_startOK)
return;

glBindVertexArray(m_vao);

#ifdef HAS_GL
glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO[0]);
glVertexAttribPointer(m_hPos, 3, GL_FLOAT, GL_FALSE, sizeof(GLfloat)*3, nullptr);
Expand Down Expand Up @@ -242,6 +249,8 @@ void CVisualizationSpectrum::Render()
glDisableVertexAttribArray(m_hPos);
glDisableVertexAttribArray(m_hCol);

glBindVertexArray(0);

glDisable(GL_DEPTH_TEST);
#ifdef HAS_GL
glDisable(GL_PROGRAM_POINT_SIZE);
Expand Down