git.s-ol.nu ~forks/DiligentTools / a3ce5f6
Imgui: handling surface pretransform assiduous 1 year, 1 month ago
17 changed file(s) with 300 addition(s) and 70 deletion(s). Raw diff Collapse all Expand all
4040 ImGuiImplAndroid(IRenderDevice* pDevice,
4141 TEXTURE_FORMAT BackBufferFmt,
4242 TEXTURE_FORMAT DepthBufferFmt,
43 Uint32 DisplayWidht,
44 Uint32 DisplayHeight,
4543 Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize,
4644 Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize);
4745 ~ImGuiImplAndroid();
5351 ImGuiImplAndroid& operator = ( ImGuiImplAndroid&&) = delete;
5452 // clang-format on
5553
56 virtual void NewFrame() override final;
54 virtual void NewFrame(Uint32 RenderSurfaceWidth,
55 Uint32 RenderSurfaceHeight,
56 SURFACE_TRANSFORM SurfacePreTransform) override final;
5757
5858 bool BeginDrag(float x, float y);
5959 bool DragMove(float x, float y);
3535 struct IRenderDevice;
3636 struct IDeviceContext;
3737 enum TEXTURE_FORMAT : Uint16;
38 enum SURFACE_TRANSFORM : Uint32;
3839
3940 class ImGuiImplDiligent_Internal;
4041
5859 ImGuiImplDiligent& operator = ( ImGuiImplDiligent&&) = delete;
5960 // clang-format on
6061
61 virtual void NewFrame();
62
63 /// Begins new frame
64
65 /// \param [in] RenderSurfaceWidth - Render surface width not accounting for pre-transform.
66 /// Most of the time this is the actual swap chain width.
67 /// \param [in] RenderSurfaceHeight - Render surface height not accounting for pre-transform.
68 /// Most of the time this is the actual swap chain height.
69 /// \param [in] SurfacePreTransform - Render surface pre-transform.
70 /// Most of the time this is the swap chain pre-transform.
71 virtual void NewFrame(Uint32 RenderSurfaceWidth,
72 Uint32 RenderSurfaceHeight,
73 SURFACE_TRANSFORM SurfacePreTransform);
74
6275 virtual void EndFrame();
6376 virtual void Render(IDeviceContext* pCtx);
6477
5151 ImGuiImplIOS& operator = ( ImGuiImplIOS&&) = delete;
5252 // clang-format on
5353
54 virtual void NewFrame() override final;
54 virtual void NewFrame(Uint32 RenderSurfaceWidth,
55 Uint32 RenderSurfaceHeight,
56 SURFACE_TRANSFORM SurfacePreTransform) override final;
5557 virtual void Render(IDeviceContext* pCtx) override final;
5658 void SetDisplaySize(Uint32 DisplayWidth, Uint32 DisplayHeight);
5759 bool OnTouchEvent(float x, float y, bool IsActive);
5454 // clang-format on
5555
5656 bool HandleXEvent(XEvent* event);
57 virtual void NewFrame() override final;
57 virtual void NewFrame(Uint32 RenderSurfaceWidth,
58 Uint32 RenderSurfaceHeight,
59 SURFACE_TRANSFORM SurfacePreTransform) override final;
5860
5961 private:
6062 std::chrono::time_point<std::chrono::high_resolution_clock> m_LastTimestamp = {};
5757 // clang-format on
5858
5959 bool HandleXCBEvent(xcb_generic_event_t* event);
60 virtual void NewFrame() override final;
60 virtual void NewFrame(Uint32 RenderSurfaceWidth,
61 Uint32 RenderSurfaceHeight,
62 SURFACE_TRANSFORM SurfacePreTransform) override final;
6163
6264 private:
6365 void HandleKeyEvent(xcb_key_release_event_t* event);
5454 ImGuiImplMacOS& operator = ( ImGuiImplMacOS&&) = delete;
5555 // clang-format on
5656
57 virtual void NewFrame() override final;
57 virtual void NewFrame(Uint32 RenderSurfaceWidth,
58 Uint32 RenderSurfaceHeight,
59 SURFACE_TRANSFORM SurfacePreTransform) override final;
5860 virtual void Render(IDeviceContext* _Nonnull pCtx) override final;
5961 bool HandleOSXEvent(NSEvent* _Nonnull event, NSView* _Nonnull view);
6062 void SetDisplaySize(Uint32 DisplayWidth, Uint32 DisplayHeight);
3838 ImGuiImplUWP(IRenderDevice* pDevice,
3939 TEXTURE_FORMAT BackBufferFmt,
4040 TEXTURE_FORMAT DepthBufferFmt,
41 Uint32 DisplayWidth,
42 Uint32 DisplayHeight,
4341 Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize,
4442 Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize);
4543 ~ImGuiImplUWP();
5149 ImGuiImplUWP& operator = ( ImGuiImplUWP&&) = delete;
5250 // clang-format on
5351
54 virtual void NewFrame() override final;
55
56 void SetDisplaySize(Uint32 DisplayWidth, Uint32 DisplayHeight)
57 {
58 m_DisplayWidth = DisplayWidth;
59 m_DisplayHeight = DisplayHeight;
60 }
52 virtual void NewFrame(Uint32 RenderSurfaceWidth,
53 Uint32 RenderSurfaceHeight,
54 SURFACE_TRANSFORM SurfacePreTransform) override final;
6155
6256 private:
63 INT64 m_Time = 0;
64 INT64 m_TicksPerSecond = 0;
65 Uint32 m_DisplayWidth = 0;
66 Uint32 m_DisplayHeight = 0;
57 INT64 m_Time = 0;
58 INT64 m_TicksPerSecond = 0;
6759 };
6860
6961 } // namespace Diligent
5252 ImGuiImplWin32& operator = ( ImGuiImplWin32&&) = delete;
5353 // clang-format on
5454
55 virtual void NewFrame() override final;
55 virtual void NewFrame(Uint32 RenderSurfaceWidth, Uint32 RenderSurfaceHeight, SURFACE_TRANSFORM SurfacePreTransform) override final;
5656 };
5757
5858 } // namespace Diligent
2727 #include "imgui.h"
2828
2929 #include "ImGuiImplAndroid.hpp"
30 #include "GraphicsTypes.h"
31 #include "DebugUtilities.hpp"
3032
3133 namespace Diligent
3234 {
3436 ImGuiImplAndroid::ImGuiImplAndroid(IRenderDevice* pDevice,
3537 TEXTURE_FORMAT BackBufferFmt,
3638 TEXTURE_FORMAT DepthBufferFmt,
37 Uint32 DisplayWidth,
38 Uint32 DisplayHeight,
3939 Uint32 InitialVertexBufferSize,
4040 Uint32 InitialIndexBufferSize) :
4141 ImGuiImplDiligent{pDevice, BackBufferFmt, DepthBufferFmt, InitialVertexBufferSize, InitialIndexBufferSize}
4242 {
43 auto& io = ImGui::GetIO();
44 io.DisplaySize = ImVec2(DisplayWidth, DisplayHeight);
43 auto& io = ImGui::GetIO();
44
4545 io.FontGlobalScale = 2;
4646 io.BackendPlatformName = "Diligent-ImGuiImplAndroid";
4747
5252 {
5353 }
5454
55 void ImGuiImplAndroid::NewFrame()
55 void ImGuiImplAndroid::NewFrame(Uint32 RenderSurfaceWidth,
56 Uint32 RenderSurfaceHeight,
57 SURFACE_TRANSFORM SurfacePreTransform)
5658 {
5759 auto now = std::chrono::high_resolution_clock::now();
5860 auto elapsed_ns = now - m_LastTimestamp;
6062 auto& io = ImGui::GetIO();
6163 io.DeltaTime = static_cast<float>(elapsed_ns.count() / 1e+9);
6264
63 ImGuiImplDiligent::NewFrame();
65 // DisplaySize must always refer to the logical size that accounts for the pre-transform
66 io.DisplaySize.x = static_cast<float>(RenderSurfaceWidth);
67 io.DisplaySize.y = static_cast<float>(RenderSurfaceHeight);
68 switch (SurfacePreTransform)
69 {
70 case SURFACE_TRANSFORM_IDENTITY:
71 case SURFACE_TRANSFORM_ROTATE_180:
72 case SURFACE_TRANSFORM_HORIZONTAL_MIRROR:
73 case SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180:
74 // Do nothing
75 break;
76
77 case SURFACE_TRANSFORM_ROTATE_90:
78 case SURFACE_TRANSFORM_ROTATE_270:
79 case SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90:
80 case SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270:
81 std::swap(io.DisplaySize.x, io.DisplaySize.y);
82 break;
83
84 case SURFACE_TRANSFORM_OPTIMAL:
85 UNEXPECTED("SURFACE_TRANSFORM_OPTIMAL is only valid as parameter during swap chain initialization.");
86 break;
87
88 default:
89 UNEXPECTED("Unknown transform");
90 }
91
92 ImGuiImplDiligent::NewFrame(RenderSurfaceWidth, RenderSurfaceHeight, SurfacePreTransform);
6493 }
6594
6695 bool ImGuiImplAndroid::BeginDrag(float x, float y)
6868 ImGui::DestroyContext();
6969 }
7070
71 void NewFrame();
71 void NewFrame(Uint32 RenderSurfaceWidth, Uint32 RenderSurfaceHeight, SURFACE_TRANSFORM SurfacePreTransform);
7272 void RenderDrawData(IDeviceContext* pCtx, ImDrawData* pDrawData);
7373
7474 // Use if you want to reset your rendering device without losing ImGui state.
7878 void CreateFontsTexture();
7979
8080 private:
81 inline float4 TransformClipRect(const ImVec2& DisplaySize, const float4& rect) const;
82
8183 RefCntAutoPtr<IRenderDevice> m_pDevice;
8284 RefCntAutoPtr<IBuffer> m_pVB;
8385 RefCntAutoPtr<IBuffer> m_pIB;
8991 const TEXTURE_FORMAT m_DepthBufferFmt;
9092 Uint32 m_VertexBufferSize = 0;
9193 Uint32 m_IndexBufferSize = 0;
94
95 Uint32 m_RenderSurfaceWidth = 0;
96 Uint32 m_RenderSurfaceHeight = 0;
97 SURFACE_TRANSFORM m_SurfacePreTransform = SURFACE_TRANSFORM_IDENTITY;
9298 };
9399
94 void ImGuiImplDiligent_Internal::NewFrame()
100 void ImGuiImplDiligent_Internal::NewFrame(Uint32 RenderSurfaceWidth,
101 Uint32 RenderSurfaceHeight,
102 SURFACE_TRANSFORM SurfacePreTransform)
95103 {
96104 if (!m_pPSO)
97105 CreateDeviceObjects();
106 m_RenderSurfaceWidth = RenderSurfaceWidth;
107 m_RenderSurfaceHeight = RenderSurfaceHeight;
108 m_SurfacePreTransform = SurfacePreTransform;
98109 }
99110
100111 // Use if you want to reset your rendering device without losing ImGui state.
279290 io.Fonts->TexID = (ImTextureID)m_pFontSRV;
280291 }
281292
293 float4 ImGuiImplDiligent_Internal::TransformClipRect(const ImVec2& DisplaySize, const float4& rect) const
294 {
295 switch (m_SurfacePreTransform)
296 {
297 case SURFACE_TRANSFORM_IDENTITY:
298 return rect;
299
300 case SURFACE_TRANSFORM_ROTATE_90:
301 {
302 // The image content is rotated 90 degrees clockwise. The origin is in the left-top corner.
303 //
304 // DsplSz.y
305 // a.x -a.y a.y Old origin
306 // 0---->| 0------->|<------| /
307 // 0__|_____|____________________ 0__|________|_______|/
308 // | | ' | | | ' |
309 // a.y | | ' | a.x | | ' |
310 // _V_|_ _ _a____b | min_y _V_|_ _d'___a' |
311 // A | | | | | | | |
312 // DsplSz.y | | |____| | | |____| |
313 // -a.y | | d c | | c' b' |
314 // _|_|__________________________| | |
315 // A | |
316 // |-----> Y' | |
317 // New Origin |________________|
318 //
319 float2 a{rect.x, rect.y};
320 float2 c{rect.z, rect.w};
321 return float4 //
322 {
323 DisplaySize.y - c.y, // min_x = c'.x
324 a.x, // min_y = a'.y
325 DisplaySize.y - a.y, // max_x = a'.x
326 c.x // max_y = c'.y
327 };
328 }
329
330 case SURFACE_TRANSFORM_ROTATE_180:
331 {
332 // The image content is rotated 180 degrees clockwise. The origin is in the left-top corner.
333 //
334 // a.x DsplSz.x - a.x
335 // 0---->| 0------------------>|
336 // 0__|_____|____________________ 0_ _|___________________|______
337 // | | ' | | | ' |
338 // a.y | | ' | DsplSz.y | | c'___d' |
339 // _V_|_ _ _a____b | -a.y | | | | |
340 // | | | | _V_|_ _ _ _ _ _ _ |____| |
341 // | |____| | | b' a' |
342 // | d c | | |
343 // |__________________________| |__________________________|
344 // A A
345 // | |
346 // New Origin Old Origin
347 float2 a{rect.x, rect.y};
348 float2 c{rect.z, rect.w};
349 return float4 //
350 {
351 DisplaySize.x - c.x, // min_x = c'.x
352 DisplaySize.y - c.y, // min_y = c'.y
353 DisplaySize.x - a.x, // max_x = a'.x
354 DisplaySize.y - a.y // max_y = a'.y
355 };
356 }
357
358 case SURFACE_TRANSFORM_ROTATE_270:
359 {
360 // The image content is rotated 270 degrees clockwise. The origin is in the left-top corner.
361 //
362 // 0 a.x DsplSz.x-a.x New Origin a.y
363 // |---->|<-------------------| 0----->|
364 // 0_ _|_____|____________________V 0 _|______|_________
365 // | | ' | | | ' |
366 // | | ' | | | ' |
367 // a.y_V_|_ _ _a____b | DsplSz.x | | ' |
368 // | | | | -a.x | | ' |
369 // | |____| | | | b'___c' |
370 // | d c | | | | | |
371 // DsplSz.y _ _|__________________________| _V_|_ _ _ |____| |
372 // | a' d' |
373 // | |
374 // |________________|
375 // A
376 // |
377 // Old origin
378 float2 a{rect.x, rect.y};
379 float2 c{rect.z, rect.w};
380 return float4 //
381 {
382 a.y, // min_x = a'.x
383 DisplaySize.x - c.x, // min_y = c'.y
384 c.y, // max_x = c'.x
385 DisplaySize.x - a.x // max_y = a'.y
386 };
387 }
388
389 case SURFACE_TRANSFORM_OPTIMAL:
390 UNEXPECTED("SURFACE_TRANSFORM_OPTIMAL is only valid as parameter during swap chain initialization.");
391 return rect;
392
393 case SURFACE_TRANSFORM_HORIZONTAL_MIRROR:
394 case SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90:
395 case SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180:
396 case SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270:
397 UNEXPECTED("Mirror transforms are not supported");
398 return rect;
399
400 default:
401 UNEXPECTED("Unknown transform");
402 return rect;
403 }
404 };
282405
283406 void ImGuiImplDiligent_Internal::RenderDrawData(IDeviceContext* pCtx, ImDrawData* pDrawData)
284407 {
333456 }
334457 }
335458
336
337459 // Setup orthographic projection matrix into our constant buffer
338460 // Our visible imgui space lies from pDrawData->DisplayPos (top left) to pDrawData->DisplayPos+data_data->DisplaySize (bottom right).
339461 // DisplayPos is (0,0) for single viewport apps.
340462 {
341 MapHelper<float4x4> CBData(pCtx, m_pVertexConstantBuffer, MAP_WRITE, MAP_FLAG_DISCARD);
342
463 // DisplaySize always refers to the logical dimensions that account for pre-transform, hence
464 // the aspect ratio will be correct after applying appropriate rotation.
343465 float L = pDrawData->DisplayPos.x;
344466 float R = pDrawData->DisplayPos.x + pDrawData->DisplaySize.x;
345467 float T = pDrawData->DisplayPos.y;
346468 float B = pDrawData->DisplayPos.y + pDrawData->DisplaySize.y;
469
347470 // clang-format off
348 *CBData = float4x4
471 float4x4 Projection
349472 {
350473 2.0f / (R - L), 0.0f, 0.0f, 0.0f,
351474 0.0f, 2.0f / (T - B), 0.0f, 0.0f,
353476 (R + L) / (L - R), (T + B) / (B - T), 0.5f, 1.0f
354477 };
355478 // clang-format on
356 }
357
358 auto DisplayWidth = static_cast<Uint32>(pDrawData->DisplaySize.x);
359 auto DisplayHeight = static_cast<Uint32>(pDrawData->DisplaySize.y);
479
480 // Bake pre-transform into projection
481 switch (m_SurfacePreTransform)
482 {
483 case SURFACE_TRANSFORM_IDENTITY:
484 // Nothing to do
485 break;
486
487 case SURFACE_TRANSFORM_ROTATE_90:
488 // The image content is rotated 90 degrees clockwise.
489 Projection *= float4x4::RotationZ(-PI_F * 0.5f);
490 break;
491
492 case SURFACE_TRANSFORM_ROTATE_180:
493 // The image content is rotated 180 degrees clockwise.
494 Projection *= float4x4::RotationZ(-PI_F * 1.0f);
495 break;
496
497 case SURFACE_TRANSFORM_ROTATE_270:
498 // The image content is rotated 270 degrees clockwise.
499 Projection *= float4x4::RotationZ(-PI_F * 1.5f);
500 break;
501
502 case SURFACE_TRANSFORM_OPTIMAL:
503 UNEXPECTED("SURFACE_TRANSFORM_OPTIMAL is only valid as parameter during swap chain initialization.");
504 break;
505
506 case SURFACE_TRANSFORM_HORIZONTAL_MIRROR:
507 case SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90:
508 case SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180:
509 case SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270:
510 UNEXPECTED("Mirror transforms are not supported");
511 break;
512
513 default:
514 UNEXPECTED("Unknown transform");
515 }
516
517 MapHelper<float4x4> CBData(pCtx, m_pVertexConstantBuffer, MAP_WRITE, MAP_FLAG_DISCARD);
518 *CBData = Projection;
519 }
520
360521 auto SetupRenderState = [&]() //
361522 {
362523 // Setup shader and vertex buffers
371532 pCtx->SetBlendFactors(blend_factor);
372533
373534 Viewport vp;
374 vp.Width = pDrawData->DisplaySize.x;
375 vp.Height = pDrawData->DisplaySize.y;
535 vp.Width = static_cast<float>(m_RenderSurfaceWidth);
536 vp.Height = static_cast<float>(m_RenderSurfaceHeight);
376537 vp.MinDepth = 0.0f;
377538 vp.MaxDepth = 1.0f;
378539 vp.TopLeftX = vp.TopLeftY = 0;
379 pCtx->SetViewports(1, &vp, DisplayWidth, DisplayHeight);
540 pCtx->SetViewports(1, &vp, m_RenderSurfaceWidth, m_RenderSurfaceHeight);
380541 };
381542
382543 SetupRenderState();
386547 int global_idx_offset = 0;
387548 int global_vtx_offset = 0;
388549
389 ImVec2 clip_off = pDrawData->DisplayPos;
390550 for (int n = 0; n < pDrawData->CmdListsCount; n++)
391551 {
392552 const ImDrawList* cmd_list = pDrawData->CmdLists[n];
405565 else
406566 {
407567 // Apply scissor/clipping rectangle
408 const Rect r =
568 float4 ClipRect //
409569 {
410 static_cast<Int32>(pcmd->ClipRect.x - clip_off.x),
411 static_cast<Int32>(pcmd->ClipRect.y - clip_off.y),
412 static_cast<Int32>(pcmd->ClipRect.z - clip_off.x),
413 static_cast<Int32>(pcmd->ClipRect.w - clip_off.y) //
570 pcmd->ClipRect.x - pDrawData->DisplayPos.x,
571 pcmd->ClipRect.y - pDrawData->DisplayPos.y,
572 pcmd->ClipRect.z - pDrawData->DisplayPos.x,
573 pcmd->ClipRect.w - pDrawData->DisplayPos.y //
414574 };
415 pCtx->SetScissorRects(1, &r, DisplayWidth, DisplayHeight);
575 // Apply pretransform
576 ClipRect = TransformClipRect(pDrawData->DisplaySize, ClipRect);
577
578 Rect r //
579 {
580 static_cast<Int32>(ClipRect.x),
581 static_cast<Int32>(ClipRect.y),
582 static_cast<Int32>(ClipRect.z),
583 static_cast<Int32>(ClipRect.w) //
584 };
585 pCtx->SetScissorRects(1, &r, m_RenderSurfaceWidth, m_RenderSurfaceHeight);
416586
417587 // Bind texture, Draw
418588 auto* texture_srv = reinterpret_cast<ITextureView*>(pcmd->TextureId);
445615 {
446616 }
447617
448 void ImGuiImplDiligent::NewFrame()
449 {
450 m_pImpl->NewFrame();
618 void ImGuiImplDiligent::NewFrame(Uint32 RenderSurfaceWidth, Uint32 RenderSurfaceHeight, SURFACE_TRANSFORM SurfacePreTransform)
619 {
620 m_pImpl->NewFrame(RenderSurfaceWidth, RenderSurfaceHeight, SurfacePreTransform);
451621 ImGui::NewFrame();
452622 }
453623
4646 {
4747 }
4848
49 void ImGuiImplIOS::NewFrame()
49 void ImGuiImplIOS::NewFrame(Uint32 RenderSurfaceWidth, Uint32 RenderSurfaceHeight, SURFACE_TRANSFORM SurfacePreTransform)
5050 {
5151 std::lock_guard<std::mutex> Lock(m_Mtx);
5252 if (m_Time == 0.0)
5656 io.DeltaTime = current_time - m_Time;
5757 m_Time = current_time;
5858
59 ImGuiImplDiligent::NewFrame();
59 ImGuiImplDiligent::NewFrame(RenderSurfaceWidth, RenderSurfaceHeight, SurfacePreTransform);
6060 }
6161
6262 void ImGuiImplIOS::SetDisplaySize(Uint32 DisplayWidth, Uint32 DisplayHeight)
9494 {
9595 }
9696
97 void ImGuiImplLinuxX11::NewFrame()
97 void ImGuiImplLinuxX11::NewFrame(Uint32 RenderSurfaceWidth,
98 Uint32 RenderSurfaceHeight,
99 SURFACE_TRANSFORM SurfacePreTransform)
98100 {
99101 auto now = std::chrono::high_resolution_clock::now();
100102 auto elapsed_ns = now - m_LastTimestamp;
102104 auto& io = ImGui::GetIO();
103105 io.DeltaTime = static_cast<float>(elapsed_ns.count() / 1e+9);
104106
105 ImGuiImplDiligent::NewFrame();
107 ImGuiImplDiligent::NewFrame(RenderSurfaceWidth, RenderSurfaceHeight, SurfacePreTransform);
106108 }
107109
108110
9999 }
100100 }
101101
102 void ImGuiImplLinuxXCB::NewFrame()
102 void ImGuiImplLinuxXCB::NewFrame(Uint32 RenderSurfaceWidth,
103 Uint32 RenderSurfaceHeight,
104 SURFACE_TRANSFORM SurfacePreTransform)
103105 {
104106 auto now = std::chrono::high_resolution_clock::now();
105107 auto elapsed_ns = now - m_LastTimestamp;
107109 auto& io = ImGui::GetIO();
108110 io.DeltaTime = static_cast<float>(elapsed_ns.count() / 1e+9);
109111
110 ImGuiImplDiligent::NewFrame();
112 ImGuiImplDiligent::NewFrame(RenderSurfaceWidth, RenderSurfaceHeight, SurfacePreTransform);
111113 }
112114
113115 // ----------------------------------------------------------------------
4848 ImGui_ImplOSX_Shutdown();
4949 }
5050
51 void ImGuiImplMacOS::NewFrame()
51 void ImGuiImplMacOS::NewFrame(Uint32 RenderSurfaceWidth,
52 Uint32 RenderSurfaceHeight,
53 SURFACE_TRANSFORM SurfacePreTransform)
5254 {
5355 std::lock_guard<std::mutex> Lock(m_Mtx);
5456 ImGui_ImplOSX_NewFrame(nil);
55 ImGuiImplDiligent::NewFrame();
57 ImGuiImplDiligent::NewFrame(RenderSurfaceWidth, RenderSurfaceHeight, SurfacePreTransform);
5658 }
5759
5860 void ImGuiImplMacOS::SetDisplaySize(Uint32 DisplayWidth, Uint32 DisplayHeight)
4040 ImGuiImplUWP::ImGuiImplUWP(IRenderDevice* pDevice,
4141 TEXTURE_FORMAT BackBufferFmt,
4242 TEXTURE_FORMAT DepthBufferFmt,
43 Uint32 DisplayWidth,
44 Uint32 DisplayHeight,
4543 Uint32 InitialVertexBufferSize,
4644 Uint32 InitialIndexBufferSize) :
47 ImGuiImplDiligent{pDevice, BackBufferFmt, DepthBufferFmt, InitialVertexBufferSize, InitialIndexBufferSize},
48 m_DisplayWidth{DisplayWidth},
49 m_DisplayHeight{DisplayHeight}
45 ImGuiImplDiligent{pDevice, BackBufferFmt, DepthBufferFmt, InitialVertexBufferSize, InitialIndexBufferSize}
5046 {
5147 ::QueryPerformanceFrequency((LARGE_INTEGER*)&m_TicksPerSecond);
5248 ::QueryPerformanceCounter((LARGE_INTEGER*)&m_Time);
8480 {
8581 }
8682
87 void ImGuiImplUWP::NewFrame()
83 void ImGuiImplUWP::NewFrame(Uint32 RenderSurfaceWidth,
84 Uint32 RenderSurfaceHeight,
85 SURFACE_TRANSFORM SurfacePreTransform)
8886 {
8987 ImGuiIO& io = ImGui::GetIO();
9088 IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");
9189
92 io.DisplaySize = ImVec2((float)m_DisplayWidth, (float)m_DisplayHeight);
90 io.DisplaySize = ImVec2(static_cast<float>(RenderSurfaceWidth), static_cast<float>(RenderSurfaceHeight));
9391
9492 // Setup time step
9593 INT64 current_time;
9997
10098 io.KeySuper = false;
10199
102 ImGuiImplDiligent::NewFrame();
100 ImGuiImplDiligent::NewFrame(RenderSurfaceWidth, RenderSurfaceHeight, SurfacePreTransform);
103101 }
104102
105103 } // namespace Diligent
2929 #endif
3030 #include <Windows.h>
3131
32 #include "GraphicsTypes.h"
3233 #include "imgui.h"
3334 #include "ImGuiImplWin32.hpp"
3435 #include "examples/imgui_impl_win32.h"
36 #include "DebugUtilities.hpp"
3537
3638 IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
3739
5456 ImGui_ImplWin32_Shutdown();
5557 }
5658
57 void ImGuiImplWin32::NewFrame()
59 void ImGuiImplWin32::NewFrame(Uint32 RenderSurfaceWidth, Uint32 RenderSurfaceHeight, SURFACE_TRANSFORM SurfacePreTransform)
5860 {
61 VERIFY(SurfacePreTransform == SURFACE_TRANSFORM_IDENTITY, "Unexpected surface pre-transform");
62
5963 ImGui_ImplWin32_NewFrame();
60 ImGuiImplDiligent::NewFrame();
64 ImGuiImplDiligent::NewFrame(RenderSurfaceWidth, RenderSurfaceHeight, SurfacePreTransform);
65
66 #ifdef DILIGENT_DEBUG
67 {
68 ImGuiIO& io = ImGui::GetIO();
69 VERIFY(io.DisplaySize.x == static_cast<float>(RenderSurfaceWidth),
70 "Render surface width (", RenderSurfaceWidth, ") does not match io.DisplaySize.x (", io.DisplaySize.x, ")");
71 VERIFY(io.DisplaySize.y == static_cast<float>(RenderSurfaceHeight),
72 "Render surface height (", RenderSurfaceHeight, ") does not match io.DisplaySize.y (", io.DisplaySize.y, ")");
73 }
74 #endif
6175 }
6276
6377 LRESULT ImGuiImplWin32::Win32_ProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2525
2626 #include <memory>
2727
28 #define NOMINIMAX
28 #define NOMINMAX
2929 #include <wrl.h>
3030 #include <wrl/client.h>
3131