Skip to content

Latest commit

 

History

History
76 lines (63 loc) · 1.49 KB

README-ZH.md

File metadata and controls

76 lines (63 loc) · 1.49 KB

OS-ImGui

一个简单的imgui库,基于Dear-ImGui.

旨在让人简单的上手imgui,仅需几分钟。

English -> README-EN

特点

  • 同时兼容内外部使用,切换方便快捷

如果你想使用内部版本, 只需要定义 "OSIMGUI_INTERNAL" 在预处理代码中.

  • 易于使用

Only one line of code is needed to call.

  • 多样绘制

示例

void DrawCallBack()
{
	ImGui::Begin("Menu");
	{
		ImGui::Text("This is a text.");
		if (ImGui::Button("Quit"))
		{
			// 使用Gui.Quit()退出程序或者卸载DLL。
			Gui.Quit();
			//...
		}
	}ImGui::End();
}
  1. 外部模式
int main()
{
	try {
		/*
		    新建窗口。
		*/
		Gui.NewWindow("WindowName", Vec2(500, 500), DrawCallBack);
		/*
		    通过指定窗口名或类名附加到窗口。
		*/
		Gui.AttachAnotherWindow("Title","", DrawCallBack);
	}
	catch (OSImGui::OSException& e)
	{
		std::cout << e.what() << std::endl;
	}

	system("pause");
	return 0;
}
  1. 内部模式
// 使用前请定义"OSIMGUI_INTERNAL" 在预处理代码中。

BOOL APIENTRY DllMain(HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
	if (ul_reason_for_call == DLL_PROCESS_ATTACH)
	{
		// 入口
		// 自动识别DirectX类型。
		Gui.Start(hModule, DrawCallBack, OSImGui::DirectXType::AUTO);
	}
	return TRUE;
}