wlc icon indicating copy to clipboard operation
wlc copied to clipboard

write_pixels color format

Open crondog opened this issue 9 years ago • 8 comments

So after doing https://github.com/Cloudef/wlc/pull/141 I have noticed that the border color which is being drawn by sway is rendered incorrectly. Sway is sending the colors in rgba format for everything however only the borders are drawn incorrectly. For some reason write_pixels is using bgra even though GL_RGBA is used. When I change format_map to GL_BGRA_EXT it works but doesn't seem right. I am out of ideas on how to fix it properly. I am still quite bad at opengl. Any ideas?

crondog avatar Mar 28 '16 04:03 crondog

The reason is that the pixels are written as uint32 per pixel, so in little endian it's reversed.

Cloudef avatar Mar 28 '16 09:03 Cloudef

If that is the case then why are there no problems when using swaybar. They both use the same code https://github.com/SirCmpwn/sway/blob/master/wayland/cairo.c#L3 https://github.com/SirCmpwn/sway/blob/window-borders/sway/render.c#L8

crondog avatar Mar 28 '16 10:03 crondog

But does swaybar render directly inside wlc? AFAIK It's separate process and doesn't probably even draw using opengl?

Cloudef avatar Mar 28 '16 10:03 Cloudef

Ah no it doesn't. Ok ill try and sort something out

crondog avatar Mar 28 '16 10:03 crondog

This does not work: https://github.com/SirCmpwn/sway/commit/7dc335bb46451ce984cb89bb7ed45ca932b2324d#commitcomment-16679816

I get:

[main.c:39] [wlc] gles2: function write_pixels at line 808: glTexSubImage2D(0x0DE1, 0, g.origin.x, g.origin.y, g.size.w, g.size.h, format_map[format].format, format_map[format].type, data) == GL_INVALID_OPERATION

So I assume GL_UNSIGNED_INT is not supported.

It seems like all the cairo formats are native endian, so I'm not sure how to do it without depending on endianness at some point in the conversion, unless gles supports it some other way than above.

mikkeloscar avatar Mar 29 '16 11:03 mikkeloscar

GL_UNSIGNED_INT is not supported in GLES2

Cloudef avatar Mar 29 '16 11:03 Cloudef

You could look at cairo's gl implementation, but what I looked the things they do are not pretty :)

Cloudef avatar Mar 29 '16 11:03 Cloudef

I was operating under the assumption that it'd be okay to use the wrong endianness and just fix it by writing the wrong endianness in sway and looking the other way.

ddevault avatar Mar 29 '16 13:03 ddevault