kettle11 / kapp

A pure Rust window and input library for Windows, Mac, and Web. (Work in progress)
Apache License 2.0
56 stars 4 forks source link

sRGB support? #56

Closed lunabunn closed 3 years ago

lunabunn commented 3 years ago

EDIT:

Add an srgb flag to GLContextAttributes and implement it for different platforms.

Web currently doesn't support specifying the color space, see: https://github.com/WICG/canvas-color-space/blob/master/CanvasColorSpaceProposal.md


Original Issue:

Currently, I'm using a fork that changes https://github.com/kettle11/kapp/blob/fa32eb749dbbf9f5d83135841917bc692ce24c2a/gl_context/src/windows/mod.rs#L202 into true, but that's obviously not a great solution 😅

Why is that a false, anyway? Is it a placeholder? Shouldn't there be a flag for this in GLContextAttributes?

kettle11 commented 3 years ago

There should totally be a flag.

But most people will want that to be true (for modern computer monitors at least).

I have no idea why I set it to false. It may be a remnant of when I was experimenting with rendering wider than sRGB color spaces.

lunabunn commented 3 years ago

Makes sense.

Assuming you won't get to it before then, I'll try to get a PR in to add the flag & implement it on Windows. I have no idea how any of this works on mac though.

kettle11 commented 3 years ago

Cool! Thanks for the PRs, I really appreciate it.

I'll investigate to see if I can figure out how to implement it on Mac (thought if I'm remembering right the story is a bit more complex).

lunabunn commented 3 years ago

Implemented on Windows.

kettle11 commented 3 years ago

On MacOS I'm nervous that setting the window to sRGB may cause performance issues, based on similar issues in other libraries:

https://github.com/libsdl-org/SDL/issues/3645 https://github.com/OpenTTD/OpenTTD/issues/7644

However we can probably just document that there may be performance issues when using an sRGB back-buffer on Mac.

lunabunn commented 3 years ago

@kettle11 AFAICT, that second issue you linked improves perf by setting sRGB. It's actually mentioned in the first issue you linked.

I couldn't find any other references to this issue, though note that OpenTTD was able to improve performance by setting the colorspace OpenTTD/OpenTTD#7644

kettle11 commented 3 years ago

@lunabunn Oh yup, you're right!

I missed that somehow. Interesting. I guess we'll just have to keep an eye out for performance issues related to this setting.

For now I added sRGB support to MacOS, which is cool because that means we can render sRGB colors mostly consistently across Mac / Windows / Web, which is something other libraries have historically not handled well.