From ae5a001e0089e8b6804c81fdbab3f6903e46ec16 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 13 Apr 2019 10:39:01 +0200 Subject: [PATCH] examples/options: export widgets canvas as a real texture It'll avoid screen change clearing the texture content --- gamecore/modules/menusystem/widgets/init.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gamecore/modules/menusystem/widgets/init.lua b/gamecore/modules/menusystem/widgets/init.lua index c5182a8..92b22eb 100644 --- a/gamecore/modules/menusystem/widgets/init.lua +++ b/gamecore/modules/menusystem/widgets/init.lua @@ -53,13 +53,17 @@ end function BaseWidget:redrawCanvas() self.width, self.height = self.menu:getWidgetSize(self.id) - self.canvas.texture = love.graphics.newCanvas(self.width, self.height) - love.graphics.setCanvas( self.canvas.texture ) + local canvas = love.graphics.newCanvas(self.width, self.height) + love.graphics.setCanvas( canvas ) self:drawCanvas() self.canvas.needRedraw = false love.graphics.setCanvas( ) + local imageData = canvas:newImageData( ) + self.canvas.texture = love.graphics.newImage( imageData ) + canvas:release( ) + imageData:release( ) end function BaseWidget:drawCanvas()