我正在 ImGui 中创建文本。它会自动右对齐,如何使该文本居中对齐?
ImGui::Text("Example Text");
Run Code Online (Sandbox Code Playgroud)
我不相信有一个函数可以做到这一点。我知道你可以为一个盒子或小部件做到这一点,但是对于一个简单的文本我该怎么做呢?
我想弄清楚如何更改“名称”打印上显示的文本的颜色,但我对如何操作几乎一无所知。我想让它变成绿色,感谢帮助或提示:D
// Name
ImGui::InputText("Name", selected_entry.name, 32);
Run Code Online (Sandbox Code Playgroud) 对于 Bazel,我正在从我的内部引入一个外部库WORKSPACE
:
new_http_archive(
name = "imgui",
build_file = "deps/BUILD.imgui",
sha256 = "c457fdc19b4e3aa74deccf6a2d9bc51f0d470b3acd9cc095bf04df16459d6474",
strip_prefix = 'imgui-1.62',
url = "https://github.com/ocornut/imgui/archive/v1.62.tar.gz",
)
Run Code Online (Sandbox Code Playgroud)
在里面BUILD.imgui
,我正在尝试构建它:
cc_library(
name = "imgui_sdl_opengl3",
linkopts = ["-ldl", "-lGL", "-L/usr/lib/x86_64-linux-gnu", "-lSDL2", "-lSDL"],
copts = ["-Iexamples/", "-D_REENTRANT",],
includes = [".","examples/libs/gl3w"],
hdrs = [
"examples/imgui_impl_opengl3.h",
"examples/libs/gl3w/GL/gl3w.h",
"examples/imgui_impl_sdl.h",
"examples/libs/gl3w/GL/glcorearb.h",
],
srcs = [
"examples/imgui_impl_opengl3.cpp",
"examples/imgui_impl_sdl.cpp",
"examples/libs/gl3w/GL/gl3w.c",
],
)
Run Code Online (Sandbox Code Playgroud)
问题是找不到#include <SDL.h>
。
我尝试将其添加到科普特:
copts = ["-Iexamples/", "-D_REENTRANT", "-I/usr/include/SDL"],
Run Code Online (Sandbox Code Playgroud)
但错误是:
The include path '/usr/include/SDL' references a path outside of the execution …
Run Code Online (Sandbox Code Playgroud) 最近几天我在搞乱 CMake,一切正常,除了我找不到将 ImGUI 与 GLFW 链接的方法
一切都是从源头构建的
这是错误:
Consolidate compiler generated dependencies of target glad
[ 2%] Built target glad
Consolidate compiler generated dependencies of target stb
[ 5%] Built target stb
Consolidate compiler generated dependencies of target glfw
[ 29%] Built target glfw
Consolidate compiler generated dependencies of target imgui
[ 30%] Building CXX object CMakeFiles/imgui.dir/lib/imgui/imgui.cpp.o
[ 31%] Building CXX object CMakeFiles/imgui.dir/lib/imgui/imgui_demo.cpp.o
[ 33%] Building CXX object CMakeFiles/imgui.dir/lib/imgui/imgui_draw.cpp.o
[ 34%] Building CXX object CMakeFiles/imgui.dir/lib/imgui/imgui_tables.cpp.o
[ 36%] Building CXX object …
Run Code Online (Sandbox Code Playgroud) 我试图找到任何可以向我展示如何进行即时模式 gui 的基本教程。我知道制作自己的 gui 是一件非常困难的事情。我已经尝试制作保留的 gui(它最终变得非常基本)。我一直在寻找任何 im gui 教程,但找不到。我试过阅读 ImGui lib,但有些东西很难理解。
你有任何视频,书籍,...?
你能给我一些建议,我怎样才能制作那种类型的 gui。
我不想使用外部库。我想学点东西。
我正在使用 C++ 中的 ImGui 开发桌面应用程序,并且我需要用户能够使用文件资源管理器在其计算机上搜索文件。使用 Python tkinter 非常容易做到这一点,但是我如何使用 C++ 做到这一点呢?
对的调用ImGui::InputText()
采用一个char
数组,我需要从 a 初始化该数组std::string
,然后将内容传输回std::string
. 最简单的形式:
char buf[255]{};
std::string s{"foo"};
void fn() {
strncpy( buf, s.c_str(), sizeof(buf)-1 );
ImGui::InputText( "Text", buf, sizeof(buf) );
s=buf;
}
Run Code Online (Sandbox Code Playgroud)
然而,让两个缓冲区(buf
以及其中分配的缓冲区std::string
)都做同样的事情似乎很浪费。我可以通过仅使用一个简单的包装器“X”来避免buf
缓冲区以及从缓冲区进行复制吗?std::string
我不关心效率,我只想要调用站点最简单的代码。这段代码确实有效,但它安全吗?有更好的方法吗?
class X {
public:
X(std::string& s) : s_{s} { s.resize(len_); }
~X() { s_.resize(strlen(s_.c_str())); }
operator char*(){ return s_.data(); }
static constexpr auto len() { return len_-1; }
private:
std::string& s_;
static constexpr auto len_=255;
};
std::string s{"foo"};
void fn() …
Run Code Online (Sandbox Code Playgroud) 我想知道如何从 ImGui 窗口中删除标题栏。为此,我使用 C++ 和 GLFW。
我对 ImGui 了解不多,而且它的文档也很少。
我想知道是否有办法创建一个 ImGui 窗口,然后随时渲染它。我只知道这种创建窗口的方式:
ImGui::Begin("Window");
ImGui::Button("Button");
ImGui::End();
Run Code Online (Sandbox Code Playgroud) 我使用以下命令在 Windows 10 上安装 Dear ImGui:
vcpkg install imgui:x64-windows
Run Code Online (Sandbox Code Playgroud)
仅安装:
imgui[core]:x64-windows -> 1.85
Run Code Online (Sandbox Code Playgroud)
我怀疑我需要从此列表中添加一个或多个绑定:
imgui[allegro5-binding] Make available Allegro5 binding
imgui[docking-experimental] Build with docking support
imgui[dx10-binding] Make available DirectX10 binding
imgui[dx11-binding] Make available DirectX11 binding
imgui[dx12-binding] Make available DirectX12 binding
imgui[dx9-binding] Make available DirectX9 binding
imgui[freetype] Build font atlases using FreeType instead of stb_truetype
imgui[glfw-binding] Make available GLFW binding
imgui[glut-binding] Make available Glut binding
imgui[libigl-imgui] Install the libigl-imgui headers
imgui[marmalade-binding] Make available Marmalade binding
imgui[metal-binding] Make available Metal binding
imgui[opengl2-binding] Make …
Run Code Online (Sandbox Code Playgroud)