MCPcopy Create free account
hub / github.com/ddiakopoulos/polymer / begin_frame

Method begin_frame

libraries/lib-app-base/src/gl-imgui.cpp:393–442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391 }
392
393 void imgui_instance::begin_frame(const uint32_t width, const uint32_t height)
394 {
395 ImGui::SetCurrentContext(data.context);
396 if (!data.FontTexture) create_render_objects();
397
398 ImGuiIO & io = ImGui::GetIO();
399
400 // Setup time step
401 double current_time = glfwGetTime();
402 io.DeltaTime = data.Time > 0.0 ? (float)(current_time - data.Time) : (float)(1.0f / 60.0f);
403 data.Time = current_time;
404
405 for (int i = 0; i < 3; i++)
406 {
407 // If a mouse press event came, always pass it as "mouse held this frame",
408 // so we don't miss click-release events that are shorter than 1 frame
409 io.MouseDown[i] = data.MousePressed[i] || glfwGetMouseButton(data.window, i) != 0;
410 data.MousePressed[i] = false;
411 }
412
413 io.MouseWheel = data.MouseWheel;
414 data.MouseWheel = 0.0f;
415
416 // Hide OS mouse cursor if ImGui is drawing it
417 glfwSetInputMode(data.window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
418
419 // Don't muck with the state if minimized
420 if (!glfwGetWindowAttrib(data.window, GLFW_ICONIFIED))
421 {
422 // Setup display size (every frame to accommodate for window resizing)
423 int w = width;
424 int h = height;
425 int display_w = width;
426 int display_h = height;
427
428 // Only use glfw window size if we have not passed in a texture size that
429 // we are rendering to
430 if (w == 0 || h == 0)
431 {
432 glfwGetWindowSize(data.window, &w, &h);
433 glfwGetFramebufferSize(data.window, &display_w, &display_h);
434 }
435
436 io.DisplaySize = ImVec2((float)w, (float)h);
437 io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
438 }
439
440 // Start the frame
441 ImGui::NewFrame();
442 }
443
444 void imgui_instance::end_frame()
445 {

Callers 13

on_drawMethod · 0.80
on_drawMethod · 0.80
on_drawMethod · 0.80
on_drawMethod · 0.80
on_drawMethod · 0.80
on_drawMethod · 0.80
on_drawMethod · 0.80
on_drawMethod · 0.80
runMethod · 0.80
runMethod · 0.80
on_drawMethod · 0.80
on_drawMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected