MCPcopy Create free account
hub / github.com/RenderKit/embree / RenderMouseCursor

Method RenderMouseCursor

tutorials/common/imgui/imgui.cpp:3366–3389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3364}
3365
3366void ImGui::RenderMouseCursor(ImVec2 base_pos, float base_scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow)
3367{
3368 ImGuiContext& g = *GImGui;
3369 IM_ASSERT(mouse_cursor > ImGuiMouseCursor_None && mouse_cursor < ImGuiMouseCursor_COUNT);
3370 for (int n = 0; n < g.Viewports.Size; n++)
3371 {
3372 ImGuiViewportP* viewport = g.Viewports[n];
3373 ImDrawList* draw_list = GetForegroundDrawList(viewport);
3374 ImFontAtlas* font_atlas = draw_list->_Data->Font->ContainerAtlas;
3375 ImVec2 offset, size, uv[4];
3376 if (font_atlas->GetMouseCursorTexData(mouse_cursor, &offset, &size, &uv[0], &uv[2]))
3377 {
3378 const ImVec2 pos = base_pos - offset;
3379 const float scale = base_scale;
3380 ImTextureID tex_id = font_atlas->TexID;
3381 draw_list->PushTextureID(tex_id);
3382 draw_list->AddImage(tex_id, pos + ImVec2(1, 0) * scale, pos + (ImVec2(1, 0) + size) * scale, uv[2], uv[3], col_shadow);
3383 draw_list->AddImage(tex_id, pos + ImVec2(2, 0) * scale, pos + (ImVec2(2, 0) + size) * scale, uv[2], uv[3], col_shadow);
3384 draw_list->AddImage(tex_id, pos, pos + size * scale, uv[2], uv[3], col_border);
3385 draw_list->AddImage(tex_id, pos, pos + size * scale, uv[0], uv[1], col_fill);
3386 draw_list->PopTextureID();
3387 }
3388 }
3389}
3390
3391
3392//-----------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 6

GetForegroundDrawListFunction · 0.85
ImVec2Function · 0.85
GetMouseCursorTexDataMethod · 0.80
PushTextureIDMethod · 0.80
AddImageMethod · 0.80
PopTextureIDMethod · 0.80

Tested by

no test coverage detected