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 #64

Open
wants to merge 1 commit 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ void CScreensaverShadertoy::Render()
{
if (m_initialized)
{
glBindVertexArray(m_state.vao);

if (m_state.fbwidth && m_state.fbheight)
{
RenderTo(m_shadertoyShader.ProgramHandle(), m_state.effect_fb);
Expand All @@ -196,6 +198,8 @@ void CScreensaverShadertoy::Render()
{
RenderTo(m_shadertoyShader.ProgramHandle(), 0);
}

glBindVertexArray(0);
}
}

Expand All @@ -213,6 +217,9 @@ bool CScreensaverShadertoy::Start()
-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);
Expand All @@ -221,6 +228,9 @@ bool CScreensaverShadertoy::Start()
Launch(m_currentPreset);
m_initialized = true;

glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);

return true;
}

Expand All @@ -235,6 +245,8 @@ void CScreensaverShadertoy::Stop()
UnloadTextures();

glDeleteBuffers(1, &m_state.vertex_buffer);

glDeleteVertexArrays(1, &m_state.vao);
}

void CScreensaverShadertoy::RenderTo(GLuint shader, GLuint effect_fb)
Expand Down
1 change: 1 addition & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class ATTR_DLL_LOCAL CScreensaverShadertoy

struct
{
GLuint vao;
GLuint vertex_buffer;
GLuint attr_vertex_e;
GLuint attr_vertex_r, uTexture;
Expand Down