diff --git a/examples/directx9_example/main.cpp b/examples/directx9_example/main.cpp index f302db66..63760eb5 100644 --- a/examples/directx9_example/main.cpp +++ b/examples/directx9_example/main.cpp @@ -20,7 +20,10 @@ struct CUSTOMVERTEX }; #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) -// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structuer) +// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure) +// If text or lines are blurry when integrating ImGui in your engine: +// - 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) static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count) { size_t total_vtx_count = 0; diff --git a/examples/opengl_example/main.cpp b/examples/opengl_example/main.cpp index 7fe45c1a..1f316475 100644 --- a/examples/opengl_example/main.cpp +++ b/examples/opengl_example/main.cpp @@ -11,14 +11,17 @@ static GLFWwindow* window; static GLuint fontTex; -// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structuer) -// We are using the fixed pipeline. -// A faster way would be to collate all vertices from all cmd_lists into a single vertex buffer +// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure) +// If text or lines are blurry when integrating ImGui in your engine: +// - 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) static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count) { if (cmd_lists_count == 0) return; + // We are using the OpenGL fixed pipeline to make the example code simpler to read! + // A probable faster way to render would be to collate all vertices from all cmd_lists into a single vertex buffer. // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers. glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/imgui.cpp b/imgui.cpp index a2f48a63..9180e7ce 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -53,7 +53,7 @@ - every frame: 1/ in your mainloop or right after you got your keyboard/mouse info, call ImGui::GetIO() and fill the 'Input' data, then call ImGui::NewFrame(). 2/ use any ImGui function you want between NewFrame() and Render() - 3/ ImGui::Render() to render all the accumulated command-lists. it will cack your RenderDrawListFn handler set in the IO structure. + 3/ ImGui::Render() to render all the accumulated command-lists. it will call your RenderDrawListFn handler that you set in the IO structure. - all rendering information are stored into command-lists until ImGui::Render() is called. - effectively it means you can create widgets at any time in your code, regardless of "update" vs "render" considerations. - a typical application skeleton may be: @@ -87,6 +87,10 @@ // swap video buffer, etc. } + - if text or lines are blurry when integrating ImGui in your engine: + - 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) + - some widgets carry state and requires an unique ID to do so. - unique ID are typically derived from a string label, an indice or a pointer. - use PushID/PopID to easily create scopes and avoid ID conflicts. A Window is also an implicit scope.