slages / love-imgui

imgui module for the LÖVE game engine
MIT License
318 stars 61 forks source link

Rendering canvas on windows causes visual glitch #22

Open aki-cat opened 6 years ago

aki-cat commented 6 years ago

Ok, so I'm creating a database font editor, and I'm using a canvas to render the fonts using love's rendering functions because it's easier than figuring out how to use fonts with imgui (which is my bad).

But here's the thing: when the canvas makes the window become big enough to have a scrollbar, it causes this: screen shot 2017-12-27 at 9 20 16 pm

But when you scroll down all the way, or when you set focus to other imgui windows, or even when a tooltip shows up, it goes back to what it's supposed to render: screen shot 2017-12-27 at 9 20 21 pm

Note that the background also becomes white, when it was supposed to be gray. It looks like the canvas is not unsetting itself, maybe?

the code looks like this:

-- let's assume canvas is declared elsewhere
love.graphics.setCanvas(canvas)
love.graphics.setFont(font)
love.graphics.setColor(255, 255, 255)
love.graphics.printf(text, 0, 0, canvas_width)
love.graphics.setCanvas()
imgui.Image(canvas, canvas_width, canvas_height)

Since this is a problem with love2d's canvases, I assumed this would be an issue in the wrapper for love2d, and not necessarily imgui itself. There are many workarounds I can think of, but if there is an actual problem with the actual wrapper I thought it'd be better to address it. I hope it's ok to post this issue.

slages commented 6 years ago

I can't manage to reproduce it, if this problem is still relevant, can you provide me with a test code?

sanikoyes commented 6 years ago

just add love.graphics.setBlendMode('alpha', 'alphamultiply') to fix this problem

aki-cat commented 6 years ago

The problem seems to be fixed in the current master. It has been a while since I came back to that code, so I'm sorry for the delay in answering.