Welcome to the IrrIMGUI project
IrrIMGUI API documentation
Index
Most Important API Bookmarks
Code Snippets
Getting started
Full explanation: Example 1: HelloWorld
Step 1: Include header files
Step 2: Initialize Irrlicht Device and GUI
using namespace irr;
SIrrlichtCreationParameters IrrlichtParams;
IrrlichtParams.DriverType = video::EDT_OPENGL;
IrrlichtParams.WindowSize = core::dimension2d<u32>(1024, 800);
IrrlichtParams.Bits = 32;
IrrlichtParams.Fullscreen = false;
IrrlichtParams.Stencilbuffer = true;
IrrlichtParams.AntiAlias = 16;
IrrlichtParams.Vsync = false;
IrrlichtParams.EventReceiver = &EventReceiver;
IrrlichtDevice * const pDevice = createDeviceEx(IrrlichtParams);
Step 3: Start GUI Frame
Inside the Main-Loop:
ImGui::Begin("My first Window");
ImGui::Text("Hello World!");
if (ImGui::Button("Exit", ImVec2(40, 20)))
{
pDevice->closeDevice();
}
ImGui::End();
Step 4: Render GUI
Inside the Main-Loop:
pSceneManager->drawAll();
Step 5: Delete GUI
After the Main-Loop:
Use custom Event Receiver
Method 1: Inherit from standard Event Receiver
Method 2: An Event Receiver from the scratch
- Create an Event Receiver class that inherits from
irr::IEventReceiver
and IrrIMGUI::CIMGUIEventStorage
- Overwrite the
irr::IEventReceiver::OnEvent
method to handle the event
- If you want to pass any input event information to the GUI, just write to the corresponding variables of IrrIMGUI::CIMGUIEventStorage
- Give a pointer of this custom Event Receiver while creating the GUI handle object and the Irrlicht Device
Use TTF fonts
Full explanation: Example 2: Different Fonts
Step 1: Load Fonts
- Hint: Look-up for further methods to load fonts in the GUI Handle class ( LoadFonts )
Step 2: Compile Fonts
Step 3: Activate a Font
Inside the Main-Loop:
ImGui::Begin("Different Fonts", NULL, ImGuiWindowFlags_ShowBorders);
ImGui::Text("Default Font");
ImGui::PushFont(pCousine16);
ImGui::Text("Cousine-Regular.ttf; 16px");
ImGui::PopFont();
ImGui::PushFont(pCousine24);
ImGui::Text("Cousine-Regular.ttf; 24px");
ImGui::PopFont();
ImGui::End();
Optional: Reset Fonts
Use images
Full explanation: Example 4: Using Images
Step 1: Create Irrlicht Image
irr::video::IVideoDriver * const pDriver = pDevice->getVideoDriver();
irr::video::IImage * pSoyuz = pDriver->createImageFromFile("../../media/Soyuz.jpg");
irr::video::IImage * pSpaceX = pDriver->createImageFromFile("../../media/SpaceX.jpg");
Step 2: Create GUI Texture
- Hint: Look-up for further methods to create textures in the GUI Handle class ( CreateTextures )
Step 3: Use image in GUI
Inside the Main-Loop:
ImGui::Begin("Images");
ImGui::Image(pSoyuzTex, ImVec2(200.0f, 132.0f));
ImGui::Separator();
ImGui::Image(pSpaceXTex, ImVec2(200.0f, 132.0f));
ImGui::End();
Step 4: Free-up image memory
pSoyuz->drop();
pSpaceX->drop();
Use Irrlicht textures
Full explanation: Example 4: Using Images
Step 1: Create GUI Texture
video::ITexture * const pRenderTarget = pDriver->addRenderTargetTexture(core::dimension2d<u32>(384, 300), "Moon");
IGUITexture *
const pRenderTextureID = pGUI->
createTexture(pRenderTarget);
- Hint: Look-up for further methods to create textures in the GUI Handle class ( CreateTextures )
Optional: Update GUI Texture
Inside the Main-Loop:
Step 2: Free-up GUI texture memory
Dependency Injection
Full explanation: Unit Testing
Step 1: Create your own factory
Step 2: Setting up your factory
Step 3: Reset factory to default
IIMGUIHandle Mock
Full explanation: Unit Testing
Step 1: Enable- and Disable Mock
Attention: Disable the Mock always inside the tear-down-function.
TEST_GROUP(TestGroupName)
{
TEST_SETUP()
{
}
TEST_TEARDOWN()
{
}
};
Step 2: Expecting calls
TEST(TestGroupName, checkCreateAndDestory)
{
irr::IrrlichtDevice * const pDevice = irr::createDevice(irr::video::EDT_NULL);
CIMGUIEventStorage EventStorage;
SIMGUISettings Settings;
mock().expectOneCall("IIMGUIHandleMock::IIMGUIHandleMock")
.withParameter("pDevice", pDevice)
.withParameter("pEventStorage", &EventStorage)
.withConstPointerParameter("pSettings", &Settings);
mock().expectOneCall("IIMGUIHandleMock::~IIMGUIHandleMock");
mock().ignoreOtherCalls();
IIMGUIHandle *
const pGUI =
createIMGUI(pDevice, &EventStorage, &Settings);
pGUI->drop();
pDevice->drop();
return;
}
Memory Leak Detection
Full explanation: Unit Testing
int main(int Arguments, char const ** ppCommandLineList)
{
{
}
return 0;
}
Additional Project Links