Skip to content

Commit 9c2a95e

Browse files
committed
CScreensaverCpBlobs: use vao
Signed-off-by: Lukas Rusak <lorusak@gmail.com>
1 parent 22d732f commit 9c2a95e

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/cpBlobsMain.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ bool CScreensaverCpBlobs::Start()
134134

135135
SetupGradientBackground(m_BGTopColor, m_BGBottomColor);
136136

137+
glGenVertexArrays(1, &m_vao);
138+
137139
glGenBuffers(1, &m_vertexVBO);
138-
glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO);
139140

140141
m_startOK = true;
141142
return true;
@@ -153,7 +154,6 @@ void CScreensaverCpBlobs::Stop()
153154

154155
m_startOK = false;
155156

156-
glBindBuffer(GL_ARRAY_BUFFER, 0);
157157
glDeleteBuffers(1, &m_vertexVBO);
158158
m_vertexVBO = 0;
159159

@@ -165,6 +165,8 @@ void CScreensaverCpBlobs::Stop()
165165

166166
if (m_specTexture)
167167
glDeleteTextures(1, &m_specTexture);
168+
169+
glDeleteVertexArrays(1, &m_vao);
168170
}
169171

170172
/*
@@ -183,6 +185,8 @@ void CScreensaverCpBlobs::Render()
183185
* TODO: Maybe add a separate interface call to inform about?
184186
*/
185187
//@{
188+
glBindVertexArray(m_vao);
189+
186190
glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO);
187191

188192
glVertexAttribPointer(m_hVertex, 3, GL_FLOAT, GL_TRUE, sizeof(sLight), BUFFER_OFFSET(offsetof(sLight, vertex)));
@@ -307,6 +311,10 @@ void CScreensaverCpBlobs::Render()
307311
glDisableVertexAttribArray(m_hNormal);
308312
glDisableVertexAttribArray(m_hColor);
309313
glDisableVertexAttribArray(m_hCoord);
314+
315+
glBindBuffer(GL_ARRAY_BUFFER, 0);
316+
317+
glBindVertexArray(0);
310318
}
311319

312320
void CScreensaverCpBlobs::SetDefaults()

src/cpBlobsMain.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class ATTR_DLL_LOCAL CScreensaverCpBlobs
7272
GLint m_hCoord = -1;
7373
GLint m_hColor = -1;
7474

75+
GLuint m_vao = 0;
7576
GLuint m_vertexVBO = 0;
7677
GLuint m_indexVBO = 0;
7778

0 commit comments

Comments
 (0)