mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 22:26:34 +00:00
Merge branch 'master' into docking
# Conflicts: # examples/imgui_impl_opengl2.cpp # examples/imgui_impl_opengl3.cpp # imgui.cpp # imgui_widgets.cpp
This commit is contained in:
commit
2cada3c143
@ -103,6 +103,11 @@ Breaking Changes:
|
|||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
- Added .editorconfig file for text editors to standardize using spaces. (#2038) [@kudaba]
|
- Added .editorconfig file for text editors to standardize using spaces. (#2038) [@kudaba]
|
||||||
|
- ImDrawData: Added FramebufferScale field (currently a copy of the value from io.DisplayFramebufferScale).
|
||||||
|
This is to allow render functions being written without pulling any data from ImGuiIO, allowing incoming
|
||||||
|
multi-viewport feature to behave on Retina display and with multiple displays.
|
||||||
|
If you are not using a custom binding, please update your render function code ahead of time,
|
||||||
|
and use draw_data->FramebufferScale instead of io.DisplayFramebufferScale. (#2306, #1676)
|
||||||
- InputText: Fixed a bug where ESCAPE would not restore the initial value in all situations. (#2321) [@relick]
|
- InputText: Fixed a bug where ESCAPE would not restore the initial value in all situations. (#2321) [@relick]
|
||||||
- InputText: Fixed a bug where ESCAPE would be first captured by the Keyboard Navigation code. (#2321, #787)
|
- InputText: Fixed a bug where ESCAPE would be first captured by the Keyboard Navigation code. (#2321, #787)
|
||||||
- InputText: Fixed redo buffer exhaustion handling (rare) which could corrupt the undo character buffer. (#2333)
|
- InputText: Fixed redo buffer exhaustion handling (rare) which could corrupt the undo character buffer. (#2333)
|
||||||
@ -114,10 +119,12 @@ Other Changes:
|
|||||||
- Tabs: Added ImGuiTabBarFlags_TabListPopupButton flag to show a popup button on manual tab bars. (#261, #351)
|
- Tabs: Added ImGuiTabBarFlags_TabListPopupButton flag to show a popup button on manual tab bars. (#261, #351)
|
||||||
- Tabs: Removed ImGuiTabBarFlags_NoTabListPopupButton which was available in 1.67 but actually had zero use.
|
- Tabs: Removed ImGuiTabBarFlags_NoTabListPopupButton which was available in 1.67 but actually had zero use.
|
||||||
- Tabs: Fixed a minor clipping glitch when changing style's FramePadding from frame to frame.
|
- Tabs: Fixed a minor clipping glitch when changing style's FramePadding from frame to frame.
|
||||||
|
- Tabs: Fixed border (when enabled) so it is aligned correctly mid-pixel and appears as bright as other borders.
|
||||||
- Menus: Tweaked horizontal overlap between parent and child menu (to help convey relative depth)
|
- Menus: Tweaked horizontal overlap between parent and child menu (to help convey relative depth)
|
||||||
from using style.ItemSpacing.x to style.ItemInnerSpacing.x, the later being expected to be smaller. (#1086)
|
from using style.ItemSpacing.x to style.ItemInnerSpacing.x, the later being expected to be smaller. (#1086)
|
||||||
- RadioButton: Fixed label horizontal alignment to precisely match Checkbox().
|
- RadioButton: Fixed label horizontal alignment to precisely match Checkbox().
|
||||||
- Window: When resizing from an edge, the border is more visible and better follow the rounded corners.
|
- Window: When resizing from an edge, the border is more visible and better follow the rounded corners.
|
||||||
|
- Window: Fixed initial width of collapsed windows not taking account of contents width (broken in 1.67). (#2336, #176)
|
||||||
- ListBox: Better optimized when clipped / non-visible.
|
- ListBox: Better optimized when clipped / non-visible.
|
||||||
- InputTextMultiline: Better optimized when clipped / non-visible.
|
- InputTextMultiline: Better optimized when clipped / non-visible.
|
||||||
- ImDrawList: Fixed AddCircle(), AddCircleFilled() angle step being off, which was visible when drawing a "circle"
|
- ImDrawList: Fixed AddCircle(), AddCircleFilled() angle step being off, which was visible when drawing a "circle"
|
||||||
@ -127,8 +134,14 @@ Other Changes:
|
|||||||
- ImFontAtlas: FreeType: Added support for imgui allocators + custom FreeType only SetAllocatorFunctions. (#2285) [@Vuhdo]
|
- ImFontAtlas: FreeType: Added support for imgui allocators + custom FreeType only SetAllocatorFunctions. (#2285) [@Vuhdo]
|
||||||
- ImFontAtlas: FreeType: Fixed using imgui_freetype.cpp in unity builds. (#2302)
|
- ImFontAtlas: FreeType: Fixed using imgui_freetype.cpp in unity builds. (#2302)
|
||||||
- Demo: Fixed "Log" demo not initializing properly, leading to the first line not showing before a Clear. (#2318) [@bluescan]
|
- Demo: Fixed "Log" demo not initializing properly, leading to the first line not showing before a Clear. (#2318) [@bluescan]
|
||||||
|
- Examples: Metal, OpenGL2, OpenGL3: Fixed offsetting of clipping rectangle with ImDrawData::DisplayPos != (0,0) when
|
||||||
|
the display frame-buffer scale scale is not (1,1). While this doesn't make a difference when using master branch,
|
||||||
|
this is effectively fixing support for multi-viewport with Mac Retina Displays on those examples. (#2306) [@rasky, @ocornut]
|
||||||
|
Also using ImDrawData::FramebufferScale instead of io.DisplayFramebufferScale.
|
||||||
|
- Examples: Clarified the use the ImDrawData::DisplayPos to offset clipping rectangles.
|
||||||
- Examples: Win32: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created
|
- Examples: Win32: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created
|
||||||
in a different thread or parent. (#1951, #2087, #2156, #2232) [many people]
|
in a different thread or parent. (#1951, #2087, #2156, #2232) [many people]
|
||||||
|
- Examples: SDL: Using the SDL_WINDOW_ALLOW_HIGHDPI flag. (#2306, #1676) [@rasky]
|
||||||
- Examples: Win32: Added support for XInput games (if ImGuiConfigFlags_NavEnableGamepad is enabled).
|
- Examples: Win32: Added support for XInput games (if ImGuiConfigFlags_NavEnableGamepad is enabled).
|
||||||
- Examples: Win32: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages. (#2264)
|
- Examples: Win32: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages. (#2264)
|
||||||
- Examples: DirectX9: Explicitly disable fog (D3DRS_FOGENABLE) before drawing in case user state has it set. (#2288, #2230)
|
- Examples: DirectX9: Explicitly disable fog (D3DRS_FOGENABLE) before drawing in case user state has it set. (#2288, #2230)
|
||||||
|
@ -92,13 +92,14 @@
|
|||||||
[[self openGLContext] makeCurrentContext];
|
[[self openGLContext] makeCurrentContext];
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
GLsizei width = (GLsizei)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
|
ImDrawData* draw_data = ImGui::GetDrawData();
|
||||||
GLsizei height = (GLsizei)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
|
GLsizei width = (GLsizei)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
|
GLsizei height = (GLsizei)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL2_RenderDrawData(draw_data);
|
||||||
|
|
||||||
// Present
|
// Present
|
||||||
[[self openGLContext] flushBuffer];
|
[[self openGLContext] flushBuffer];
|
||||||
|
@ -30,7 +30,8 @@ int main(int, char**)
|
|||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
||||||
SDL_DisplayMode current;
|
SDL_DisplayMode current;
|
||||||
SDL_GetCurrentDisplayMode(0, ¤t);
|
SDL_GetCurrentDisplayMode(0, ¤t);
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
|
||||||
SDL_GLContext gl_context = SDL_GL_CreateContext(window);
|
SDL_GLContext gl_context = SDL_GL_CreateContext(window);
|
||||||
SDL_GL_MakeCurrent(window, gl_context);
|
SDL_GL_MakeCurrent(window, gl_context);
|
||||||
SDL_GL_SetSwapInterval(1); // Enable vsync
|
SDL_GL_SetSwapInterval(1); // Enable vsync
|
||||||
|
@ -54,7 +54,8 @@ int main(int, char**)
|
|||||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||||
SDL_DisplayMode current;
|
SDL_DisplayMode current;
|
||||||
SDL_GetCurrentDisplayMode(0, ¤t);
|
SDL_GetCurrentDisplayMode(0, ¤t);
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL3 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL3 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
|
||||||
SDL_GLContext gl_context = SDL_GL_CreateContext(window);
|
SDL_GLContext gl_context = SDL_GL_CreateContext(window);
|
||||||
SDL_GL_MakeCurrent(window, gl_context);
|
SDL_GL_MakeCurrent(window, gl_context);
|
||||||
SDL_GL_SetSwapInterval(1); // Enable vsync
|
SDL_GL_SetSwapInterval(1); // Enable vsync
|
||||||
|
@ -308,7 +308,8 @@ int main(int, char**)
|
|||||||
// Setup window
|
// Setup window
|
||||||
SDL_DisplayMode current;
|
SDL_DisplayMode current;
|
||||||
SDL_GetCurrentDisplayMode(0, ¤t);
|
SDL_GetCurrentDisplayMode(0, ¤t);
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+Vulkan example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_VULKAN|SDL_WINDOW_RESIZABLE);
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+Vulkan example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
|
||||||
|
|
||||||
// Setup Vulkan
|
// Setup Vulkan
|
||||||
uint32_t extensions_count = 0;
|
uint32_t extensions_count = 0;
|
||||||
|
@ -122,8 +122,9 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data)
|
|||||||
indices = (const int*)cmd_list->IdxBuffer.Data;
|
indices = (const int*)cmd_list->IdxBuffer.Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Render command lists
|
||||||
int idx_offset = 0;
|
int idx_offset = 0;
|
||||||
ImVec2 pos = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
||||||
@ -134,7 +135,7 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ALLEGRO_BITMAP* texture = (ALLEGRO_BITMAP*)pcmd->TextureId;
|
ALLEGRO_BITMAP* texture = (ALLEGRO_BITMAP*)pcmd->TextureId;
|
||||||
al_set_clipping_rectangle(pcmd->ClipRect.x - pos.x, pcmd->ClipRect.y - pos.y, pcmd->ClipRect.z - pcmd->ClipRect.x, pcmd->ClipRect.w - pcmd->ClipRect.y);
|
al_set_clipping_rectangle(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_off.y, pcmd->ClipRect.z - pcmd->ClipRect.x, pcmd->ClipRect.w - pcmd->ClipRect.y);
|
||||||
al_draw_prim(&vertices[0], g_VertexDecl, texture, idx_offset, idx_offset + pcmd->ElemCount, ALLEGRO_PRIM_TRIANGLE_LIST);
|
al_draw_prim(&vertices[0], g_VertexDecl, texture, idx_offset, idx_offset + pcmd->ElemCount, ALLEGRO_PRIM_TRIANGLE_LIST);
|
||||||
}
|
}
|
||||||
idx_offset += pcmd->ElemCount;
|
idx_offset += pcmd->ElemCount;
|
||||||
|
@ -205,7 +205,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
// Render command lists
|
// Render command lists
|
||||||
int vtx_offset = 0;
|
int vtx_offset = 0;
|
||||||
int idx_offset = 0;
|
int idx_offset = 0;
|
||||||
ImVec2 pos = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||||
@ -220,7 +220,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Apply scissor/clipping rectangle
|
// Apply scissor/clipping rectangle
|
||||||
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)};
|
const D3D10_RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y)};
|
||||||
ctx->RSSetScissorRects(1, &r);
|
ctx->RSSetScissorRects(1, &r);
|
||||||
|
|
||||||
// Bind texture, Draw
|
// Bind texture, Draw
|
||||||
|
@ -210,7 +210,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
// Render command lists
|
// Render command lists
|
||||||
int vtx_offset = 0;
|
int vtx_offset = 0;
|
||||||
int idx_offset = 0;
|
int idx_offset = 0;
|
||||||
ImVec2 pos = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||||
@ -225,7 +225,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Apply scissor/clipping rectangle
|
// Apply scissor/clipping rectangle
|
||||||
const D3D11_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) };
|
const D3D11_RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) };
|
||||||
ctx->RSSetScissorRects(1, &r);
|
ctx->RSSetScissorRects(1, &r);
|
||||||
|
|
||||||
// Bind texture, Draw
|
// Bind texture, Draw
|
||||||
|
@ -203,7 +203,7 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
|
|||||||
// Render command lists
|
// Render command lists
|
||||||
int vtx_offset = 0;
|
int vtx_offset = 0;
|
||||||
int idx_offset = 0;
|
int idx_offset = 0;
|
||||||
ImVec2 pos = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||||
@ -216,7 +216,7 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const D3D12_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) };
|
const D3D12_RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) };
|
||||||
ctx->SetGraphicsRootDescriptorTable(1, *(D3D12_GPU_DESCRIPTOR_HANDLE*)&pcmd->TextureId);
|
ctx->SetGraphicsRootDescriptorTable(1, *(D3D12_GPU_DESCRIPTOR_HANDLE*)&pcmd->TextureId);
|
||||||
ctx->RSSetScissorRects(1, &r);
|
ctx->RSSetScissorRects(1, &r);
|
||||||
ctx->DrawIndexedInstanced(pcmd->ElemCount, 1, idx_offset, vtx_offset, 0);
|
ctx->DrawIndexedInstanced(pcmd->ElemCount, 1, idx_offset, vtx_offset, 0);
|
||||||
|
@ -166,7 +166,7 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
// Render command lists
|
// Render command lists
|
||||||
int vtx_offset = 0;
|
int vtx_offset = 0;
|
||||||
int idx_offset = 0;
|
int idx_offset = 0;
|
||||||
ImVec2 pos = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||||
@ -179,7 +179,7 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const 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) };
|
const RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) };
|
||||||
const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->TextureId;
|
const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->TextureId;
|
||||||
g_pd3dDevice->SetTexture(0, texture);
|
g_pd3dDevice->SetTexture(0, texture);
|
||||||
g_pd3dDevice->SetScissorRect(&r);
|
g_pd3dDevice->SetScissorRect(&r);
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
// Missing features:
|
||||||
|
// [ ] Renderer: Clipping rectangles are not honored.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
@ -38,10 +40,6 @@ static ImVec2 g_RenderScale = ImVec2(1.0f,1.0f);
|
|||||||
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
||||||
void ImGui_Marmalade_RenderDrawData(ImDrawData* draw_data)
|
void ImGui_Marmalade_RenderDrawData(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
// Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
@ -54,7 +52,7 @@ void ImGui_Marmalade_RenderDrawData(ImDrawData* draw_data)
|
|||||||
|
|
||||||
for (int i = 0; i < nVert; i++)
|
for (int i = 0; i < nVert; i++)
|
||||||
{
|
{
|
||||||
// TODO: optimize multiplication on gpu using vertex shader/projection matrix.
|
// FIXME-OPT: optimize multiplication on GPU using vertex shader/projection matrix.
|
||||||
pVertStream[i].x = cmd_list->VtxBuffer[i].pos.x * g_RenderScale.x;
|
pVertStream[i].x = cmd_list->VtxBuffer[i].pos.x * g_RenderScale.x;
|
||||||
pVertStream[i].y = cmd_list->VtxBuffer[i].pos.y * g_RenderScale.y;
|
pVertStream[i].y = cmd_list->VtxBuffer[i].pos.y * g_RenderScale.y;
|
||||||
pUVStream[i].x = cmd_list->VtxBuffer[i].uv.x;
|
pUVStream[i].x = cmd_list->VtxBuffer[i].uv.x;
|
||||||
@ -76,6 +74,7 @@ void ImGui_Marmalade_RenderDrawData(ImDrawData* draw_data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// FIXME: Not honoring ClipRect fields.
|
||||||
CIwMaterial* pCurrentMaterial = IW_GX_ALLOC_MATERIAL();
|
CIwMaterial* pCurrentMaterial = IW_GX_ALLOC_MATERIAL();
|
||||||
pCurrentMaterial->SetShadeMode(CIwMaterial::SHADE_FLAT);
|
pCurrentMaterial->SetShadeMode(CIwMaterial::SHADE_FLAT);
|
||||||
pCurrentMaterial->SetCullMode(CIwMaterial::CULL_NONE);
|
pCurrentMaterial->SetCullMode(CIwMaterial::CULL_NONE);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2019-02-11: Metal: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
|
||||||
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
||||||
// 2018-07-05: Metal: Added new Metal backend implementation.
|
// 2018-07-05: Metal: Added new Metal backend implementation.
|
||||||
|
|
||||||
@ -403,12 +404,10 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|||||||
commandEncoder:(id<MTLRenderCommandEncoder>)commandEncoder
|
commandEncoder:(id<MTLRenderCommandEncoder>)commandEncoder
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
int fb_width = (int)(drawData->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
int fb_width = (int)(drawData->DisplaySize.x * io.DisplayFramebufferScale.x);
|
int fb_height = (int)(drawData->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
int fb_height = (int)(drawData->DisplaySize.y * io.DisplayFramebufferScale.y);
|
|
||||||
if (fb_width <= 0 || fb_height <= 0 || drawData->CmdListsCount == 0)
|
if (fb_width <= 0 || fb_height <= 0 || drawData->CmdListsCount == 0)
|
||||||
return;
|
return;
|
||||||
drawData->ScaleClipRects(io.DisplayFramebufferScale);
|
|
||||||
|
|
||||||
[commandEncoder setCullMode:MTLCullModeNone];
|
[commandEncoder setCullMode:MTLCullModeNone];
|
||||||
[commandEncoder setDepthStencilState:g_sharedMetalContext.depthStencilState];
|
[commandEncoder setDepthStencilState:g_sharedMetalContext.depthStencilState];
|
||||||
@ -442,26 +441,23 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|||||||
|
|
||||||
[commandEncoder setVertexBytes:&ortho_projection length:sizeof(ortho_projection) atIndex:1];
|
[commandEncoder setVertexBytes:&ortho_projection length:sizeof(ortho_projection) atIndex:1];
|
||||||
|
|
||||||
size_t vertexBufferLength = 0;
|
size_t vertexBufferLength = drawData->TotalVtxCount * sizeof(ImDrawVert);
|
||||||
size_t indexBufferLength = 0;
|
size_t indexBufferLength = drawData->TotalIdxCount * sizeof(ImDrawIdx);
|
||||||
for (int n = 0; n < drawData->CmdListsCount; n++)
|
MetalBuffer* vertexBuffer = [self dequeueReusableBufferOfLength:vertexBufferLength device:commandBuffer.device];
|
||||||
{
|
MetalBuffer* indexBuffer = [self dequeueReusableBufferOfLength:indexBufferLength device:commandBuffer.device];
|
||||||
const ImDrawList* cmd_list = drawData->CmdLists[n];
|
|
||||||
vertexBufferLength += cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
|
|
||||||
indexBufferLength += cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx);
|
|
||||||
}
|
|
||||||
|
|
||||||
MetalBuffer *vertexBuffer = [self dequeueReusableBufferOfLength:vertexBufferLength device:commandBuffer.device];
|
|
||||||
MetalBuffer *indexBuffer = [self dequeueReusableBufferOfLength:indexBufferLength device:commandBuffer.device];
|
|
||||||
|
|
||||||
id<MTLRenderPipelineState> renderPipelineState = [self renderPipelineStateForFrameAndDevice:commandBuffer.device];
|
id<MTLRenderPipelineState> renderPipelineState = [self renderPipelineStateForFrameAndDevice:commandBuffer.device];
|
||||||
[commandEncoder setRenderPipelineState:renderPipelineState];
|
[commandEncoder setRenderPipelineState:renderPipelineState];
|
||||||
|
|
||||||
[commandEncoder setVertexBuffer:vertexBuffer.buffer offset:0 atIndex:0];
|
[commandEncoder setVertexBuffer:vertexBuffer.buffer offset:0 atIndex:0];
|
||||||
|
|
||||||
|
// Will project scissor/clipping rectangles into framebuffer space
|
||||||
|
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||||
|
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
||||||
|
|
||||||
|
// Render command lists
|
||||||
size_t vertexBufferOffset = 0;
|
size_t vertexBufferOffset = 0;
|
||||||
size_t indexBufferOffset = 0;
|
size_t indexBufferOffset = 0;
|
||||||
ImVec2 pos = drawData->DisplayPos;
|
|
||||||
for (int n = 0; n < drawData->CmdListsCount; n++)
|
for (int n = 0; n < drawData->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
const ImDrawList* cmd_list = drawData->CmdLists[n];
|
const ImDrawList* cmd_list = drawData->CmdLists[n];
|
||||||
@ -482,14 +478,23 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ImVec4 clip_rect = ImVec4(pcmd->ClipRect.x - pos.x, pcmd->ClipRect.y - pos.y, pcmd->ClipRect.z - pos.x, pcmd->ClipRect.w - pos.y);
|
// Project scissor/clipping rectangles into framebuffer space
|
||||||
|
ImVec4 clip_rect;
|
||||||
|
clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x;
|
||||||
|
clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y;
|
||||||
|
clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x;
|
||||||
|
clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y;
|
||||||
|
|
||||||
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
||||||
{
|
{
|
||||||
// Apply scissor/clipping rectangle
|
// Apply scissor/clipping rectangle
|
||||||
MTLScissorRect scissorRect = { .x = NSUInteger(clip_rect.x),
|
MTLScissorRect scissorRect =
|
||||||
|
{
|
||||||
|
.x = NSUInteger(clip_rect.x),
|
||||||
.y = NSUInteger(clip_rect.y),
|
.y = NSUInteger(clip_rect.y),
|
||||||
.width = NSUInteger(clip_rect.z - clip_rect.x),
|
.width = NSUInteger(clip_rect.z - clip_rect.x),
|
||||||
.height = NSUInteger(clip_rect.w - clip_rect.y) };
|
.height = NSUInteger(clip_rect.w - clip_rect.y)
|
||||||
|
};
|
||||||
[commandEncoder setScissorRect:scissorRect];
|
[commandEncoder setScissorRect:scissorRect];
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (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: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
|
||||||
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
||||||
// 2018-08-03: OpenGL: Disabling/restoring GL_LIGHTING and GL_COLOR_MATERIAL to increase compatibility with legacy OpenGL applications.
|
// 2018-08-03: OpenGL: Disabling/restoring GL_LIGHTING and GL_COLOR_MATERIAL to increase compatibility with legacy OpenGL applications.
|
||||||
// 2018-06-08: Misc: Extracted imgui_impl_opengl2.cpp/.h away from the old combined GLFW/SDL+OpenGL2 examples.
|
// 2018-06-08: Misc: Extracted imgui_impl_opengl2.cpp/.h away from the old combined GLFW/SDL+OpenGL2 examples.
|
||||||
@ -87,12 +88,10 @@ void ImGui_ImplOpenGL2_NewFrame()
|
|||||||
void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data)
|
void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
int fb_width = (int)(draw_data->DisplaySize.x * io.DisplayFramebufferScale.x);
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
int fb_height = (int)(draw_data->DisplaySize.y * io.DisplayFramebufferScale.y);
|
|
||||||
if (fb_width == 0 || fb_height == 0)
|
if (fb_width == 0 || fb_height == 0)
|
||||||
return;
|
return;
|
||||||
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
|
||||||
|
|
||||||
// We are using the OpenGL fixed pipeline to make the example code simpler to read!
|
// We are using the OpenGL fixed pipeline to make the example code simpler to read!
|
||||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill.
|
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill.
|
||||||
@ -133,8 +132,11 @@ void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data)
|
|||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
|
// Will project scissor/clipping rectangles into framebuffer space
|
||||||
|
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||||
|
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
ImVec2 pos = draw_data->DisplayPos;
|
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||||
@ -154,7 +156,13 @@ void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ImVec4 clip_rect = ImVec4(pcmd->ClipRect.x - pos.x, pcmd->ClipRect.y - pos.y, pcmd->ClipRect.z - pos.x, pcmd->ClipRect.w - pos.y);
|
// Project scissor/clipping rectangles into framebuffer space
|
||||||
|
ImVec4 clip_rect;
|
||||||
|
clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x;
|
||||||
|
clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y;
|
||||||
|
clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x;
|
||||||
|
clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y;
|
||||||
|
|
||||||
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
||||||
{
|
{
|
||||||
// Apply scissor/clipping rectangle
|
// Apply scissor/clipping rectangle
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (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: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
|
||||||
// 2019-02-01: OpenGL: Using GLSL 410 shaders for any version over 410 (e.g. 430, 450).
|
// 2019-02-01: OpenGL: Using GLSL 410 shaders for any version over 410 (e.g. 430, 450).
|
||||||
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
||||||
// 2018-11-13: OpenGL: Support for GL 4.5's glClipControl(GL_UPPER_LEFT).
|
// 2018-11-13: OpenGL: Support for GL 4.5's glClipControl(GL_UPPER_LEFT).
|
||||||
@ -149,12 +150,10 @@ void ImGui_ImplOpenGL3_NewFrame()
|
|||||||
void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
int fb_width = (int)(draw_data->DisplaySize.x * io.DisplayFramebufferScale.x);
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
int fb_height = (int)(draw_data->DisplaySize.y * io.DisplayFramebufferScale.y);
|
|
||||||
if (fb_width <= 0 || fb_height <= 0)
|
if (fb_width <= 0 || fb_height <= 0)
|
||||||
return;
|
return;
|
||||||
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
|
||||||
|
|
||||||
// Backup GL state
|
// Backup GL state
|
||||||
GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
|
GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
|
||||||
@ -232,8 +231,11 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
glVertexAttribPointer(g_AttribLocationUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv));
|
glVertexAttribPointer(g_AttribLocationUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv));
|
||||||
glVertexAttribPointer(g_AttribLocationColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col));
|
glVertexAttribPointer(g_AttribLocationColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col));
|
||||||
|
|
||||||
// Draw
|
// Will project scissor/clipping rectangles into framebuffer space
|
||||||
ImVec2 pos = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||||
|
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
||||||
|
|
||||||
|
// Render command lists
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||||
@ -255,7 +257,13 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ImVec4 clip_rect = ImVec4(pcmd->ClipRect.x - pos.x, pcmd->ClipRect.y - pos.y, pcmd->ClipRect.z - pos.x, pcmd->ClipRect.w - pos.y);
|
// Project scissor/clipping rectangles into framebuffer space
|
||||||
|
ImVec4 clip_rect;
|
||||||
|
clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x;
|
||||||
|
clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y;
|
||||||
|
clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x;
|
||||||
|
clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y;
|
||||||
|
|
||||||
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
||||||
{
|
{
|
||||||
// Apply scissor/clipping rectangle
|
// Apply scissor/clipping rectangle
|
||||||
|
@ -294,7 +294,7 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
// Render the command lists:
|
// Render the command lists:
|
||||||
int vtx_offset = 0;
|
int vtx_offset = 0;
|
||||||
int idx_offset = 0;
|
int idx_offset = 0;
|
||||||
ImVec2 display_pos = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||||
@ -310,8 +310,8 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
// Apply scissor/clipping rectangle
|
// Apply scissor/clipping rectangle
|
||||||
// FIXME: We could clamp width/height based on clamped min/max values.
|
// FIXME: We could clamp width/height based on clamped min/max values.
|
||||||
VkRect2D scissor;
|
VkRect2D scissor;
|
||||||
scissor.offset.x = (int32_t)(pcmd->ClipRect.x - display_pos.x) > 0 ? (int32_t)(pcmd->ClipRect.x - display_pos.x) : 0;
|
scissor.offset.x = (int32_t)(pcmd->ClipRect.x - clip_off.x) > 0 ? (int32_t)(pcmd->ClipRect.x - clip_off.x) : 0;
|
||||||
scissor.offset.y = (int32_t)(pcmd->ClipRect.y - display_pos.y) > 0 ? (int32_t)(pcmd->ClipRect.y - display_pos.y) : 0;
|
scissor.offset.y = (int32_t)(pcmd->ClipRect.y - clip_off.y) > 0 ? (int32_t)(pcmd->ClipRect.y - clip_off.y) : 0;
|
||||||
scissor.extent.width = (uint32_t)(pcmd->ClipRect.z - pcmd->ClipRect.x);
|
scissor.extent.width = (uint32_t)(pcmd->ClipRect.z - pcmd->ClipRect.x);
|
||||||
scissor.extent.height = (uint32_t)(pcmd->ClipRect.w - pcmd->ClipRect.y + 1); // FIXME: Why +1 here?
|
scissor.extent.height = (uint32_t)(pcmd->ClipRect.w - pcmd->ClipRect.y + 1); // FIXME: Why +1 here?
|
||||||
vkCmdSetScissor(command_buffer, 0, 1, &scissor);
|
vkCmdSetScissor(command_buffer, 0, 1, &scissor);
|
||||||
|
@ -3934,6 +3934,7 @@ static void SetupViewportDrawData(ImGuiViewportP* viewport, ImVector<ImDrawList*
|
|||||||
draw_data->TotalVtxCount = draw_data->TotalIdxCount = 0;
|
draw_data->TotalVtxCount = draw_data->TotalIdxCount = 0;
|
||||||
draw_data->DisplayPos = viewport->Pos;
|
draw_data->DisplayPos = viewport->Pos;
|
||||||
draw_data->DisplaySize = viewport->Size;
|
draw_data->DisplaySize = viewport->Size;
|
||||||
|
draw_data->FramebufferScale = ImGui::GetIO().DisplayFramebufferScale; // FIXME-VIEWPORT: This may vary on a per-monitor/viewport basis?
|
||||||
for (int n = 0; n < draw_lists->Size; n++)
|
for (int n = 0; n < draw_lists->Size; n++)
|
||||||
{
|
{
|
||||||
draw_data->TotalVtxCount += draw_lists->Data[n]->VtxBuffer.Size;
|
draw_data->TotalVtxCount += draw_lists->Data[n]->VtxBuffer.Size;
|
||||||
@ -4882,7 +4883,8 @@ static ImVec2 CalcSizeAfterConstraint(ImGuiWindow* window, ImVec2 new_size)
|
|||||||
static ImVec2 CalcSizeContents(ImGuiWindow* window)
|
static ImVec2 CalcSizeContents(ImGuiWindow* window)
|
||||||
{
|
{
|
||||||
if (window->Collapsed)
|
if (window->Collapsed)
|
||||||
return window->SizeContents;
|
if (window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0)
|
||||||
|
return window->SizeContents;
|
||||||
if (window->Hidden && window->HiddenFramesForResize == 0 && window->HiddenFramesRegular > 0)
|
if (window->Hidden && window->HiddenFramesForResize == 0 && window->HiddenFramesRegular > 0)
|
||||||
return window->SizeContents;
|
return window->SizeContents;
|
||||||
|
|
||||||
|
45
imgui.h
45
imgui.h
@ -1369,7 +1369,7 @@ struct ImGuiIO
|
|||||||
float FontGlobalScale; // = 1.0f // Global scale all fonts
|
float FontGlobalScale; // = 1.0f // Global scale all fonts
|
||||||
bool FontAllowUserScaling; // = false // Allow user scaling text of individual window with CTRL+Wheel.
|
bool FontAllowUserScaling; // = false // Allow user scaling text of individual window with CTRL+Wheel.
|
||||||
ImFont* FontDefault; // = NULL // Font to use on NewFrame(). Use NULL to uses Fonts->Fonts[0].
|
ImFont* FontDefault; // = NULL // Font to use on NewFrame(). Use NULL to uses Fonts->Fonts[0].
|
||||||
ImVec2 DisplayFramebufferScale; // = (1.0f,1.0f) // For hi-dpi/retina display or other situations where window coordinates are different from framebuffer coordinates. User storage only, presently not used by ImGui.
|
ImVec2 DisplayFramebufferScale; // = (1, 1) // For retina display or other situations where window coordinates are different from framebuffer coordinates. This generally ends up in ImDrawData::FramebufferScale.
|
||||||
|
|
||||||
// Docking options (when ImGuiConfigFlags_DockingEnable is set)
|
// Docking options (when ImGuiConfigFlags_DockingEnable is set)
|
||||||
bool ConfigDockingNoSplit; // = false // Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.
|
bool ConfigDockingNoSplit; // = false // Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.
|
||||||
@ -1983,13 +1983,14 @@ struct ImDrawData
|
|||||||
int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size
|
int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size
|
||||||
ImVec2 DisplayPos; // Upper-left position of the viewport to render (== upper-left of the orthogonal projection matrix to use)
|
ImVec2 DisplayPos; // Upper-left position of the viewport to render (== upper-left of the orthogonal projection matrix to use)
|
||||||
ImVec2 DisplaySize; // Size of the viewport to render (== io.DisplaySize for the main viewport) (DisplayPos + DisplaySize == lower-right of the orthogonal projection matrix to use)
|
ImVec2 DisplaySize; // Size of the viewport to render (== io.DisplaySize for the main viewport) (DisplayPos + DisplaySize == lower-right of the orthogonal projection matrix to use)
|
||||||
|
ImVec2 FramebufferScale; // Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
ImDrawData() { Valid = false; Clear(); }
|
ImDrawData() { Valid = false; Clear(); }
|
||||||
~ImDrawData() { Clear(); }
|
~ImDrawData() { Clear(); }
|
||||||
void Clear() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; DisplayPos = DisplaySize = ImVec2(0.f, 0.f); } // The ImDrawList are owned by ImGuiContext!
|
void Clear() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; DisplayPos = DisplaySize = FramebufferScale = ImVec2(0.f, 0.f); } // The ImDrawList are owned by ImGuiContext!
|
||||||
IMGUI_API void DeIndexAllBuffers(); // Helper to convert all buffers from indexed to non-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
|
IMGUI_API void DeIndexAllBuffers(); // Helper to convert all buffers from indexed to non-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
|
||||||
IMGUI_API void ScaleClipRects(const ImVec2& sc); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
|
IMGUI_API void ScaleClipRects(const ImVec2& fb_scale); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -2168,24 +2169,26 @@ struct ImFontAtlas
|
|||||||
// ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32().
|
// ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32().
|
||||||
struct ImFont
|
struct ImFont
|
||||||
{
|
{
|
||||||
// Members: Hot ~62/78 bytes
|
// Members: Hot ~24/32 bytes (for CalcTextSize)
|
||||||
float FontSize; // <user set> // Height of characters, set during loading (don't change after loading)
|
ImVector<float> IndexAdvanceX; // 12/16 // out // // Sparse. Glyphs->AdvanceX in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI).
|
||||||
float Scale; // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
|
float FontSize; // 4 // in // <user set> // Height of characters, set during loading (don't change after loading)
|
||||||
ImVec2 DisplayOffset; // = (0.f,0.f) // Offset font rendering by xx pixels
|
float FallbackAdvanceX; // 4 // out // = FallbackGlyph->AdvanceX
|
||||||
ImVector<ImFontGlyph> Glyphs; // // All glyphs.
|
ImWchar FallbackChar; // 2 // in // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
|
||||||
ImVector<float> IndexAdvanceX; // // Sparse. Glyphs->AdvanceX in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI).
|
|
||||||
ImVector<ImWchar> IndexLookup; // // Sparse. Index glyphs by Unicode code-point.
|
|
||||||
const ImFontGlyph* FallbackGlyph; // == FindGlyph(FontFallbackChar)
|
|
||||||
float FallbackAdvanceX; // == FallbackGlyph->AdvanceX
|
|
||||||
ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
|
|
||||||
|
|
||||||
// Members: Cold ~18/26 bytes
|
// Members: Hot ~36/48 bytes (for CalcTextSize + render loop)
|
||||||
short ConfigDataCount; // ~ 1 // Number of ImFontConfig involved in creating this font. Bigger than 1 when merging multiple font sources into one ImFont.
|
ImVector<ImWchar> IndexLookup; // 12-16 // out // // Sparse. Index glyphs by Unicode code-point.
|
||||||
ImFontConfig* ConfigData; // // Pointer within ContainerAtlas->ConfigData
|
ImVector<ImFontGlyph> Glyphs; // 12-16 // out // // All glyphs.
|
||||||
ImFontAtlas* ContainerAtlas; // // What we has been loaded into
|
ImVec2 DisplayOffset; // 8 // in // = (0,0) // Offset font rendering by xx pixels
|
||||||
float Ascent, Descent; // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
|
const ImFontGlyph* FallbackGlyph; // 4-8 // out // = FindGlyph(FontFallbackChar)
|
||||||
bool DirtyLookupTables;
|
|
||||||
int MetricsTotalSurface;// // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
|
// Members: Cold ~28/40 bytes
|
||||||
|
ImFontAtlas* ContainerAtlas; // 4-8 // out // // What we has been loaded into
|
||||||
|
ImFontConfig* ConfigData; // 4-8 // in // // Pointer within ContainerAtlas->ConfigData
|
||||||
|
short ConfigDataCount; // 2 // in // ~ 1 // Number of ImFontConfig involved in creating this font. Bigger than 1 when merging multiple font sources into one ImFont.
|
||||||
|
bool DirtyLookupTables; // 1 // out //
|
||||||
|
float Scale; // 4 // in // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
|
||||||
|
float Ascent, Descent; // 8 // out // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
|
||||||
|
int MetricsTotalSurface;// 4 // out // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
IMGUI_API ImFont();
|
IMGUI_API ImFont();
|
||||||
|
@ -2818,8 +2818,13 @@ void ImGui::ShowFontSelector(const char* label)
|
|||||||
if (ImGui::BeginCombo(label, font_current->GetDebugName()))
|
if (ImGui::BeginCombo(label, font_current->GetDebugName()))
|
||||||
{
|
{
|
||||||
for (int n = 0; n < io.Fonts->Fonts.Size; n++)
|
for (int n = 0; n < io.Fonts->Fonts.Size; n++)
|
||||||
if (ImGui::Selectable(io.Fonts->Fonts[n]->GetDebugName(), io.Fonts->Fonts[n] == font_current))
|
{
|
||||||
io.FontDefault = io.Fonts->Fonts[n];
|
ImFont* font = io.Fonts->Fonts[n];
|
||||||
|
ImGui::PushID((void*)font);
|
||||||
|
if (ImGui::Selectable(font->GetDebugName(), font == font_current))
|
||||||
|
io.FontDefault = font;
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
@ -1293,8 +1293,10 @@ void ImDrawData::DeIndexAllBuffers()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
|
// Helper to scale the ClipRect field of each ImDrawCmd.
|
||||||
void ImDrawData::ScaleClipRects(const ImVec2& scale)
|
// Use if your final output buffer is at a different scale than draw_data->DisplaySize,
|
||||||
|
// or if there is a difference between your window resolution and framebuffer resolution.
|
||||||
|
void ImDrawData::ScaleClipRects(const ImVec2& fb_scale)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < CmdListsCount; i++)
|
for (int i = 0; i < CmdListsCount; i++)
|
||||||
{
|
{
|
||||||
@ -1302,7 +1304,7 @@ void ImDrawData::ScaleClipRects(const ImVec2& scale)
|
|||||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
ImDrawCmd* cmd = &cmd_list->CmdBuffer[cmd_i];
|
ImDrawCmd* cmd = &cmd_list->CmdBuffer[cmd_i];
|
||||||
cmd->ClipRect = ImVec4(cmd->ClipRect.x * scale.x, cmd->ClipRect.y * scale.y, cmd->ClipRect.z * scale.x, cmd->ClipRect.w * scale.y);
|
cmd->ClipRect = ImVec4(cmd->ClipRect.x * fb_scale.x, cmd->ClipRect.y * fb_scale.y, cmd->ClipRect.z * fb_scale.x, cmd->ClipRect.w * fb_scale.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2396,38 +2398,36 @@ void ImFontGlyphRangesBuilder::BuildRanges(ImVector<ImWchar>* out_ranges)
|
|||||||
|
|
||||||
ImFont::ImFont()
|
ImFont::ImFont()
|
||||||
{
|
{
|
||||||
Scale = 1.0f;
|
FontSize = 0.0f;
|
||||||
|
FallbackAdvanceX = 0.0f;
|
||||||
FallbackChar = (ImWchar)'?';
|
FallbackChar = (ImWchar)'?';
|
||||||
DisplayOffset = ImVec2(0.0f, 0.0f);
|
DisplayOffset = ImVec2(0.0f, 0.0f);
|
||||||
ClearOutputData();
|
FallbackGlyph = NULL;
|
||||||
|
ContainerAtlas = NULL;
|
||||||
|
ConfigData = NULL;
|
||||||
|
ConfigDataCount = 0;
|
||||||
|
DirtyLookupTables = false;
|
||||||
|
Scale = 1.0f;
|
||||||
|
Ascent = Descent = 0.0f;
|
||||||
|
MetricsTotalSurface = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImFont::~ImFont()
|
ImFont::~ImFont()
|
||||||
{
|
{
|
||||||
// Invalidate active font so that the user gets a clear crash instead of a dangling pointer.
|
|
||||||
// If you want to delete fonts you need to do it between Render() and NewFrame().
|
|
||||||
// FIXME-CLEANUP
|
|
||||||
/*
|
|
||||||
ImGuiContext& g = *GImGui;
|
|
||||||
if (g.Font == this)
|
|
||||||
g.Font = NULL;
|
|
||||||
*/
|
|
||||||
ClearOutputData();
|
ClearOutputData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImFont::ClearOutputData()
|
void ImFont::ClearOutputData()
|
||||||
{
|
{
|
||||||
FontSize = 0.0f;
|
FontSize = 0.0f;
|
||||||
|
FallbackAdvanceX = 0.0f;
|
||||||
Glyphs.clear();
|
Glyphs.clear();
|
||||||
IndexAdvanceX.clear();
|
IndexAdvanceX.clear();
|
||||||
IndexLookup.clear();
|
IndexLookup.clear();
|
||||||
FallbackGlyph = NULL;
|
FallbackGlyph = NULL;
|
||||||
FallbackAdvanceX = 0.0f;
|
|
||||||
ConfigDataCount = 0;
|
|
||||||
ConfigData = NULL;
|
|
||||||
ContainerAtlas = NULL;
|
ContainerAtlas = NULL;
|
||||||
Ascent = Descent = 0.0f;
|
|
||||||
DirtyLookupTables = true;
|
DirtyLookupTables = true;
|
||||||
|
Ascent = Descent = 0.0f;
|
||||||
MetricsTotalSurface = 0;
|
MetricsTotalSurface = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6346,7 +6346,7 @@ static ImGuiTabItem* ImGui::TabBarTabListPopupButton(ImGuiTabBar* tab_bar)
|
|||||||
// - TabItemEx() [Internal]
|
// - TabItemEx() [Internal]
|
||||||
// - SetTabItemClosed()
|
// - SetTabItemClosed()
|
||||||
// - TabItemCalcSize() [Internal]
|
// - TabItemCalcSize() [Internal]
|
||||||
// - TabItemRenderBackground() [Internal]
|
// - TabItemBackground() [Internal]
|
||||||
// - TabItemLabelAndCloseButton() [Internal]
|
// - TabItemLabelAndCloseButton() [Internal]
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -6576,7 +6576,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|||||||
// Enlarge tab display when hovering
|
// Enlarge tab display when hovering
|
||||||
bb.Max.x = bb.Min.x + (float)(int)ImLerp(bb.GetWidth(), tab->WidthContents, ImSaturate((g.HoveredIdNotActiveTimer - 0.40f) * 6.0f));
|
bb.Max.x = bb.Min.x + (float)(int)ImLerp(bb.GetWidth(), tab->WidthContents, ImSaturate((g.HoveredIdNotActiveTimer - 0.40f) * 6.0f));
|
||||||
display_draw_list = GetOverlayDrawList(window);
|
display_draw_list = GetOverlayDrawList(window);
|
||||||
TabItemRenderBackground(display_draw_list, bb, flags, GetColorU32(ImGuiCol_TitleBgActive));
|
TabItemBackground(display_draw_list, bb, flags, GetColorU32(ImGuiCol_TitleBgActive));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -6661,16 +6661,21 @@ void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabI
|
|||||||
IM_UNUSED(flags);
|
IM_UNUSED(flags);
|
||||||
IM_ASSERT(width > 0.0f);
|
IM_ASSERT(width > 0.0f);
|
||||||
const float rounding = ImMax(0.0f, ImMin(g.Style.TabRounding, width * 0.5f - 1.0f));
|
const float rounding = ImMax(0.0f, ImMin(g.Style.TabRounding, width * 0.5f - 1.0f));
|
||||||
float y1 = bb.Min.y + 1.0f;
|
const float y1 = bb.Min.y + 1.0f;
|
||||||
float y2 = bb.Max.y + ((flags & ImGuiTabItemFlags_Preview) ? 0.0f : -1.0f);
|
const float y2 = bb.Max.y + ((flags & ImGuiTabItemFlags_Preview) ? 0.0f : -1.0f);
|
||||||
draw_list->PathLineTo(ImVec2(bb.Min.x, y2));
|
draw_list->PathLineTo(ImVec2(bb.Min.x, y2));
|
||||||
draw_list->PathArcToFast(ImVec2(bb.Min.x + rounding, y1 + rounding), rounding, 6, 9);
|
draw_list->PathArcToFast(ImVec2(bb.Min.x + rounding, y1 + rounding), rounding, 6, 9);
|
||||||
draw_list->PathArcToFast(ImVec2(bb.Max.x - rounding, y1 + rounding), rounding, 9, 12);
|
draw_list->PathArcToFast(ImVec2(bb.Max.x - rounding, y1 + rounding), rounding, 9, 12);
|
||||||
draw_list->PathLineTo(ImVec2(bb.Max.x, y2));
|
draw_list->PathLineTo(ImVec2(bb.Max.x, y2));
|
||||||
draw_list->AddConvexPolyFilled(draw_list->_Path.Data, draw_list->_Path.Size, col);
|
draw_list->PathFillConvex(col);
|
||||||
if (g.Style.TabBorderSize > 0.0f)
|
if (g.Style.TabBorderSize > 0.0f)
|
||||||
draw_list->AddPolyline(draw_list->_Path.Data, draw_list->_Path.Size, GetColorU32(ImGuiCol_Border), false, g.Style.TabBorderSize);
|
{
|
||||||
draw_list->PathClear();
|
draw_list->PathLineTo(ImVec2(bb.Min.x + 0.5f, y2));
|
||||||
|
draw_list->PathArcToFast(ImVec2(bb.Min.x + rounding + 0.5f, y1 + rounding + 0.5f), rounding, 6, 9);
|
||||||
|
draw_list->PathArcToFast(ImVec2(bb.Max.x - rounding - 0.5f, y1 + rounding + 0.5f), rounding, 9, 12);
|
||||||
|
draw_list->PathLineTo(ImVec2(bb.Max.x - 0.5f, y2));
|
||||||
|
draw_list->PathStroke(GetColorU32(ImGuiCol_Border), false, g.Style.TabBorderSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render text label (with custom clipping) + Unsaved Document marker + Close Button logic
|
// Render text label (with custom clipping) + Unsaved Document marker + Close Button logic
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
// stb_rect_pack.h - v0.11 - public domain - rectangle packing
|
// [DEAR IMGUI]
|
||||||
|
// This is a slightly modified version of stb_rect_pack.h 0.99.
|
||||||
|
// Those changes would need to be pushed into nothings/stb:
|
||||||
|
// - Added STBRP__CDECL
|
||||||
|
// Grep for [DEAR IMGUI] to find the changes.
|
||||||
|
|
||||||
|
// stb_rect_pack.h - v0.99 - public domain - rectangle packing
|
||||||
// Sean Barrett 2014
|
// Sean Barrett 2014
|
||||||
//
|
//
|
||||||
// Useful for e.g. packing rectangular textures into an atlas.
|
// Useful for e.g. packing rectangular textures into an atlas.
|
||||||
@ -34,6 +40,7 @@
|
|||||||
//
|
//
|
||||||
// Version history:
|
// Version history:
|
||||||
//
|
//
|
||||||
|
// 0.99 (2019-02-07) warning fixes
|
||||||
// 0.11 (2017-03-03) return packing success/fail result
|
// 0.11 (2017-03-03) return packing success/fail result
|
||||||
// 0.10 (2016-10-25) remove cast-away-const to avoid warnings
|
// 0.10 (2016-10-25) remove cast-away-const to avoid warnings
|
||||||
// 0.09 (2016-08-27) fix compiler warnings
|
// 0.09 (2016-08-27) fix compiler warnings
|
||||||
@ -204,6 +211,7 @@ struct stbrp_context
|
|||||||
#define STBRP_ASSERT assert
|
#define STBRP_ASSERT assert
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// [DEAR IMGUI] Added STBRP__CDECL
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define STBRP__NOTUSED(v) (void)(v)
|
#define STBRP__NOTUSED(v) (void)(v)
|
||||||
#define STBRP__CDECL __cdecl
|
#define STBRP__CDECL __cdecl
|
||||||
@ -512,6 +520,7 @@ static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, i
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// [DEAR IMGUI] Added STBRP__CDECL
|
||||||
static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
|
static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
const stbrp_rect *p = (const stbrp_rect *) a;
|
const stbrp_rect *p = (const stbrp_rect *) a;
|
||||||
@ -523,6 +532,7 @@ static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
|
|||||||
return (p->w > q->w) ? -1 : (p->w < q->w);
|
return (p->w > q->w) ? -1 : (p->w < q->w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// [DEAR IMGUI] Added STBRP__CDECL
|
||||||
static int STBRP__CDECL rect_original_order(const void *a, const void *b)
|
static int STBRP__CDECL rect_original_order(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
const stbrp_rect *p = (const stbrp_rect *) a;
|
const stbrp_rect *p = (const stbrp_rect *) a;
|
||||||
@ -543,9 +553,6 @@ STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int nu
|
|||||||
// we use the 'was_packed' field internally to allow sorting/unsorting
|
// we use the 'was_packed' field internally to allow sorting/unsorting
|
||||||
for (i=0; i < num_rects; ++i) {
|
for (i=0; i < num_rects; ++i) {
|
||||||
rects[i].was_packed = i;
|
rects[i].was_packed = i;
|
||||||
#ifndef STBRP_LARGE_RECTS
|
|
||||||
STBRP_ASSERT(rects[i].w <= 0xffff && rects[i].h <= 0xffff);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort according to heuristic
|
// sort according to heuristic
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
// [ImGui] this is a slightly modified version of stb_textedit.h 1.12. Those changes would need to be pushed into nothings/stb
|
// [DEAR IMGUI]
|
||||||
// [ImGui] - 2018-06: fixed undo/redo after pasting large amount of text (over 32 kb). Redo will still fail when undo buffers are exhausted, but text won't be corrupted (see nothings/stb issue #620)
|
// This is a slightly modified version of stb_textedit.h 1.13.
|
||||||
// [ImGui] - 2018-06: fix in stb_textedit_discard_redo (see https://github.com/nothings/stb/issues/321)
|
// Those changes would need to be pushed into nothings/stb:
|
||||||
// [ImGui] - fixed some minor warnings
|
// - Fix in stb_textedit_discard_redo (see https://github.com/nothings/stb/issues/321)
|
||||||
|
// Grep for [DEAR IMGUI] to find the changes.
|
||||||
|
|
||||||
// stb_textedit.h - v1.12 - public domain - Sean Barrett
|
// stb_textedit.h - v1.13 - public domain - Sean Barrett
|
||||||
// Development of this library was sponsored by RAD Game Tools
|
// Development of this library was sponsored by RAD Game Tools
|
||||||
//
|
//
|
||||||
// This C header file implements the guts of a multi-line text-editing
|
// This C header file implements the guts of a multi-line text-editing
|
||||||
@ -34,6 +35,7 @@
|
|||||||
//
|
//
|
||||||
// VERSION HISTORY
|
// VERSION HISTORY
|
||||||
//
|
//
|
||||||
|
// 1.13 (2019-02-07) fix bug in undo size management
|
||||||
// 1.12 (2018-01-29) user can change STB_TEXTEDIT_KEYTYPE, fix redo to avoid crash
|
// 1.12 (2018-01-29) user can change STB_TEXTEDIT_KEYTYPE, fix redo to avoid crash
|
||||||
// 1.11 (2017-03-03) fix HOME on last line, dragging off single-line textfield
|
// 1.11 (2017-03-03) fix HOME on last line, dragging off single-line textfield
|
||||||
// 1.10 (2016-10-25) supress warnings about casting away const with -Wcast-qual
|
// 1.10 (2016-10-25) supress warnings about casting away const with -Wcast-qual
|
||||||
@ -692,7 +694,7 @@ static void stb_textedit_prep_selection_at_cursor(STB_TexteditState *state)
|
|||||||
static int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
static int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||||
{
|
{
|
||||||
if (STB_TEXT_HAS_SELECTION(state)) {
|
if (STB_TEXT_HAS_SELECTION(state)) {
|
||||||
stb_textedit_delete_selection(str,state); // implicity clamps
|
stb_textedit_delete_selection(str,state); // implicitly clamps
|
||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -744,7 +746,7 @@ retry:
|
|||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stb_textedit_delete_selection(str,state); // implicity clamps
|
stb_textedit_delete_selection(str,state); // implicitly clamps
|
||||||
if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) {
|
if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) {
|
||||||
stb_text_makeundo_insert(state, state->cursor, 1);
|
stb_text_makeundo_insert(state, state->cursor, 1);
|
||||||
++state->cursor;
|
++state->cursor;
|
||||||
@ -1132,6 +1134,7 @@ static void stb_textedit_discard_redo(StbUndoState *state)
|
|||||||
state->undo_rec[i].char_storage += n;
|
state->undo_rec[i].char_storage += n;
|
||||||
}
|
}
|
||||||
// now move all the redo records towards the end of the buffer; the first one is at 'redo_point'
|
// now move all the redo records towards the end of the buffer; the first one is at 'redo_point'
|
||||||
|
// {DEAR IMGUI]
|
||||||
size_t move_size = (size_t)((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point - 1) * sizeof(state->undo_rec[0]));
|
size_t move_size = (size_t)((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point - 1) * sizeof(state->undo_rec[0]));
|
||||||
const char* buf_begin = (char*)state->undo_rec; (void)buf_begin;
|
const char* buf_begin = (char*)state->undo_rec; (void)buf_begin;
|
||||||
const char* buf_end = (char*)state->undo_rec + sizeof(state->undo_rec); (void)buf_end;
|
const char* buf_end = (char*)state->undo_rec + sizeof(state->undo_rec); (void)buf_end;
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
// [ImGui] this is a slightly modified version of stb_truetype.h 1.19. Those changes would need to be pushed into nothings/stb
|
// [DEAR IMGUI]
|
||||||
// grep for [ImGui] to find the changes.
|
// This is a slightly modified version of stb_truetype.h 1.20.
|
||||||
|
// Mostly fixing for compiler and static analyzer warnings.
|
||||||
|
// Grep for [DEAR IMGUI] to find the changes.
|
||||||
|
|
||||||
// stb_truetype.h - v1.19 - public domain
|
// stb_truetype.h - v1.20 - public domain
|
||||||
// authored from 2009-2016 by Sean Barrett / RAD Game Tools
|
// authored from 2009-2016 by Sean Barrett / RAD Game Tools
|
||||||
//
|
//
|
||||||
// This library processes TrueType files:
|
// This library processes TrueType files:
|
||||||
@ -52,6 +54,7 @@
|
|||||||
//
|
//
|
||||||
// VERSION HISTORY
|
// VERSION HISTORY
|
||||||
//
|
//
|
||||||
|
// 1.20 (2019-02-07) PackFontRange skips missing codepoints; GetScaleFontVMetrics()
|
||||||
// 1.19 (2018-02-11) GPOS kerning, STBTT_fmod
|
// 1.19 (2018-02-11) GPOS kerning, STBTT_fmod
|
||||||
// 1.18 (2018-01-29) add missing function
|
// 1.18 (2018-01-29) add missing function
|
||||||
// 1.17 (2017-07-23) make more arguments const; doc fix
|
// 1.17 (2017-07-23) make more arguments const; doc fix
|
||||||
@ -78,7 +81,7 @@
|
|||||||
//
|
//
|
||||||
// USAGE
|
// USAGE
|
||||||
//
|
//
|
||||||
// Include this file in whatever places neeed to refer to it. In ONE C/C++
|
// Include this file in whatever places need to refer to it. In ONE C/C++
|
||||||
// file, write:
|
// file, write:
|
||||||
// #define STB_TRUETYPE_IMPLEMENTATION
|
// #define STB_TRUETYPE_IMPLEMENTATION
|
||||||
// before the #include of this file. This expands out the actual
|
// before the #include of this file. This expands out the actual
|
||||||
@ -250,8 +253,8 @@
|
|||||||
// Documentation & header file 520 LOC \___ 660 LOC documentation
|
// Documentation & header file 520 LOC \___ 660 LOC documentation
|
||||||
// Sample code 140 LOC /
|
// Sample code 140 LOC /
|
||||||
// Truetype parsing 620 LOC ---- 620 LOC TrueType
|
// Truetype parsing 620 LOC ---- 620 LOC TrueType
|
||||||
// Software rasterization 240 LOC \ .
|
// Software rasterization 240 LOC \
|
||||||
// Curve tesselation 120 LOC \__ 550 LOC Bitmap creation
|
// Curve tessellation 120 LOC \__ 550 LOC Bitmap creation
|
||||||
// Bitmap management 100 LOC /
|
// Bitmap management 100 LOC /
|
||||||
// Baked bitmap interface 70 LOC /
|
// Baked bitmap interface 70 LOC /
|
||||||
// Font name matching & access 150 LOC ---- 150
|
// Font name matching & access 150 LOC ---- 150
|
||||||
@ -559,6 +562,8 @@ STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int p
|
|||||||
//
|
//
|
||||||
// It's inefficient; you might want to c&p it and optimize it.
|
// It's inefficient; you might want to c&p it and optimize it.
|
||||||
|
|
||||||
|
STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap);
|
||||||
|
// Query the font vertical metrics without having to create a font first.
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@ -644,6 +649,12 @@ STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h
|
|||||||
// To use with PackFontRangesGather etc., you must set it before calls
|
// To use with PackFontRangesGather etc., you must set it before calls
|
||||||
// call to PackFontRangesGatherRects.
|
// call to PackFontRangesGatherRects.
|
||||||
|
|
||||||
|
STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip);
|
||||||
|
// If skip != 0, this tells stb_truetype to skip any codepoints for which
|
||||||
|
// there is no corresponding glyph. If skip=0, which is the default, then
|
||||||
|
// codepoints without a glyph recived the font's "missing character" glyph,
|
||||||
|
// typically an empty box by convention.
|
||||||
|
|
||||||
STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above
|
STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above
|
||||||
int char_index, // character to display
|
int char_index, // character to display
|
||||||
float *xpos, float *ypos, // pointers to current position in screen pixel space
|
float *xpos, float *ypos, // pointers to current position in screen pixel space
|
||||||
@ -672,6 +683,7 @@ struct stbtt_pack_context {
|
|||||||
int height;
|
int height;
|
||||||
int stride_in_bytes;
|
int stride_in_bytes;
|
||||||
int padding;
|
int padding;
|
||||||
|
int skip_missing;
|
||||||
unsigned int h_oversample, v_oversample;
|
unsigned int h_oversample, v_oversample;
|
||||||
unsigned char *pixels;
|
unsigned char *pixels;
|
||||||
void *nodes;
|
void *nodes;
|
||||||
@ -697,7 +709,7 @@ STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index);
|
|||||||
// file will only define one font and it always be at offset 0, so it will
|
// file will only define one font and it always be at offset 0, so it will
|
||||||
// return '0' for index 0, and -1 for all other indices.
|
// return '0' for index 0, and -1 for all other indices.
|
||||||
|
|
||||||
// The following structure is defined publically so you can declare one on
|
// The following structure is defined publicly so you can declare one on
|
||||||
// the stack or as a global or etc, but you should treat it as opaque.
|
// the stack or as a global or etc, but you should treat it as opaque.
|
||||||
struct stbtt_fontinfo
|
struct stbtt_fontinfo
|
||||||
{
|
{
|
||||||
@ -736,6 +748,7 @@ STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codep
|
|||||||
// and you want a speed-up, call this function with the character you're
|
// and you want a speed-up, call this function with the character you're
|
||||||
// going to process, then use glyph-based functions instead of the
|
// going to process, then use glyph-based functions instead of the
|
||||||
// codepoint-based functions.
|
// codepoint-based functions.
|
||||||
|
// Returns 0 if the character codepoint is not defined in the font.
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@ -823,7 +836,7 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s
|
|||||||
// returns # of vertices and fills *vertices with the pointer to them
|
// returns # of vertices and fills *vertices with the pointer to them
|
||||||
// these are expressed in "unscaled" coordinates
|
// these are expressed in "unscaled" coordinates
|
||||||
//
|
//
|
||||||
// The shape is a series of countours. Each one starts with
|
// The shape is a series of contours. Each one starts with
|
||||||
// a STBTT_moveto, then consists of a series of mixed
|
// a STBTT_moveto, then consists of a series of mixed
|
||||||
// STBTT_lineto and STBTT_curveto segments. A lineto
|
// STBTT_lineto and STBTT_curveto segments. A lineto
|
||||||
// draws a line from previous endpoint to its x,y; a curveto
|
// draws a line from previous endpoint to its x,y; a curveto
|
||||||
@ -919,7 +932,7 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc
|
|||||||
STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff);
|
STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff);
|
||||||
// These functions compute a discretized SDF field for a single character, suitable for storing
|
// These functions compute a discretized SDF field for a single character, suitable for storing
|
||||||
// in a single-channel texture, sampling with bilinear filtering, and testing against
|
// in a single-channel texture, sampling with bilinear filtering, and testing against
|
||||||
// larger than some threshhold to produce scalable fonts.
|
// larger than some threshold to produce scalable fonts.
|
||||||
// info -- the font
|
// info -- the font
|
||||||
// scale -- controls the size of the resulting SDF bitmap, same as it would be creating a regular bitmap
|
// scale -- controls the size of the resulting SDF bitmap, same as it would be creating a regular bitmap
|
||||||
// glyph/codepoint -- the character to generate the SDF for
|
// glyph/codepoint -- the character to generate the SDF for
|
||||||
@ -2371,7 +2384,7 @@ static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph)
|
|||||||
if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount)
|
if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount)
|
||||||
return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID));
|
return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID));
|
||||||
|
|
||||||
// [ImGui: commented to fix static analyzer warning]
|
// [DEAR IMGUI] Commented to fix static analyzer warning
|
||||||
//classDefTable = classDef1ValueArray + 2 * glyphCount;
|
//classDefTable = classDef1ValueArray + 2 * glyphCount;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -2396,7 +2409,7 @@ static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph)
|
|||||||
return (stbtt_int32)ttUSHORT(classRangeRecord + 4);
|
return (stbtt_int32)ttUSHORT(classRangeRecord + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// [ImGui: commented to fix static analyzer warning]
|
// [DEAR IMGUI] Commented to fix static analyzer warning
|
||||||
//classDefTable = classRangeRecords + 6 * classRangeCount;
|
//classDefTable = classRangeRecords + 6 * classRangeCount;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -3029,6 +3042,7 @@ static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill,
|
|||||||
dx = -dx;
|
dx = -dx;
|
||||||
dy = -dy;
|
dy = -dy;
|
||||||
t = x0, x0 = xb, xb = t;
|
t = x0, x0 = xb, xb = t;
|
||||||
|
// [DEAR IMGUI] Fix static analyzer warning
|
||||||
(void)dx; // [ImGui: fix static analyzer warning]
|
(void)dx; // [ImGui: fix static analyzer warning]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3167,7 +3181,13 @@ static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e,
|
|||||||
if (e->y0 != e->y1) {
|
if (e->y0 != e->y1) {
|
||||||
stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata);
|
stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata);
|
||||||
if (z != NULL) {
|
if (z != NULL) {
|
||||||
STBTT_assert(z->ey >= scan_y_top);
|
if (j == 0 && off_y != 0) {
|
||||||
|
if (z->ey < scan_y_top) {
|
||||||
|
// this can happen due to subpixel positioning and some kind of fp rounding error i think
|
||||||
|
z->ey = scan_y_top;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
STBTT_assert(z->ey >= scan_y_top); // if we get really unlucky a tiny bit of an edge can be out of bounds
|
||||||
// insert at front
|
// insert at front
|
||||||
z->next = active;
|
z->next = active;
|
||||||
active = z;
|
active = z;
|
||||||
@ -3236,7 +3256,7 @@ static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n)
|
|||||||
|
|
||||||
static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n)
|
static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n)
|
||||||
{
|
{
|
||||||
/* threshhold for transitioning to insertion sort */
|
/* threshold for transitioning to insertion sort */
|
||||||
while (n > 12) {
|
while (n > 12) {
|
||||||
stbtt__edge t;
|
stbtt__edge t;
|
||||||
int c01,c12,c,m,i,j;
|
int c01,c12,c,m,i,j;
|
||||||
@ -3371,7 +3391,7 @@ static void stbtt__add_point(stbtt__point *points, int n, float x, float y)
|
|||||||
points[n].y = y;
|
points[n].y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// tesselate until threshhold p is happy... @TODO warped to compensate for non-linear stretching
|
// tessellate until threshold p is happy... @TODO warped to compensate for non-linear stretching
|
||||||
static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n)
|
static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n)
|
||||||
{
|
{
|
||||||
// midpoint
|
// midpoint
|
||||||
@ -3796,6 +3816,7 @@ STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, in
|
|||||||
spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw;
|
spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw;
|
||||||
spc->h_oversample = 1;
|
spc->h_oversample = 1;
|
||||||
spc->v_oversample = 1;
|
spc->v_oversample = 1;
|
||||||
|
spc->skip_missing = 0;
|
||||||
|
|
||||||
stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes);
|
stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes);
|
||||||
|
|
||||||
@ -3821,6 +3842,11 @@ STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h
|
|||||||
spc->v_oversample = v_oversample;
|
spc->v_oversample = v_oversample;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip)
|
||||||
|
{
|
||||||
|
spc->skip_missing = skip;
|
||||||
|
}
|
||||||
|
|
||||||
#define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1)
|
#define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1)
|
||||||
|
|
||||||
static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width)
|
static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width)
|
||||||
@ -3974,13 +4000,17 @@ STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stb
|
|||||||
int x0,y0,x1,y1;
|
int x0,y0,x1,y1;
|
||||||
int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
|
int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
|
||||||
int glyph = stbtt_FindGlyphIndex(info, codepoint);
|
int glyph = stbtt_FindGlyphIndex(info, codepoint);
|
||||||
stbtt_GetGlyphBitmapBoxSubpixel(info,glyph,
|
if (glyph == 0 && spc->skip_missing) {
|
||||||
scale * spc->h_oversample,
|
rects[k].w = rects[k].h = 0;
|
||||||
scale * spc->v_oversample,
|
} else {
|
||||||
0,0,
|
stbtt_GetGlyphBitmapBoxSubpixel(info,glyph,
|
||||||
&x0,&y0,&x1,&y1);
|
scale * spc->h_oversample,
|
||||||
rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1);
|
scale * spc->v_oversample,
|
||||||
rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1);
|
0,0,
|
||||||
|
&x0,&y0,&x1,&y1);
|
||||||
|
rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1);
|
||||||
|
rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1);
|
||||||
|
}
|
||||||
++k;
|
++k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4033,7 +4063,7 @@ STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const
|
|||||||
sub_y = stbtt__oversample_shift(spc->v_oversample);
|
sub_y = stbtt__oversample_shift(spc->v_oversample);
|
||||||
for (j=0; j < ranges[i].num_chars; ++j) {
|
for (j=0; j < ranges[i].num_chars; ++j) {
|
||||||
stbrp_rect *r = &rects[k];
|
stbrp_rect *r = &rects[k];
|
||||||
if (r->was_packed) {
|
if (r->was_packed && r->w != 0 && r->h != 0) {
|
||||||
stbtt_packedchar *bc = &ranges[i].chardata_for_range[j];
|
stbtt_packedchar *bc = &ranges[i].chardata_for_range[j];
|
||||||
int advance, lsb, x0,y0,x1,y1;
|
int advance, lsb, x0,y0,x1,y1;
|
||||||
int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
|
int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
|
||||||
@ -4147,6 +4177,19 @@ STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *
|
|||||||
return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1);
|
return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap)
|
||||||
|
{
|
||||||
|
int i_ascent, i_descent, i_lineGap;
|
||||||
|
float scale;
|
||||||
|
stbtt_fontinfo info;
|
||||||
|
stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata, index));
|
||||||
|
scale = size > 0 ? stbtt_ScaleForPixelHeight(&info, size) : stbtt_ScaleForMappingEmToPixels(&info, -size);
|
||||||
|
stbtt_GetFontVMetrics(&info, &i_ascent, &i_descent, &i_lineGap);
|
||||||
|
*ascent = (float) i_ascent * scale;
|
||||||
|
*descent = (float) i_descent * scale;
|
||||||
|
*lineGap = (float) i_lineGap * scale;
|
||||||
|
}
|
||||||
|
|
||||||
STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer)
|
STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer)
|
||||||
{
|
{
|
||||||
float ipw = 1.0f / pw, iph = 1.0f / ph;
|
float ipw = 1.0f / pw, iph = 1.0f / ph;
|
||||||
@ -4259,7 +4302,7 @@ static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex
|
|||||||
int winding = 0;
|
int winding = 0;
|
||||||
|
|
||||||
orig[0] = x;
|
orig[0] = x;
|
||||||
//orig[1] = y; // [ImGui] commmented double assignment without reading
|
//orig[1] = y; // [DEAR IMGUI] commmented double assignment
|
||||||
|
|
||||||
// make sure y never passes through a vertex of the shape
|
// make sure y never passes through a vertex of the shape
|
||||||
y_frac = (float) STBTT_fmod(y, 1.0f);
|
y_frac = (float) STBTT_fmod(y, 1.0f);
|
||||||
|
Loading…
Reference in New Issue
Block a user