Jump to content

Recommended Posts

Posted
15 minutes ago, klepto2 said:

to enable stats you have to call: 

world->RecordStats(true);

otherwise no value in the renderstats will be filled.


Not Run
image.thumb.png.524951249d10d9b34101f36ecb285f53.png

-- 📊 Activar recolección de estadísticas
    world:RecordStats(true)
 
    Print(" [Debug] Sistema de depuración listo.")
 
    ---------------------------------------------------
    -- 🔁 Actualización periódica de stats en pantalla
    ---------------------------------------------------
    function this:Update()
        local stats = self.world.renderstats
        local fps = tostring(math.floor(stats.framerate or 0))
 
        if self.labels.fps then
            self.labels.fps:SetText("FPS: " .. fps)
        end
 
        -- 📈 Memoria de Lua y tiempo de CPU promedio
        local memLua = math.floor(collectgarbage("count")) .. " KB"
        self.frameCounter = self.frameCounter + 1
        self.timeAccumulator = self.timeAccumulator + (stats.rendertime or 0)
 
        if self.frameCounter >= 30 then
            local avgCPU = self.timeAccumulator / self.frameCounter
            local cpuTime = string.format("%.2f ms", avgCPU)
            self.labels.mem:SetText("Lua: " .. memLua .. " | CPU: " .. cpuTime)
 
            self.timeAccumulator = 0
            self.frameCounter = 0
        end
 
        -- 🖥️ Resolución actual de ventana
        local fbsize = self.window:GetWindow():GetSize()
        local resText = tostring(fbsize.x) .. " x " .. tostring(fbsize.y)
        if self.labels.res then
            self.labels.res:SetText("Resolution: " .. resText)
        end
 
        -- 🔳 Estado de ventana
        local fs = self.window:IsFullscreen() and "Fullscreen" or "Windowed"
        if self.labels.fs then
            self.labels.fs:SetText("Window: " .. fs)
        end
 
        -- 🌑 Cantidad de sombras generadas (estadística de motor)
        local shadows = tostring(stats.shadows or 0)
        if self.labels.shadows then
            self.labels.shadows:SetText("Shadows: " .. shadows)
        end
    end

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...