I am writing a program to display a textured quad with data from a real time capture of a video signal.
Because of an Image Generator limitation, i will need to alter the position and texture coordinates of the vertices buffer.
If I was statically declaring the vertices, I would use the following code:
GLfloat vertices[20] = { 1.0f, 1.0f, 0.9f, 1.0f, 1.0f, // Top Right
1.0f, -1.0f, 0.9f, 1.0f, 0.0f, // Bottom Right
-1.0f, -1.0f, 0.9f, 0.0f, 0.0f, // Bottom Left
-1.0f, 1.0f, 0.9f, 0.0f, 1.0f }; // Top Left
GLuint indices[6] = { 0, 1, 3, // First Triangle
1, 2, 3 };// Second Traingle
glGenVertexArrays( 1, &VAO[Output] );
glGenBuffers( 1, &VBO[Output] );
glGenBuffers( 1, &EBO[Output] );
glBindVertexArray( VAO[Output] );
glBindBuffer( GL_ARRAY_BUFFER, VBO[Output] );
glBufferData( GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, EBO[Output] );
glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW );
glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)0 );
glEnableVertexAttribArray( 0 );
glVertexAttribPointer( 1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat)) );
glEnableVertexAttribArray( 1 );
If I need to modify the vertices and texture coordinates:
Should I declare a Vertex Array Object (VAO) at all?
If I declare a VAO, can I just modify the vertices and only call glBindVertexArray, glBindBuffer and glBufferData for the vertices inside the main loop?
If no VAO, would that just be a glBindBuffer and glBufferData for the vertices inside the main loop?
I realize i can not have an element array buffer without a VAO, so I will just increase the total vertices to cover the two distinct triangles.
thanks in advance for your help.