Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use VAO #124

Open
wants to merge 23 commits into
base: Omega
Choose a base branch
from
Open
Show file tree
Hide file tree
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: 11 additions & 0 deletions src/biof/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ bool CScreensaverBiof::Start()
if (!LoadShaderFiles(vertShader, fraqShader) || !CompileAndLink())
return false;

glGenVertexArrays(1, &m_vao);
glBindVertexArray(m_vao);

glGenBuffers(4, m_vboHandle);

m_normal.clear();
Expand Down Expand Up @@ -163,6 +166,8 @@ bool CScreensaverBiof::Start()

glBindBuffer(GL_ARRAY_BUFFER, 0);

glBindVertexArray(0);

m_startFrameTime = std::chrono::duration<double>(std::chrono::system_clock::now().time_since_epoch()).count();
m_startOK = true;
return true;
Expand All @@ -180,6 +185,8 @@ void CScreensaverBiof::Stop()
glDeleteBuffers(4, m_vboHandle);
memset(m_vboHandle, 0, sizeof(m_vboHandle));

glBindVertexArray(0);

glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
}
Expand All @@ -189,6 +196,8 @@ void CScreensaverBiof::Render()
if (!m_startOK)
return;

glBindVertexArray(m_vao);

if ((m_geometry == SPHERES) || (m_geometry == BIGSPHERES))
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
Expand Down Expand Up @@ -293,6 +302,8 @@ void CScreensaverBiof::Render()
glDisableVertexAttribArray(m_hVertex);
glDisableVertexAttribArray(m_hColor);

glBindVertexArray(0);

if ((m_geometry == SPHERES) || (m_geometry == BIGSPHERES))
glDisable(GL_CULL_FACE);

Expand Down
2 changes: 2 additions & 0 deletions src/biof/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class ATTR_DLL_LOCAL CScreensaverBiof

bool m_startOK = false;

GLuint m_vao = -1;

GLuint m_vboHandle[4] = {0};

int m_pointsQty, m_linesQty;
Expand Down
8 changes: 8 additions & 0 deletions src/busyspheres/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ bool CScreensaverBusySpheres::Start()
}
m_texture_id = kodi::gui::gl::Load(Texture);

glGenVertexArrays(1, &m_vao);

glGenBuffers(1, &m_vertexVBO);
glGenBuffers(1, &m_indexVBO);

Expand All @@ -92,6 +94,8 @@ void CScreensaverBusySpheres::Stop()
m_vertexVBO = 0;
glDeleteBuffers(1, &m_indexVBO);
m_indexVBO = 0;

glDeleteVertexArrays(1, &m_vao);
}

void CScreensaverBusySpheres::Render()
Expand All @@ -101,6 +105,8 @@ void CScreensaverBusySpheres::Render()
if (!m_startOK)
return;

glBindVertexArray(m_vao);

glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexVBO);
glBindTexture(GL_TEXTURE_2D, m_texture_id);
Expand Down Expand Up @@ -269,6 +275,8 @@ void CScreensaverBusySpheres::Render()
glDisableVertexAttribArray(m_aPosition);
glDisableVertexAttribArray(m_aColor);
glDisableVertexAttribArray(m_aCoord);

glBindVertexArray(0);
}

void CScreensaverBusySpheres::OnCompiledAndLinked()
Expand Down
1 change: 1 addition & 0 deletions src/busyspheres/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class ATTR_DLL_LOCAL CScreensaverBusySpheres
GLint m_aCoord = -1;
GLint m_aColor = -1;

GLuint m_vao = 0;
GLuint m_vertexVBO = 0;
GLuint m_indexVBO = 0;

Expand Down
12 changes: 11 additions & 1 deletion src/colorfire/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ bool CScreensaverColorFire::Start()
m_light[3].coord = glm::vec2(0.0f, 1.0f);
m_light[3].vertex = glm::vec3(-1.0f, 1.0f, 0.0f);

glGenVertexArrays(1, &m_vao);

glGenBuffers(1, &m_vertexVBO);
glGenBuffers(1, &m_indexVBO);

Expand All @@ -157,13 +159,14 @@ void CScreensaverColorFire::Stop()

m_startOK = false;

glBindBuffer(GL_ARRAY_BUFFER, 0);
glDeleteBuffers(1, &m_vertexVBO);
m_vertexVBO = 0;
glDeleteBuffers(1, &m_indexVBO);
m_indexVBO = 0;
glDeleteTextures(1, &m_texture);
m_texture = 0;

glDeleteVertexArrays(1, &m_vao);
}

void CScreensaverColorFire::Render()
Expand All @@ -177,6 +180,8 @@ void CScreensaverColorFire::Render()
* TODO: Maybe add a separate interface call to inform about?
*/
//@{
glBindVertexArray(m_vao);

glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_BLEND);

Expand Down Expand Up @@ -220,6 +225,11 @@ void CScreensaverColorFire::Render()
glDisableVertexAttribArray(m_hColor);
glDisableVertexAttribArray(m_hCoord);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);

glBindVertexArray(0);

glBlendFunc(GL_ONE, GL_ZERO);
glDisable(GL_BLEND);
}
Expand Down
1 change: 1 addition & 0 deletions src/colorfire/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class ATTR_DLL_LOCAL CScreensaverColorFire
GLint m_hCoord = -1;
GLint m_hColor = -1;

GLuint m_vao = 0;
GLuint m_vertexVBO = 0;
GLuint m_indexVBO = 0;
GLuint m_texture = 0;
Expand Down
13 changes: 11 additions & 2 deletions src/cyclone/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,9 @@ bool CScreensaverCyclone::Start()
m_particles[j] = new CParticle(m_cyclones[i]);
}

glGenVertexArrays(1, &m_vao);

glGenBuffers(1, &m_vertexVBO);
glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO);

m_lastTime = std::chrono::duration<double>(std::chrono::system_clock::now().time_since_epoch()).count();
m_startOK = true;
Expand All @@ -559,10 +560,11 @@ void CScreensaverCyclone::Stop()

m_startOK = false;

glBindBuffer(GL_ARRAY_BUFFER, 0);
glDeleteBuffers(1, &m_vertexVBO);
m_vertexVBO = 0;

glDeleteVertexArrays(1, &m_vao);

glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);

Expand All @@ -584,6 +586,9 @@ void CScreensaverCyclone::Render()
* TODO: Maybe add a separate interface call to inform about?
*/
//@{

glBindVertexArray(m_vao);

glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO);
glVertexAttribPointer(m_hVertex, 3, GL_FLOAT, GL_TRUE, sizeof(sLight), BUFFER_OFFSET(offsetof(sLight, vertex)));
glEnableVertexAttribArray(m_hVertex);
Expand Down Expand Up @@ -617,6 +622,10 @@ void CScreensaverCyclone::Render()
glDisableVertexAttribArray(m_hVertex);
glDisableVertexAttribArray(m_hNormal);
glDisableVertexAttribArray(m_hColor);

glBindBuffer(GL_ARRAY_BUFFER, 0);

glBindVertexArray(0);
}

void CScreensaverCyclone::DrawEntry(int primitive, const sLight* data, unsigned int size)
Expand Down
1 change: 1 addition & 0 deletions src/cyclone/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class ATTR_DLL_LOCAL CScreensaverCyclone
GLint m_hVertex = -1;
GLint m_hColor = -1;

GLuint m_vao = 0;
GLuint m_vertexVBO = 0;

CCyclone **m_cyclones;
Expand Down
16 changes: 12 additions & 4 deletions src/drempels/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ bool CScreensaverDrempels::Start()
m_quad[3].coord = glm::vec2(1.0f, 0.0f);
m_quad[3].vertex = glm::vec3(1.0f, 0.0f, 0.0f);

glGenVertexArrays(1, &m_vao);

glGenBuffers(1, &m_vertexVBO);
glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO);
glGenBuffers(1, &m_indexVBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexVBO);

RandomizeStartValues();

Expand All @@ -215,10 +215,8 @@ void CScreensaverDrempels::Stop()
delete [] m_cell;
delete [] m_buf;

glBindBuffer(GL_ARRAY_BUFFER, 0);
glDeleteBuffers(1, &m_vertexVBO);
m_vertexVBO = 0;
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glDeleteBuffers(1, &m_indexVBO);
m_indexVBO = 0;
glDeleteTextures(1, &m_tex);
Expand All @@ -231,6 +229,8 @@ void CScreensaverDrempels::Stop()
m_uvtex = 0;
glDeleteTextures(1, &m_btex);
m_btex = 0;

glDeleteVertexArrays(1, &m_vao);
}

void CScreensaverDrempels::Render()
Expand All @@ -244,6 +244,8 @@ void CScreensaverDrempels::Render()
* TODO: Maybe add a separate interface call to inform about?
*/
//@{
glBindVertexArray(m_vao);

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO);
Expand Down Expand Up @@ -636,10 +638,16 @@ void CScreensaverDrempels::Render()
DrawQuads(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
}

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

glDisableVertexAttribArray(m_hVertex);
glDisableVertexAttribArray(m_hColor);
glDisableVertexAttribArray(m_hCoord);

glBindBuffer(GL_ARRAY_BUFFER, 0);

glBindVertexArray(0);

glBlendFunc(GL_ONE, GL_ZERO);
}

Expand Down
1 change: 1 addition & 0 deletions src/drempels/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class ATTR_DLL_LOCAL CScreensaverDrempels
GLint m_hCoord = -1;
GLint m_hColor = -1;

GLuint m_vao = 0;
GLuint m_vertexVBO = 0;
GLuint m_indexVBO = 0;

Expand Down
12 changes: 10 additions & 2 deletions src/euphoria/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,9 @@ bool CScreensaverEuphoria::Start()
m_wisps = new CWisp[g_settings.dWisps];
m_backwisps = new CWisp[g_settings.dBackground];

glGenVertexArrays(1, &m_vao);

glGenBuffers(1, &m_vertexVBO);
glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO);

m_feedbackIntensity = float(g_settings.dFeedback) / 101.0f;
m_lastTime = std::chrono::duration<double>(std::chrono::system_clock::now().time_since_epoch()).count();
Expand All @@ -638,10 +639,11 @@ void CScreensaverEuphoria::Stop()

m_startOK = false;

glBindBuffer(GL_ARRAY_BUFFER, 0);
glDeleteBuffers(1, &m_vertexVBO);
m_vertexVBO = 0;

glDeleteVertexArrays(1, &m_vao);

glViewport(m_viewport.x, m_viewport.y, m_viewport.width, m_viewport.height);
glDisable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ZERO);
Expand Down Expand Up @@ -673,6 +675,8 @@ void CScreensaverEuphoria::Render()
* TODO: Maybe add a separate interface call to inform about?
*/
//@{
glBindVertexArray(m_vao);

glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);

Expand Down Expand Up @@ -789,6 +793,10 @@ void CScreensaverEuphoria::Render()
glDisableVertexAttribArray(m_hColor);
glDisableVertexAttribArray(m_hCoord);

glBindBuffer(GL_ARRAY_BUFFER, 0);

glBindVertexArray(0);

glDisable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ZERO);
}
Expand Down
1 change: 1 addition & 0 deletions src/euphoria/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class ATTR_DLL_LOCAL CScreensaverEuphoria
GLint m_hCoord = -1;
GLint m_hColor = -1;

GLuint m_vao = 0;
GLuint m_vertexVBO = 0;

CWisp *m_backwisps;
Expand Down
11 changes: 11 additions & 0 deletions src/feedback/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ bool CScreensaverFeedback::Start()
// Window initialization
glViewport(X(), Y(), Width(), Height());

glGenVertexArrays(1, &m_vao);

glGenBuffers(1, &m_vertexVBO);
glGenBuffers(1, &m_indexVBO);

Expand Down Expand Up @@ -171,6 +173,8 @@ void CScreensaverFeedback::Stop()
delete[] m_velocities;
delete[] m_accelerations;
delete[] m_framedTextures;

glDeleteVertexArrays(1, &m_vao);
}

void CScreensaverFeedback::Render()
Expand All @@ -184,6 +188,8 @@ void CScreensaverFeedback::Render()
* TODO: Maybe add a separate interface call to inform about?
*/
//@{
glBindVertexArray(m_vao);

glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexVBO);
BindTexture(GL_TEXTURE_2D, m_texture);
Expand Down Expand Up @@ -433,6 +439,11 @@ void CScreensaverFeedback::Render()
glDisableVertexAttribArray(m_hVertex);
glDisableVertexAttribArray(m_hColor);
glDisableVertexAttribArray(m_hCoord);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);

glBindVertexArray(0);
}

void CScreensaverFeedback::OnCompiledAndLinked()
Expand Down
1 change: 1 addition & 0 deletions src/feedback/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class ATTR_DLL_LOCAL CScreensaverFeedback
GLint m_hCoord = -1;
GLint m_hColor = -1;

GLuint m_vao = 0;
GLuint m_vertexVBO = 0;
GLuint m_indexVBO = 0;

Expand Down
Loading