From 5a4d656cde78ce08fd19087f2e9817c1e46349a5 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 28 Jan 2026 14:41:46 -0500 Subject: [PATCH] Enable vertex attributes. --- Outputs/OpenGL/CompositionShader.cpp | 60 +++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/Outputs/OpenGL/CompositionShader.cpp b/Outputs/OpenGL/CompositionShader.cpp index c77be5c48..778e792f3 100644 --- a/Outputs/OpenGL/CompositionShader.cpp +++ b/Outputs/OpenGL/CompositionShader.cpp @@ -7,6 +7,7 @@ // #include "CompositionShader.hpp" +#include "Outputs/ScanTargets/BufferingScanTarget.hpp" namespace { @@ -369,6 +370,61 @@ OpenGL::Shader OpenGL::composition_shader( prefix + fragment_shader ); - // TODO: bind inputs to match ScanTarget::Scan. - return std::move(shader); +#define rt_offset_of(field) reinterpret_cast((reinterpret_cast(&scan.field) - reinterpret_cast(&scan))) + BufferingScanTarget::Scan scan; + + for(int c = 0; c < 2; c++) { + const std::string endpoint = std::string("scanEndpoint") + std::to_string(c); + + shader.enable_vertex_attribute_with_pointer( + endpoint + "DataOffset", + 1, GL_UNSIGNED_SHORT, GL_FALSE, + sizeof(scan), + rt_offset_of(scan.end_points[c].data_offset), + 1 + ); + + shader.enable_vertex_attribute_with_pointer( + endpoint + "CyclesSinceRetrace", + 1, GL_UNSIGNED_SHORT, GL_FALSE, + sizeof(scan), + rt_offset_of(scan.end_points[c].cycles_since_end_of_horizontal_retrace), + 1 + ); + + shader.enable_vertex_attribute_with_pointer( + endpoint + "CompositeAngle", + 1, GL_UNSIGNED_BYTE, GL_FALSE, + sizeof(scan), + rt_offset_of(scan.end_points[c].cycles_since_end_of_horizontal_retrace), + 1 + ); + } + + shader.enable_vertex_attribute_with_pointer( + "scanDataY", + 1, GL_UNSIGNED_SHORT, GL_FALSE, + sizeof(scan), + rt_offset_of(data_y), + 1 + ); + + shader.enable_vertex_attribute_with_pointer( + "scanLine", + 1, GL_UNSIGNED_SHORT, GL_FALSE, + sizeof(scan), + rt_offset_of(line), + 1 + ); + + shader.enable_vertex_attribute_with_pointer( + "scanCompositeAmplitude", + 1, GL_UNSIGNED_BYTE, GL_FALSE, + sizeof(scan), + rt_offset_of(scan.composite_amplitude), + 1 + ); +#undef rt_offset_of + + return shader; }