Note that I use only OpenGL and compile Irrlicht without the others. I assume something similar would work with other drivers but I havent tried.
IGE_CHECK() just logs an error and returns false if the action fails, IGE_TRACE() just logs the text, etc...
setting up ImGui is relatively easy:
to initialize ImGui :
Code: Select all
// internal initialization method
bool IGE_ImGui::initializeImGui()
{
IGE_TRACE("IGE_ImGui::initializeImGui()");
// Setup Dear ImGui context
IMGUI_CHECKVERSION();
IGE_CHECK(ImGui::CreateContext(),"ImGui::CreateContext() failed",IGE_FAILURE);
ImGuiIO& io = ImGui::GetIO(); //(void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
// Setup Dear ImGui style
ImGui::StyleColorsDark();
//ImGui_ImplGlfw_InitForOpenGL(m_Application->getWindow()->getWindow(), true);
ImGui_ImplWin32_Init(getApplication()->getContext()->m_Driver->getExposedVideoData().OpenGLWin32.HWnd);
IGE_CHECK(ImGui_ImplOpenGL3_Init("#version 130"),"ImGui_ImplOpenGL3_Init failed",IGE_FAILURE);
// everything went fine
return IGE_SUCCESS;
}
Code: Select all
m_Driver->beginFrame();
// Start the Dear ImGui frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
.. render all of the ImGui stuff
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
m_Driver->endFrame();
in the eventreciever class during OnEvent(const SEvent& event) i call this
Code: Select all
void IGE_ImGui::ImGui_ImplIrrlicht_ProcessEvent(const irr::SEvent& event)
{
ImGuiIO& io = ImGui::GetIO();
switch (event.EventType)
{
case irr::EET_MOUSE_INPUT_EVENT:
{
const irr::SEvent::SMouseInput& mouseEvent = event.MouseInput;
if (mouseEvent.Event == irr::EMIE_LMOUSE_PRESSED_DOWN) io.MouseDown[0] = true;
else if (mouseEvent.Event == irr::EMIE_LMOUSE_LEFT_UP) io.MouseDown[0] = false;
else if (mouseEvent.Event == irr::EMIE_RMOUSE_PRESSED_DOWN) io.MouseDown[1] = true;
else if (mouseEvent.Event == irr::EMIE_RMOUSE_LEFT_UP) io.MouseDown[1] = false;
io.MousePos = ImVec2(mouseEvent.X, mouseEvent.Y);
} break;
case irr::EET_KEY_INPUT_EVENT:
{
const irr::SEvent::SKeyInput& keyEvent = event.KeyInput;
io.KeyMap[ImGuiKey_Space] = 0;
io.KeysDown[keyEvent.Key] = keyEvent.PressedDown;
io.KeyCtrl = io.KeysDown[irr::KEY_LCONTROL] || io.KeysDown[irr::KEY_RCONTROL];
io.KeyShift = io.KeysDown[irr::KEY_LSHIFT] || io.KeysDown[irr::KEY_RSHIFT];
io.KeyAlt = io.KeysDown[irr::KEY_MENU];
io.KeySuper = io.KeysDown[irr::KEY_LWIN] || io.KeysDown[irr::KEY_RWIN];
if (event.KeyInput.Char > 0 && event.KeyInput.Char < 0x10000) io.AddInputCharacter((unsigned short)event.KeyInput.Char);
} break;
}
}
The only real issue is the texture system. I have hacked it with this :
///////////////////////////////////////////////////////////////////////////
* ITexture.h
add public uint32_t UserData variable to base class
* COpenGLCoreTexture.h
UserData = m_TextureName during OpenGl texture creation
///////////////////////////////////////////////////////////////////////////
example usage :
Code: Select all
uint32_t TextureID = m_Driver->getTexture("_assets/_Textures/dwarf.jpg")->UserData;
ImGui::ImageButton((void*)(intptr_t)TextureID, ImVec2(600,600));