Jump to content

Recommended Posts

Posted
1 hour ago, Dreikblack said:

You need to do before w:RecordStats()

return nil.


 

function World:New()
    local this = setmetatable({}, World)
 
    -- Crear el mundo
    local world = CreateWorld()
    world:RecordStats(true)
    local mapName = "Maps/start.map"
   
    this.scene = nil
 
   
 
    Print("⚠️[World] Mundo creado exitosamente.")
 
 
 
    -- Métodos de instancia
    function this:Update()
        world:Update()
    end
 
    function this:Render(framebuffer)
        world:Render(framebuffer)
        Print(tonumber(world.renderstats.vram))
    end

 

image.thumb.png.6b6783d4bc5f7edfbb591558db85cba2.png

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Posted

Code Sample documentatation. 

image.thumb.png.6579d76101918dd7c2222da4cd78d622.png

 

 

-- Get the displays
local displays = GetDisplays()
 
-- Create a window
local window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[1])
 
-- Create a framebuffer
local framebuffer = CreateFramebuffer(window)
 
-- Create a world
local world = CreateWorld()
 
-- Create a camera
local camera = CreateCamera(world)
camera:SetClearColor(0.125)
camera:Move(0, 0, -4)
 
-- Create light
local light = CreateBoxLight(world)
light:SetRange(-20, 20)
light:SetArea(20, 20)
light:SetRotation(45, 35, 0)
 
-- Create model
local box = CreateBox(world)
 
-- Enable stats recording
world:RecordStats(true)
 
-- Setup 2D display
local cam2d = CreateCamera(world, PROJECTION_ORTHOGRAPHIC)
cam2d:SetRenderLayers(128)
cam2d:SetClearMode(CLEAR_DEPTH)
cam2d:SetPosition(framebuffer.size.x * 0.5, framebuffer.size.y * 0.5, 0)
 
local font = LoadFont("Fonts/arial.ttf")
local sprite = CreateSprite(world, font, "", 18)
sprite:SetRenderLayers(128)
sprite:SetPosition(2, framebuffer.size.y - font:GetHeight(18) - 2, 0)
 
-- Main loop
while window:Closed() == false and window:KeyDown(KEY_ESCAPE) == false do
 
    box:Turn(0,1,0)
 
    -- Display the framerate
    sprite:SetText("FPS: " .. tostring(world.renderstats.vram))
 
    world:Update()
    world:Render(framebuffer)
end

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Posted

This is currently not implemented, because I have not found a reliable cross-hardware way to do this.

  • Sad 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted
 -- Uso de memoria de Lua (KB)
        local memLua = math.floor(collectgarbage("count")) .. " KB"
   
        -- Acumulamos el tiempo de CPU para sacar un promedio
        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)
   
            -- Reiniciamos los contadores
            self.timeAccumulator = 0
            self.frameCounter = 0
        end

 

image.thumb.png.62889b6c4c9bf1e05901e20021feacc8.png

 

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

  • Solution
Posted

I am adding vram to the structure definition for Lua. The value will indicate the AVAILABLE memory, not the total, and will work with Nvidia and AMD cards.

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

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...