Commit 6df7aa14 authored by abmyii's avatar abmyii
Browse files

Rotate clockwise instead of anti-clockwise to simulate 'true' landscape

parent f1bcf6bc
Pipeline #216351624 passed with stage
in 2 minutes and 56 seconds
......@@ -92,6 +92,7 @@ void read_pixels(int bpp, GLenum format, mir::geometry::Size const& size, std::v
auto width = size.width.as_uint32_t();
auto height = size.height.as_uint32_t();
// https://stackoverflow.com/a/60696921
std::vector<char> pixels(bpp * width * height);
glReadPixels(0, 0, width, height, format, GL_UNSIGNED_BYTE, pixels.data());
......@@ -103,15 +104,17 @@ void read_pixels(int bpp, GLenum format, mir::geometry::Size const& size, std::v
* (3 3 3) (2 2 2) (5 5 5)
* (7 7 7) (9 9 9) (8 8 8)
*
* It will be rotated 90 degrees anti-clockwise, with the pixel values remaining grouped like so:
* It will be rotated 90 degrees in either direction, with the pixel values remaining grouped, e.g.:
*
* (90 degrees anti-clockwise)
* (6 6 6) (5 5 5) (8 8 8)
* (4 4 4) (2 2 2) (9 9 9)
* (1 1 1) (3 3 3) (7 7 7)
*
**/
int i = 0;
for (int x = width*bpp; x > 0; x -= bpp) {
for (int y = 0; y < height; y++) {
for (int x = 0; x < width*bpp; x += bpp) {
for (int y = height; y > 0; y--) {
int offset = (width * bpp * y) + x;
// Set each of <bpp> pixels (i.e. <offset-3>, <offset-2>, <offset-1> <offset>)
......@@ -505,7 +508,7 @@ static void doptr(int buttonMask, int x, int y, rfbClientPtr cl)
int middle_down = buttonMask & 0x2;
if (landscape) {
y = maxy - y;
x = maxx - x;
std::swap(x, y);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment