@ -30,13 +30,34 @@ The Immediate Mode GUI paradigm may at first appear unusual to some users. This
- [Jari Komppa's tutorial on building an ImGui library](http://iki.fi/sol/imgui/).
- [Casey Muratori's original video that popularized the concept](https://mollyrocket.com/861).
Frequently Asked Question
-------------------------
<b>How do you use ImGui on a platform that may not have a mouse and keyboard?</b>
I recommend using [Synergy](http://synergy-project.org) and the uSynergy.c micro client to share your mouse and keyboard. This way you can seemingly use your PC input devices on a video game console or a tablet. ImGui was also designed to function with touch inputs if you increase the padding of widgets to compensate for the lack of precision of touch devices, but it is recommended you use a mouse to allow optimising for screen real-estate.
<b>I integrated ImGui in my engine and the text or lines are blurry..</b>
- Try adjusting ImGui::GetIO().PixelCenterOffset to 0.0f or 0.5f.
- In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f).
<b>Can you create elaborate/serious tools with ImGui?</b>
Yes. I have written data browsers, debuggers, profilers and all sort of non-trivial tools with the library. There's no reason you cannot, and in my experience the simplicity of the API is very empowering. However note that ImGui is programmer centric and the immediate-mode GUI paradigm might requires a bit of adaptation before you can realize its full potential.
<b>Can you reskin the look of ImGui?</b>
Yes, you can alter the look of the interface to some degree: changing colors, sizes and padding, font. However, as ImGui is designed and optimised to create debug tools, the amount of skinning you can apply is limited. There is only so much you can stray away from the default look and feel of the interface. The example below uses modified settings to create a more compact UI with different colors:
Developed by [Omar Cornut](http://www.miracleworld.net). The library was developed with the support of [Media Molecule](http://www.mediamolecule.com) and first used internally on the game [Tearaway](http://tearaway.mediamolecule.com).
Embeds [proggy_clean](http://www.proggyfonts.net/) font by Tristan Grimmer (also MIT license).
Embeds [proggy_clean](http://upperbounds.net) font by Tristan Grimmer (also MIT license).
Inspiration, feedback, and testing: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. Thanks!
// Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
io.MousePos.x=(signedshort)(lParam);
io.MousePos.y=(signedshort)(lParam>>16);
returntrue;
caseWM_CHAR:
// You can also use ToAscii()+GetKeyboardState() to retrieve characters.
if(wParam>1&&wParam<256)
io.AddInputCharacter((char)wParam);
returntrue;
caseWM_DESTROY:
{
Cleanup();
PostQuitMessage(0);
return0;
}
}
returnDefWindowProc(hWnd,msg,wParam,lParam);
}
voidInitImGui()
{
RECTrect;
GetClientRect(hWnd,&rect);
ImGuiIO&io=ImGui::GetIO();
io.DisplaySize=ImVec2((float)(rect.right-rect.left),(float)(rect.bottom-rect.top));// Display size, in pixels. For clamping windows positions.
io.DeltaTime=1.0f/60.0f;// Time elapsed since last frame, in seconds (in this sample app we'll override this every frame because our timestep is variable)
io.KeyMap[ImGuiKey_Tab]=VK_TAB;// Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime.
io.DisplaySize=ImVec2((float)(rect.right-rect.left),(float)(rect.bottom-rect.top));// Display size, in pixels. For clamping windows positions.
io.DeltaTime=1.0f/60.0f;// Time elapsed since last frame, in seconds (in this sample app we'll override this every frame because our timestep is variable)
io.KeyMap[ImGuiKey_Tab]=VK_TAB;// Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime.
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)",ms_per_frame_avg,1000.0f/ms_per_frame_avg);
// Show the ImGui test window
// Most of user example code is in ImGui::ShowTestWindow()
if(show_test_window)
{
ImGui::SetNewWindowDefaultPos(ImVec2(650,20));// Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)",ms_per_frame_avg,1000.0f/ms_per_frame_avg);
// Show the ImGui test window
// Most of user example code is in ImGui::ShowTestWindow()
if(show_test_window)
{
ImGui::SetNewWindowDefaultPos(ImVec2(650,20));// Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
io.DisplaySize=ImVec2((float)w,(float)h);// Display size, in pixels. For clamping windows positions.
io.DeltaTime=1.0f/60.0f;// Time elapsed since last frame, in seconds (in this sample app we'll override this every frame because our timestep is variable)
io.PixelCenterOffset=0.5f;// Align OpenGL texels
io.KeyMap[ImGuiKey_Tab]=GLFW_KEY_TAB;// Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
io.DisplaySize=ImVec2((float)w,(float)h);// Display size, in pixels. For clamping windows positions.
io.DeltaTime=1.0f/60.0f;// Time elapsed since last frame, in seconds (in this sample app we'll override this every frame because our timestep is variable)
io.PixelCenterOffset=0.0f;// Align OpenGL texels
io.KeyMap[ImGuiKey_Tab]=GLFW_KEY_TAB;// Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)",ms_per_frame_avg,1000.0f/ms_per_frame_avg);
// Show the ImGui test window
// Most of user example code is in ImGui::ShowTestWindow()
if(show_test_window)
{
ImGui::SetNewWindowDefaultPos(ImVec2(650,20));// Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)",ms_per_frame_avg,1000.0f/ms_per_frame_avg);
// Show the ImGui test window
// Most of user example code is in ImGui::ShowTestWindow()
if(show_test_window)
{
ImGui::SetNewWindowDefaultPos(ImVec2(650,20));// Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!