From abce0ed3c4e1bad3b2fcbc75673b3204b271ad04 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 17 Apr 2016 16:17:23 -0400 Subject: [PATCH] Added setup of the source vertex array. --- Outputs/CRT/Internals/CRTOpenGL.cpp | 28 +++++++++++++++++++++++++++- Outputs/CRT/Internals/CRTOpenGL.hpp | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Outputs/CRT/Internals/CRTOpenGL.cpp b/Outputs/CRT/Internals/CRTOpenGL.cpp index 554d10f75..367da1859 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.cpp +++ b/Outputs/CRT/Internals/CRTOpenGL.cpp @@ -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(); diff --git a/Outputs/CRT/Internals/CRTOpenGL.hpp b/Outputs/CRT/Internals/CRTOpenGL.hpp index 9e92675bd..8378fdf99 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.hpp +++ b/Outputs/CRT/Internals/CRTOpenGL.hpp @@ -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