sokol-luajit/editor/editor.lua

86 lines
2.6 KiB
Lua
Raw Normal View History

2024-12-12 20:56:46 +08:00
package.path = package.path..";../?.lua"
local dirtools = require("tools.vfs.dirtools").init("sokol%-luajit")
--_G.SOKOL_DLL = "sokol_debug_dll"
local sapp = require("sokol_app")
sg = require("sokol_gfx")
local slib = require("sokol_libs") -- Warn - always after gfx!!
local utils = require("utils")
local ffi = require("ffi")
2024-12-13 14:16:07 +08:00
-- --------------------------------------------------------------------------------------
-- Tiny ECS will be our core object manager.
-- Rendering, physics collision and more will be components to this system
-- Rendering specifically will be built with a ldb that will run all the culling, sorting
-- and binning needed. This will be decoupled from the editor itself.
local tiny = require('editor.world-manager')
2024-12-12 20:56:46 +08:00
-- --------------------------------------------------------------------------------------
local function init()
2024-12-13 14:16:07 +08:00
tiny:init({noserver = false})
2024-12-12 20:56:46 +08:00
local desc = ffi.new("sg_desc[1]")
desc[0].environment = slib.sglue_environment()
desc[0].logger.func = slib.slog_func
desc[0].disable_validation = false
sg.sg_setup( desc )
print("Sokol Is Valid: "..tostring(sg.sg_isvalid()))
local cmd = [[start "" http://localhost:9190/index.html]]
io.popen(cmd, "r")
end
-- --------------------------------------------------------------------------------------
local function input(event)
end
-- --------------------------------------------------------------------------------------
local function frame()
-- /* NOTE: the vs_params_t struct has been code-generated by the shader-code-gen */
local w = sapp.sapp_widthf()
local h = sapp.sapp_heightf()
local t = (sapp.sapp_frame_duration() * 60.0)
2024-12-13 14:16:07 +08:00
tiny:update(sapp.sapp_frame_duration())
2024-12-12 20:56:46 +08:00
-- Display frame stats in console.
-- hutils.show_stats()
end
-- --------------------------------------------------------------------------------------
local function cleanup()
sg.sg_shutdown()
2024-12-13 14:16:07 +08:00
tiny:final()
2024-12-12 20:56:46 +08:00
end
-- --------------------------------------------------------------------------------------
local app_desc = ffi.new("sapp_desc[1]")
app_desc[0].init_cb = init
app_desc[0].frame_cb = frame
app_desc[0].cleanup_cb = cleanup
app_desc[0].event_cb = input
app_desc[0].width = 1920
app_desc[0].height = 1080
app_desc[0].window_title = "editor - sokol"
app_desc[0].fullscreen = false
app_desc[0].icon.sokol_default = true
app_desc[0].enable_clipboard = true
app_desc[0].logger.func = slib.slog_func
sapp.sapp_run( app_desc )
-- --------------------------------------------------------------------------------------