1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-04-20 10:17:05 +00:00

Apply and update aspect ratio.

This commit is contained in:
Thomas Harte
2026-02-06 18:01:23 -05:00
parent 39b522e0f9
commit e59e51afa5
6 changed files with 32 additions and 17 deletions
@@ -58,7 +58,7 @@
</CommandLineArgument>
<CommandLineArgument
argument = "&quot;/Users/thomasharte/Library/Mobile Documents/com~apple~CloudDocs/Soft/Master System/Alex Kidd in Miracle World.sms&quot;"
isEnabled = "YES">
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--volume=0.1"
@@ -66,7 +66,7 @@
</CommandLineArgument>
<CommandLineArgument
argument = "&quot;/Users/thomasharte/Library/Mobile Documents/com~apple~CloudDocs/Soft/Master System/Alex Kidd in Miracle World (US).sms&quot;"
isEnabled = "NO">
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "&quot;/Users/thomasharte/Library/Mobile\ Documents/com\~apple\~CloudDocs/Soft/Archimedes/Lemmings.adf&quot;"
@@ -74,11 +74,11 @@
</CommandLineArgument>
<CommandLineArgument
argument = "--new=zxspectrum"
isEnabled = "NO">
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--display=CompositeColour"
isEnabled = "YES">
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "/Users/thomasharte/Downloads/Program/Program.prg"
+1 -1
View File
@@ -356,7 +356,7 @@ void Shader::set_uniform_matrix(
const GLfloat *const values
) {
with_location(name, [&](const GLint location) {
const GLboolean glTranspose = transpose ? GL_TRUE : GL_FALSE;
const GLboolean glTranspose = transpose ? GL_TRUE : GL_FALSE;
switch(size) {
case 2: glUniformMatrix2fv(location, count, glTranspose, values); break;
case 3: glUniformMatrix3fv(location, count, glTranspose, values); break;
+18 -7
View File
@@ -130,6 +130,22 @@ void ScanTarget::set_target_framebuffer(GLuint target_framebuffer) {
});
}
void ScanTarget::update_aspect_ratio_transformation() {
if(output_buffer_.empty()) {
return;
}
const auto framing = aspect_ratio_transformation(
BufferingScanTarget::modals(),
float(output_buffer_.width()) / float(output_buffer_.height())
);
if(!line_output_shader_.empty()) {
line_output_shader_.set_aspect_ratio_transformation(framing);
}
// TODO: apply framing to scan_output_shader_, once it exists.
}
void ScanTarget::setup_pipeline() {
const auto modals = BufferingScanTarget::modals();
const auto data_type_size = Outputs::Display::size_for_data_type(modals.input_data_type);
@@ -297,6 +313,7 @@ void ScanTarget::setup_pipeline() {
}
}
update_aspect_ratio_transformation();
existing_modals_ = modals;
}
@@ -422,13 +439,7 @@ void ScanTarget::update(const int output_width, const int output_height) {
GL_NEAREST,
true
);
const auto framing = aspect_ratio_transformation(
BufferingScanTarget::modals(),
float(output_buffer_width) / float(output_buffer_height)
);
line_output_shader_.set_aspect_ratio_transformation(framing);
// TODO: apply framing to scan_output_shader_, once it exists.
update_aspect_ratio_transformation();
}
// Do S-Video or composite line decoding.
+2
View File
@@ -117,6 +117,8 @@ private:
LineOutputShader line_output_shader_;
CopyShader copy_shader_;
FillShader fill_shader_;
void update_aspect_ratio_transformation();
};
}
+4 -5
View File
@@ -18,8 +18,7 @@ constexpr char vertex_shader[] = R"glsl(
uniform mediump vec2 sourceSize;
uniform highp vec2 positionScale;
uniform mediump float lineHeight;
// TODO: programmable crop should affect scaling via uniforms.
uniform lowp mat3 scale;
in highp vec2 lineEndpoint0Position;
in highp float lineEndpoint0CyclesSinceRetrace;
@@ -55,7 +54,7 @@ void main(void) {
) / positionScale;
gl_Position =
vec4(
(centre + (longitudinal - 0.5) * normal * lineHeight) * vec2(2.0, -2.0) + vec2(-1.0, 1.0),
(scale * vec3(centre + (longitudinal - 0.5) * normal * lineHeight, 1.0)).xy,
0.0,
1.0
) ;
@@ -126,8 +125,8 @@ OpenGL::LineOutputShader::LineOutputShader(
shader_.set_uniform("alpha", GLfloat(alpha));
}
void OpenGL::LineOutputShader::set_aspect_ratio_transformation(const std::array<float, 9> &) {
void OpenGL::LineOutputShader::set_aspect_ratio_transformation(const std::array<float, 9> &transform) {
shader_.set_uniform_matrix("scale", 3, false, transform.data());
}
void OpenGL::LineOutputShader::bind() {
@@ -39,6 +39,9 @@ public:
void reset() {
shader_.reset();
}
bool empty() const {
return shader_.empty();
}
private:
Shader shader_;
};