ImGui::PlotLines lua API

This commit is contained in:
Mikulas Florek 2023-10-05 15:21:06 +02:00
parent c1213a26a4
commit 7d44effd32
4 changed files with 21 additions and 4 deletions

View File

@ -42,6 +42,7 @@ declare ImGui: {
NewLine : () -> (),
NextColumn : () -> (),
OpenPopup : (string) -> (),
PlotLines : (string, {number}, Vec2) -> (),
PopItemWidth : () -> (),
PopID : () -> (),
PopStyleColor : (number) -> (),

View File

@ -41,7 +41,8 @@ declare ImGui: {
NewLine : () -> (),
NextColumn : () -> (),
OpenPopup : (string) -> (),
PopItemWidth : () -> (),
PlotLines : (string, {number}, Vec2) -> (),
PopItemWidth : () -> (),
PopID : () -> (),
PopStyleColor : (number) -> (),
PopStyleVar : (number) -> (),

View File

@ -265,6 +265,22 @@ int SetNextWindowSize(float w, float h)
return 0;
}
void PlotLines(lua_State* L, const char* str_id) {
LuaWrapper::checkTableArg(L, 2);
Vec2 size = LuaWrapper::checkArg<Vec2>(L, 3);
const i32 num_values = lua_objlen(L, 2);
auto getter = [](void* data, i32 idx) -> float {
lua_State* L = (lua_State*)data;
int t = lua_rawgeti(L, 2, idx + 1);
float res = FLT_MAX;
if (t == LUA_TNUMBER) {
res = (float)lua_tonumber(L, -1);
}
lua_pop(L, 1);
return res;
};
ImGui::PlotLines(str_id, getter, L, num_values, 0, nullptr, FLT_MAX, FLT_MAX, size);
}
void OpenPopup(const char* str_id) { ImGui::OpenPopup(str_id); }
@ -1064,6 +1080,7 @@ void registerEngineAPI(lua_State* L, Engine* engine)
LuaImGui::registerCFunction(L, "NewLine", &LuaWrapper::wrap<&ImGui::NewLine>);
LuaImGui::registerCFunction(L, "NextColumn", &LuaWrapper::wrap<&ImGui::NextColumn>);
LuaImGui::registerCFunction(L, "OpenPopup", &LuaWrapper::wrap<LuaImGui::OpenPopup>);
LuaImGui::registerCFunction(L, "PlotLines", &LuaWrapper::wrap<&LuaImGui::PlotLines>);
LuaImGui::registerCFunction(L, "PopItemWidth", &LuaWrapper::wrap<&ImGui::PopItemWidth>);
LuaImGui::registerCFunction(L, "PopID", &LuaWrapper::wrap<&ImGui::PopID>);
LuaImGui::registerCFunction(L, "PopStyleColor", &LuaWrapper::wrap<&ImGui::PopStyleColor>);

View File

@ -392,9 +392,7 @@ struct RendererImpl final : Renderer
m_shader_defines.reserve(32);
gpu::preinit(m_allocator, shouldLoadRenderdoc());
m_frames[0].create(*this, m_allocator, m_engine.getPageAllocator());
m_frames[1].create(*this, m_allocator, m_engine.getPageAllocator());
m_frames[2].create(*this, m_allocator, m_engine.getPageAllocator());
for (Local<FrameData>& f : m_frames) f.create(*this, m_allocator, m_engine.getPageAllocator());
}
float getLODMultiplier() const override { return m_lod_multiplier; }