1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-27 01:31:42 +00:00

Added setup of the source vertex array.

This commit is contained in:
Thomas Harte 2016-04-17 16:17:23 -04:00
parent 6ff9ffba6c
commit abce0ed3c4
2 changed files with 28 additions and 1 deletions

View File

@ -140,6 +140,8 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
if(!composite_input_shader_program && !rgb_shader_program)
{
prepare_composite_input_shader();
prepare_source_vertex_array();
prepare_rgb_output_shader();
prepare_output_vertex_array();
@ -319,7 +321,7 @@ char *OpenGLOutputBuilder::get_input_vertex_shader()
"void main(void)"
"{"
"ivec2 textureSize = textureSize(texID, 0);"
"inputPositionVarying = vec2(inputPositionVarying.x / textureSize.x, (inputPositionVarying.y + 0.5) / textureSize.y);"
"inputPositionVarying = vec2(inputPosition.x / textureSize.x, (inputPosition.y + 0.5) / textureSize.y);"
"gl_Position = vec4(outputPosition / outputTextureSize, 0.0, 1.0);"
"phaseVarying = (phaseCyclesPerTick * phaseTime + phaseAndAmplitude.x) * 2.0 * 3.141592654;"
@ -486,6 +488,30 @@ void OpenGLOutputBuilder::prepare_composite_input_shader()
free(fragment_shader);
}
void OpenGLOutputBuilder::prepare_source_vertex_array()
{
if(composite_input_shader_program)
{
GLint inputPositionAttribute = composite_input_shader_program->get_attrib_location("inputPosition");
GLint outputPositionAttribute = composite_input_shader_program->get_attrib_location("outputPosition");
GLint phaseAndAmplitudeAttribute = composite_input_shader_program->get_attrib_location("phaseAndAmplitude");
GLint phaseTimeAttribute = composite_input_shader_program->get_attrib_location("phaseTime");
glEnableVertexAttribArray((GLuint)inputPositionAttribute);
glEnableVertexAttribArray((GLuint)outputPositionAttribute);
glEnableVertexAttribArray((GLuint)phaseAndAmplitudeAttribute);
glEnableVertexAttribArray((GLuint)phaseTimeAttribute);
const GLsizei vertexStride = SourceVertexSize;
glBindBuffer(GL_ARRAY_BUFFER, source_array_buffer);
glVertexAttribPointer((GLuint)inputPositionAttribute, 2, GL_UNSIGNED_SHORT, GL_FALSE, vertexStride, (void *)SourceVertexOffsetOfInputPosition);
glVertexAttribPointer((GLuint)outputPositionAttribute, 2, GL_UNSIGNED_SHORT, GL_FALSE, vertexStride, (void *)SourceVertexOffsetOfOutputPosition);
glVertexAttribPointer((GLuint)phaseAndAmplitudeAttribute, 2, GL_UNSIGNED_BYTE, GL_TRUE, vertexStride, (void *)SourceVertexOffsetOfPhaseAndAmplitude);
glVertexAttribPointer((GLuint)phaseTimeAttribute, 2, GL_UNSIGNED_SHORT, GL_FALSE, vertexStride, (void *)SourceVertexOffsetOfPhaseTime);
}
}
/*void OpenGLOutputBuilder::prepare_output_shader(char *fragment_shader)
{
char *vertex_shader = get_output_vertex_shader();

View File

@ -48,6 +48,7 @@ class OpenGLOutputBuilder {
void prepare_rgb_output_shader();
void prepare_composite_input_shader();
void prepare_output_vertex_array();
void prepare_source_vertex_array();
void push_size_uniforms(unsigned int output_width, unsigned int output_height);
// the run and input data buffers