gabstv / ebiten-imgui

Dear ImGui renderer for Ebitengine
MIT License
122 stars 18 forks source link

getTexture: convert from straight to premultiplied alpha. #14

Closed divVerent closed 2 years ago

divVerent commented 2 years ago

imgui uses straight alpha (see e.g. http://docs.ros.org/en/kinetic/api/librealsense2/html/imgui__draw_8cpp_source.html#l01108), while Ebiten expects premultiplied alpha (see https://pkg.go.dev/github.com/hajimehoshi/ebiten/v2#Image.ReplacePixels). So sadly a conversion is necessary. Not doing the conversion in-place, as the font pixel data is pointing into a memory area owned by imgui, which could lead to double converting the same data (just in the examples it does not really matter).

In Ebiten 2.3, a min() statement was removed from the shader to improve performance, which "accidentally" had fixed up textures like the ones imgui produced; after this change, ebiten-imgui is compatible both with Ebiten 2.2 and 2.3.

Fixes https://github.com/hajimehoshi/ebiten/issues/2080

gabstv commented 2 years ago

Thank you! I tested and it fixes the main glitch from updating to Ebiten 2.3.x. Merged.