imgui: Add support for sdl2 renderer (#1513)

+ allow to enable multiple backends
pull/1514/head
Jérôme Leclercq 2 years ago committed by GitHub
parent 017c4a3da4
commit a591c43770
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      packages/i/imgui/port/xmake.lua
  2. 12
      packages/i/imgui/xmake.lua

@ -5,6 +5,7 @@ option("wchar32", {showmenu = true, default = false})
option("freetype", {showmenu = true, default = false})
option("glfw_opengl3", {showmenu = true, default = false})
option("glfw_vulkan", {showmenu = true, default = false})
option("sdl2", {showmenu = true, default = false})
option("user_config", {showmenu = true, default = nil, type = "string"})
option("use_glad", {showmenu = true, default = false})
@ -17,11 +18,15 @@ if has_config("glfw_opengl3") then
if has_config("use_glad") then
add_requires("glad")
end
elseif has_config("glfw_vulkan") then
end
if has_config("glfw_vulkan") then
add_requires("glfw")
add_requires("vulkansdk")
add_requires("vulkan-headers")
end
if has_config("sdl2") then
add_requires("libsdl >=2.0.17")
end
target("imgui")
set_kind("static")
@ -52,12 +57,20 @@ target("imgui")
else
add_headerfiles("backends/imgui_impl_opengl3_loader.h")
end
elseif has_config("glfw_vulkan") then
end
if has_config("glfw_vulkan") then
add_files("backends/imgui_impl_vulkan.cpp", "backends/imgui_impl_glfw.cpp")
add_headerfiles("backends/imgui_impl_vulkan.h", "backends/imgui_impl_glfw.h")
add_packages("glfw")
add_packages("vulkan-headers")
end
if has_config("sdl2") then
add_files("backends/imgui_impl_sdl.cpp", "backends/imgui_impl_sdlrenderer.cpp")
add_headerfiles("backends/imgui_impl_sdl.h", "backends/imgui_impl_sdlrenderer.h")
add_packages("libsdl")
end
if has_config("user_config") then
local user_config = get_config("user_config")

@ -24,8 +24,9 @@ package("imgui")
add_versions("v1.75", "1023227fae4cf9c8032f56afcaea8902e9bfaad6d9094d6e48fb8f3903c7b866")
add_configs("user_config", {description = "Use user config (disables test!)", default = nil, type = "string"})
add_configs("glfw_opengl3", {description = "Use glfw+opengl3 as backend", default = false, type = "boolean"})
add_configs("glfw_vulkan", {description = "Use glfw+vulkan as backend", default = false, type = "boolean"})
add_configs("glfw_opengl3", {description = "Enable glfw+opengl3 backend", default = false, type = "boolean"})
add_configs("glfw_vulkan", {description = "Enable glfw+vulkan backend", default = false, type = "boolean"})
add_configs("sdl2", {description = "Enable sdl2 backend", default = false, type = "boolean"})
add_configs("wchar32", {description = "Use 32-bit for ImWchar (default is 16-bit)", default = false, type = "boolean"})
add_configs("freetype", {description = "Use FreeType to build and rasterize the font atlas", default = false, type = "boolean"})
@ -45,9 +46,13 @@ package("imgui")
package:add("defines", "IMGUI_IMPL_OPENGL_LOADER_GLAD")
end
package:add("deps", "glfw")
elseif package:config("glfw_vulkan") then
end
if package:config("glfw_vulkan") then
package:add("deps", "glfw")
end
if package:config("sdl2") then
package:add("deps", "libsdl >=2.0.17")
end
if package:version_str():find("-docking", 1, true) then
package:set("urls", {"https://github.com/ocornut/imgui.git"})
end
@ -59,6 +64,7 @@ package("imgui")
freetype = package:config("freetype"),
glfw_opengl3 = package:config("glfw_opengl3"),
glfw_vulkan = package:config("glfw_vulkan"),
sdl2 = package:config("sdl2"),
user_config = package:config("user_config"),
use_glad = package:version():lt("1.84") -- this flag will be used if glfw_opengl3 is enabled
}

Loading…
Cancel
Save