Skip to content

Use VAO #115

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

Open
wants to merge 1 commit into
base: Omega
Choose a base branch
from
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: 11 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -154,6 +154,8 @@ void CVisualizationShadertoy::Render()
{
if (m_initialized)
{
glBindVertexArray(m_state.vao);

if (m_state.fbwidth && m_state.fbheight)
{
RenderTo(m_shadertoyShader.ProgramHandle(), m_state.effect_fb);
@@ -163,6 +165,8 @@ void CVisualizationShadertoy::Render()
{
RenderTo(m_shadertoyShader.ProgramHandle(), 0);
}

glBindVertexArray(0);
}
}

@@ -180,11 +184,16 @@ bool CVisualizationShadertoy::Start(int iChannels, int iSamplesPerSec, int iBits
-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);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);

glBindVertexArray(0);

m_samplesPerSec = iSamplesPerSec;
Launch(m_currentPreset);
m_initialized = true;
@@ -203,6 +212,8 @@ void CVisualizationShadertoy::Stop()
UnloadTextures();

glDeleteBuffers(1, &m_state.vertex_buffer);

glDeleteVertexArrays(1, &m_state.vao);
}


1 change: 1 addition & 0 deletions src/main.h
Original file line number Diff line number Diff line change
@@ -81,6 +81,7 @@ class ATTR_DLL_LOCAL CVisualizationShadertoy

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