mirror of
https://github.com/ocornut/imgui.git
synced 2026-09-22 20:24:58 +08:00
Merge branch 'master' into docking
build / Build - Windows (push) Canceled after 0s
build / Build - Linux (push) Canceled after 0s
build / Build - MacOS (push) Canceled after 0s
build / Build - iOS (push) Canceled after 0s
build / Build - Emscripten (push) Canceled after 0s
build / Build - Android (push) Canceled after 0s
build / Test - Windows (push) Canceled after 0s
build / Test - Linux (push) Canceled after 0s
build / Build - Windows (push) Canceled after 0s
build / Build - Linux (push) Canceled after 0s
build / Build - MacOS (push) Canceled after 0s
build / Build - iOS (push) Canceled after 0s
build / Build - Emscripten (push) Canceled after 0s
build / Build - Android (push) Canceled after 0s
build / Test - Windows (push) Canceled after 0s
build / Test - Linux (push) Canceled after 0s
# Conflicts: # imgui.cpp
This commit is contained in:
@@ -9,6 +9,8 @@ imgui*.ini
|
||||
|
||||
## General build artifacts
|
||||
*.o
|
||||
*.so*
|
||||
*.a
|
||||
*.obj
|
||||
*.exe
|
||||
examples/*/Debug/*
|
||||
@@ -57,6 +59,11 @@ examples/example_sdl3_wgpu/web/*
|
||||
.idea
|
||||
cmake-build-*
|
||||
|
||||
## QNX artifacts
|
||||
*.pinfo
|
||||
*.dep
|
||||
*.gcno
|
||||
|
||||
## Unix executables from our example Makefiles
|
||||
examples/example_apple_metal/example_apple_metal
|
||||
examples/example_apple_opengl2/example_apple_opengl2
|
||||
|
||||
@@ -269,8 +269,7 @@ void ImGui_ImplAllegro5_UpdateTexture(ImTextureData* tex)
|
||||
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == nullptr);
|
||||
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
|
||||
|
||||
// Create texture
|
||||
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||
// Create texture (bilinear sampling is required)
|
||||
const int new_bitmap_flags = al_get_new_bitmap_flags();
|
||||
int new_bitmap_format = al_get_new_bitmap_format();
|
||||
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR);
|
||||
|
||||
@@ -563,8 +563,7 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
|
||||
bd->pd3dDevice->CreateDepthStencilState(&desc, &bd->pDepthStencilState);
|
||||
}
|
||||
|
||||
// Create texture sampler
|
||||
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||
// Create texture sampler (bilinear sampling is required)
|
||||
{
|
||||
D3D10_SAMPLER_DESC desc;
|
||||
ZeroMemory(&desc, sizeof(desc));
|
||||
|
||||
@@ -684,7 +684,7 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
|
||||
param[1].DescriptorTable.pDescriptorRanges = &descRange;
|
||||
param[1].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
|
||||
|
||||
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
||||
// Bilinear sampling is required
|
||||
D3D12_STATIC_SAMPLER_DESC staticSampler[1] = {};
|
||||
staticSampler[0].Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
staticSampler[0].AddressU = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||
|
||||
@@ -743,7 +743,7 @@ static void ImGui_ImplMetal_InvalidateDeviceObjectsForPlatformWindows()
|
||||
return [[MetalBuffer alloc] initWithBuffer:backing];
|
||||
}
|
||||
|
||||
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
||||
// Bilinear sampling is required.
|
||||
- (id<MTLRenderPipelineState>)renderPipelineStateForFramebufferDescriptor:(FramebufferDescriptor*)descriptor device:(id<MTLDevice>)device
|
||||
{
|
||||
NSError* error = nil;
|
||||
|
||||
@@ -282,8 +282,7 @@ void ImGui_ImplOpenGL2_UpdateTexture(ImTextureData* tex)
|
||||
const void* pixels = tex->GetPixels();
|
||||
GLuint gl_texture_id = 0;
|
||||
|
||||
// Upload texture to graphics system
|
||||
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||
// Upload texture to graphics system (bilinear sampling is required).
|
||||
GLint last_texture;
|
||||
GL_CALL(glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture));
|
||||
GL_CALL(glGenTextures(1, &gl_texture_id));
|
||||
|
||||
@@ -695,8 +695,7 @@ void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex)
|
||||
const void* pixels = tex->GetPixels();
|
||||
GLuint gl_texture_id = 0;
|
||||
|
||||
// Upload texture to graphics system
|
||||
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||
// Upload texture to graphics system (bilinear sampling is required).
|
||||
GLint last_texture;
|
||||
GL_CALL(glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture));
|
||||
GL_CALL(glGenTextures(1, &gl_texture_id));
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,35 @@
|
||||
// dear imgui: Platform Backend for QNX Screen
|
||||
// This needs to be used along with a Renderer Backend (e.g. OpenGL3, Vulkan).
|
||||
|
||||
// Implemented features:
|
||||
// [X] Platform: Keyboard support. Uses io.AddKeyEvent() and native QNX key symbols.
|
||||
// [X] Platform: Mouse support. Handles position, three buttons and horizontal/vertical wheels.
|
||||
// [X] Platform: Touch support. Maps the first active touch contact to the primary mouse button.
|
||||
// [X] Platform: Focus and window-size updates.
|
||||
// Missing features or Issues:
|
||||
// [ ] Platform: Clipboard support.
|
||||
// [ ] Platform: Gamepad support.
|
||||
// [ ] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors).
|
||||
|
||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||
// Learn about Dear ImGui:
|
||||
// - FAQ https://dearimgui.com/faq
|
||||
// - Getting Started https://dearimgui.com/getting-started
|
||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||
// - Introduction, links and more at the top of imgui.cpp
|
||||
|
||||
#pragma once
|
||||
#include "imgui.h" // IMGUI_IMPL_API
|
||||
#ifndef IMGUI_DISABLE
|
||||
|
||||
#include <screen/screen.h>
|
||||
|
||||
// The application owns the Screen context, window and event object.
|
||||
// Poll events with screen_get_event() and pass each non-NONE event to ProcessEvent().
|
||||
IMGUI_IMPL_API bool ImGui_ImplQNX_Init(screen_context_t context, screen_window_t window);
|
||||
IMGUI_IMPL_API void ImGui_ImplQNX_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplQNX_NewFrame();
|
||||
IMGUI_IMPL_API bool ImGui_ImplQNX_ProcessEvent(screen_event_t event);
|
||||
|
||||
#endif // #ifndef IMGUI_DISABLE
|
||||
@@ -593,7 +593,7 @@ void ImGui_ImplSDLGPU3_CreateDeviceObjects()
|
||||
|
||||
if (bd->TexSamplerLinear == nullptr)
|
||||
{
|
||||
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
||||
// Bilinear sampling is required.
|
||||
SDL_GPUSamplerCreateInfo sampler_info = {};
|
||||
sampler_info.min_filter = SDL_GPU_FILTER_LINEAR;
|
||||
sampler_info.mag_filter = SDL_GPU_FILTER_LINEAR;
|
||||
|
||||
@@ -214,8 +214,7 @@ void ImGui_ImplSDLRenderer2_UpdateTexture(ImTextureData* tex)
|
||||
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == nullptr);
|
||||
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
|
||||
|
||||
// Create texture
|
||||
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||
// Create texture (bilinear sampling is required)
|
||||
SDL_Texture* sdl_texture = SDL_CreateTexture(bd->Renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STATIC, tex->Width, tex->Height);
|
||||
IM_ASSERT(sdl_texture != nullptr && "Backend failed to create texture!");
|
||||
SDL_UpdateTexture(sdl_texture, nullptr, tex->GetPixels(), tex->GetPitch());
|
||||
|
||||
@@ -244,8 +244,7 @@ void ImGui_ImplSDLRenderer3_UpdateTexture(ImTextureData* tex)
|
||||
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == nullptr);
|
||||
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
|
||||
|
||||
// Create texture
|
||||
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||
// Create texture (bilinear sampling is required)
|
||||
SDL_Texture* sdl_texture = SDL_CreateTexture(bd->Renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STATIC, tex->Width, tex->Height);
|
||||
IM_ASSERT(sdl_texture != nullptr && "Backend failed to create texture!");
|
||||
SDL_UpdateTexture(sdl_texture, nullptr, tex->GetPixels(), tex->GetPitch());
|
||||
|
||||
@@ -1185,8 +1185,7 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
||||
check_vk_result(err);
|
||||
}
|
||||
|
||||
// Create samplers
|
||||
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
||||
// Create samplers (bilinear sampling is required)
|
||||
if (!bd->SamplerLinear || !bd->SamplerNearest)
|
||||
{
|
||||
VkSamplerCreateInfo info = {};
|
||||
|
||||
@@ -846,8 +846,7 @@ bool ImGui_ImplWGPU_CreateDeviceObjects()
|
||||
|
||||
ImGui_ImplWGPU_CreateUniformBuffer();
|
||||
|
||||
// Create samplers (Linear/Nearest)
|
||||
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||
// Create samplers (Linear/Nearest) (bilinear sampling is required)
|
||||
WGPUSamplerDescriptor sampler_desc = {};
|
||||
sampler_desc.addressModeU = WGPUAddressMode_ClampToEdge;
|
||||
sampler_desc.addressModeV = WGPUAddressMode_ClampToEdge;
|
||||
|
||||
+2
-3
@@ -79,6 +79,7 @@ List of Platforms Backends:
|
||||
imgui_impl_osx.mm ; macOS native API (not as feature complete as glfw/sdl backends)
|
||||
imgui_impl_sdl2.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
|
||||
imgui_impl_sdl3.cpp ; SDL3 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
|
||||
imgui_impl_qnx.cpp ; QNX Screen
|
||||
imgui_impl_win32.cpp ; Win32 native API (Windows)
|
||||
imgui_impl_glut.cpp ; GLUT/FreeGLUT (this is prehistoric software and absolutely not recommended today!)
|
||||
|
||||
@@ -235,9 +236,7 @@ void MyImGuiBackend_RenderDrawData(ImDrawData* draw_data)
|
||||
// - Scissor enabled
|
||||
MyEngineSetupenderState();
|
||||
|
||||
// TODO: Setup texture sampling state
|
||||
// - Sample with bilinear filtering (NOT point/nearest filtering).
|
||||
// - Use 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines;' to allow point/nearest filtering.
|
||||
// TODO: Setup texture sampler to bilinear (NOT point/nearest filtering).
|
||||
|
||||
// TODO: Setup viewport covering draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize
|
||||
|
||||
|
||||
@@ -35,6 +35,33 @@ HOW TO UPDATE?
|
||||
and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users.
|
||||
- Please report any issue!
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
VERSION 1.93.0 WIP (In Progress)
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
Breaking Changes:
|
||||
|
||||
- Style: obsoleted `style.CurveTessellationTol (default 1.25)` which was in Pixels² unit in
|
||||
favor of `style.CurveTesselationMaxError` (default 1.12)` which is in Pixels unit. It is
|
||||
easier to tweak + this allows us to easily scale error threshold on high density screens.
|
||||
- style.CurveTesselationMaxError == sqrf(style.CurveTessellationTol).
|
||||
|
||||
Other Changes:
|
||||
|
||||
- Fonts:
|
||||
- Reworked `AddFontDefault()` to use `io.DisplayFrameBufferScale` as part of the heuristic
|
||||
to select `AddFontDefaultVector()` by default, effectively using ProggyForever instead of
|
||||
ProggyClean on most Apple/Retina setups by default.
|
||||
- ImDrawList:
|
||||
- Per-viewport FramebufferScale for Apple/Retina screen is applied to draw lists:
|
||||
- AA Fringe is scaled accordingly.
|
||||
- Circle and Curves tessellation error are scaled accordingly.
|
||||
- Backends:
|
||||
- QNX: added QNX Screen backend. (#9492) [@mgorchak-blackberry]
|
||||
- Examples:
|
||||
- QNX+OpenGL3, QNX+Vulkan: added QNX Screen examples. (#9492) [@mgorchak-blackberry]
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
VERSION 1.92.9b (Released 2026-07-31)
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
@@ -117,6 +117,16 @@ Because this application doesn't create a window nor a graphic context, there's
|
||||
Please note that imgui_impl_null itself is a rather empty backend. We provide it for consistency but
|
||||
it is similarly easy to create a skeleton application without the null backend.
|
||||
|
||||
[example_qnx_opengl3/](https://github.com/ocornut/imgui/blob/master/examples/example_qnx_opengl3/) <BR>
|
||||
QNX Screen + OpenGL ES 3 example. <BR>
|
||||
= main.cpp + imgui_impl_qnx.cpp + imgui_impl_opengl3.cpp <BR>
|
||||
Uses the QNX recursive make build system and compiles the OpenGL3 renderer with `IMGUI_IMPL_OPENGL_ES3`.
|
||||
|
||||
[example_qnx_vulkan/](https://github.com/ocornut/imgui/blob/master/examples/example_qnx_vulkan/) <BR>
|
||||
QNX Screen + Vulkan example using `VK_QNX_screen_surface`. <BR>
|
||||
= main.cpp + imgui_impl_qnx.cpp + imgui_impl_vulkan.cpp <BR>
|
||||
Uses the QNX recursive make build system and the Vulkan backend's example helper structures.
|
||||
|
||||
[example_sdl2_directx11/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl2_directx11/) <BR>
|
||||
SDL2 + DirectX11 example, Windows only. <BR>
|
||||
= main.cpp + imgui_impl_sdl2.cpp + imgui_impl_dx11.cpp <BR>
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
LIST=OS
|
||||
include recurse.mk
|
||||
@@ -0,0 +1,29 @@
|
||||
# Dear ImGui QNX Screen + OpenGL ES 3 example
|
||||
|
||||
This example uses:
|
||||
|
||||
- `imgui_impl_qnx.cpp` as the QNX Screen platform backend
|
||||
- `imgui_impl_opengl3.cpp` as the renderer backend
|
||||
- EGL to create an OpenGL ES 3 context and Screen window surface
|
||||
|
||||
`imgui_impl_opengl3.cpp` supports desktop OpenGL and OpenGL ES. On QNX this
|
||||
example compiles it with `IMGUI_IMPL_OPENGL_ES3` and uses `#version 300 es`.
|
||||
No separate Screen/OpenGL renderer backend is required.
|
||||
|
||||
## Build
|
||||
|
||||
Load the QNX SDP environment, then run:
|
||||
|
||||
```sh
|
||||
cd examples/example_qnx_opengl3
|
||||
make
|
||||
```
|
||||
|
||||
The QNX recursive make files build for the CPUs enabled in your SDP
|
||||
configuration and install the program as `example_qnx_opengl3`.
|
||||
|
||||
## Input
|
||||
|
||||
The application polls its `screen_context_t` event queue and forwards every
|
||||
non-`SCREEN_EVENT_NONE` event to `ImGui_ImplQNX_ProcessEvent()`.
|
||||
Escape exits the example.
|
||||
@@ -0,0 +1,31 @@
|
||||
ifndef QCONFIG
|
||||
QCONFIG=qconfig.mk
|
||||
endif
|
||||
include $(QCONFIG)
|
||||
|
||||
NAME=example_qnx_opengl3
|
||||
|
||||
SRCS = \
|
||||
main.cpp \
|
||||
imgui.cpp \
|
||||
imgui_demo.cpp \
|
||||
imgui_draw.cpp \
|
||||
imgui_tables.cpp \
|
||||
imgui_widgets.cpp \
|
||||
imgui_impl_qnx.cpp \
|
||||
imgui_impl_opengl3.cpp
|
||||
|
||||
EXTRA_SRCVPATH += $(PROJECT_ROOT)/../.. $(PROJECT_ROOT)/../../backends
|
||||
EXTRA_INCVPATH += $(PROJECT_ROOT)/../.. $(PROJECT_ROOT)/../../backends
|
||||
|
||||
CXXFLAGS += -std=gnu++11 -DIMGUI_IMPL_OPENGL_ES3
|
||||
LIBS += EGL GLESv2 screen m
|
||||
|
||||
INSTALLDIR=$(firstword $(INSTALLDIR_$(OS)) usr/bin)
|
||||
|
||||
define PINFO
|
||||
PINFO DESCRIPTION=Dear ImGui QNX Screen and OpenGL ES 3 example
|
||||
endef
|
||||
|
||||
include $(MKFILES_ROOT)/qmacros.mk
|
||||
include $(MKFILES_ROOT)/qtargets.mk
|
||||
@@ -0,0 +1,307 @@
|
||||
// Dear ImGui: standalone example application for QNX Screen + OpenGL ES 3
|
||||
|
||||
// Learn about Dear ImGui:
|
||||
// - FAQ https://dearimgui.com/faq
|
||||
// - Getting Started https://dearimgui.com/getting-started
|
||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||
// - Introduction, links and more at the top of imgui.cpp
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_qnx.h"
|
||||
#include "imgui_impl_opengl3.h"
|
||||
#include <stdio.h> // printf, fprintf
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/keycodes.h>
|
||||
#include <screen/screen.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES3/gl3.h>
|
||||
|
||||
#ifndef EGL_OPENGL_ES3_BIT
|
||||
#ifdef EGL_OPENGL_ES3_BIT_KHR
|
||||
#define EGL_OPENGL_ES3_BIT EGL_OPENGL_ES3_BIT_KHR
|
||||
#else
|
||||
#define EGL_OPENGL_ES3_BIT 0x0040
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct QNXWindow
|
||||
{
|
||||
screen_context_t Context = nullptr;
|
||||
screen_window_t Window = nullptr;
|
||||
screen_event_t Event = nullptr;
|
||||
EGLDisplay Display = EGL_NO_DISPLAY;
|
||||
EGLContext GLContext = EGL_NO_CONTEXT;
|
||||
EGLSurface GLSurface = EGL_NO_SURFACE;
|
||||
int Size[2] = {};
|
||||
};
|
||||
|
||||
// Forward declarations of helper functions
|
||||
bool CreateQNXWindow(QNXWindow* window);
|
||||
void DestroyQNXWindow(QNXWindow* window);
|
||||
bool ProcessQNXEvents(QNXWindow* window);
|
||||
|
||||
// Main code
|
||||
int main(int, char**)
|
||||
{
|
||||
// Setup QNX Screen and EGL
|
||||
QNXWindow window;
|
||||
if (!CreateQNXWindow(&window))
|
||||
{
|
||||
DestroyQNXWindow(&window);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// GL ES 3.0 + GLSL 300 es
|
||||
const char* glsl_version = "#version 300 es";
|
||||
float main_scale = 1.0f;
|
||||
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup Dear ImGui style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsLight();
|
||||
|
||||
// Setup scaling
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
||||
style.FontScaleDpi = main_scale; // Set initial font scale. (in docking branch: using io.ConfigDpiScaleFonts=true automatically overrides this for every window depending on the current monitor)
|
||||
|
||||
// Setup Platform/Renderer backends
|
||||
ImGui_ImplQNX_Init(window.Context, window.Window);
|
||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||
|
||||
// Load Fonts
|
||||
// - If fonts are not explicitly loaded, Dear ImGui will select an embedded font: either AddFontDefaultVector() or AddFontDefaultBitmap().
|
||||
// This selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a small threshold.
|
||||
// - You can load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||
// - If a file cannot be loaded, AddFont functions will return a nullptr. Please handle those errors in your code (e.g. use an assertion, display an error and quit).
|
||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use FreeType for higher quality font rendering.
|
||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||
//style.FontSizeBase = 20.0f;
|
||||
//io.Fonts->AddFontDefaultVector();
|
||||
//io.Fonts->AddFontDefaultBitmap();
|
||||
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf");
|
||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf");
|
||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf");
|
||||
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf");
|
||||
//IM_ASSERT(font != nullptr);
|
||||
|
||||
// Our state
|
||||
bool show_demo_window = true;
|
||||
bool show_another_window = false;
|
||||
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||
|
||||
// Main loop
|
||||
bool done = false;
|
||||
while (!done)
|
||||
{
|
||||
// Poll and handle events (inputs, window resize, etc.)
|
||||
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
|
||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
|
||||
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||
if (!ProcessQNXEvents(&window))
|
||||
done = true;
|
||||
|
||||
// Start the Dear ImGui frame
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplQNX_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
||||
if (show_demo_window)
|
||||
ImGui::ShowDemoWindow(&show_demo_window);
|
||||
|
||||
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to create a named window.
|
||||
{
|
||||
static float f = 0.0f;
|
||||
static int counter = 0;
|
||||
|
||||
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
|
||||
|
||||
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
|
||||
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
|
||||
ImGui::Checkbox("Another Window", &show_another_window);
|
||||
|
||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
||||
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
||||
|
||||
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||
counter++;
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("counter = %d", counter);
|
||||
|
||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
// 3. Show another simple window.
|
||||
if (show_another_window)
|
||||
{
|
||||
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
|
||||
ImGui::Text("Hello from another window!");
|
||||
if (ImGui::Button("Close Me"))
|
||||
show_another_window = false;
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
// Rendering
|
||||
ImGui::Render();
|
||||
glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
|
||||
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
eglSwapBuffers(window.Display, window.GLSurface);
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplQNX_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
|
||||
DestroyQNXWindow(&window);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
|
||||
bool CreateQNXWindow(QNXWindow* window)
|
||||
{
|
||||
if (screen_create_context(&window->Context, 0) != 0 ||
|
||||
screen_create_window(&window->Window, window->Context) != 0 ||
|
||||
screen_create_event(&window->Event) != 0)
|
||||
{
|
||||
fprintf(stderr, "QNX Screen initialization failed: %s\n", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
// A newly created QNX Screen window reports the fullscreen dimensions.
|
||||
if (screen_get_window_property_iv(window->Window, SCREEN_PROPERTY_SIZE, window->Size) != 0 || window->Size[0] <= 0 || window->Size[1] <= 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to obtain QNX Screen window size: %s\n", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
const int usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_OPENGL_ES3 | SCREEN_USAGE_NATIVE;
|
||||
const int transparency = SCREEN_TRANSPARENCY_NONE;
|
||||
const int swap_interval = 1;
|
||||
if (screen_set_window_property_iv(window->Window, SCREEN_PROPERTY_USAGE, &usage) != 0 ||
|
||||
screen_set_window_property_iv(window->Window, SCREEN_PROPERTY_SIZE, window->Size) != 0 ||
|
||||
screen_set_window_property_iv(window->Window, SCREEN_PROPERTY_TRANSPARENCY, &transparency) != 0 ||
|
||||
screen_set_window_property_iv(window->Window, SCREEN_PROPERTY_SWAP_INTERVAL, &swap_interval) != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to configure QNX Screen window: %s\n", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
window->Display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if (window->Display == EGL_NO_DISPLAY || eglInitialize(window->Display, nullptr, nullptr) != EGL_TRUE || eglBindAPI(EGL_OPENGL_ES_API) != EGL_TRUE)
|
||||
{
|
||||
fprintf(stderr, "EGL initialization failed: 0x%04x\n", eglGetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
const EGLint config_attributes[] =
|
||||
{
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT,
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 8,
|
||||
EGL_DEPTH_SIZE, 24,
|
||||
EGL_STENCIL_SIZE, 8,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLConfig config = nullptr;
|
||||
EGLint config_count = 0;
|
||||
if (eglChooseConfig(window->Display, config_attributes, &config, 1, &config_count) != EGL_TRUE || config_count == 0)
|
||||
{
|
||||
fprintf(stderr, "eglChooseConfig() failed: 0x%04x\n", eglGetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
EGLint native_visual = 0;
|
||||
if (eglGetConfigAttrib(window->Display, config, EGL_NATIVE_VISUAL_ID, &native_visual) != EGL_TRUE ||
|
||||
screen_set_window_property_iv(window->Window, SCREEN_PROPERTY_FORMAT, &native_visual) != 0 ||
|
||||
screen_create_window_buffers(window->Window, 2) != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to create QNX Screen buffers: %s\n", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
const EGLint context_attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE };
|
||||
window->GLContext = eglCreateContext(window->Display, config, EGL_NO_CONTEXT, context_attributes);
|
||||
window->GLSurface = eglCreateWindowSurface(window->Display, config, window->Window, nullptr);
|
||||
if (window->GLContext == EGL_NO_CONTEXT || window->GLSurface == EGL_NO_SURFACE ||
|
||||
eglMakeCurrent(window->Display, window->GLSurface, window->GLSurface, window->GLContext) != EGL_TRUE ||
|
||||
eglSwapInterval(window->Display, 1) != EGL_TRUE)
|
||||
{
|
||||
fprintf(stderr, "EGL context creation failed: 0x%04x\n", eglGetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
const int visible = 1;
|
||||
if (screen_set_window_property_iv(window->Window, SCREEN_PROPERTY_VISIBLE, &visible) != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to show QNX Screen window: %s\n", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DestroyQNXWindow(QNXWindow* window)
|
||||
{
|
||||
if (window->Display != EGL_NO_DISPLAY)
|
||||
{
|
||||
eglMakeCurrent(window->Display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
if (window->GLSurface != EGL_NO_SURFACE)
|
||||
eglDestroySurface(window->Display, window->GLSurface);
|
||||
if (window->GLContext != EGL_NO_CONTEXT)
|
||||
eglDestroyContext(window->Display, window->GLContext);
|
||||
eglTerminate(window->Display);
|
||||
}
|
||||
if (window->Event != nullptr)
|
||||
screen_destroy_event(window->Event);
|
||||
if (window->Window != nullptr)
|
||||
screen_destroy_window(window->Window);
|
||||
if (window->Context != nullptr)
|
||||
screen_destroy_context(window->Context);
|
||||
}
|
||||
|
||||
bool ProcessQNXEvents(QNXWindow* window)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if (screen_get_event(window->Context, window->Event, 0) != 0)
|
||||
return false;
|
||||
|
||||
int type = SCREEN_EVENT_NONE;
|
||||
if (screen_get_event_property_iv(window->Event, SCREEN_PROPERTY_TYPE, &type) != 0)
|
||||
return false;
|
||||
if (type == SCREEN_EVENT_NONE)
|
||||
return true;
|
||||
|
||||
ImGui_ImplQNX_ProcessEvent(window->Event);
|
||||
if (type == SCREEN_EVENT_CLOSE)
|
||||
return false;
|
||||
if (type == SCREEN_EVENT_KEYBOARD)
|
||||
{
|
||||
int flags = 0;
|
||||
int key_cap = 0;
|
||||
if (screen_get_event_property_iv(window->Event, SCREEN_PROPERTY_FLAGS, &flags) == 0 &&
|
||||
screen_get_event_property_iv(window->Event, SCREEN_PROPERTY_KEY_CAP, &key_cap) == 0 &&
|
||||
(flags & SCREEN_FLAG_KEY_DOWN) != 0 && key_cap == KEYCODE_ESCAPE)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
LIST=CPU
|
||||
ifndef QRECURSE
|
||||
QRECURSE=recurse.mk
|
||||
ifdef QCONFIG
|
||||
QRDIR=$(dir $(QCONFIG))
|
||||
endif
|
||||
endif
|
||||
include $(QRDIR)$(QRECURSE)
|
||||
@@ -0,0 +1,8 @@
|
||||
LIST=VARIANT
|
||||
ifndef QRECURSE
|
||||
QRECURSE=recurse.mk
|
||||
ifdef QCONFIG
|
||||
QRDIR=$(dir $(QCONFIG))
|
||||
endif
|
||||
endif
|
||||
include $(QRDIR)$(QRECURSE)
|
||||
@@ -0,0 +1 @@
|
||||
include ../../../common.mk
|
||||
@@ -0,0 +1,8 @@
|
||||
LIST=VARIANT
|
||||
ifndef QRECURSE
|
||||
QRECURSE=recurse.mk
|
||||
ifdef QCONFIG
|
||||
QRDIR=$(dir $(QCONFIG))
|
||||
endif
|
||||
endif
|
||||
include $(QRDIR)$(QRECURSE)
|
||||
@@ -0,0 +1 @@
|
||||
include ../../../common.mk
|
||||
@@ -0,0 +1,2 @@
|
||||
LIST=OS
|
||||
include recurse.mk
|
||||
@@ -0,0 +1,29 @@
|
||||
# Dear ImGui QNX Screen + Vulkan example
|
||||
|
||||
This example uses:
|
||||
|
||||
- `imgui_impl_qnx.cpp` as the QNX Screen platform backend
|
||||
- the unmodified `imgui_impl_vulkan.cpp` renderer backend
|
||||
- `vkCreateScreenSurfaceQNX()` and `VK_QNX_screen_surface`
|
||||
|
||||
No separate Screen/Vulkan renderer backend is required. The QNX-specific work
|
||||
is limited to the Screen platform backend, native window setup, and Vulkan WSI
|
||||
surface creation.
|
||||
|
||||
## Build
|
||||
|
||||
Load the QNX SDP environment, then run:
|
||||
|
||||
```sh
|
||||
cd examples/example_qnx_vulkan
|
||||
make
|
||||
```
|
||||
|
||||
The build defines `VK_USE_PLATFORM_SCREEN_QNX` and links `libvulkan` and
|
||||
`libscreen`.
|
||||
|
||||
## Input and resize
|
||||
|
||||
The application forwards Screen input events to `ImGui_ImplQNX_ProcessEvent()`.
|
||||
It recreates the Vulkan swapchain when the Screen window size changes or Vulkan
|
||||
reports `VK_ERROR_OUT_OF_DATE_KHR` / `VK_SUBOPTIMAL_KHR`. Escape exits.
|
||||
@@ -0,0 +1,31 @@
|
||||
ifndef QCONFIG
|
||||
QCONFIG=qconfig.mk
|
||||
endif
|
||||
include $(QCONFIG)
|
||||
|
||||
NAME=example_qnx_vulkan
|
||||
|
||||
SRCS = \
|
||||
main.cpp \
|
||||
imgui.cpp \
|
||||
imgui_demo.cpp \
|
||||
imgui_draw.cpp \
|
||||
imgui_tables.cpp \
|
||||
imgui_widgets.cpp \
|
||||
imgui_impl_qnx.cpp \
|
||||
imgui_impl_vulkan.cpp
|
||||
|
||||
EXTRA_SRCVPATH += $(PROJECT_ROOT)/../.. $(PROJECT_ROOT)/../../backends
|
||||
EXTRA_INCVPATH += $(PROJECT_ROOT)/../.. $(PROJECT_ROOT)/../../backends
|
||||
|
||||
CXXFLAGS += -std=gnu++11 -DVK_USE_PLATFORM_SCREEN_QNX=1
|
||||
LIBS += vulkan screen m
|
||||
|
||||
INSTALLDIR=$(firstword $(INSTALLDIR_$(OS)) usr/bin)
|
||||
|
||||
define PINFO
|
||||
PINFO DESCRIPTION=Dear ImGui QNX Screen and Vulkan example
|
||||
endef
|
||||
|
||||
include $(MKFILES_ROOT)/qmacros.mk
|
||||
include $(MKFILES_ROOT)/qtargets.mk
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
||||
LIST=CPU
|
||||
ifndef QRECURSE
|
||||
QRECURSE=recurse.mk
|
||||
ifdef QCONFIG
|
||||
QRDIR=$(dir $(QCONFIG))
|
||||
endif
|
||||
endif
|
||||
include $(QRDIR)$(QRECURSE)
|
||||
@@ -0,0 +1,8 @@
|
||||
LIST=VARIANT
|
||||
ifndef QRECURSE
|
||||
QRECURSE=recurse.mk
|
||||
ifdef QCONFIG
|
||||
QRDIR=$(dir $(QCONFIG))
|
||||
endif
|
||||
endif
|
||||
include $(QRDIR)$(QRECURSE)
|
||||
@@ -0,0 +1 @@
|
||||
include ../../../common.mk
|
||||
@@ -0,0 +1,8 @@
|
||||
LIST=VARIANT
|
||||
ifndef QRECURSE
|
||||
QRECURSE=recurse.mk
|
||||
ifdef QCONFIG
|
||||
QRDIR=$(dir $(QCONFIG))
|
||||
endif
|
||||
endif
|
||||
include $(QRDIR)$(QRECURSE)
|
||||
@@ -0,0 +1 @@
|
||||
include ../../../common.mk
|
||||
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.92.9b
|
||||
// dear imgui, v1.93.0 WIP
|
||||
// (main code and documentation)
|
||||
|
||||
// Help:
|
||||
@@ -402,6 +402,8 @@ IMPLEMENTING SUPPORT for ImGuiBackendFlags_RendererHasTextures:
|
||||
you may use GetMainViewport()->Pos to offset hard-coded positions, e.g. SetNextWindowPos(GetMainViewport()->Pos)
|
||||
- likewise io.MousePos and GetMousePos() will use OS coordinates.
|
||||
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
|
||||
- 2026/08/03 (1.93.0) - Style: obsoleted `style.CurveTessellationTol (default 1.25)` which was in Pixels² unit in favor of `style.CurveTesselationMaxError` (default 1.12)` which is in Pixels unit.
|
||||
- style.CurveTesselationMaxError == sqrf(style.CurveTessellationTol).
|
||||
- 2026/07/20 (1.92.9) - DragXXX, SliderXXX, InputScalar: with `ImGuiItemFlags_LiveEditOnInputScalar` now defaulting to being disabled:
|
||||
inputting a value with the keyboard doesn't write intermediate values to backing variable. (#9476)
|
||||
- Before: DragFloat() with user typing "123" --> write back 1, then 12, then 123.
|
||||
@@ -1600,10 +1602,12 @@ ImGuiStyle::ImGuiStyle()
|
||||
DockingNodeHasCloseButton = true; // Docking nodes have their own CloseButton() to close all docked windows.
|
||||
DockingSeparatorSize = 2.0f; // Thickness of resizing border between docked windows
|
||||
MouseCursorScale = 1.0f; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later.
|
||||
|
||||
// Rendering & Tesselation
|
||||
AntiAliasedLines = true; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU.
|
||||
AntiAliasedLinesUseTex = true; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering).
|
||||
AntiAliasedFill = true; // Enable anti-aliased filled shapes (rounded rectangles, circles, etc.).
|
||||
CurveTessellationTol = 1.25f; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
||||
CurveTessellationMaxError = 1.12f; // Maximum error (in pixels) when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
||||
CircleTessellationMaxError = 0.30f; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
|
||||
|
||||
// Behaviors
|
||||
@@ -1616,6 +1620,9 @@ ImGuiStyle::ImGuiStyle()
|
||||
// [Internal]
|
||||
_MainScale = 1.0f;
|
||||
_NextFrameFontSizeBase = 0.0f;
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
CurveTessellationTol = 0.0f; // Old CurveTessellationTol = CurveTessellationMaxError*CurveTessellationMaxError.
|
||||
#endif
|
||||
|
||||
// Default theme
|
||||
ImGui::StyleColorsDark(this);
|
||||
@@ -2165,7 +2172,7 @@ ImVec2 ImBezierCubicClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec
|
||||
}
|
||||
|
||||
// Closely mimics PathBezierToCasteljau() in imgui_draw.cpp
|
||||
static void ImBezierCubicClosestPointCasteljauStep(const ImVec2& p, ImVec2& p_closest, ImVec2& p_last, float& p_closest_dist2, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level)
|
||||
static void ImBezierCubicClosestPointCasteljauStep(const ImVec2& p, ImVec2& p_closest, ImVec2& p_last, float& p_closest_dist2, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float max_error_sqr, int level)
|
||||
{
|
||||
float dx = x4 - x1;
|
||||
float dy = y4 - y1;
|
||||
@@ -2173,7 +2180,7 @@ static void ImBezierCubicClosestPointCasteljauStep(const ImVec2& p, ImVec2& p_cl
|
||||
float d3 = ((x3 - x4) * dy - (y3 - y4) * dx);
|
||||
d2 = (d2 >= 0) ? d2 : -d2;
|
||||
d3 = (d3 >= 0) ? d3 : -d3;
|
||||
if ((d2 + d3) * (d2 + d3) < tess_tol * (dx * dx + dy * dy))
|
||||
if ((d2 + d3) * (d2 + d3) < max_error_sqr * (dx * dx + dy * dy))
|
||||
{
|
||||
ImVec2 p_current(x4, y4);
|
||||
ImVec2 p_line = ImLineClosestPoint(p_last, p_current, p);
|
||||
@@ -2193,20 +2200,21 @@ static void ImBezierCubicClosestPointCasteljauStep(const ImVec2& p, ImVec2& p_cl
|
||||
float x123 = (x12 + x23)*0.5f, y123 = (y12 + y23)*0.5f;
|
||||
float x234 = (x23 + x34)*0.5f, y234 = (y23 + y34)*0.5f;
|
||||
float x1234 = (x123 + x234)*0.5f, y1234 = (y123 + y234)*0.5f;
|
||||
ImBezierCubicClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol, level + 1);
|
||||
ImBezierCubicClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol, level + 1);
|
||||
ImBezierCubicClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1, y1, x12, y12, x123, y123, x1234, y1234, max_error_sqr, level + 1);
|
||||
ImBezierCubicClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1234, y1234, x234, y234, x34, y34, x4, y4, max_error_sqr, level + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// tess_tol is generally the same value you would find in ImGui::GetStyle().CurveTessellationTol
|
||||
// tess_tol is generally the same value you would find in ImGui::GetStyle().CurveTessellationMaxError
|
||||
// Because those ImXXX functions are lower-level than ImGui:: we cannot access this value automatically.
|
||||
ImVec2 ImBezierCubicClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, float tess_tol)
|
||||
ImVec2 ImBezierCubicClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, float max_error)
|
||||
{
|
||||
IM_ASSERT(tess_tol > 0.0f);
|
||||
IM_ASSERT(max_error > 0.0f);
|
||||
ImVec2 p_last = p1;
|
||||
ImVec2 p_closest;
|
||||
float p_closest_dist2 = FLT_MAX;
|
||||
ImBezierCubicClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, tess_tol, 0);
|
||||
float max_error_sqr = max_error * max_error;
|
||||
ImBezierCubicClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, max_error_sqr, 0);
|
||||
return p_closest;
|
||||
}
|
||||
|
||||
@@ -4309,7 +4317,7 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
|
||||
Font = NULL;
|
||||
FontBaked = NULL;
|
||||
FontSize = FontSizeBase = FontBakedScale = CurrentDpiScale = 0.0f;
|
||||
FontRasterizerDensity = 1.0f;
|
||||
CurrentPixelDensity = 1.0f;
|
||||
IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
|
||||
if (shared_font_atlas == NULL)
|
||||
IO.Fonts->OwnerContext = this;
|
||||
@@ -4810,7 +4818,7 @@ static void SetCurrentWindow(ImGuiWindow* window)
|
||||
if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasTextures)
|
||||
{
|
||||
ImGuiViewport* viewport = window->Viewport;
|
||||
g.FontRasterizerDensity = (viewport->FramebufferScale.x != 0.0f) ? viewport->FramebufferScale.x : g.IO.DisplayFramebufferScale.x; // == SetFontRasterizerDensity()
|
||||
g.CurrentPixelDensity = (viewport->FramebufferScale.x != 0.0f) ? viewport->FramebufferScale.x : g.IO.DisplayFramebufferScale.x; // == SetPixelDensity()
|
||||
}
|
||||
const bool backup_skip_items = window->SkipItems;
|
||||
window->SkipItems = false;
|
||||
@@ -5419,6 +5427,7 @@ static ImDrawList* GetViewportBgFgDrawList(ImGuiViewportP* viewport, size_t draw
|
||||
if (viewport->BgFgDrawListsLastTimeActive[drawlist_no] != (float)g.Time)
|
||||
{
|
||||
draw_list->_ResetForNewFrame();
|
||||
draw_list->_SetPixelDensity(viewport->FramebufferScale.x);
|
||||
draw_list->PushTexture(g.IO.Fonts->TexRef);
|
||||
draw_list->PushClipRect(viewport->Pos, viewport->Pos + viewport->Size, false);
|
||||
viewport->BgFgDrawListsLastTimeActive[drawlist_no] = (float)g.Time;
|
||||
@@ -5760,7 +5769,7 @@ static void SetupDrawListSharedData()
|
||||
for (ImGuiViewportP* viewport : g.Viewports)
|
||||
virtual_space.Add(viewport->GetMainRect());
|
||||
g.DrawListSharedData.ClipRectFullscreen = virtual_space.ToVec4();
|
||||
g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol;
|
||||
g.DrawListSharedData.CurveTessellationMaxError = g.Style.CurveTessellationMaxError;
|
||||
g.DrawListSharedData.SetCircleTessellationMaxError(g.Style.CircleTessellationMaxError);
|
||||
g.DrawListSharedData.InitialFlags = ImDrawListFlags_None;
|
||||
if (g.Style.AntiAliasedLines)
|
||||
@@ -5771,7 +5780,6 @@ static void SetupDrawListSharedData()
|
||||
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedFill;
|
||||
if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset)
|
||||
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset;
|
||||
g.DrawListSharedData.InitialFringeScale = 1.0f; // FIXME-DPI: Change this for some DPI scaling experiments.
|
||||
}
|
||||
|
||||
void ImGui::NewFrame()
|
||||
@@ -8578,6 +8586,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
|
||||
// Setup draw list and outer clipping rectangle
|
||||
IM_ASSERT(window->DrawList->CmdBuffer.Size == 1 && window->DrawList->CmdBuffer[0].ElemCount == 0);
|
||||
window->DrawList->_SetPixelDensity(window->Viewport->FramebufferScale.x);
|
||||
window->DrawList->PushTexture(g.Font->OwnerAtlas->TexRef);
|
||||
PushClipRect(host_rect.Min, host_rect.Max, false);
|
||||
|
||||
@@ -8755,7 +8764,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
// Set default BgClickFlags
|
||||
// This is set at the end of this function, so UpdateWindowManualResize()/ClampWindowPos() may use last-frame value if overridden by user code.
|
||||
// FIXME: The general intent is that we will later expose config options to default to enable scrolling + select scrolling mouse button.
|
||||
window->BgClickFlags = (flags & ImGuiWindowFlags_ChildWindow) ? parent_window->BgClickFlags : (g.IO.ConfigWindowsMoveFromTitleBarOnly ? ImGuiWindowBgClickFlags_None : ImGuiWindowBgClickFlags_Move);
|
||||
window->BgClickFlags = (flags & ImGuiWindowFlags_ChildWindow) ? parent_window->BgClickFlags : (g.IO.ConfigWindowsMoveFromTitleBarOnly ? ImGuiWindowBgClickFlags_None : ImGuiWindowBgClickFlags_Move); // -V1004
|
||||
|
||||
// We fill last item data based on Title Bar/Tab, in order for IsItemHovered() and IsItemActive() to be usable after Begin().
|
||||
// This is useful to allow creating context menus on title bar only, etc.
|
||||
@@ -9660,7 +9669,7 @@ bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max)
|
||||
// - UnregisterFontAtlas() [Internal]
|
||||
// - SetCurrentFont() [Internal]
|
||||
// - UpdateCurrentFontSize() [Internal]
|
||||
// - SetFontRasterizerDensity() [Internal]
|
||||
// - SetPixelDensity() [Internal]
|
||||
// - PushFont()
|
||||
// - PopFont()
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -9853,7 +9862,7 @@ void ImGui::UpdateCurrentFontSize(float restore_font_size_after_scaling)
|
||||
final_size = GetRoundedFontSize(final_size);
|
||||
final_size = ImClamp(final_size, 1.0f, IMGUI_FONT_SIZE_MAX);
|
||||
if (g.Font != NULL && (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasTextures))
|
||||
g.Font->CurrentRasterizerDensity = g.FontRasterizerDensity;
|
||||
g.Font->CurrentRasterizerDensity = g.CurrentPixelDensity;
|
||||
|
||||
g.FontSize = final_size;
|
||||
g.DrawListSharedData.FontSize = g.FontSize;
|
||||
@@ -9877,13 +9886,13 @@ void ImGui::UpdateCurrentFontSize(float restore_font_size_after_scaling)
|
||||
|
||||
// Exposed in case user may want to override setting density.
|
||||
// IMPORTANT: Begin()/End() is overriding density. Be considerate of this you change it.
|
||||
void ImGui::SetFontRasterizerDensity(float rasterizer_density)
|
||||
void ImGui::SetPixelDensity(float pixel_density)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(g.IO.BackendFlags & ImGuiBackendFlags_RendererHasTextures);
|
||||
if (g.FontRasterizerDensity == rasterizer_density)
|
||||
if (g.CurrentPixelDensity == pixel_density)
|
||||
return;
|
||||
g.FontRasterizerDensity = rasterizer_density;
|
||||
g.CurrentPixelDensity = pixel_density;
|
||||
UpdateCurrentFontSize(0.0f);
|
||||
}
|
||||
|
||||
@@ -11727,7 +11736,7 @@ static void ImGui::ErrorCheckNewFrameSanityChecks()
|
||||
IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!");
|
||||
IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?");
|
||||
IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!");
|
||||
IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!");
|
||||
IM_ASSERT(g.Style.CurveTessellationMaxError > 0.0f && "Invalid style setting!");
|
||||
IM_ASSERT(g.Style.CircleTessellationMaxError > 0.0f && "Invalid style setting!");
|
||||
IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting!"); // Allows us to avoid a few clamps in color computations
|
||||
IM_ASSERT(g.Style.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting!");
|
||||
@@ -11777,6 +11786,11 @@ static void ImGui::ErrorCheckNewFrameSanityChecks()
|
||||
g.PlatformIO.Platform_GetClipboardTextFn = [](ImGuiContext* ctx) { return ctx->IO.GetClipboardTextFn(ctx->IO.ClipboardUserData); };
|
||||
if (g.IO.SetClipboardTextFn != NULL && (g.PlatformIO.Platform_SetClipboardTextFn == NULL || g.PlatformIO.Platform_SetClipboardTextFn == Platform_SetClipboardTextFn_DefaultImpl))
|
||||
g.PlatformIO.Platform_SetClipboardTextFn = [](ImGuiContext* ctx, const char* text) { return ctx->IO.SetClipboardTextFn(ctx->IO.ClipboardUserData, text); };
|
||||
|
||||
// Remap legacy CurveTessellationTol into CurveTessellationMaxError (OBSOLETED in 1.93.0, August 2026)
|
||||
if (g.Style.CurveTessellationTol != 0.0f)
|
||||
g.Style.CurveTessellationMaxError = ImSqrt(g.Style.CurveTessellationTol);
|
||||
g.Style.CurveTessellationTol = 0.0f;
|
||||
#endif
|
||||
|
||||
// Perform simple check: error if Docking or Viewport are enabled _exactly_ on frame 1 (instead of frame 0 or later), which is a common error leading to loss of .ini data.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.92.9b
|
||||
// dear imgui, v1.93.0 WIP
|
||||
// (headers)
|
||||
|
||||
// Help:
|
||||
@@ -29,8 +29,8 @@
|
||||
|
||||
// Library Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||
#define IMGUI_VERSION "1.92.9b"
|
||||
#define IMGUI_VERSION_NUM 19291
|
||||
#define IMGUI_VERSION "1.93.0 WIP"
|
||||
#define IMGUI_VERSION_NUM 19292
|
||||
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
|
||||
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
|
||||
#define IMGUI_HAS_VIEWPORT // In 'docking' WIP branch.
|
||||
@@ -2461,10 +2461,12 @@ struct ImGuiStyle
|
||||
bool DockingNodeHasCloseButton; // Docking node has their own CloseButton() to close all docked windows.
|
||||
float DockingSeparatorSize; // Thickness of resizing border between docked windows
|
||||
float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). We apply per-monitor DPI scaling over this scale. May be removed later.
|
||||
|
||||
// Rendering & Tesselation
|
||||
bool AntiAliasedLines; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
|
||||
bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering). Latched at the beginning of the frame (copied to ImDrawList).
|
||||
bool AntiAliasedFill; // Enable anti-aliased edges around filled shapes (rounded rectangles, circles, etc.). Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
|
||||
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
||||
float CurveTessellationMaxError; // Maximum error (in pixels) when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
||||
float CircleTessellationMaxError; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
|
||||
|
||||
// Colors
|
||||
@@ -2488,6 +2490,7 @@ struct ImGuiStyle
|
||||
|
||||
// Obsolete names
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
float CurveTessellationTol; // [OBSOLETE] Old CurveTessellationTol = New CurveTessellationMaxError*CurveTessellationMaxError. // Changed in 1.93.0
|
||||
// TabMinWidthForCloseButton = TabCloseButtonMinWidthUnselected // Renamed in 1.91.9.
|
||||
#endif
|
||||
};
|
||||
@@ -3477,7 +3480,8 @@ struct ImDrawList
|
||||
ImVector<ImVec4> _ClipRectStack; // [Internal]
|
||||
ImVector<ImTextureRef> _TextureStack; // [Internal]
|
||||
ImVector<ImU8> _CallbacksDataBuf; // [Internal]
|
||||
float _FringeScale; // [Internal] anti-alias fringe is scaled by this value, this helps to keep things sharp while zooming at vertex buffer content
|
||||
float _FringeScale; // [Internal] anti-alias fringe is scaled by this value, this helps to keep things sharp while zooming at vertex buffer content.
|
||||
float _InvFringeScale; // [internal] 1.0 / _FringeScale // FIXME: Consider renaming to _PixelDensity.
|
||||
const char* _OwnerName; // Pointer to owner window's name for debugging
|
||||
|
||||
// If you want to create ImDrawList instances, pass them ImGui::GetDrawListSharedData().
|
||||
@@ -3611,6 +3615,7 @@ struct ImDrawList
|
||||
// [Internal helpers]
|
||||
IMGUI_API void _SetDrawListSharedData(ImDrawListSharedData* data);
|
||||
IMGUI_API void _ResetForNewFrame();
|
||||
IMGUI_API void _SetPixelDensity(float pixel_density);
|
||||
IMGUI_API void _ClearFreeMemory();
|
||||
IMGUI_API void _PopUnusedDrawCmd();
|
||||
IMGUI_API void _TryMergeDrawCmds();
|
||||
|
||||
+4
-3
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.92.9b
|
||||
// dear imgui, v1.93.0 WIP
|
||||
// (demo code)
|
||||
|
||||
// Help:
|
||||
@@ -8942,8 +8942,9 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
|
||||
Checkbox("Anti-aliased fill", &style.AntiAliasedFill);
|
||||
PushItemWidth(GetFontSize() * 8);
|
||||
DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, 10.0f, "%.2f");
|
||||
if (style.CurveTessellationTol < 0.10f) style.CurveTessellationTol = 0.10f;
|
||||
DragFloat("Curve Tessellation Max Error", &style.CurveTessellationMaxError, 0.02f, 0.10f, 10.0f, "%.2f");
|
||||
if (style.CurveTessellationMaxError < 0.10f)
|
||||
style.CurveTessellationMaxError = 0.10f;
|
||||
|
||||
// When editing the "Circle Segment Max Error" value, draw a preview of its effect on auto-tessellated circles.
|
||||
DragFloat("Circle Tessellation Max Error", &style.CircleTessellationMaxError , 0.005f, 0.10f, 5.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp);
|
||||
|
||||
+30
-17
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.92.9b
|
||||
// dear imgui, v1.93.0 WIP
|
||||
// (drawing and font code)
|
||||
|
||||
/*
|
||||
@@ -402,7 +402,6 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst)
|
||||
ImDrawListSharedData::ImDrawListSharedData()
|
||||
{
|
||||
memset((void*)this, 0, sizeof(*this));
|
||||
InitialFringeScale = 1.0f;
|
||||
for (int i = 0; i < IM_COUNTOF(ArcFastVtx); i++)
|
||||
{
|
||||
const float a = ((float)i * 2 * IM_PI) / (float)IM_COUNTOF(ArcFastVtx);
|
||||
@@ -479,7 +478,7 @@ void ImDrawList::_ResetForNewFrame()
|
||||
_Path.resize(0);
|
||||
_Splitter.Clear();
|
||||
CmdBuffer.push_back(ImDrawCmd());
|
||||
_FringeScale = _Data->InitialFringeScale;
|
||||
// Caller needs to bet _SetPixelDensity() as well.
|
||||
}
|
||||
|
||||
void ImDrawList::_ClearFreeMemory()
|
||||
@@ -661,6 +660,7 @@ void ImDrawList::_OnChangedVtxOffset()
|
||||
int ImDrawList::_CalcCircleAutoSegmentCount(float radius) const
|
||||
{
|
||||
// Automatic segment count
|
||||
radius *= _InvFringeScale;
|
||||
const int radius_idx = (int)(radius + 0.999f); // ceil to never reduce accuracy
|
||||
if (radius_idx >= 0 && radius_idx < IM_COUNTOF(_Data->CircleSegmentCounts))
|
||||
return _Data->CircleSegmentCounts[radius_idx]; // Use cached value
|
||||
@@ -726,6 +726,13 @@ void ImDrawList::_SetTexture(ImTextureRef tex_ref)
|
||||
_OnChangedTexture();
|
||||
}
|
||||
|
||||
void ImDrawList::_SetPixelDensity(float pixel_density)
|
||||
{
|
||||
IM_ASSERT(pixel_density > 0.0f);
|
||||
_FringeScale = 1.0f / pixel_density;
|
||||
_InvFringeScale = pixel_density;
|
||||
}
|
||||
|
||||
// Reserve space for a number of vertices and indices.
|
||||
// You must finish filling your reserved data before calling PrimReserve() again, as it may reallocate or
|
||||
// submit the intermediate results. PrimUnreserve() can be used to release unused allocations.
|
||||
@@ -1376,7 +1383,7 @@ ImVec2 ImBezierQuadraticCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p
|
||||
}
|
||||
|
||||
// Closely mimics ImBezierCubicClosestPointCasteljau() in imgui.cpp
|
||||
static void PathBezierCubicCurveToCasteljau(ImVector<ImVec2>* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level)
|
||||
static void PathBezierCubicCurveToCasteljau(ImVector<ImVec2>* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float max_error_sqr, int level)
|
||||
{
|
||||
float dx = x4 - x1;
|
||||
float dy = y4 - y1;
|
||||
@@ -1384,7 +1391,7 @@ static void PathBezierCubicCurveToCasteljau(ImVector<ImVec2>* path, float x1, fl
|
||||
float d3 = (x3 - x4) * dy - (y3 - y4) * dx;
|
||||
d2 = (d2 >= 0) ? d2 : -d2;
|
||||
d3 = (d3 >= 0) ? d3 : -d3;
|
||||
if ((d2 + d3) * (d2 + d3) < tess_tol * (dx * dx + dy * dy))
|
||||
if ((d2 + d3) * (d2 + d3) < max_error_sqr * (dx * dx + dy * dy))
|
||||
{
|
||||
path->push_back(ImVec2(x4, y4));
|
||||
}
|
||||
@@ -1396,16 +1403,16 @@ static void PathBezierCubicCurveToCasteljau(ImVector<ImVec2>* path, float x1, fl
|
||||
float x123 = (x12 + x23) * 0.5f, y123 = (y12 + y23) * 0.5f;
|
||||
float x234 = (x23 + x34) * 0.5f, y234 = (y23 + y34) * 0.5f;
|
||||
float x1234 = (x123 + x234) * 0.5f, y1234 = (y123 + y234) * 0.5f;
|
||||
PathBezierCubicCurveToCasteljau(path, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol, level + 1);
|
||||
PathBezierCubicCurveToCasteljau(path, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol, level + 1);
|
||||
PathBezierCubicCurveToCasteljau(path, x1, y1, x12, y12, x123, y123, x1234, y1234, max_error_sqr, level + 1);
|
||||
PathBezierCubicCurveToCasteljau(path, x1234, y1234, x234, y234, x34, y34, x4, y4, max_error_sqr, level + 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void PathBezierQuadraticCurveToCasteljau(ImVector<ImVec2>* path, float x1, float y1, float x2, float y2, float x3, float y3, float tess_tol, int level)
|
||||
static void PathBezierQuadraticCurveToCasteljau(ImVector<ImVec2>* path, float x1, float y1, float x2, float y2, float x3, float y3, float max_error_sqr, int level)
|
||||
{
|
||||
float dx = x3 - x1, dy = y3 - y1;
|
||||
float det = (x2 - x3) * dy - (y2 - y3) * dx;
|
||||
if (det * det * 4.0f < tess_tol * (dx * dx + dy * dy))
|
||||
if (det * det * 4.0f < max_error_sqr * (dx * dx + dy * dy))
|
||||
{
|
||||
path->push_back(ImVec2(x3, y3));
|
||||
}
|
||||
@@ -1414,8 +1421,8 @@ static void PathBezierQuadraticCurveToCasteljau(ImVector<ImVec2>* path, float x1
|
||||
float x12 = (x1 + x2) * 0.5f, y12 = (y1 + y2) * 0.5f;
|
||||
float x23 = (x2 + x3) * 0.5f, y23 = (y2 + y3) * 0.5f;
|
||||
float x123 = (x12 + x23) * 0.5f, y123 = (y12 + y23) * 0.5f;
|
||||
PathBezierQuadraticCurveToCasteljau(path, x1, y1, x12, y12, x123, y123, tess_tol, level + 1);
|
||||
PathBezierQuadraticCurveToCasteljau(path, x123, y123, x23, y23, x3, y3, tess_tol, level + 1);
|
||||
PathBezierQuadraticCurveToCasteljau(path, x1, y1, x12, y12, x123, y123, max_error_sqr, level + 1);
|
||||
PathBezierQuadraticCurveToCasteljau(path, x123, y123, x23, y23, x3, y3, max_error_sqr, level + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1424,8 +1431,9 @@ void ImDrawList::PathBezierCubicCurveTo(const ImVec2& p2, const ImVec2& p3, cons
|
||||
ImVec2 p1 = _Path.back();
|
||||
if (num_segments == 0)
|
||||
{
|
||||
IM_ASSERT(_Data->CurveTessellationTol > 0.0f);
|
||||
PathBezierCubicCurveToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, _Data->CurveTessellationTol, 0); // Auto-tessellated
|
||||
IM_ASSERT(_Data->CurveTessellationMaxError > 0.0f);
|
||||
float max_error_sqr = (_Data->CurveTessellationMaxError * _FringeScale) * (_Data->CurveTessellationMaxError * _FringeScale);
|
||||
PathBezierCubicCurveToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, max_error_sqr, 0); // Auto-tessellated
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1440,8 +1448,9 @@ void ImDrawList::PathBezierQuadraticCurveTo(const ImVec2& p2, const ImVec2& p3,
|
||||
ImVec2 p1 = _Path.back();
|
||||
if (num_segments == 0)
|
||||
{
|
||||
IM_ASSERT(_Data->CurveTessellationTol > 0.0f);
|
||||
PathBezierQuadraticCurveToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, _Data->CurveTessellationTol, 0);// Auto-tessellated
|
||||
IM_ASSERT(_Data->CurveTessellationMaxError > 0.0f);
|
||||
float max_error_sqr = (_Data->CurveTessellationMaxError * _FringeScale) * (_Data->CurveTessellationMaxError * _FringeScale);
|
||||
PathBezierQuadraticCurveToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, max_error_sqr, 0);// Auto-tessellated
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3174,11 +3183,15 @@ const char* ImGui_GetDefaultCompressedFontDataProggyForever(int* out_size);
|
||||
// This duplicates some of the logic in UpdateFontsNewFrame() which is a bit chicken-and-eggy/tricky to extract due to variety of codepaths and possible initialization ordering.
|
||||
static float GetExpectedContextFontSize(ImGuiContext* ctx)
|
||||
{
|
||||
return ((ctx->Style.FontSizeBase > 0.0f) ? ctx->Style.FontSizeBase : 13.0f) * ctx->Style.FontScaleMain * ctx->Style.FontScaleDpi;
|
||||
float fb_scale = (ctx->IO.DisplayFramebufferScale.x != 0.0f) ? ctx->IO.DisplayFramebufferScale.x : 1.0f;
|
||||
if (ctx->IO.DisplayFramebufferScale.x == 1.0f && ctx->IO.DisplaySize.x <= 0.0f && ctx->IO.ConfigMacOSXBehaviors)
|
||||
fb_scale = 2.0f; // If called before backend had a chance to init DisplayFramebufferScale. default to expecting Retina.
|
||||
float scale = ctx->Style.FontScaleMain * ctx->Style.FontScaleDpi * fb_scale;
|
||||
return ((ctx->Style.FontSizeBase > 0.0f) ? ctx->Style.FontSizeBase : 13.0f) * scale;
|
||||
}
|
||||
|
||||
// Legacy function with heuristic to select Pixel or Vector font.
|
||||
// The selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a small threshold at the time of adding the default font.
|
||||
// The selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi * io.DisplayFramebufferScale) reaching a small threshold at the time of adding the default font.
|
||||
// Prefer calling AddFontDefaultVector() or AddFontDefaultBitmap() based on your own logic.
|
||||
ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg)
|
||||
{
|
||||
|
||||
+7
-8
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.92.9b
|
||||
// dear imgui, v1.93.0 WIP
|
||||
// (internal structures/api)
|
||||
|
||||
// You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility.
|
||||
@@ -560,8 +560,8 @@ IM_MSVC_RUNTIME_CHECKS_RESTORE
|
||||
|
||||
// Helpers: Geometry
|
||||
IMGUI_API ImVec2 ImBezierCubicCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, float t);
|
||||
IMGUI_API ImVec2 ImBezierCubicClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, int num_segments); // For curves with explicit number of segments
|
||||
IMGUI_API ImVec2 ImBezierCubicClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, float tess_tol);// For auto-tessellated curves you can use tess_tol = style.CurveTessellationTol
|
||||
IMGUI_API ImVec2 ImBezierCubicClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, int num_segments); // For curves with explicit number of segments
|
||||
IMGUI_API ImVec2 ImBezierCubicClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, float max_error);// For auto-tessellated curves you can use max_error = style.CurveTessellationMaxError
|
||||
IMGUI_API ImVec2 ImBezierQuadraticCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, float t);
|
||||
IMGUI_API ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p);
|
||||
IMGUI_API bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
|
||||
@@ -906,9 +906,8 @@ struct IMGUI_API ImDrawListSharedData
|
||||
ImFont* Font; // Current font (used for simplified AddText overload)
|
||||
float FontSize; // Current font size (used for for simplified AddText overload)
|
||||
float FontScale; // Current font scale (== FontSize / Font->FontSize)
|
||||
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo()
|
||||
float CurveTessellationMaxError; // Tessellation tolerance when using PathBezierCurveTo()
|
||||
float CircleTessellationMaxError; // Number of circle segments to use per pixel of radius for AddCircle() etc
|
||||
float InitialFringeScale; // Initial scale to apply to AA fringe
|
||||
ImDrawListFlags InitialFlags; // Initial flags at the beginning of the frame (it is possible to alter flags on a per-drawlist basis afterwards)
|
||||
ImVec4 ClipRectFullscreen; // Value for PushClipRectFullscreen()
|
||||
ImVector<ImVec2> TempBuffer; // Temporary write buffer
|
||||
@@ -2464,7 +2463,7 @@ struct ImGuiContext
|
||||
float FontSize; // Currently bound font size == line height (== FontSizeBase + externals scales applied in the UpdateCurrentFontSize() function).
|
||||
float FontSizeBase; // Font size before scaling == style.FontSizeBase == value passed to PushFont() when specified.
|
||||
float FontBakedScale; // == FontBaked->Size / FontSize. Scale factor over baked size. Rarely used nowadays, very often == 1.0f.
|
||||
float FontRasterizerDensity; // Current font density. Used by all calls to GetFontBaked().
|
||||
float CurrentPixelDensity; // Current font density. Used by all calls to GetFontBaked().
|
||||
float CurrentDpiScale; // Current window/viewport DpiScale == CurrentViewport->DpiScale
|
||||
ImDrawListSharedData DrawListSharedData;
|
||||
ImGuiID WithinEndChildID; // Set within EndChild()
|
||||
@@ -3624,8 +3623,8 @@ namespace ImGui
|
||||
IMGUI_API void UnregisterFontAtlas(ImFontAtlas* atlas);
|
||||
IMGUI_API void SetCurrentFont(ImFont* font, float font_size_before_scaling, float font_size_after_scaling);
|
||||
IMGUI_API void UpdateCurrentFontSize(float restore_font_size_after_scaling);
|
||||
IMGUI_API void SetFontRasterizerDensity(float rasterizer_density);
|
||||
inline float GetFontRasterizerDensity() { return GImGui->FontRasterizerDensity; }
|
||||
IMGUI_API void SetPixelDensity(float pixel_density); // was SetFontRasterizerDensity()
|
||||
inline float GetPixelDensity() { return GImGui->CurrentPixelDensity; }
|
||||
inline float GetRoundedFontSize(float size) { return IM_ROUND(size); }
|
||||
IMGUI_API ImFont* GetDefaultFont();
|
||||
IMGUI_API void PushPasswordFont();
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.92.9b
|
||||
// dear imgui, v1.93.0 WIP
|
||||
// (tables and columns code)
|
||||
|
||||
/*
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.92.9b
|
||||
// dear imgui, v1.93.0 WIP
|
||||
// (widgets code)
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user