mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-13 00:09:55 +02:00
Merge branch 'examples_refactor2' into viewport (#1870)
# Conflicts: # examples/README.txt # examples/directx11_example/main.cpp # examples/directx12_example/main.cpp # examples/imgui_impl_dx10.cpp # examples/imgui_impl_dx11.cpp # examples/imgui_impl_dx12.cpp # examples/imgui_impl_glfw.cpp # examples/imgui_impl_opengl2.cpp # examples/imgui_impl_opengl2.h # examples/imgui_impl_opengl3.cpp # examples/imgui_impl_sdl2.cpp # examples/imgui_impl_sdl2.h # examples/imgui_impl_vulkan.cpp # examples/imgui_impl_vulkan.h # examples/imgui_impl_win32.cpp # examples/imgui_impl_win32.h # examples/opengl2_example/main.cpp # examples/opengl3_example/main.cpp # examples/sdl_opengl2_example/main.cpp # examples/sdl_opengl3_example/main.cpp # examples/sdl_vulkan_example/main.cpp # examples/vulkan_example/main.cpp # imgui.cpp # imgui.h
This commit is contained in:
@ -13,7 +13,8 @@
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2018-XX-XX: DirectX10: Offset projection matrix and clipping rectangle by draw_data->DisplayPos (which will be non-zero for multi-viewport applications).
|
||||
// 2018-06-08: Misc: Extracted imgui_impl_dx10.cpp/.h away from the old combined DX10+Win32 example.
|
||||
// 2018-06-08: DirectX10: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
|
||||
// 2018-04-09: Misc: Fixed erroneous call to io.Fonts->ClearInputData() + ClearTexData() that was left in DX10 example but removed in 1.47 (Nov 2015) on other back-ends.
|
||||
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX10_RenderDrawData() in the .h file so you can call it yourself.
|
||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||
@ -48,7 +49,7 @@ static int g_VertexBufferSize = 5000, g_IndexBufferSize = 1
|
||||
|
||||
struct VERTEX_CONSTANT_BUFFER
|
||||
{
|
||||
float mvp[4][4];
|
||||
float mvp[4][4];
|
||||
};
|
||||
|
||||
// Forward Declarations
|
||||
@ -108,7 +109,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
||||
g_pIB->Unmap();
|
||||
|
||||
// Setup orthographic projection matrix into our constant buffer
|
||||
// Our visible imgui space lies from draw_data->DisplayPps (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps.
|
||||
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is (0,0) for single viewport apps.
|
||||
{
|
||||
void* mapped_resource;
|
||||
if (g_pVertexConstantBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, &mapped_resource) != S_OK)
|
||||
@ -199,7 +200,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
||||
// Render command lists
|
||||
int vtx_offset = 0;
|
||||
int idx_offset = 0;
|
||||
ImVec2 display_pos = draw_data->DisplayPos;
|
||||
ImVec2 pos = draw_data->DisplayPos;
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
@ -214,9 +215,8 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
||||
else
|
||||
{
|
||||
// Apply scissor/clipping rectangle
|
||||
const ImVec4 clip_rect = ImVec4(pcmd->ClipRect.x - display_pos.x, pcmd->ClipRect.y - display_pos.y, pcmd->ClipRect.z - display_pos.x, pcmd->ClipRect.w - display_pos.y);
|
||||
const D3D10_RECT clip_rect_dx = { (LONG)clip_rect.x, (LONG)clip_rect.y, (LONG)clip_rect.z, (LONG)clip_rect.w };
|
||||
ctx->RSSetScissorRects(1, &clip_rect_dx);
|
||||
const D3D10_RECT r = { (LONG)(pcmd->ClipRect.x - pos.x), (LONG)(pcmd->ClipRect.y - pos.y), (LONG)(pcmd->ClipRect.z - pos.x), (LONG)(pcmd->ClipRect.w - pos.y)};
|
||||
ctx->RSSetScissorRects(1, &r);
|
||||
|
||||
// Bind texture, Draw
|
||||
ctx->PSSetShaderResources(0, 1, (ID3D10ShaderResourceView**)&pcmd->TextureId);
|
||||
|
Reference in New Issue
Block a user