fix: better handling of indirect rendering
This commit is contained in:
parent
07400ce991
commit
6c55a070fe
10 changed files with 64 additions and 21 deletions
|
@ -138,6 +138,7 @@ end
|
|||
-- Draw the whole game
|
||||
|
||||
function CoreSystem:draw()
|
||||
self.scenemanager:redraw()
|
||||
self.scenemanager:draw()
|
||||
end
|
||||
|
||||
|
|
|
@ -127,4 +127,8 @@ function SceneManager:draw()
|
|||
self.controller.screen:cease()
|
||||
end
|
||||
|
||||
function SceneManager:redraw()
|
||||
self.currentScene:redraw()
|
||||
end
|
||||
|
||||
return SceneManager
|
||||
|
|
|
@ -20,9 +20,6 @@ end
|
|||
|
||||
function CanvasElement:updateElement(dt)
|
||||
CanvasElement.super.updateElement(self, dt)
|
||||
if (self.canvas.needRedraw or self.canvas.isAnimated) then
|
||||
self:redraw()
|
||||
end
|
||||
end
|
||||
|
||||
function CanvasElement:getCanvasDimensions()
|
||||
|
@ -30,6 +27,12 @@ function CanvasElement:getCanvasDimensions()
|
|||
end
|
||||
|
||||
function CanvasElement:redraw()
|
||||
if (self.canvas.needRedraw or self.canvas.isAnimated) then
|
||||
self:generateTexture()
|
||||
end
|
||||
end
|
||||
|
||||
function CanvasElement:generateTexture()
|
||||
local w, h = self:getDimensions()
|
||||
|
||||
local canvas = love.graphics.newCanvas(w + (self.canvas.padding*2), h + (self.canvas.padding*2))
|
||||
|
|
|
@ -110,6 +110,10 @@ end
|
|||
-- DRAW FUNCTIONS
|
||||
-- Draw the menu and its content
|
||||
|
||||
function GuiElement:redraw()
|
||||
|
||||
end
|
||||
|
||||
function GuiElement:drawElement()
|
||||
self:draw()
|
||||
end
|
||||
|
|
|
@ -162,6 +162,12 @@ end
|
|||
-- DRAW FUNCTIONS
|
||||
-- Draw the menu and its content
|
||||
|
||||
function Gui:redraw()
|
||||
for _, element in pairs(self.elements) do
|
||||
element:redraw()
|
||||
end
|
||||
end
|
||||
|
||||
function Gui:drawTop()
|
||||
for _, element in ipairs(self:getVisibleElement(true)) do
|
||||
element:drawElement()
|
||||
|
|
|
@ -185,5 +185,12 @@ function MenuModel:moveCursor(relative)
|
|||
page:moveCursor(relative)
|
||||
end
|
||||
|
||||
-- DRAW
|
||||
-- Draw widget
|
||||
function MenuModel:redraw()
|
||||
local page = self:getCurrentPage()
|
||||
page:redraw()
|
||||
end
|
||||
|
||||
|
||||
return MenuModel
|
||||
|
|
|
@ -189,5 +189,11 @@ function Page:moveCursor(relative)
|
|||
self:moveCursorAbsolute(self.selected + relative)
|
||||
end
|
||||
|
||||
-- DRAW
|
||||
function Page:redraw()
|
||||
for _, widget in ipairs(self.widgets) do
|
||||
widget:redraw()
|
||||
end
|
||||
end
|
||||
|
||||
return Page
|
||||
|
|
|
@ -169,6 +169,11 @@ function Menu:drawWidgetBackground(x, y, w, h)
|
|||
|
||||
end
|
||||
|
||||
function Menu:redraw()
|
||||
self.widget:redraw()
|
||||
Menu.super.redraw(self)
|
||||
end
|
||||
|
||||
-- WIDGET FUNCTIONS
|
||||
-- Handle widgets of the functions
|
||||
|
||||
|
|
|
@ -73,7 +73,13 @@ function BaseWidget:register()
|
|||
self.menu:addWidget(self)
|
||||
end
|
||||
|
||||
function BaseWidget:redrawCanvas()
|
||||
function BaseWidget:redraw()
|
||||
if (self.canvas.needRedraw) then
|
||||
self:generateTexture()
|
||||
end
|
||||
end
|
||||
|
||||
function BaseWidget:generateTexture()
|
||||
self.width, self.height = self.menu:getWidgetSize(self.id)
|
||||
|
||||
local canvas = love.graphics.newCanvas(self.width, self.height)
|
||||
|
@ -134,9 +140,6 @@ end
|
|||
-- Update the widget
|
||||
|
||||
function BaseWidget:update(dt)
|
||||
if (self.canvas.needRedraw) then
|
||||
self:redrawCanvas()
|
||||
end
|
||||
-- N/A
|
||||
end
|
||||
|
||||
|
|
|
@ -149,6 +149,10 @@ end
|
|||
-- DRAW FUNCTIONS
|
||||
-- Draw the scene and its content
|
||||
|
||||
function Scene:redraw()
|
||||
self.gui:redraw()
|
||||
end
|
||||
|
||||
function Scene:drawScene()
|
||||
self:drawStart()
|
||||
self:drawWorld()
|
||||
|
|
Loading…
Reference in a new issue