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

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.
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
Expand Up @@ -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);
Expand All @@ -163,6 +165,8 @@ void CVisualizationShadertoy::Render()
{
RenderTo(m_shadertoyShader.ProgramHandle(), 0);
}

glBindVertexArray(0);
}
}

Expand All @@ -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;
Expand All @@ -203,6 +212,8 @@ void CVisualizationShadertoy::Stop()
UnloadTextures();

glDeleteBuffers(1, &m_state.vertex_buffer);

glDeleteVertexArrays(1, &m_state.vao);
}


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

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