mirror of
https://github.com/johndoe6345789/SDL3CPlusPlus.git
synced 2026-04-30 16:45:02 +00:00
feat: Add MaterialX support and enhance time retrieval in scripting
This commit is contained in:
@@ -520,6 +520,7 @@ void ScriptEngineService::RegisterBindings(lua_State* L) {
|
||||
bind("config_get_json", &ScriptEngineService::ConfigGetJson);
|
||||
bind("config_get_table", &ScriptEngineService::ConfigGetTable);
|
||||
bind("materialx_get_surface_parameters", &ScriptEngineService::MaterialXGetSurfaceParameters);
|
||||
bind("time_get_seconds", &ScriptEngineService::TimeGetSeconds);
|
||||
bind("window_get_size", &ScriptEngineService::WindowGetSize);
|
||||
bind("window_set_title", &ScriptEngineService::WindowSetTitle);
|
||||
bind("window_is_minimized", &ScriptEngineService::WindowIsMinimized);
|
||||
@@ -1320,6 +1321,23 @@ int ScriptEngineService::ConfigGetTable(lua_State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ScriptEngineService::TimeGetSeconds(lua_State* L) {
|
||||
auto* context = static_cast<LuaBindingContext*>(lua_touserdata(L, lua_upvalueindex(1)));
|
||||
auto logger = context ? context->logger : nullptr;
|
||||
const Uint64 counter = SDL_GetPerformanceCounter();
|
||||
const Uint64 frequency = SDL_GetPerformanceFrequency();
|
||||
double seconds = 0.0;
|
||||
if (frequency > 0) {
|
||||
seconds = static_cast<double>(counter) / static_cast<double>(frequency);
|
||||
}
|
||||
if (logger) {
|
||||
logger->Trace("ScriptEngineService", "TimeGetSeconds",
|
||||
"seconds=" + std::to_string(seconds));
|
||||
}
|
||||
lua_pushnumber(L, seconds);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ScriptEngineService::MaterialXGetSurfaceParameters(lua_State* L) {
|
||||
auto* context = static_cast<LuaBindingContext*>(lua_touserdata(L, lua_upvalueindex(1)));
|
||||
auto logger = context ? context->logger : nullptr;
|
||||
|
||||
Reference in New Issue
Block a user