1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-03-12 10:42:14 +00:00

Switch to std::swap_ranges.

This commit is contained in:
Thomas Harte
2026-01-22 12:34:33 -05:00
parent 1495957f72
commit 81a65484a8
3 changed files with 15 additions and 14 deletions

View File

@@ -54,10 +54,6 @@
<CommandLineArguments>
<CommandLineArgument
argument = "&quot;/Users/thomasharte/Library/Mobile Documents/com~apple~CloudDocs/Soft/Master System/R-Type (NTSC).sms&quot;"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--display=compositecolour"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
@@ -66,10 +62,6 @@
</CommandLineArgument>
<CommandLineArgument
argument = "--new=zxspectrum"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "&quot;/Users/thomasharte/Library/Mobile\ Documents/com\~apple\~CloudDocs/Soft/Master\ System/Alex\ Kidd\ in\ Miracle\ World\ \(JP\).sms&quot;"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument

View File

@@ -94,7 +94,6 @@ private:
GLuint line_buffer_name_ = 0, line_vertex_array_ = 0;
template <typename T> void allocate_buffer(const T &array, GLuint &buffer_name, GLuint &vertex_array_name);
template <typename T> void patch_buffer(const T &array, GLuint target, uint16_t submit_pointer, uint16_t read_pointer);
GLuint write_area_texture_name_ = 0;
bool texture_exists_ = false;

View File

@@ -10,7 +10,7 @@
#include "OpenGL.hpp"
#include <utility>
#include <algorithm>
#include <vector>
namespace Outputs::Display::OpenGL {
@@ -35,16 +35,26 @@ struct Screenshot {
// Grab the framebuffer contents, temporarily setting single-byte alignment.
int prior_alignment;
glGetIntegerv(GL_PACK_ALIGNMENT, &prior_alignment);
glReadPixels((dimensions[2] - GLint(width)) >> 1, 0, GLint(width), GLint(height), GL_RGBA, GL_UNSIGNED_BYTE, pixel_data.data());
glReadPixels(
(dimensions[2] - GLint(width)) >> 1,
0,
GLint(width),
GLint(height),
GL_RGBA,
GL_UNSIGNED_BYTE,
pixel_data.data()
);
glPixelStorei(GL_PACK_ALIGNMENT, prior_alignment);
// Flip the contents into raster order.
const size_t line_size = size_t(width * 4);
for(size_t y = 0; y < size_t(height) / 2; ++y) {
const size_t flipped_y = size_t(height - 1) - y;
for(size_t x = 0; x < line_size; x++) {
std::swap(pixel_data[flipped_y * line_size + x], pixel_data[y * line_size + x]);
}
std::swap_ranges(
&pixel_data[flipped_y * line_size],
&pixel_data[flipped_y * line_size + line_size],
&pixel_data[y * line_size]
);
}
}