Skip to content

Commit fc34e25

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

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/cpBlobsMain.cpp

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

135135
SetupGradientBackground(m_BGTopColor, m_BGBottomColor);
136136

137+
#if defined(HAS_GL)
138+
glGenVertexArrays(1, &m_vao);
139+
#endif
140+
137141
glGenBuffers(1, &m_vertexVBO);
138-
glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO);
139142

140143
m_startOK = true;
141144
return true;
@@ -153,7 +156,6 @@ void CScreensaverCpBlobs::Stop()
153156

154157
m_startOK = false;
155158

156-
glBindBuffer(GL_ARRAY_BUFFER, 0);
157159
glDeleteBuffers(1, &m_vertexVBO);
158160
m_vertexVBO = 0;
159161

@@ -165,6 +167,10 @@ void CScreensaverCpBlobs::Stop()
165167

166168
if (m_specTexture)
167169
glDeleteTextures(1, &m_specTexture);
170+
171+
#if defined(HAS_GL)
172+
glDeleteVertexArrays(1, &m_vao);
173+
#endif
168174
}
169175

170176
/*
@@ -183,6 +189,10 @@ void CScreensaverCpBlobs::Render()
183189
* TODO: Maybe add a separate interface call to inform about?
184190
*/
185191
//@{
192+
#if defined(HAS_GL)
193+
glBindVertexArray(m_vao);
194+
#endif
195+
186196
glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO);
187197

188198
glVertexAttribPointer(m_hVertex, 3, GL_FLOAT, GL_TRUE, sizeof(sLight), BUFFER_OFFSET(offsetof(sLight, vertex)));
@@ -307,6 +317,12 @@ void CScreensaverCpBlobs::Render()
307317
glDisableVertexAttribArray(m_hNormal);
308318
glDisableVertexAttribArray(m_hColor);
309319
glDisableVertexAttribArray(m_hCoord);
320+
321+
glBindBuffer(GL_ARRAY_BUFFER, 0);
322+
323+
#if defined(HAS_GL)
324+
glBindVertexArray(0);
325+
#endif
310326
}
311327

312328
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)