mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-29 18:08:29 +00:00
external/imgui: update to 1.90.8
Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2254>
This commit is contained in:
parent
a4cfebeb45
commit
e89f2c3555
58
src/external/CMakeLists.txt
vendored
58
src/external/CMakeLists.txt
vendored
|
@ -118,44 +118,68 @@ target_include_directories(
|
|||
if(XRT_HAVE_OPENGL)
|
||||
add_library(
|
||||
xrt-external-imgui STATIC
|
||||
imgui/imgui/cimgui.cpp
|
||||
imgui/imgui/cimgui.h
|
||||
imgui/imgui/cimplot.cpp
|
||||
imgui/imgui/cimplot.h
|
||||
# imgui 1.90.8-docking
|
||||
imgui/imgui/imconfig.h
|
||||
imgui/imgui/imgui.cpp
|
||||
imgui/imgui/imgui_tables.cpp
|
||||
imgui/imgui/imgui.h
|
||||
imgui/imgui/imgui_demo.cpp
|
||||
imgui/imgui/imgui_draw.cpp
|
||||
imgui/imgui/imgui_impl_opengl3.cpp
|
||||
imgui/imgui/imgui_impl_opengl3.h
|
||||
imgui/imgui/backends/imgui_impl_opengl3.cpp
|
||||
imgui/imgui/backends/imgui_impl_opengl3.h
|
||||
imgui/imgui/imgui_internal.h
|
||||
imgui/imgui/imgui_widgets.cpp
|
||||
imgui/imgui/implot.cpp
|
||||
imgui/imgui/implot.h
|
||||
imgui/imgui/implot_demo.cpp
|
||||
imgui/imgui/implot_internal.h
|
||||
imgui/imgui/implot_items.cpp
|
||||
imgui/imgui/imstb_rectpack.h
|
||||
imgui/imgui/imstb_textedit.h
|
||||
imgui/imgui/imstb_truetype.h
|
||||
# cimgui 7c16d31cdb9d2db3038b324fe967ffa76b02c8c4
|
||||
imgui/cimgui/cimgui.cpp
|
||||
imgui/cimgui/cimgui.h
|
||||
imgui/cimgui/cimgui_impl.h
|
||||
# implot 0.17 f156599faefe316f7dd20fe6c783bf87c8bb6fd9
|
||||
imgui/implot/implot.cpp
|
||||
imgui/implot/implot.h
|
||||
imgui/implot/implot_internal.h
|
||||
imgui/implot/implot_items.cpp
|
||||
imgui/implot/implot_demo.cpp
|
||||
# cimplot 439f705b1cfae0e9fbe42c13ab5b45becc47d404
|
||||
imgui/cimplot/cimplot.cpp
|
||||
imgui/cimplot/cimplot.h
|
||||
imgui/imgui_monado/imgui_monado.cpp
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
xrt-external-imgui SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui
|
||||
xrt-external-imgui SYSTEM
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/imgui/cimgui
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/imgui/implot
|
||||
)
|
||||
target_include_directories(xrt-external-imgui PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
|
||||
target_compile_definitions(xrt-external-imgui PUBLIC CIMGUI_NO_EXPORT)
|
||||
target_compile_definitions(xrt-external-imgui PUBLIC CIMGUI_NO_EXPORT CIMGUI_USE_OPENGL3)
|
||||
|
||||
if(WIN32)
|
||||
target_compile_definitions(
|
||||
xrt-external-imgui
|
||||
PUBLIC "IMGUI_IMPL_API=extern\ \"C\" __declspec\(dllexport\)"
|
||||
)
|
||||
else()
|
||||
target_compile_definitions(xrt-external-imgui PUBLIC "IMGUI_IMPL_API=extern\ \"C\"")
|
||||
endif()
|
||||
|
||||
set_target_properties(xrt-external-imgui PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
|
||||
target_link_libraries(xrt-external-imgui PUBLIC xrt-external-glad)
|
||||
|
||||
if(XRT_HAVE_SDL2)
|
||||
add_library(
|
||||
xrt-external-imgui-sdl2 STATIC
|
||||
imgui/imgui/cimgui_sdl.cpp imgui/imgui/imgui_impl_sdl.cpp
|
||||
imgui/imgui/imgui_impl_sdl.h
|
||||
xrt-external-imgui-sdl2 STATIC imgui/imgui/backends/imgui_impl_sdl2.cpp
|
||||
imgui/imgui/backends/imgui_impl_sdl2.h
|
||||
)
|
||||
target_include_directories(
|
||||
xrt-external-imgui-sdl2 SYSTEM
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui
|
||||
)
|
||||
target_compile_definitions(xrt-external-imgui-sdl2 PUBLIC CIMGUI_USE_SDL2)
|
||||
target_link_libraries(
|
||||
xrt-external-imgui-sdl2 PUBLIC xrt-external-imgui xrt-external-sdl2
|
||||
)
|
||||
|
|
|
@ -19,3 +19,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
File diff suppressed because it is too large
Load diff
4806
src/external/imgui/cimgui/cimgui.h
vendored
Normal file
4806
src/external/imgui/cimgui/cimgui.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
66
src/external/imgui/cimgui/cimgui_impl.h
vendored
Normal file
66
src/external/imgui/cimgui/cimgui_impl.h
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
#ifdef CIMGUI_USE_GLFW
|
||||
|
||||
typedef struct GLFWwindow GLFWwindow;
|
||||
typedef struct GLFWmonitor GLFWmonitor;
|
||||
struct GLFWwindow;
|
||||
struct GLFWmonitor;CIMGUI_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window,bool install_callbacks);
|
||||
CIMGUI_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window,bool install_callbacks);
|
||||
CIMGUI_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window,bool install_callbacks);
|
||||
CIMGUI_API void ImGui_ImplGlfw_Shutdown(void);
|
||||
CIMGUI_API void ImGui_ImplGlfw_NewFrame(void);
|
||||
CIMGUI_API void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window);
|
||||
CIMGUI_API void ImGui_ImplGlfw_RestoreCallbacks(GLFWwindow* window);
|
||||
CIMGUI_API void ImGui_ImplGlfw_SetCallbacksChainForAllWindows(bool chain_for_all_windows);
|
||||
CIMGUI_API void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window,int focused);
|
||||
CIMGUI_API void ImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window,int entered);
|
||||
CIMGUI_API void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window,double x,double y);
|
||||
CIMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window,int button,int action,int mods);
|
||||
CIMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window,double xoffset,double yoffset);
|
||||
CIMGUI_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window,int key,int scancode,int action,int mods);
|
||||
CIMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window,unsigned int c);
|
||||
CIMGUI_API void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor,int event);
|
||||
|
||||
#endif
|
||||
#ifdef CIMGUI_USE_OPENGL3
|
||||
CIMGUI_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version);
|
||||
CIMGUI_API void ImGui_ImplOpenGL3_Shutdown(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL3_NewFrame(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
|
||||
CIMGUI_API bool ImGui_ImplOpenGL3_CreateFontsTexture(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL3_DestroyFontsTexture(void);
|
||||
CIMGUI_API bool ImGui_ImplOpenGL3_CreateDeviceObjects(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(void);
|
||||
|
||||
#endif
|
||||
#ifdef CIMGUI_USE_OPENGL2
|
||||
CIMGUI_API bool ImGui_ImplOpenGL2_Init(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL2_Shutdown(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL2_NewFrame(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data);
|
||||
CIMGUI_API bool ImGui_ImplOpenGL2_CreateFontsTexture(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL2_DestroyFontsTexture(void);
|
||||
CIMGUI_API bool ImGui_ImplOpenGL2_CreateDeviceObjects(void);
|
||||
CIMGUI_API void ImGui_ImplOpenGL2_DestroyDeviceObjects(void);
|
||||
|
||||
#endif
|
||||
#ifdef CIMGUI_USE_SDL2
|
||||
|
||||
typedef struct SDL_Window SDL_Window;
|
||||
typedef struct SDL_Renderer SDL_Renderer;
|
||||
typedef struct _SDL_GameController _SDL_GameController;
|
||||
struct SDL_Window;
|
||||
struct SDL_Renderer;
|
||||
struct _SDL_GameController;
|
||||
typedef union SDL_Event SDL_Event;
|
||||
typedef enum { ImGui_ImplSDL2_GamepadMode_AutoFirst, ImGui_ImplSDL2_GamepadMode_AutoAll, ImGui_ImplSDL2_GamepadMode_Manual }ImGui_ImplSDL2_GamepadMode;CIMGUI_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window,void* sdl_gl_context);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window,SDL_Renderer* renderer);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_InitForOther(SDL_Window* window);
|
||||
CIMGUI_API void ImGui_ImplSDL2_Shutdown(void);
|
||||
CIMGUI_API void ImGui_ImplSDL2_NewFrame(void);
|
||||
CIMGUI_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
||||
CIMGUI_API void ImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode mode,struct _SDL_GameController** manual_gamepads_array,int manual_gamepads_count);
|
||||
|
||||
#endif
|
|
@ -1,6 +1,6 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2020 Omar Cornut
|
||||
Copyright (c) 2020 Victor Bombí
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -19,3 +19,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
3012
src/external/imgui/cimplot/cimplot.cpp
vendored
Normal file
3012
src/external/imgui/cimplot/cimplot.cpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
1563
src/external/imgui/cimplot/cimplot.h
vendored
Normal file
1563
src/external/imgui/cimplot/cimplot.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
21
src/external/imgui/imgui/LICENSE.txt
vendored
Normal file
21
src/external/imgui/imgui/LICENSE.txt
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2024 Omar Cornut
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
996
src/external/imgui/imgui/backends/imgui_impl_opengl3.cpp
vendored
Normal file
996
src/external/imgui/imgui/backends/imgui_impl_opengl3.cpp
vendored
Normal file
|
@ -0,0 +1,996 @@
|
|||
// dear imgui: Renderer Backend for modern OpenGL with shaders / programmatic pipeline
|
||||
// - Desktop GL: 2.x 3.x 4.x
|
||||
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
|
||||
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
|
||||
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||
|
||||
// About WebGL/ES:
|
||||
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
||||
// - This is done automatically on iOS, Android and Emscripten targets.
|
||||
// - For other targets, the define needs to be visible from the imgui_impl_opengl3.cpp compilation unit. If unsure, define globally or in imconfig.h.
|
||||
|
||||
// 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
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2024-05-07: OpenGL: Update loader for Linux to support EGL/GLVND. (#7562)
|
||||
// 2024-04-16: OpenGL: Detect ES3 contexts on desktop based on version string, to e.g. avoid calling glPolygonMode() on them. (#7447)
|
||||
// 2024-01-09: OpenGL: Update GL3W based imgui_impl_opengl3_loader.h to load "libGL.so" and variants, fixing regression on distros missing a symlink.
|
||||
// 2023-11-08: OpenGL: Update GL3W based imgui_impl_opengl3_loader.h to load "libGL.so" instead of "libGL.so.1", accommodating for NetBSD systems having only "libGL.so.3" available. (#6983)
|
||||
// 2023-10-05: OpenGL: Rename symbols in our internal loader so that LTO compilation with another copy of gl3w is possible. (#6875, #6668, #4445)
|
||||
// 2023-06-20: OpenGL: Fixed erroneous use glGetIntegerv(GL_CONTEXT_PROFILE_MASK) on contexts lower than 3.2. (#6539, #6333)
|
||||
// 2023-05-09: OpenGL: Support for glBindSampler() backup/restore on ES3. (#6375)
|
||||
// 2023-04-18: OpenGL: Restore front and back polygon mode separately when supported by context. (#6333)
|
||||
// 2023-03-23: OpenGL: Properly restoring "no shader program bound" if it was the case prior to running the rendering function. (#6267, #6220, #6224)
|
||||
// 2023-03-15: OpenGL: Fixed GL loader crash when GL_VERSION returns NULL. (#6154, #4445, #3530)
|
||||
// 2023-03-06: OpenGL: Fixed restoration of a potentially deleted OpenGL program, by calling glIsProgram(). (#6220, #6224)
|
||||
// 2022-11-09: OpenGL: Reverted use of glBufferSubData(), too many corruptions issues + old issues seemingly can't be reproed with Intel drivers nowadays (revert 2021-12-15 and 2022-05-23 changes).
|
||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||
// 2022-09-27: OpenGL: Added ability to '#define IMGUI_IMPL_OPENGL_DEBUG'.
|
||||
// 2022-05-23: OpenGL: Reworking 2021-12-15 "Using buffer orphaning" so it only happens on Intel GPU, seems to cause problems otherwise. (#4468, #4825, #4832, #5127).
|
||||
// 2022-05-13: OpenGL: Fixed state corruption on OpenGL ES 2.0 due to not preserving GL_ELEMENT_ARRAY_BUFFER_BINDING and vertex attribute states.
|
||||
// 2021-12-15: OpenGL: Using buffer orphaning + glBufferSubData(), seems to fix leaks with multi-viewports with some Intel HD drivers.
|
||||
// 2021-08-23: OpenGL: Fixed ES 3.0 shader ("#version 300 es") use normal precision floats to avoid wobbly rendering at HD resolutions.
|
||||
// 2021-08-19: OpenGL: Embed and use our own minimal GL loader (imgui_impl_opengl3_loader.h), removing requirement and support for third-party loader.
|
||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||
// 2021-06-25: OpenGL: Use OES_vertex_array extension on Emscripten + backup/restore current state.
|
||||
// 2021-06-21: OpenGL: Destroy individual vertex/fragment shader objects right after they are linked into the main shader.
|
||||
// 2021-05-24: OpenGL: Access GL_CLIP_ORIGIN when "GL_ARB_clip_control" extension is detected, inside of just OpenGL 4.5 version.
|
||||
// 2021-05-19: OpenGL: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
||||
// 2021-04-06: OpenGL: Don't try to read GL_CLIP_ORIGIN unless we're OpenGL 4.5 or greater.
|
||||
// 2021-02-18: OpenGL: Change blending equation to preserve alpha in output buffer.
|
||||
// 2021-01-03: OpenGL: Backup, setup and restore GL_STENCIL_TEST state.
|
||||
// 2020-10-23: OpenGL: Backup, setup and restore GL_PRIMITIVE_RESTART state.
|
||||
// 2020-10-15: OpenGL: Use glGetString(GL_VERSION) instead of glGetIntegerv(GL_MAJOR_VERSION, ...) when the later returns zero (e.g. Desktop GL 2.x)
|
||||
// 2020-09-17: OpenGL: Fix to avoid compiling/calling glBindSampler() on ES or pre 3.3 context which have the defines set by a loader.
|
||||
// 2020-07-10: OpenGL: Added support for glad2 OpenGL loader.
|
||||
// 2020-05-08: OpenGL: Made default GLSL version 150 (instead of 130) on OSX.
|
||||
// 2020-04-21: OpenGL: Fixed handling of glClipControl(GL_UPPER_LEFT) by inverting projection matrix.
|
||||
// 2020-04-12: OpenGL: Fixed context version check mistakenly testing for 4.0+ instead of 3.2+ to enable ImGuiBackendFlags_RendererHasVtxOffset.
|
||||
// 2020-03-24: OpenGL: Added support for glbinding 2.x OpenGL loader.
|
||||
// 2020-01-07: OpenGL: Added support for glbinding 3.x OpenGL loader.
|
||||
// 2019-10-25: OpenGL: Using a combination of GL define and runtime GL version to decide whether to use glDrawElementsBaseVertex(). Fix building with pre-3.2 GL loaders.
|
||||
// 2019-09-22: OpenGL: Detect default GL loader using __has_include compiler facility.
|
||||
// 2019-09-16: OpenGL: Tweak initialization code to allow application calling ImGui_ImplOpenGL3_CreateFontsTexture() before the first NewFrame() call.
|
||||
// 2019-05-29: OpenGL: Desktop GL only: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
||||
// 2019-04-30: OpenGL: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||
// 2019-03-29: OpenGL: Not calling glBindBuffer more than necessary in the render loop.
|
||||
// 2019-03-15: OpenGL: Added a GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized GL function loaders early.
|
||||
// 2019-03-03: OpenGL: Fix support for ES 2.0 (WebGL 1.0).
|
||||
// 2019-02-20: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN even if defined by the headers/loader.
|
||||
// 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).
|
||||
// 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) / GL_CLIP_ORIGIN.
|
||||
// 2018-08-29: OpenGL: Added support for more OpenGL loaders: glew and glad, with comments indicative that any loader can be used.
|
||||
// 2018-08-09: OpenGL: Default to OpenGL ES 3 on iOS and Android. GLSL version default to "#version 300 ES".
|
||||
// 2018-07-30: OpenGL: Support for GLSL 300 ES and 410 core. Fixes for Emscripten compilation.
|
||||
// 2018-07-10: OpenGL: Support for more GLSL versions (based on the GLSL version string). Added error output when shaders fail to compile/link.
|
||||
// 2018-06-08: Misc: Extracted imgui_impl_opengl3.cpp/.h away from the old combined GLFW/SDL+OpenGL3 examples.
|
||||
// 2018-06-08: OpenGL: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
|
||||
// 2018-05-25: OpenGL: Removed unnecessary backup/restore of GL_ELEMENT_ARRAY_BUFFER_BINDING since this is part of the VAO state.
|
||||
// 2018-05-14: OpenGL: Making the call to glBindSampler() optional so 3.2 context won't fail if the function is a nullptr pointer.
|
||||
// 2018-03-06: OpenGL: Added const char* glsl_version parameter to ImGui_ImplOpenGL3_Init() so user can override the GLSL version e.g. "#version 150".
|
||||
// 2018-02-23: OpenGL: Create the VAO in the render function so the setup can more easily be used with multiple shared GL context.
|
||||
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplSdlGL3_RenderDrawData() in the .h file so you can call it yourself.
|
||||
// 2018-01-07: OpenGL: Changed GLSL shader version from 330 to 150.
|
||||
// 2017-09-01: OpenGL: Save and restore current bound sampler. Save and restore current polygon mode.
|
||||
// 2017-05-01: OpenGL: Fixed save and restore of current blend func state.
|
||||
// 2017-05-01: OpenGL: Fixed save and restore of current GL_ACTIVE_TEXTURE.
|
||||
// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
|
||||
// 2016-07-29: OpenGL: Explicitly setting GL_UNPACK_ROW_LENGTH to reduce issues because SDL changes it. (#752)
|
||||
|
||||
//----------------------------------------
|
||||
// OpenGL GLSL GLSL
|
||||
// version version string
|
||||
//----------------------------------------
|
||||
// 2.0 110 "#version 110"
|
||||
// 2.1 120 "#version 120"
|
||||
// 3.0 130 "#version 130"
|
||||
// 3.1 140 "#version 140"
|
||||
// 3.2 150 "#version 150"
|
||||
// 3.3 330 "#version 330 core"
|
||||
// 4.0 400 "#version 400 core"
|
||||
// 4.1 410 "#version 410 core"
|
||||
// 4.2 420 "#version 410 core"
|
||||
// 4.3 430 "#version 430 core"
|
||||
// ES 2.0 100 "#version 100" = WebGL 1.0
|
||||
// ES 3.0 300 "#version 300 es" = WebGL 2.0
|
||||
//----------------------------------------
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include "imgui.h"
|
||||
#ifndef IMGUI_DISABLE
|
||||
#include "imgui_impl_opengl3.h"
|
||||
#include <stdio.h>
|
||||
#include <stdint.h> // intptr_t
|
||||
#if defined(__APPLE__)
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
// Clang/GCC warnings with -Weverything
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast
|
||||
#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness
|
||||
#pragma clang diagnostic ignored "-Wunused-macros" // warning: macro is not used
|
||||
#pragma clang diagnostic ignored "-Wnonportable-system-include-path"
|
||||
#pragma clang diagnostic ignored "-Wcast-function-type" // warning: cast between incompatible function types (for loader)
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||
#pragma GCC diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx'
|
||||
#pragma GCC diagnostic ignored "-Wcast-function-type" // warning: cast between incompatible function types (for loader)
|
||||
#endif
|
||||
|
||||
// GL includes
|
||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV))
|
||||
#include <OpenGLES/ES2/gl.h> // Use GL ES 2
|
||||
#else
|
||||
#include <GLES2/gl2.h> // Use GL ES 2
|
||||
#endif
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
#ifndef GL_GLEXT_PROTOTYPES
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#endif
|
||||
#include <GLES2/gl2ext.h>
|
||||
#endif
|
||||
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
||||
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV))
|
||||
#include <OpenGLES/ES3/gl.h> // Use GL ES 3
|
||||
#else
|
||||
#include <GLES3/gl3.h> // Use GL ES 3
|
||||
#endif
|
||||
#elif !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
|
||||
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
|
||||
// Helper libraries are often used for this purpose! Here we are using our own minimal custom loader based on gl3w.
|
||||
// In the rest of your app/engine, you can use another loader of your choice (gl3w, glew, glad, glbinding, glext, glLoadGen, etc.).
|
||||
// If you happen to be developing a new feature for this backend (imgui_impl_opengl3.cpp):
|
||||
// - You may need to regenerate imgui_impl_opengl3_loader.h to add new symbols. See https://github.com/dearimgui/gl3w_stripped
|
||||
// - You can temporarily use an unstripped version. See https://github.com/dearimgui/gl3w_stripped/releases
|
||||
// Changes to this backend using new APIs should be accompanied by a regenerated stripped loader version.
|
||||
#define IMGL3W_IMPL
|
||||
#include "imgui_impl_opengl3_loader.h"
|
||||
#endif
|
||||
|
||||
// Vertex arrays are not supported on ES2/WebGL1 unless Emscripten which uses an extension
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
#define IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
#define IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||
#define glBindVertexArray glBindVertexArrayOES
|
||||
#define glGenVertexArrays glGenVertexArraysOES
|
||||
#define glDeleteVertexArrays glDeleteVertexArraysOES
|
||||
#define GL_VERTEX_ARRAY_BINDING GL_VERTEX_ARRAY_BINDING_OES
|
||||
#endif
|
||||
|
||||
// Desktop GL 2.0+ has extension and glPolygonMode() which GL ES and WebGL don't have..
|
||||
// A desktop ES context can technically compile fine with our loader, so we also perform a runtime checks
|
||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3)
|
||||
#define IMGUI_IMPL_OPENGL_HAS_EXTENSIONS // has glGetIntegerv(GL_NUM_EXTENSIONS)
|
||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE // may have glPolygonMode()
|
||||
#endif
|
||||
|
||||
// Desktop GL 2.1+ and GL ES 3.0+ have glBindBuffer() with GL_PIXEL_UNPACK_BUFFER target.
|
||||
#if !defined(IMGUI_IMPL_OPENGL_ES2)
|
||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_BUFFER_PIXEL_UNPACK
|
||||
#endif
|
||||
|
||||
// Desktop GL 3.1+ has GL_PRIMITIVE_RESTART state
|
||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_1)
|
||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART
|
||||
#endif
|
||||
|
||||
// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
|
||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_2)
|
||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||
#endif
|
||||
|
||||
// Desktop GL 3.3+ and GL ES 3.0+ have glBindSampler()
|
||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) && (defined(IMGUI_IMPL_OPENGL_ES3) || defined(GL_VERSION_3_3))
|
||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||
#endif
|
||||
|
||||
// [Debugging]
|
||||
//#define IMGUI_IMPL_OPENGL_DEBUG
|
||||
#ifdef IMGUI_IMPL_OPENGL_DEBUG
|
||||
#include <stdio.h>
|
||||
#define GL_CALL(_CALL) do { _CALL; GLenum gl_err = glGetError(); if (gl_err != 0) fprintf(stderr, "GL error 0x%x returned from '%s'.\n", gl_err, #_CALL); } while (0) // Call with error check
|
||||
#else
|
||||
#define GL_CALL(_CALL) _CALL // Call without error check
|
||||
#endif
|
||||
|
||||
// OpenGL Data
|
||||
struct ImGui_ImplOpenGL3_Data
|
||||
{
|
||||
GLuint GlVersion; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries (e.g. 320 for GL 3.2)
|
||||
char GlslVersionString[32]; // Specified by user or detected based on compile time GL settings.
|
||||
bool GlProfileIsES2;
|
||||
bool GlProfileIsES3;
|
||||
bool GlProfileIsCompat;
|
||||
GLint GlProfileMask;
|
||||
GLuint FontTexture;
|
||||
GLuint ShaderHandle;
|
||||
GLint AttribLocationTex; // Uniforms location
|
||||
GLint AttribLocationProjMtx;
|
||||
GLuint AttribLocationVtxPos; // Vertex attributes location
|
||||
GLuint AttribLocationVtxUV;
|
||||
GLuint AttribLocationVtxColor;
|
||||
unsigned int VboHandle, ElementsHandle;
|
||||
GLsizeiptr VertexBufferSize;
|
||||
GLsizeiptr IndexBufferSize;
|
||||
bool HasPolygonMode;
|
||||
bool HasClipOrigin;
|
||||
bool UseBufferSubData;
|
||||
|
||||
ImGui_ImplOpenGL3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||
};
|
||||
|
||||
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
|
||||
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
|
||||
static ImGui_ImplOpenGL3_Data* ImGui_ImplOpenGL3_GetBackendData()
|
||||
{
|
||||
return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||
}
|
||||
|
||||
// Forward Declarations
|
||||
static void ImGui_ImplOpenGL3_InitPlatformInterface();
|
||||
static void ImGui_ImplOpenGL3_ShutdownPlatformInterface();
|
||||
|
||||
// OpenGL vertex attribute state (for ES 1.0 and ES 2.0 only)
|
||||
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||
struct ImGui_ImplOpenGL3_VtxAttribState
|
||||
{
|
||||
GLint Enabled, Size, Type, Normalized, Stride;
|
||||
GLvoid* Ptr;
|
||||
|
||||
void GetState(GLint index)
|
||||
{
|
||||
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &Enabled);
|
||||
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_SIZE, &Size);
|
||||
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_TYPE, &Type);
|
||||
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &Normalized);
|
||||
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_STRIDE, &Stride);
|
||||
glGetVertexAttribPointerv(index, GL_VERTEX_ATTRIB_ARRAY_POINTER, &Ptr);
|
||||
}
|
||||
void SetState(GLint index)
|
||||
{
|
||||
glVertexAttribPointer(index, Size, Type, (GLboolean)Normalized, Stride, Ptr);
|
||||
if (Enabled) glEnableVertexAttribArray(index); else glDisableVertexAttribArray(index);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
// Functions
|
||||
bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
IMGUI_CHECKVERSION();
|
||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||
|
||||
// Initialize our loader
|
||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
|
||||
if (imgl3wInit() != 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to initialize OpenGL loader!\n");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Setup backend capabilities flags
|
||||
ImGui_ImplOpenGL3_Data* bd = IM_NEW(ImGui_ImplOpenGL3_Data)();
|
||||
io.BackendRendererUserData = (void*)bd;
|
||||
io.BackendRendererName = "imgui_impl_opengl3";
|
||||
|
||||
// Query for GL version (e.g. 320 for GL 3.2)
|
||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||
// GLES 2
|
||||
bd->GlVersion = 200;
|
||||
bd->GlProfileIsES2 = true;
|
||||
#else
|
||||
// Desktop or GLES 3
|
||||
const char* gl_version_str = (const char*)glGetString(GL_VERSION);
|
||||
GLint major = 0;
|
||||
GLint minor = 0;
|
||||
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
||||
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
||||
if (major == 0 && minor == 0)
|
||||
sscanf(gl_version_str, "%d.%d", &major, &minor); // Query GL_VERSION in desktop GL 2.x, the string will start with "<major>.<minor>"
|
||||
bd->GlVersion = (GLuint)(major * 100 + minor * 10);
|
||||
#if defined(GL_CONTEXT_PROFILE_MASK)
|
||||
if (bd->GlVersion >= 320)
|
||||
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &bd->GlProfileMask);
|
||||
bd->GlProfileIsCompat = (bd->GlProfileMask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0;
|
||||
#endif
|
||||
|
||||
#if defined(IMGUI_IMPL_OPENGL_ES3)
|
||||
bd->GlProfileIsES3 = true;
|
||||
#else
|
||||
if (strncmp(gl_version_str, "OpenGL ES 3", 11) == 0)
|
||||
bd->GlProfileIsES3 = true;
|
||||
#endif
|
||||
|
||||
bd->UseBufferSubData = false;
|
||||
/*
|
||||
// Query vendor to enable glBufferSubData kludge
|
||||
#ifdef _WIN32
|
||||
if (const char* vendor = (const char*)glGetString(GL_VENDOR))
|
||||
if (strncmp(vendor, "Intel", 5) == 0)
|
||||
bd->UseBufferSubData = true;
|
||||
#endif
|
||||
*/
|
||||
#endif
|
||||
|
||||
#ifdef IMGUI_IMPL_OPENGL_DEBUG
|
||||
printf("GlVersion = %d, \"%s\"\nGlProfileIsCompat = %d\nGlProfileMask = 0x%X\nGlProfileIsES2 = %d, GlProfileIsES3 = %d\nGL_VENDOR = '%s'\nGL_RENDERER = '%s'\n", bd->GlVersion, gl_version_str, bd->GlProfileIsCompat, bd->GlProfileMask, bd->GlProfileIsES2, bd->GlProfileIsES3, (const char*)glGetString(GL_VENDOR), (const char*)glGetString(GL_RENDERER)); // [DEBUG]
|
||||
#endif
|
||||
|
||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||
if (bd->GlVersion >= 320)
|
||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||
#endif
|
||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||
|
||||
// Store GLSL version string so we can refer to it later in case we recreate shaders.
|
||||
// Note: GLSL version is NOT the same as GL version. Leave this to nullptr if unsure.
|
||||
if (glsl_version == nullptr)
|
||||
{
|
||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||
glsl_version = "#version 100";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
||||
glsl_version = "#version 300 es";
|
||||
#elif defined(__APPLE__)
|
||||
glsl_version = "#version 150";
|
||||
#else
|
||||
glsl_version = "#version 130";
|
||||
#endif
|
||||
}
|
||||
IM_ASSERT((int)strlen(glsl_version) + 2 < IM_ARRAYSIZE(bd->GlslVersionString));
|
||||
strcpy(bd->GlslVersionString, glsl_version);
|
||||
strcat(bd->GlslVersionString, "\n");
|
||||
|
||||
// Make an arbitrary GL call (we don't actually need the result)
|
||||
// IF YOU GET A CRASH HERE: it probably means the OpenGL function loader didn't do its job. Let us know!
|
||||
GLint current_texture;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture);
|
||||
|
||||
// Detect extensions we support
|
||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
|
||||
bd->HasPolygonMode = (!bd->GlProfileIsES2 && !bd->GlProfileIsES3);
|
||||
#endif
|
||||
bd->HasClipOrigin = (bd->GlVersion >= 450);
|
||||
#ifdef IMGUI_IMPL_OPENGL_HAS_EXTENSIONS
|
||||
GLint num_extensions = 0;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
|
||||
for (GLint i = 0; i < num_extensions; i++)
|
||||
{
|
||||
const char* extension = (const char*)glGetStringi(GL_EXTENSIONS, i);
|
||||
if (extension != nullptr && strcmp(extension, "GL_ARB_clip_control") == 0)
|
||||
bd->HasClipOrigin = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||
ImGui_ImplOpenGL3_InitPlatformInterface();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_Shutdown()
|
||||
{
|
||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
ImGui_ImplOpenGL3_ShutdownPlatformInterface();
|
||||
ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
||||
io.BackendRendererName = nullptr;
|
||||
io.BackendRendererUserData = nullptr;
|
||||
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||
IM_DELETE(bd);
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_NewFrame()
|
||||
{
|
||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplOpenGL3_Init()?");
|
||||
|
||||
if (!bd->ShaderHandle)
|
||||
ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||
}
|
||||
|
||||
static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height, GLuint vertex_array_object)
|
||||
{
|
||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||
|
||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART
|
||||
if (bd->GlVersion >= 310)
|
||||
glDisable(GL_PRIMITIVE_RESTART);
|
||||
#endif
|
||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
|
||||
if (bd->HasPolygonMode)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
#endif
|
||||
|
||||
// Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
|
||||
#if defined(GL_CLIP_ORIGIN)
|
||||
bool clip_origin_lower_left = true;
|
||||
if (bd->HasClipOrigin)
|
||||
{
|
||||
GLenum current_clip_origin = 0; glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)¤t_clip_origin);
|
||||
if (current_clip_origin == GL_UPPER_LEFT)
|
||||
clip_origin_lower_left = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Setup viewport, orthographic projection matrix
|
||||
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
||||
GL_CALL(glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height));
|
||||
float L = draw_data->DisplayPos.x;
|
||||
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
|
||||
float T = draw_data->DisplayPos.y;
|
||||
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
|
||||
#if defined(GL_CLIP_ORIGIN)
|
||||
if (!clip_origin_lower_left) { float tmp = T; T = B; B = tmp; } // Swap top and bottom if origin is upper left
|
||||
#endif
|
||||
const float ortho_projection[4][4] =
|
||||
{
|
||||
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 2.0f/(T-B), 0.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, -1.0f, 0.0f },
|
||||
{ (R+L)/(L-R), (T+B)/(B-T), 0.0f, 1.0f },
|
||||
};
|
||||
glUseProgram(bd->ShaderHandle);
|
||||
glUniform1i(bd->AttribLocationTex, 0);
|
||||
glUniformMatrix4fv(bd->AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
||||
|
||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||
if (bd->GlVersion >= 330 || bd->GlProfileIsES3)
|
||||
glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 and GL ES 3.0 may set that otherwise.
|
||||
#endif
|
||||
|
||||
(void)vertex_array_object;
|
||||
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||
glBindVertexArray(vertex_array_object);
|
||||
#endif
|
||||
|
||||
// Bind vertex/index buffers and setup attributes for ImDrawVert
|
||||
GL_CALL(glBindBuffer(GL_ARRAY_BUFFER, bd->VboHandle));
|
||||
GL_CALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bd->ElementsHandle));
|
||||
GL_CALL(glEnableVertexAttribArray(bd->AttribLocationVtxPos));
|
||||
GL_CALL(glEnableVertexAttribArray(bd->AttribLocationVtxUV));
|
||||
GL_CALL(glEnableVertexAttribArray(bd->AttribLocationVtxColor));
|
||||
GL_CALL(glVertexAttribPointer(bd->AttribLocationVtxPos, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)offsetof(ImDrawVert, pos)));
|
||||
GL_CALL(glVertexAttribPointer(bd->AttribLocationVtxUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)offsetof(ImDrawVert, uv)));
|
||||
GL_CALL(glVertexAttribPointer(bd->AttribLocationVtxColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)offsetof(ImDrawVert, col)));
|
||||
}
|
||||
|
||||
// OpenGL3 Render function.
|
||||
// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly.
|
||||
// This is in order to be able to run within an OpenGL engine that doesn't do so.
|
||||
void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||
{
|
||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||
if (fb_width <= 0 || fb_height <= 0)
|
||||
return;
|
||||
|
||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||
|
||||
// Backup GL state
|
||||
GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program);
|
||||
GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture);
|
||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||
GLuint last_sampler; if (bd->GlVersion >= 330 || bd->GlProfileIsES3) { glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler); } else { last_sampler = 0; }
|
||||
#endif
|
||||
GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer);
|
||||
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||
// This is part of VAO on OpenGL 3.0+ and OpenGL ES 3.0+.
|
||||
GLint last_element_array_buffer; glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_element_array_buffer);
|
||||
ImGui_ImplOpenGL3_VtxAttribState last_vtx_attrib_state_pos; last_vtx_attrib_state_pos.GetState(bd->AttribLocationVtxPos);
|
||||
ImGui_ImplOpenGL3_VtxAttribState last_vtx_attrib_state_uv; last_vtx_attrib_state_uv.GetState(bd->AttribLocationVtxUV);
|
||||
ImGui_ImplOpenGL3_VtxAttribState last_vtx_attrib_state_color; last_vtx_attrib_state_color.GetState(bd->AttribLocationVtxColor);
|
||||
#endif
|
||||
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||
GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object);
|
||||
#endif
|
||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
|
||||
GLint last_polygon_mode[2]; if (bd->HasPolygonMode) { glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode); }
|
||||
#endif
|
||||
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
|
||||
GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
|
||||
GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb);
|
||||
GLenum last_blend_dst_rgb; glGetIntegerv(GL_BLEND_DST_RGB, (GLint*)&last_blend_dst_rgb);
|
||||
GLenum last_blend_src_alpha; glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*)&last_blend_src_alpha);
|
||||
GLenum last_blend_dst_alpha; glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*)&last_blend_dst_alpha);
|
||||
GLenum last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*)&last_blend_equation_rgb);
|
||||
GLenum last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*)&last_blend_equation_alpha);
|
||||
GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
|
||||
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
|
||||
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
|
||||
GLboolean last_enable_stencil_test = glIsEnabled(GL_STENCIL_TEST);
|
||||
GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
|
||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART
|
||||
GLboolean last_enable_primitive_restart = (bd->GlVersion >= 310) ? glIsEnabled(GL_PRIMITIVE_RESTART) : GL_FALSE;
|
||||
#endif
|
||||
|
||||
// Setup desired GL state
|
||||
// Recreate the VAO every time (this is to easily allow multiple GL contexts to be rendered to. VAO are not shared among GL contexts)
|
||||
// The renderer would actually work without any VAO bound, but then our VertexAttrib calls would overwrite the default one currently bound.
|
||||
GLuint vertex_array_object = 0;
|
||||
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||
GL_CALL(glGenVertexArrays(1, &vertex_array_object));
|
||||
#endif
|
||||
ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object);
|
||||
|
||||
// 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
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
|
||||
// Upload vertex/index buffers
|
||||
// - OpenGL drivers are in a very sorry state nowadays....
|
||||
// During 2021 we attempted to switch from glBufferData() to orphaning+glBufferSubData() following reports
|
||||
// of leaks on Intel GPU when using multi-viewports on Windows.
|
||||
// - After this we kept hearing of various display corruptions issues. We started disabling on non-Intel GPU, but issues still got reported on Intel.
|
||||
// - We are now back to using exclusively glBufferData(). So bd->UseBufferSubData IS ALWAYS FALSE in this code.
|
||||
// We are keeping the old code path for a while in case people finding new issues may want to test the bd->UseBufferSubData path.
|
||||
// - See https://github.com/ocornut/imgui/issues/4468 and please report any corruption issues.
|
||||
const GLsizeiptr vtx_buffer_size = (GLsizeiptr)cmd_list->VtxBuffer.Size * (int)sizeof(ImDrawVert);
|
||||
const GLsizeiptr idx_buffer_size = (GLsizeiptr)cmd_list->IdxBuffer.Size * (int)sizeof(ImDrawIdx);
|
||||
if (bd->UseBufferSubData)
|
||||
{
|
||||
if (bd->VertexBufferSize < vtx_buffer_size)
|
||||
{
|
||||
bd->VertexBufferSize = vtx_buffer_size;
|
||||
GL_CALL(glBufferData(GL_ARRAY_BUFFER, bd->VertexBufferSize, nullptr, GL_STREAM_DRAW));
|
||||
}
|
||||
if (bd->IndexBufferSize < idx_buffer_size)
|
||||
{
|
||||
bd->IndexBufferSize = idx_buffer_size;
|
||||
GL_CALL(glBufferData(GL_ELEMENT_ARRAY_BUFFER, bd->IndexBufferSize, nullptr, GL_STREAM_DRAW));
|
||||
}
|
||||
GL_CALL(glBufferSubData(GL_ARRAY_BUFFER, 0, vtx_buffer_size, (const GLvoid*)cmd_list->VtxBuffer.Data));
|
||||
GL_CALL(glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, idx_buffer_size, (const GLvoid*)cmd_list->IdxBuffer.Data));
|
||||
}
|
||||
else
|
||||
{
|
||||
GL_CALL(glBufferData(GL_ARRAY_BUFFER, vtx_buffer_size, (const GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW));
|
||||
GL_CALL(glBufferData(GL_ELEMENT_ARRAY_BUFFER, idx_buffer_size, (const GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW));
|
||||
}
|
||||
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||
{
|
||||
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
||||
if (pcmd->UserCallback != nullptr)
|
||||
{
|
||||
// User callback, registered via ImDrawList::AddCallback()
|
||||
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||
ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object);
|
||||
else
|
||||
pcmd->UserCallback(cmd_list, pcmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Project scissor/clipping rectangles into framebuffer space
|
||||
ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y);
|
||||
ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y);
|
||||
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
||||
continue;
|
||||
|
||||
// Apply scissor/clipping rectangle (Y is inverted in OpenGL)
|
||||
GL_CALL(glScissor((int)clip_min.x, (int)((float)fb_height - clip_max.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y)));
|
||||
|
||||
// Bind texture, Draw
|
||||
GL_CALL(glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->GetTexID()));
|
||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||
if (bd->GlVersion >= 320)
|
||||
GL_CALL(glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset));
|
||||
else
|
||||
#endif
|
||||
GL_CALL(glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Destroy the temporary VAO
|
||||
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||
GL_CALL(glDeleteVertexArrays(1, &vertex_array_object));
|
||||
#endif
|
||||
|
||||
// Restore modified GL state
|
||||
// This "glIsProgram()" check is required because if the program is "pending deletion" at the time of binding backup, it will have been deleted by now and will cause an OpenGL error. See #6220.
|
||||
if (last_program == 0 || glIsProgram(last_program)) glUseProgram(last_program);
|
||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||
if (bd->GlVersion >= 330 || bd->GlProfileIsES3)
|
||||
glBindSampler(0, last_sampler);
|
||||
#endif
|
||||
glActiveTexture(last_active_texture);
|
||||
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||
glBindVertexArray(last_vertex_array_object);
|
||||
#endif
|
||||
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, last_element_array_buffer);
|
||||
last_vtx_attrib_state_pos.SetState(bd->AttribLocationVtxPos);
|
||||
last_vtx_attrib_state_uv.SetState(bd->AttribLocationVtxUV);
|
||||
last_vtx_attrib_state_color.SetState(bd->AttribLocationVtxColor);
|
||||
#endif
|
||||
glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha);
|
||||
glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha);
|
||||
if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND);
|
||||
if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE);
|
||||
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
|
||||
if (last_enable_stencil_test) glEnable(GL_STENCIL_TEST); else glDisable(GL_STENCIL_TEST);
|
||||
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
|
||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART
|
||||
if (bd->GlVersion >= 310) { if (last_enable_primitive_restart) glEnable(GL_PRIMITIVE_RESTART); else glDisable(GL_PRIMITIVE_RESTART); }
|
||||
#endif
|
||||
|
||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
|
||||
// Desktop OpenGL 3.0 and OpenGL 3.1 had separate polygon draw modes for front-facing and back-facing faces of polygons
|
||||
if (bd->HasPolygonMode) { if (bd->GlVersion <= 310 || bd->GlProfileIsCompat) { glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]); glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]); } else { glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]); } }
|
||||
#endif // IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
|
||||
|
||||
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
|
||||
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
||||
(void)bd; // Not all compilation paths use this
|
||||
}
|
||||
|
||||
bool ImGui_ImplOpenGL3_CreateFontsTexture()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||
|
||||
// Build texture atlas
|
||||
unsigned char* pixels;
|
||||
int width, height;
|
||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
|
||||
|
||||
// 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)
|
||||
GLint last_texture;
|
||||
GL_CALL(glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture));
|
||||
GL_CALL(glGenTextures(1, &bd->FontTexture));
|
||||
GL_CALL(glBindTexture(GL_TEXTURE_2D, bd->FontTexture));
|
||||
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
|
||||
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
|
||||
#ifdef GL_UNPACK_ROW_LENGTH // Not on WebGL/ES
|
||||
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
|
||||
#endif
|
||||
GL_CALL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
||||
|
||||
// Store our identifier
|
||||
io.Fonts->SetTexID((ImTextureID)(intptr_t)bd->FontTexture);
|
||||
|
||||
// Restore state
|
||||
GL_CALL(glBindTexture(GL_TEXTURE_2D, last_texture));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_DestroyFontsTexture()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||
if (bd->FontTexture)
|
||||
{
|
||||
glDeleteTextures(1, &bd->FontTexture);
|
||||
io.Fonts->SetTexID(0);
|
||||
bd->FontTexture = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// If you get an error please report on github. You may try different GL context version or GLSL version. See GL<>GLSL version table at the top of this file.
|
||||
static bool CheckShader(GLuint handle, const char* desc)
|
||||
{
|
||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||
GLint status = 0, log_length = 0;
|
||||
glGetShaderiv(handle, GL_COMPILE_STATUS, &status);
|
||||
glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &log_length);
|
||||
if ((GLboolean)status == GL_FALSE)
|
||||
fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile %s! With GLSL: %s\n", desc, bd->GlslVersionString);
|
||||
if (log_length > 1)
|
||||
{
|
||||
ImVector<char> buf;
|
||||
buf.resize((int)(log_length + 1));
|
||||
glGetShaderInfoLog(handle, log_length, nullptr, (GLchar*)buf.begin());
|
||||
fprintf(stderr, "%s\n", buf.begin());
|
||||
}
|
||||
return (GLboolean)status == GL_TRUE;
|
||||
}
|
||||
|
||||
// If you get an error please report on GitHub. You may try different GL context version or GLSL version.
|
||||
static bool CheckProgram(GLuint handle, const char* desc)
|
||||
{
|
||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||
GLint status = 0, log_length = 0;
|
||||
glGetProgramiv(handle, GL_LINK_STATUS, &status);
|
||||
glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length);
|
||||
if ((GLboolean)status == GL_FALSE)
|
||||
fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link %s! With GLSL %s\n", desc, bd->GlslVersionString);
|
||||
if (log_length > 1)
|
||||
{
|
||||
ImVector<char> buf;
|
||||
buf.resize((int)(log_length + 1));
|
||||
glGetProgramInfoLog(handle, log_length, nullptr, (GLchar*)buf.begin());
|
||||
fprintf(stderr, "%s\n", buf.begin());
|
||||
}
|
||||
return (GLboolean)status == GL_TRUE;
|
||||
}
|
||||
|
||||
bool ImGui_ImplOpenGL3_CreateDeviceObjects()
|
||||
{
|
||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||
|
||||
// Backup GL state
|
||||
GLint last_texture, last_array_buffer;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_BUFFER_PIXEL_UNPACK
|
||||
GLint last_pixel_unpack_buffer = 0;
|
||||
if (bd->GlVersion >= 210) { glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &last_pixel_unpack_buffer); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); }
|
||||
#endif
|
||||
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||
GLint last_vertex_array;
|
||||
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
||||
#endif
|
||||
|
||||
// Parse GLSL version string
|
||||
int glsl_version = 130;
|
||||
sscanf(bd->GlslVersionString, "#version %d", &glsl_version);
|
||||
|
||||
const GLchar* vertex_shader_glsl_120 =
|
||||
"uniform mat4 ProjMtx;\n"
|
||||
"attribute vec2 Position;\n"
|
||||
"attribute vec2 UV;\n"
|
||||
"attribute vec4 Color;\n"
|
||||
"varying vec2 Frag_UV;\n"
|
||||
"varying vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Frag_UV = UV;\n"
|
||||
" Frag_Color = Color;\n"
|
||||
" gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* vertex_shader_glsl_130 =
|
||||
"uniform mat4 ProjMtx;\n"
|
||||
"in vec2 Position;\n"
|
||||
"in vec2 UV;\n"
|
||||
"in vec4 Color;\n"
|
||||
"out vec2 Frag_UV;\n"
|
||||
"out vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Frag_UV = UV;\n"
|
||||
" Frag_Color = Color;\n"
|
||||
" gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* vertex_shader_glsl_300_es =
|
||||
"precision highp float;\n"
|
||||
"layout (location = 0) in vec2 Position;\n"
|
||||
"layout (location = 1) in vec2 UV;\n"
|
||||
"layout (location = 2) in vec4 Color;\n"
|
||||
"uniform mat4 ProjMtx;\n"
|
||||
"out vec2 Frag_UV;\n"
|
||||
"out vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Frag_UV = UV;\n"
|
||||
" Frag_Color = Color;\n"
|
||||
" gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* vertex_shader_glsl_410_core =
|
||||
"layout (location = 0) in vec2 Position;\n"
|
||||
"layout (location = 1) in vec2 UV;\n"
|
||||
"layout (location = 2) in vec4 Color;\n"
|
||||
"uniform mat4 ProjMtx;\n"
|
||||
"out vec2 Frag_UV;\n"
|
||||
"out vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Frag_UV = UV;\n"
|
||||
" Frag_Color = Color;\n"
|
||||
" gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* fragment_shader_glsl_120 =
|
||||
"#ifdef GL_ES\n"
|
||||
" precision mediump float;\n"
|
||||
"#endif\n"
|
||||
"uniform sampler2D Texture;\n"
|
||||
"varying vec2 Frag_UV;\n"
|
||||
"varying vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_FragColor = Frag_Color * texture2D(Texture, Frag_UV.st);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* fragment_shader_glsl_130 =
|
||||
"uniform sampler2D Texture;\n"
|
||||
"in vec2 Frag_UV;\n"
|
||||
"in vec4 Frag_Color;\n"
|
||||
"out vec4 Out_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* fragment_shader_glsl_300_es =
|
||||
"precision mediump float;\n"
|
||||
"uniform sampler2D Texture;\n"
|
||||
"in vec2 Frag_UV;\n"
|
||||
"in vec4 Frag_Color;\n"
|
||||
"layout (location = 0) out vec4 Out_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* fragment_shader_glsl_410_core =
|
||||
"in vec2 Frag_UV;\n"
|
||||
"in vec4 Frag_Color;\n"
|
||||
"uniform sampler2D Texture;\n"
|
||||
"layout (location = 0) out vec4 Out_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
|
||||
"}\n";
|
||||
|
||||
// Select shaders matching our GLSL versions
|
||||
const GLchar* vertex_shader = nullptr;
|
||||
const GLchar* fragment_shader = nullptr;
|
||||
if (glsl_version < 130)
|
||||
{
|
||||
vertex_shader = vertex_shader_glsl_120;
|
||||
fragment_shader = fragment_shader_glsl_120;
|
||||
}
|
||||
else if (glsl_version >= 410)
|
||||
{
|
||||
vertex_shader = vertex_shader_glsl_410_core;
|
||||
fragment_shader = fragment_shader_glsl_410_core;
|
||||
}
|
||||
else if (glsl_version == 300)
|
||||
{
|
||||
vertex_shader = vertex_shader_glsl_300_es;
|
||||
fragment_shader = fragment_shader_glsl_300_es;
|
||||
}
|
||||
else
|
||||
{
|
||||
vertex_shader = vertex_shader_glsl_130;
|
||||
fragment_shader = fragment_shader_glsl_130;
|
||||
}
|
||||
|
||||
// Create shaders
|
||||
const GLchar* vertex_shader_with_version[2] = { bd->GlslVersionString, vertex_shader };
|
||||
GLuint vert_handle = glCreateShader(GL_VERTEX_SHADER);
|
||||
glShaderSource(vert_handle, 2, vertex_shader_with_version, nullptr);
|
||||
glCompileShader(vert_handle);
|
||||
CheckShader(vert_handle, "vertex shader");
|
||||
|
||||
const GLchar* fragment_shader_with_version[2] = { bd->GlslVersionString, fragment_shader };
|
||||
GLuint frag_handle = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
glShaderSource(frag_handle, 2, fragment_shader_with_version, nullptr);
|
||||
glCompileShader(frag_handle);
|
||||
CheckShader(frag_handle, "fragment shader");
|
||||
|
||||
// Link
|
||||
bd->ShaderHandle = glCreateProgram();
|
||||
glAttachShader(bd->ShaderHandle, vert_handle);
|
||||
glAttachShader(bd->ShaderHandle, frag_handle);
|
||||
glLinkProgram(bd->ShaderHandle);
|
||||
CheckProgram(bd->ShaderHandle, "shader program");
|
||||
|
||||
glDetachShader(bd->ShaderHandle, vert_handle);
|
||||
glDetachShader(bd->ShaderHandle, frag_handle);
|
||||
glDeleteShader(vert_handle);
|
||||
glDeleteShader(frag_handle);
|
||||
|
||||
bd->AttribLocationTex = glGetUniformLocation(bd->ShaderHandle, "Texture");
|
||||
bd->AttribLocationProjMtx = glGetUniformLocation(bd->ShaderHandle, "ProjMtx");
|
||||
bd->AttribLocationVtxPos = (GLuint)glGetAttribLocation(bd->ShaderHandle, "Position");
|
||||
bd->AttribLocationVtxUV = (GLuint)glGetAttribLocation(bd->ShaderHandle, "UV");
|
||||
bd->AttribLocationVtxColor = (GLuint)glGetAttribLocation(bd->ShaderHandle, "Color");
|
||||
|
||||
// Create buffers
|
||||
glGenBuffers(1, &bd->VboHandle);
|
||||
glGenBuffers(1, &bd->ElementsHandle);
|
||||
|
||||
ImGui_ImplOpenGL3_CreateFontsTexture();
|
||||
|
||||
// Restore modified GL state
|
||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_BUFFER_PIXEL_UNPACK
|
||||
if (bd->GlVersion >= 210) { glBindBuffer(GL_PIXEL_UNPACK_BUFFER, last_pixel_unpack_buffer); }
|
||||
#endif
|
||||
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||
glBindVertexArray(last_vertex_array);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_DestroyDeviceObjects()
|
||||
{
|
||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||
if (bd->VboHandle) { glDeleteBuffers(1, &bd->VboHandle); bd->VboHandle = 0; }
|
||||
if (bd->ElementsHandle) { glDeleteBuffers(1, &bd->ElementsHandle); bd->ElementsHandle = 0; }
|
||||
if (bd->ShaderHandle) { glDeleteProgram(bd->ShaderHandle); bd->ShaderHandle = 0; }
|
||||
ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
static void ImGui_ImplOpenGL3_RenderWindow(ImGuiViewport* viewport, void*)
|
||||
{
|
||||
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||
{
|
||||
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
ImGui_ImplOpenGL3_RenderDrawData(viewport->DrawData);
|
||||
}
|
||||
|
||||
static void ImGui_ImplOpenGL3_InitPlatformInterface()
|
||||
{
|
||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||
platform_io.Renderer_RenderWindow = ImGui_ImplOpenGL3_RenderWindow;
|
||||
}
|
||||
|
||||
static void ImGui_ImplOpenGL3_ShutdownPlatformInterface()
|
||||
{
|
||||
ImGui::DestroyPlatformWindows();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif // #ifndef IMGUI_DISABLE
|
67
src/external/imgui/imgui/backends/imgui_impl_opengl3.h
vendored
Normal file
67
src/external/imgui/imgui/backends/imgui_impl_opengl3.h
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
// dear imgui: Renderer Backend for modern OpenGL with shaders / programmatic pipeline
|
||||
// - Desktop GL: 2.x 3.x 4.x
|
||||
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
|
||||
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
|
||||
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||
|
||||
// About WebGL/ES:
|
||||
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
||||
// - This is done automatically on iOS, Android and Emscripten targets.
|
||||
// - For other targets, the define needs to be visible from the imgui_impl_opengl3.cpp compilation unit. If unsure, define globally or in imconfig.h.
|
||||
|
||||
// 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
|
||||
|
||||
// About GLSL version:
|
||||
// The 'glsl_version' initialization parameter should be nullptr (default) or a "#version XXX" string.
|
||||
// On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es"
|
||||
// Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
|
||||
|
||||
#pragma once
|
||||
#include "imgui.h" // IMGUI_IMPL_API
|
||||
#ifndef IMGUI_DISABLE
|
||||
|
||||
// Backend API
|
||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = nullptr);
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
|
||||
|
||||
// (Optional) Called by Init/NewFrame/Shutdown
|
||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
||||
|
||||
// Configuration flags to add in your imconfig file:
|
||||
//#define IMGUI_IMPL_OPENGL_ES2 // Enable ES 2 (Auto-detected on Emscripten)
|
||||
//#define IMGUI_IMPL_OPENGL_ES3 // Enable ES 3 (Auto-detected on iOS/Android)
|
||||
|
||||
// You can explicitly select GLES2 or GLES3 API by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
|
||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_ES3)
|
||||
|
||||
// Try to detect GLES on matching platforms
|
||||
#if defined(__APPLE__)
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
|
||||
#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
|
||||
#elif defined(__EMSCRIPTEN__) || defined(__amigaos4__)
|
||||
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
|
||||
#else
|
||||
// Otherwise imgui_impl_opengl3_loader.h will be used.
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif // #ifndef IMGUI_DISABLE
|
910
src/external/imgui/imgui/backends/imgui_impl_opengl3_loader.h
vendored
Normal file
910
src/external/imgui/imgui/backends/imgui_impl_opengl3_loader.h
vendored
Normal file
|
@ -0,0 +1,910 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// About imgui_impl_opengl3_loader.h:
|
||||
//
|
||||
// We embed our own OpenGL loader to not require user to provide their own or to have to use ours,
|
||||
// which proved to be endless problems for users.
|
||||
// Our loader is custom-generated, based on gl3w but automatically filtered to only include
|
||||
// enums/functions that we use in our imgui_impl_opengl3.cpp source file in order to be small.
|
||||
//
|
||||
// YOU SHOULD NOT NEED TO INCLUDE/USE THIS DIRECTLY. THIS IS USED BY imgui_impl_opengl3.cpp ONLY.
|
||||
// THE REST OF YOUR APP SHOULD USE A DIFFERENT GL LOADER: ANY GL LOADER OF YOUR CHOICE.
|
||||
//
|
||||
// IF YOU GET BUILD ERRORS IN THIS FILE (commonly macro redefinitions or function redefinitions):
|
||||
// IT LIKELY MEANS THAT YOU ARE BUILDING 'imgui_impl_opengl3.cpp' OR INCLUDING 'imgui_impl_opengl3_loader.h'
|
||||
// IN THE SAME COMPILATION UNIT AS ONE OF YOUR FILE WHICH IS USING A THIRD-PARTY OPENGL LOADER.
|
||||
// (e.g. COULD HAPPEN IF YOU ARE DOING A UNITY/JUMBO BUILD, OR INCLUDING .CPP FILES FROM OTHERS)
|
||||
// YOU SHOULD NOT BUILD BOTH IN THE SAME COMPILATION UNIT.
|
||||
// BUT IF YOU REALLY WANT TO, you can '#define IMGUI_IMPL_OPENGL_LOADER_CUSTOM' and imgui_impl_opengl3.cpp
|
||||
// WILL NOT BE USING OUR LOADER, AND INSTEAD EXPECT ANOTHER/YOUR LOADER TO BE AVAILABLE IN THE COMPILATION UNIT.
|
||||
//
|
||||
// Regenerate with:
|
||||
// python3 gl3w_gen.py --output ../imgui/backends/imgui_impl_opengl3_loader.h --ref ../imgui/backends/imgui_impl_opengl3.cpp ./extra_symbols.txt
|
||||
//
|
||||
// More info:
|
||||
// https://github.com/dearimgui/gl3w_stripped
|
||||
// https://github.com/ocornut/imgui/issues/4445
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* This file was generated with gl3w_gen.py, part of imgl3w
|
||||
* (hosted at https://github.com/dearimgui/gl3w_stripped)
|
||||
*
|
||||
* This is free and unencumbered software released into the public domain.
|
||||
*
|
||||
* Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
* distribute this software, either in source code form or as a compiled
|
||||
* binary, for any purpose, commercial or non-commercial, and by any
|
||||
* means.
|
||||
*
|
||||
* In jurisdictions that recognize copyright laws, the author or authors
|
||||
* of this software dedicate any and all copyright interest in the
|
||||
* software to the public domain. We make this dedication for the benefit
|
||||
* of the public at large and to the detriment of our heirs and
|
||||
* successors. We intend this dedication to be an overt act of
|
||||
* relinquishment in perpetuity of all present and future rights to this
|
||||
* software under copyright law.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __gl3w_h_
|
||||
#define __gl3w_h_
|
||||
|
||||
// Adapted from KHR/khrplatform.h to avoid including entire file.
|
||||
#ifndef __khrplatform_h_
|
||||
typedef float khronos_float_t;
|
||||
typedef signed char khronos_int8_t;
|
||||
typedef unsigned char khronos_uint8_t;
|
||||
typedef signed short int khronos_int16_t;
|
||||
typedef unsigned short int khronos_uint16_t;
|
||||
#ifdef _WIN64
|
||||
typedef signed long long int khronos_intptr_t;
|
||||
typedef signed long long int khronos_ssize_t;
|
||||
#else
|
||||
typedef signed long int khronos_intptr_t;
|
||||
typedef signed long int khronos_ssize_t;
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
typedef signed __int64 khronos_int64_t;
|
||||
typedef unsigned __int64 khronos_uint64_t;
|
||||
#elif (defined(__clang__) || defined(__GNUC__)) && (__cplusplus < 201100)
|
||||
#include <stdint.h>
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#else
|
||||
typedef signed long long khronos_int64_t;
|
||||
typedef unsigned long long khronos_uint64_t;
|
||||
#endif
|
||||
#endif // __khrplatform_h_
|
||||
|
||||
#ifndef __gl_glcorearb_h_
|
||||
#define __gl_glcorearb_h_ 1
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
** Copyright 2013-2020 The Khronos Group Inc.
|
||||
** SPDX-License-Identifier: MIT
|
||||
**
|
||||
** This header is generated from the Khronos OpenGL / OpenGL ES XML
|
||||
** API Registry. The current version of the Registry, generator scripts
|
||||
** used to make the header, and the header can be found at
|
||||
** https://github.com/KhronosGroup/OpenGL-Registry
|
||||
*/
|
||||
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#ifndef APIENTRY
|
||||
#define APIENTRY
|
||||
#endif
|
||||
#ifndef APIENTRYP
|
||||
#define APIENTRYP APIENTRY *
|
||||
#endif
|
||||
#ifndef GLAPI
|
||||
#define GLAPI extern
|
||||
#endif
|
||||
/* glcorearb.h is for use with OpenGL core profile implementations.
|
||||
** It should should be placed in the same directory as gl.h and
|
||||
** included as <GL/glcorearb.h>.
|
||||
**
|
||||
** glcorearb.h includes only APIs in the latest OpenGL core profile
|
||||
** implementation together with APIs in newer ARB extensions which
|
||||
** can be supported by the core profile. It does not, and never will
|
||||
** include functionality removed from the core profile, such as
|
||||
** fixed-function vertex and fragment processing.
|
||||
**
|
||||
** Do not #include both <GL/glcorearb.h> and either of <GL/gl.h> or
|
||||
** <GL/glext.h> in the same source file.
|
||||
*/
|
||||
/* Generated C header for:
|
||||
* API: gl
|
||||
* Profile: core
|
||||
* Versions considered: .*
|
||||
* Versions emitted: .*
|
||||
* Default extensions included: glcore
|
||||
* Additional extensions included: _nomatch_^
|
||||
* Extensions removed: _nomatch_^
|
||||
*/
|
||||
#ifndef GL_VERSION_1_0
|
||||
typedef void GLvoid;
|
||||
typedef unsigned int GLenum;
|
||||
|
||||
typedef khronos_float_t GLfloat;
|
||||
typedef int GLint;
|
||||
typedef int GLsizei;
|
||||
typedef unsigned int GLbitfield;
|
||||
typedef double GLdouble;
|
||||
typedef unsigned int GLuint;
|
||||
typedef unsigned char GLboolean;
|
||||
typedef khronos_uint8_t GLubyte;
|
||||
#define GL_COLOR_BUFFER_BIT 0x00004000
|
||||
#define GL_FALSE 0
|
||||
#define GL_TRUE 1
|
||||
#define GL_TRIANGLES 0x0004
|
||||
#define GL_ONE 1
|
||||
#define GL_SRC_ALPHA 0x0302
|
||||
#define GL_ONE_MINUS_SRC_ALPHA 0x0303
|
||||
#define GL_FRONT 0x0404
|
||||
#define GL_BACK 0x0405
|
||||
#define GL_FRONT_AND_BACK 0x0408
|
||||
#define GL_POLYGON_MODE 0x0B40
|
||||
#define GL_CULL_FACE 0x0B44
|
||||
#define GL_DEPTH_TEST 0x0B71
|
||||
#define GL_STENCIL_TEST 0x0B90
|
||||
#define GL_VIEWPORT 0x0BA2
|
||||
#define GL_BLEND 0x0BE2
|
||||
#define GL_SCISSOR_BOX 0x0C10
|
||||
#define GL_SCISSOR_TEST 0x0C11
|
||||
#define GL_UNPACK_ROW_LENGTH 0x0CF2
|
||||
#define GL_PACK_ALIGNMENT 0x0D05
|
||||
#define GL_TEXTURE_2D 0x0DE1
|
||||
#define GL_UNSIGNED_BYTE 0x1401
|
||||
#define GL_UNSIGNED_SHORT 0x1403
|
||||
#define GL_UNSIGNED_INT 0x1405
|
||||
#define GL_FLOAT 0x1406
|
||||
#define GL_RGBA 0x1908
|
||||
#define GL_FILL 0x1B02
|
||||
#define GL_VENDOR 0x1F00
|
||||
#define GL_RENDERER 0x1F01
|
||||
#define GL_VERSION 0x1F02
|
||||
#define GL_EXTENSIONS 0x1F03
|
||||
#define GL_LINEAR 0x2601
|
||||
#define GL_TEXTURE_MAG_FILTER 0x2800
|
||||
#define GL_TEXTURE_MIN_FILTER 0x2801
|
||||
typedef void (APIENTRYP PFNGLPOLYGONMODEPROC) (GLenum face, GLenum mode);
|
||||
typedef void (APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param);
|
||||
typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);
|
||||
typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask);
|
||||
typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
|
||||
typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap);
|
||||
typedef void (APIENTRYP PFNGLENABLEPROC) (GLenum cap);
|
||||
typedef void (APIENTRYP PFNGLFLUSHPROC) (void);
|
||||
typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param);
|
||||
typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
|
||||
typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void);
|
||||
typedef void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data);
|
||||
typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGPROC) (GLenum name);
|
||||
typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC) (GLenum cap);
|
||||
typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glPolygonMode (GLenum face, GLenum mode);
|
||||
GLAPI void APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
GLAPI void APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
|
||||
GLAPI void APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);
|
||||
GLAPI void APIENTRY glClear (GLbitfield mask);
|
||||
GLAPI void APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
|
||||
GLAPI void APIENTRY glDisable (GLenum cap);
|
||||
GLAPI void APIENTRY glEnable (GLenum cap);
|
||||
GLAPI void APIENTRY glFlush (void);
|
||||
GLAPI void APIENTRY glPixelStorei (GLenum pname, GLint param);
|
||||
GLAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
|
||||
GLAPI GLenum APIENTRY glGetError (void);
|
||||
GLAPI void APIENTRY glGetIntegerv (GLenum pname, GLint *data);
|
||||
GLAPI const GLubyte *APIENTRY glGetString (GLenum name);
|
||||
GLAPI GLboolean APIENTRY glIsEnabled (GLenum cap);
|
||||
GLAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
#endif
|
||||
#endif /* GL_VERSION_1_0 */
|
||||
#ifndef GL_VERSION_1_1
|
||||
typedef khronos_float_t GLclampf;
|
||||
typedef double GLclampd;
|
||||
#define GL_TEXTURE_BINDING_2D 0x8069
|
||||
typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices);
|
||||
typedef void (APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture);
|
||||
typedef void (APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures);
|
||||
typedef void (APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures);
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices);
|
||||
GLAPI void APIENTRY glBindTexture (GLenum target, GLuint texture);
|
||||
GLAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);
|
||||
GLAPI void APIENTRY glGenTextures (GLsizei n, GLuint *textures);
|
||||
#endif
|
||||
#endif /* GL_VERSION_1_1 */
|
||||
#ifndef GL_VERSION_1_3
|
||||
#define GL_TEXTURE0 0x84C0
|
||||
#define GL_ACTIVE_TEXTURE 0x84E0
|
||||
typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glActiveTexture (GLenum texture);
|
||||
#endif
|
||||
#endif /* GL_VERSION_1_3 */
|
||||
#ifndef GL_VERSION_1_4
|
||||
#define GL_BLEND_DST_RGB 0x80C8
|
||||
#define GL_BLEND_SRC_RGB 0x80C9
|
||||
#define GL_BLEND_DST_ALPHA 0x80CA
|
||||
#define GL_BLEND_SRC_ALPHA 0x80CB
|
||||
#define GL_FUNC_ADD 0x8006
|
||||
typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
|
||||
typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
|
||||
GLAPI void APIENTRY glBlendEquation (GLenum mode);
|
||||
#endif
|
||||
#endif /* GL_VERSION_1_4 */
|
||||
#ifndef GL_VERSION_1_5
|
||||
typedef khronos_ssize_t GLsizeiptr;
|
||||
typedef khronos_intptr_t GLintptr;
|
||||
#define GL_ARRAY_BUFFER 0x8892
|
||||
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
|
||||
#define GL_ARRAY_BUFFER_BINDING 0x8894
|
||||
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
|
||||
#define GL_STREAM_DRAW 0x88E0
|
||||
typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
|
||||
typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers);
|
||||
typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
|
||||
typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage);
|
||||
typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data);
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer);
|
||||
GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers);
|
||||
GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers);
|
||||
GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage);
|
||||
GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data);
|
||||
#endif
|
||||
#endif /* GL_VERSION_1_5 */
|
||||
#ifndef GL_VERSION_2_0
|
||||
typedef char GLchar;
|
||||
typedef khronos_int16_t GLshort;
|
||||
typedef khronos_int8_t GLbyte;
|
||||
typedef khronos_uint16_t GLushort;
|
||||
#define GL_BLEND_EQUATION_RGB 0x8009
|
||||
#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
|
||||
#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
|
||||
#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
|
||||
#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
|
||||
#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
|
||||
#define GL_BLEND_EQUATION_ALPHA 0x883D
|
||||
#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
|
||||
#define GL_FRAGMENT_SHADER 0x8B30
|
||||
#define GL_VERTEX_SHADER 0x8B31
|
||||
#define GL_COMPILE_STATUS 0x8B81
|
||||
#define GL_LINK_STATUS 0x8B82
|
||||
#define GL_INFO_LOG_LENGTH 0x8B84
|
||||
#define GL_CURRENT_PROGRAM 0x8B8D
|
||||
#define GL_UPPER_LEFT 0x8CA2
|
||||
typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);
|
||||
typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
|
||||
typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader);
|
||||
typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void);
|
||||
typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type);
|
||||
typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program);
|
||||
typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader);
|
||||
typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);
|
||||
typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);
|
||||
typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
|
||||
typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);
|
||||
typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);
|
||||
typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
||||
typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
|
||||
typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
||||
typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
|
||||
typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params);
|
||||
typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer);
|
||||
typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program);
|
||||
typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program);
|
||||
typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
|
||||
typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program);
|
||||
typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0);
|
||||
typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
|
||||
GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader);
|
||||
GLAPI void APIENTRY glCompileShader (GLuint shader);
|
||||
GLAPI GLuint APIENTRY glCreateProgram (void);
|
||||
GLAPI GLuint APIENTRY glCreateShader (GLenum type);
|
||||
GLAPI void APIENTRY glDeleteProgram (GLuint program);
|
||||
GLAPI void APIENTRY glDeleteShader (GLuint shader);
|
||||
GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader);
|
||||
GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index);
|
||||
GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index);
|
||||
GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name);
|
||||
GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params);
|
||||
GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
||||
GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params);
|
||||
GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
||||
GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name);
|
||||
GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params);
|
||||
GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer);
|
||||
GLAPI GLboolean APIENTRY glIsProgram (GLuint program);
|
||||
GLAPI void APIENTRY glLinkProgram (GLuint program);
|
||||
GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
|
||||
GLAPI void APIENTRY glUseProgram (GLuint program);
|
||||
GLAPI void APIENTRY glUniform1i (GLint location, GLint v0);
|
||||
GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
|
||||
GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
|
||||
#endif
|
||||
#endif /* GL_VERSION_2_0 */
|
||||
#ifndef GL_VERSION_2_1
|
||||
#define GL_PIXEL_UNPACK_BUFFER 0x88EC
|
||||
#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
|
||||
#endif /* GL_VERSION_2_1 */
|
||||
#ifndef GL_VERSION_3_0
|
||||
typedef khronos_uint16_t GLhalf;
|
||||
#define GL_MAJOR_VERSION 0x821B
|
||||
#define GL_MINOR_VERSION 0x821C
|
||||
#define GL_NUM_EXTENSIONS 0x821D
|
||||
#define GL_FRAMEBUFFER_SRGB 0x8DB9
|
||||
#define GL_VERTEX_ARRAY_BINDING 0x85B5
|
||||
typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data);
|
||||
typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data);
|
||||
typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index);
|
||||
typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array);
|
||||
typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays);
|
||||
typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays);
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index);
|
||||
GLAPI void APIENTRY glBindVertexArray (GLuint array);
|
||||
GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays);
|
||||
GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays);
|
||||
#endif
|
||||
#endif /* GL_VERSION_3_0 */
|
||||
#ifndef GL_VERSION_3_1
|
||||
#define GL_VERSION_3_1 1
|
||||
#define GL_PRIMITIVE_RESTART 0x8F9D
|
||||
#endif /* GL_VERSION_3_1 */
|
||||
#ifndef GL_VERSION_3_2
|
||||
#define GL_VERSION_3_2 1
|
||||
typedef struct __GLsync *GLsync;
|
||||
typedef khronos_uint64_t GLuint64;
|
||||
typedef khronos_int64_t GLint64;
|
||||
#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
|
||||
#define GL_CONTEXT_PROFILE_MASK 0x9126
|
||||
typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex);
|
||||
typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data);
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex);
|
||||
#endif
|
||||
#endif /* GL_VERSION_3_2 */
|
||||
#ifndef GL_VERSION_3_3
|
||||
#define GL_VERSION_3_3 1
|
||||
#define GL_SAMPLER_BINDING 0x8919
|
||||
typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler);
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler);
|
||||
#endif
|
||||
#endif /* GL_VERSION_3_3 */
|
||||
#ifndef GL_VERSION_4_1
|
||||
typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data);
|
||||
typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data);
|
||||
#endif /* GL_VERSION_4_1 */
|
||||
#ifndef GL_VERSION_4_3
|
||||
typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
|
||||
#endif /* GL_VERSION_4_3 */
|
||||
#ifndef GL_VERSION_4_5
|
||||
#define GL_CLIP_ORIGIN 0x935C
|
||||
typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param);
|
||||
typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param);
|
||||
#endif /* GL_VERSION_4_5 */
|
||||
#ifndef GL_ARB_bindless_texture
|
||||
typedef khronos_uint64_t GLuint64EXT;
|
||||
#endif /* GL_ARB_bindless_texture */
|
||||
#ifndef GL_ARB_cl_event
|
||||
struct _cl_context;
|
||||
struct _cl_event;
|
||||
#endif /* GL_ARB_cl_event */
|
||||
#ifndef GL_ARB_clip_control
|
||||
#define GL_ARB_clip_control 1
|
||||
#endif /* GL_ARB_clip_control */
|
||||
#ifndef GL_ARB_debug_output
|
||||
typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
|
||||
#endif /* GL_ARB_debug_output */
|
||||
#ifndef GL_EXT_EGL_image_storage
|
||||
typedef void *GLeglImageOES;
|
||||
#endif /* GL_EXT_EGL_image_storage */
|
||||
#ifndef GL_EXT_direct_state_access
|
||||
typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params);
|
||||
typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params);
|
||||
typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params);
|
||||
typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param);
|
||||
typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param);
|
||||
#endif /* GL_EXT_direct_state_access */
|
||||
#ifndef GL_NV_draw_vulkan_image
|
||||
typedef void (APIENTRY *GLVULKANPROCNV)(void);
|
||||
#endif /* GL_NV_draw_vulkan_image */
|
||||
#ifndef GL_NV_gpu_shader5
|
||||
typedef khronos_int64_t GLint64EXT;
|
||||
#endif /* GL_NV_gpu_shader5 */
|
||||
#ifndef GL_NV_vertex_buffer_unified_memory
|
||||
typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result);
|
||||
#endif /* GL_NV_vertex_buffer_unified_memory */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GL3W_API
|
||||
#define GL3W_API
|
||||
#endif
|
||||
|
||||
#ifndef __gl_h_
|
||||
#define __gl_h_
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define GL3W_OK 0
|
||||
#define GL3W_ERROR_INIT -1
|
||||
#define GL3W_ERROR_LIBRARY_OPEN -2
|
||||
#define GL3W_ERROR_OPENGL_VERSION -3
|
||||
|
||||
typedef void (*GL3WglProc)(void);
|
||||
typedef GL3WglProc (*GL3WGetProcAddressProc)(const char *proc);
|
||||
|
||||
/* gl3w api */
|
||||
GL3W_API int imgl3wInit(void);
|
||||
GL3W_API int imgl3wInit2(GL3WGetProcAddressProc proc);
|
||||
GL3W_API int imgl3wIsSupported(int major, int minor);
|
||||
GL3W_API GL3WglProc imgl3wGetProcAddress(const char *proc);
|
||||
|
||||
/* gl3w internal state */
|
||||
union ImGL3WProcs {
|
||||
GL3WglProc ptr[59];
|
||||
struct {
|
||||
PFNGLACTIVETEXTUREPROC ActiveTexture;
|
||||
PFNGLATTACHSHADERPROC AttachShader;
|
||||
PFNGLBINDBUFFERPROC BindBuffer;
|
||||
PFNGLBINDSAMPLERPROC BindSampler;
|
||||
PFNGLBINDTEXTUREPROC BindTexture;
|
||||
PFNGLBINDVERTEXARRAYPROC BindVertexArray;
|
||||
PFNGLBLENDEQUATIONPROC BlendEquation;
|
||||
PFNGLBLENDEQUATIONSEPARATEPROC BlendEquationSeparate;
|
||||
PFNGLBLENDFUNCSEPARATEPROC BlendFuncSeparate;
|
||||
PFNGLBUFFERDATAPROC BufferData;
|
||||
PFNGLBUFFERSUBDATAPROC BufferSubData;
|
||||
PFNGLCLEARPROC Clear;
|
||||
PFNGLCLEARCOLORPROC ClearColor;
|
||||
PFNGLCOMPILESHADERPROC CompileShader;
|
||||
PFNGLCREATEPROGRAMPROC CreateProgram;
|
||||
PFNGLCREATESHADERPROC CreateShader;
|
||||
PFNGLDELETEBUFFERSPROC DeleteBuffers;
|
||||
PFNGLDELETEPROGRAMPROC DeleteProgram;
|
||||
PFNGLDELETESHADERPROC DeleteShader;
|
||||
PFNGLDELETETEXTURESPROC DeleteTextures;
|
||||
PFNGLDELETEVERTEXARRAYSPROC DeleteVertexArrays;
|
||||
PFNGLDETACHSHADERPROC DetachShader;
|
||||
PFNGLDISABLEPROC Disable;
|
||||
PFNGLDISABLEVERTEXATTRIBARRAYPROC DisableVertexAttribArray;
|
||||
PFNGLDRAWELEMENTSPROC DrawElements;
|
||||
PFNGLDRAWELEMENTSBASEVERTEXPROC DrawElementsBaseVertex;
|
||||
PFNGLENABLEPROC Enable;
|
||||
PFNGLENABLEVERTEXATTRIBARRAYPROC EnableVertexAttribArray;
|
||||
PFNGLFLUSHPROC Flush;
|
||||
PFNGLGENBUFFERSPROC GenBuffers;
|
||||
PFNGLGENTEXTURESPROC GenTextures;
|
||||
PFNGLGENVERTEXARRAYSPROC GenVertexArrays;
|
||||
PFNGLGETATTRIBLOCATIONPROC GetAttribLocation;
|
||||
PFNGLGETERRORPROC GetError;
|
||||
PFNGLGETINTEGERVPROC GetIntegerv;
|
||||
PFNGLGETPROGRAMINFOLOGPROC GetProgramInfoLog;
|
||||
PFNGLGETPROGRAMIVPROC GetProgramiv;
|
||||
PFNGLGETSHADERINFOLOGPROC GetShaderInfoLog;
|
||||
PFNGLGETSHADERIVPROC GetShaderiv;
|
||||
PFNGLGETSTRINGPROC GetString;
|
||||
PFNGLGETSTRINGIPROC GetStringi;
|
||||
PFNGLGETUNIFORMLOCATIONPROC GetUniformLocation;
|
||||
PFNGLGETVERTEXATTRIBPOINTERVPROC GetVertexAttribPointerv;
|
||||
PFNGLGETVERTEXATTRIBIVPROC GetVertexAttribiv;
|
||||
PFNGLISENABLEDPROC IsEnabled;
|
||||
PFNGLISPROGRAMPROC IsProgram;
|
||||
PFNGLLINKPROGRAMPROC LinkProgram;
|
||||
PFNGLPIXELSTOREIPROC PixelStorei;
|
||||
PFNGLPOLYGONMODEPROC PolygonMode;
|
||||
PFNGLREADPIXELSPROC ReadPixels;
|
||||
PFNGLSCISSORPROC Scissor;
|
||||
PFNGLSHADERSOURCEPROC ShaderSource;
|
||||
PFNGLTEXIMAGE2DPROC TexImage2D;
|
||||
PFNGLTEXPARAMETERIPROC TexParameteri;
|
||||
PFNGLUNIFORM1IPROC Uniform1i;
|
||||
PFNGLUNIFORMMATRIX4FVPROC UniformMatrix4fv;
|
||||
PFNGLUSEPROGRAMPROC UseProgram;
|
||||
PFNGLVERTEXATTRIBPOINTERPROC VertexAttribPointer;
|
||||
PFNGLVIEWPORTPROC Viewport;
|
||||
} gl;
|
||||
};
|
||||
|
||||
GL3W_API extern union ImGL3WProcs imgl3wProcs;
|
||||
|
||||
/* OpenGL functions */
|
||||
#define glActiveTexture imgl3wProcs.gl.ActiveTexture
|
||||
#define glAttachShader imgl3wProcs.gl.AttachShader
|
||||
#define glBindBuffer imgl3wProcs.gl.BindBuffer
|
||||
#define glBindSampler imgl3wProcs.gl.BindSampler
|
||||
#define glBindTexture imgl3wProcs.gl.BindTexture
|
||||
#define glBindVertexArray imgl3wProcs.gl.BindVertexArray
|
||||
#define glBlendEquation imgl3wProcs.gl.BlendEquation
|
||||
#define glBlendEquationSeparate imgl3wProcs.gl.BlendEquationSeparate
|
||||
#define glBlendFuncSeparate imgl3wProcs.gl.BlendFuncSeparate
|
||||
#define glBufferData imgl3wProcs.gl.BufferData
|
||||
#define glBufferSubData imgl3wProcs.gl.BufferSubData
|
||||
#define glClear imgl3wProcs.gl.Clear
|
||||
#define glClearColor imgl3wProcs.gl.ClearColor
|
||||
#define glCompileShader imgl3wProcs.gl.CompileShader
|
||||
#define glCreateProgram imgl3wProcs.gl.CreateProgram
|
||||
#define glCreateShader imgl3wProcs.gl.CreateShader
|
||||
#define glDeleteBuffers imgl3wProcs.gl.DeleteBuffers
|
||||
#define glDeleteProgram imgl3wProcs.gl.DeleteProgram
|
||||
#define glDeleteShader imgl3wProcs.gl.DeleteShader
|
||||
#define glDeleteTextures imgl3wProcs.gl.DeleteTextures
|
||||
#define glDeleteVertexArrays imgl3wProcs.gl.DeleteVertexArrays
|
||||
#define glDetachShader imgl3wProcs.gl.DetachShader
|
||||
#define glDisable imgl3wProcs.gl.Disable
|
||||
#define glDisableVertexAttribArray imgl3wProcs.gl.DisableVertexAttribArray
|
||||
#define glDrawElements imgl3wProcs.gl.DrawElements
|
||||
#define glDrawElementsBaseVertex imgl3wProcs.gl.DrawElementsBaseVertex
|
||||
#define glEnable imgl3wProcs.gl.Enable
|
||||
#define glEnableVertexAttribArray imgl3wProcs.gl.EnableVertexAttribArray
|
||||
#define glFlush imgl3wProcs.gl.Flush
|
||||
#define glGenBuffers imgl3wProcs.gl.GenBuffers
|
||||
#define glGenTextures imgl3wProcs.gl.GenTextures
|
||||
#define glGenVertexArrays imgl3wProcs.gl.GenVertexArrays
|
||||
#define glGetAttribLocation imgl3wProcs.gl.GetAttribLocation
|
||||
#define glGetError imgl3wProcs.gl.GetError
|
||||
#define glGetIntegerv imgl3wProcs.gl.GetIntegerv
|
||||
#define glGetProgramInfoLog imgl3wProcs.gl.GetProgramInfoLog
|
||||
#define glGetProgramiv imgl3wProcs.gl.GetProgramiv
|
||||
#define glGetShaderInfoLog imgl3wProcs.gl.GetShaderInfoLog
|
||||
#define glGetShaderiv imgl3wProcs.gl.GetShaderiv
|
||||
#define glGetString imgl3wProcs.gl.GetString
|
||||
#define glGetStringi imgl3wProcs.gl.GetStringi
|
||||
#define glGetUniformLocation imgl3wProcs.gl.GetUniformLocation
|
||||
#define glGetVertexAttribPointerv imgl3wProcs.gl.GetVertexAttribPointerv
|
||||
#define glGetVertexAttribiv imgl3wProcs.gl.GetVertexAttribiv
|
||||
#define glIsEnabled imgl3wProcs.gl.IsEnabled
|
||||
#define glIsProgram imgl3wProcs.gl.IsProgram
|
||||
#define glLinkProgram imgl3wProcs.gl.LinkProgram
|
||||
#define glPixelStorei imgl3wProcs.gl.PixelStorei
|
||||
#define glPolygonMode imgl3wProcs.gl.PolygonMode
|
||||
#define glReadPixels imgl3wProcs.gl.ReadPixels
|
||||
#define glScissor imgl3wProcs.gl.Scissor
|
||||
#define glShaderSource imgl3wProcs.gl.ShaderSource
|
||||
#define glTexImage2D imgl3wProcs.gl.TexImage2D
|
||||
#define glTexParameteri imgl3wProcs.gl.TexParameteri
|
||||
#define glUniform1i imgl3wProcs.gl.Uniform1i
|
||||
#define glUniformMatrix4fv imgl3wProcs.gl.UniformMatrix4fv
|
||||
#define glUseProgram imgl3wProcs.gl.UseProgram
|
||||
#define glVertexAttribPointer imgl3wProcs.gl.VertexAttribPointer
|
||||
#define glViewport imgl3wProcs.gl.Viewport
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef IMGL3W_IMPL
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define GL3W_ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
#if defined(_WIN32)
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#endif
|
||||
#include <windows.h>
|
||||
|
||||
static HMODULE libgl;
|
||||
typedef PROC(__stdcall* GL3WglGetProcAddr)(LPCSTR);
|
||||
static GL3WglGetProcAddr wgl_get_proc_address;
|
||||
|
||||
static int open_libgl(void)
|
||||
{
|
||||
libgl = LoadLibraryA("opengl32.dll");
|
||||
if (!libgl)
|
||||
return GL3W_ERROR_LIBRARY_OPEN;
|
||||
wgl_get_proc_address = (GL3WglGetProcAddr)GetProcAddress(libgl, "wglGetProcAddress");
|
||||
return GL3W_OK;
|
||||
}
|
||||
|
||||
static void close_libgl(void) { FreeLibrary(libgl); }
|
||||
static GL3WglProc get_proc(const char *proc)
|
||||
{
|
||||
GL3WglProc res;
|
||||
res = (GL3WglProc)wgl_get_proc_address(proc);
|
||||
if (!res)
|
||||
res = (GL3WglProc)GetProcAddress(libgl, proc);
|
||||
return res;
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
#include <dlfcn.h>
|
||||
|
||||
static void *libgl;
|
||||
static int open_libgl(void)
|
||||
{
|
||||
libgl = dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY | RTLD_LOCAL);
|
||||
if (!libgl)
|
||||
return GL3W_ERROR_LIBRARY_OPEN;
|
||||
return GL3W_OK;
|
||||
}
|
||||
|
||||
static void close_libgl(void) { dlclose(libgl); }
|
||||
|
||||
static GL3WglProc get_proc(const char *proc)
|
||||
{
|
||||
GL3WglProc res;
|
||||
*(void **)(&res) = dlsym(libgl, proc);
|
||||
return res;
|
||||
}
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
|
||||
static void* libgl; // OpenGL library
|
||||
static void* libglx; // GLX library
|
||||
static void* libegl; // EGL library
|
||||
static GL3WGetProcAddressProc gl_get_proc_address;
|
||||
|
||||
static void close_libgl(void)
|
||||
{
|
||||
if (libgl) {
|
||||
dlclose(libgl);
|
||||
libgl = NULL;
|
||||
}
|
||||
if (libegl) {
|
||||
dlclose(libegl);
|
||||
libegl = NULL;
|
||||
}
|
||||
if (libglx) {
|
||||
dlclose(libglx);
|
||||
libglx = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int is_library_loaded(const char* name, void** lib)
|
||||
{
|
||||
*lib = dlopen(name, RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD);
|
||||
return *lib != NULL;
|
||||
}
|
||||
|
||||
static int open_libs(void)
|
||||
{
|
||||
// On Linux we have two APIs to get process addresses: EGL and GLX.
|
||||
// EGL is supported under both X11 and Wayland, whereas GLX is X11-specific.
|
||||
|
||||
libgl = NULL;
|
||||
libegl = NULL;
|
||||
libglx = NULL;
|
||||
|
||||
// First check what's already loaded, the windowing library might have
|
||||
// already loaded either EGL or GLX and we want to use the same one.
|
||||
|
||||
if (is_library_loaded("libEGL.so.1", &libegl) ||
|
||||
is_library_loaded("libGLX.so.0", &libglx)) {
|
||||
libgl = dlopen("libOpenGL.so.0", RTLD_LAZY | RTLD_LOCAL);
|
||||
if (libgl)
|
||||
return GL3W_OK;
|
||||
else
|
||||
close_libgl();
|
||||
}
|
||||
|
||||
if (is_library_loaded("libGL.so", &libgl))
|
||||
return GL3W_OK;
|
||||
if (is_library_loaded("libGL.so.1", &libgl))
|
||||
return GL3W_OK;
|
||||
if (is_library_loaded("libGL.so.3", &libgl))
|
||||
return GL3W_OK;
|
||||
|
||||
// Neither is already loaded, so we have to load one. Try EGL first
|
||||
// because it is supported under both X11 and Wayland.
|
||||
|
||||
// Load OpenGL + EGL
|
||||
libgl = dlopen("libOpenGL.so.0", RTLD_LAZY | RTLD_LOCAL);
|
||||
libegl = dlopen("libEGL.so.1", RTLD_LAZY | RTLD_LOCAL);
|
||||
if (libgl && libegl)
|
||||
return GL3W_OK;
|
||||
else
|
||||
close_libgl();
|
||||
|
||||
// Fall back to legacy libGL, which includes GLX
|
||||
// While most systems use libGL.so.1, NetBSD seems to use that libGL.so.3. See https://github.com/ocornut/imgui/issues/6983
|
||||
libgl = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL);
|
||||
if (!libgl)
|
||||
libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL);
|
||||
if (!libgl)
|
||||
libgl = dlopen("libGL.so.3", RTLD_LAZY | RTLD_LOCAL);
|
||||
|
||||
if (libgl)
|
||||
return GL3W_OK;
|
||||
|
||||
return GL3W_ERROR_LIBRARY_OPEN;
|
||||
}
|
||||
|
||||
static int open_libgl(void)
|
||||
{
|
||||
int res = open_libs();
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
if (libegl)
|
||||
*(void**)(&gl_get_proc_address) = dlsym(libegl, "eglGetProcAddress");
|
||||
else if (libglx)
|
||||
*(void**)(&gl_get_proc_address) = dlsym(libglx, "glXGetProcAddressARB");
|
||||
else
|
||||
*(void**)(&gl_get_proc_address) = dlsym(libgl, "glXGetProcAddressARB");
|
||||
|
||||
if (!gl_get_proc_address) {
|
||||
close_libgl();
|
||||
return GL3W_ERROR_LIBRARY_OPEN;
|
||||
}
|
||||
|
||||
return GL3W_OK;
|
||||
}
|
||||
|
||||
static GL3WglProc get_proc(const char* proc)
|
||||
{
|
||||
GL3WglProc res = NULL;
|
||||
|
||||
// Before EGL version 1.5, eglGetProcAddress doesn't support querying core
|
||||
// functions and may return a dummy function if we try, so try to load the
|
||||
// function from the GL library directly first.
|
||||
if (libegl)
|
||||
*(void**)(&res) = dlsym(libgl, proc);
|
||||
|
||||
if (!res)
|
||||
res = gl_get_proc_address(proc);
|
||||
|
||||
if (!libegl && !res)
|
||||
*(void**)(&res) = dlsym(libgl, proc);
|
||||
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct { int major, minor; } version;
|
||||
|
||||
static int parse_version(void)
|
||||
{
|
||||
if (!glGetIntegerv)
|
||||
return GL3W_ERROR_INIT;
|
||||
glGetIntegerv(GL_MAJOR_VERSION, &version.major);
|
||||
glGetIntegerv(GL_MINOR_VERSION, &version.minor);
|
||||
if (version.major == 0 && version.minor == 0)
|
||||
{
|
||||
// Query GL_VERSION in desktop GL 2.x, the string will start with "<major>.<minor>"
|
||||
if (const char* gl_version = (const char*)glGetString(GL_VERSION))
|
||||
sscanf(gl_version, "%d.%d", &version.major, &version.minor);
|
||||
}
|
||||
if (version.major < 2)
|
||||
return GL3W_ERROR_OPENGL_VERSION;
|
||||
return GL3W_OK;
|
||||
}
|
||||
|
||||
static void load_procs(GL3WGetProcAddressProc proc);
|
||||
|
||||
int imgl3wInit(void)
|
||||
{
|
||||
int res = open_libgl();
|
||||
if (res)
|
||||
return res;
|
||||
atexit(close_libgl);
|
||||
return imgl3wInit2(get_proc);
|
||||
}
|
||||
|
||||
int imgl3wInit2(GL3WGetProcAddressProc proc)
|
||||
{
|
||||
load_procs(proc);
|
||||
return parse_version();
|
||||
}
|
||||
|
||||
int imgl3wIsSupported(int major, int minor)
|
||||
{
|
||||
if (major < 2)
|
||||
return 0;
|
||||
if (version.major == major)
|
||||
return version.minor >= minor;
|
||||
return version.major >= major;
|
||||
}
|
||||
|
||||
GL3WglProc imgl3wGetProcAddress(const char *proc) { return get_proc(proc); }
|
||||
|
||||
static const char *proc_names[] = {
|
||||
"glActiveTexture",
|
||||
"glAttachShader",
|
||||
"glBindBuffer",
|
||||
"glBindSampler",
|
||||
"glBindTexture",
|
||||
"glBindVertexArray",
|
||||
"glBlendEquation",
|
||||
"glBlendEquationSeparate",
|
||||
"glBlendFuncSeparate",
|
||||
"glBufferData",
|
||||
"glBufferSubData",
|
||||
"glClear",
|
||||
"glClearColor",
|
||||
"glCompileShader",
|
||||
"glCreateProgram",
|
||||
"glCreateShader",
|
||||
"glDeleteBuffers",
|
||||
"glDeleteProgram",
|
||||
"glDeleteShader",
|
||||
"glDeleteTextures",
|
||||
"glDeleteVertexArrays",
|
||||
"glDetachShader",
|
||||
"glDisable",
|
||||
"glDisableVertexAttribArray",
|
||||
"glDrawElements",
|
||||
"glDrawElementsBaseVertex",
|
||||
"glEnable",
|
||||
"glEnableVertexAttribArray",
|
||||
"glFlush",
|
||||
"glGenBuffers",
|
||||
"glGenTextures",
|
||||
"glGenVertexArrays",
|
||||
"glGetAttribLocation",
|
||||
"glGetError",
|
||||
"glGetIntegerv",
|
||||
"glGetProgramInfoLog",
|
||||
"glGetProgramiv",
|
||||
"glGetShaderInfoLog",
|
||||
"glGetShaderiv",
|
||||
"glGetString",
|
||||
"glGetStringi",
|
||||
"glGetUniformLocation",
|
||||
"glGetVertexAttribPointerv",
|
||||
"glGetVertexAttribiv",
|
||||
"glIsEnabled",
|
||||
"glIsProgram",
|
||||
"glLinkProgram",
|
||||
"glPixelStorei",
|
||||
"glPolygonMode",
|
||||
"glReadPixels",
|
||||
"glScissor",
|
||||
"glShaderSource",
|
||||
"glTexImage2D",
|
||||
"glTexParameteri",
|
||||
"glUniform1i",
|
||||
"glUniformMatrix4fv",
|
||||
"glUseProgram",
|
||||
"glVertexAttribPointer",
|
||||
"glViewport",
|
||||
};
|
||||
|
||||
GL3W_API union ImGL3WProcs imgl3wProcs;
|
||||
|
||||
static void load_procs(GL3WGetProcAddressProc proc)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < GL3W_ARRAY_SIZE(proc_names); i++)
|
||||
imgl3wProcs.ptr[i] = proc(proc_names[i]);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
1150
src/external/imgui/imgui/backends/imgui_impl_sdl2.cpp
vendored
Normal file
1150
src/external/imgui/imgui/backends/imgui_impl_sdl2.cpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
49
src/external/imgui/imgui/backends/imgui_impl_sdl2.h
vendored
Normal file
49
src/external/imgui/imgui/backends/imgui_impl_sdl2.h
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
// dear imgui: Platform Backend for SDL2
|
||||
// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
|
||||
// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Platform: Clipboard support.
|
||||
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen.
|
||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||
// Issues:
|
||||
// [ ] Platform: Multi-viewport: Minimized windows seems to break mouse wheel events (at least under Windows).
|
||||
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
|
||||
// [x] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
||||
|
||||
// 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
|
||||
|
||||
struct SDL_Window;
|
||||
struct SDL_Renderer;
|
||||
struct _SDL_GameController;
|
||||
typedef union SDL_Event SDL_Event;
|
||||
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window);
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window);
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer);
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOther(SDL_Window* window);
|
||||
IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame();
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
||||
|
||||
// Gamepad selection automatically starts in AutoFirst mode, picking first available SDL_Gamepad. You may override this.
|
||||
// When using manual mode, caller is responsible for opening/closing gamepad.
|
||||
enum ImGui_ImplSDL2_GamepadMode { ImGui_ImplSDL2_GamepadMode_AutoFirst, ImGui_ImplSDL2_GamepadMode_AutoAll, ImGui_ImplSDL2_GamepadMode_Manual };
|
||||
IMGUI_IMPL_API void ImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode mode, struct _SDL_GameController** manual_gamepads_array = NULL, int manual_gamepads_count = -1);
|
||||
|
||||
#endif // #ifndef IMGUI_DISABLE
|
2827
src/external/imgui/imgui/cimgui.h
vendored
2827
src/external/imgui/imgui/cimgui.h
vendored
File diff suppressed because it is too large
Load diff
32
src/external/imgui/imgui/cimgui_sdl.cpp
vendored
32
src/external/imgui/imgui/cimgui_sdl.cpp
vendored
|
@ -1,32 +0,0 @@
|
|||
#include "imgui.h"
|
||||
#include "imgui_internal.h"
|
||||
#include "cimgui.h"
|
||||
#include "imgui_impl_sdl.h"
|
||||
|
||||
|
||||
CIMGUI_API bool igImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
|
||||
{
|
||||
return ImGui_ImplSDL2_InitForOpenGL(window, sdl_gl_context);
|
||||
}
|
||||
#if 0
|
||||
CIMGUI_API bool igImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
|
||||
{
|
||||
return ImGui_ImplSDL2_InitForVulkan(window);
|
||||
}
|
||||
CIMGUI_API bool igImGui_ImplSDL2_InitForD3D(SDL_Window* window)
|
||||
{
|
||||
return ImGui_ImplSDL2_InitForD3D(window);
|
||||
}
|
||||
#endif
|
||||
CIMGUI_API void igImGui_ImplSDL2_Shutdown()
|
||||
{
|
||||
ImGui_ImplSDL2_Shutdown();
|
||||
}
|
||||
CIMGUI_API void igImGui_ImplSDL2_NewFrame(SDL_Window* window)
|
||||
{
|
||||
ImGui_ImplSDL2_NewFrame(window);
|
||||
}
|
||||
CIMGUI_API bool igImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
||||
{
|
||||
return ImGui_ImplSDL2_ProcessEvent(event);
|
||||
}
|
1181
src/external/imgui/imgui/cimplot.cpp
vendored
1181
src/external/imgui/imgui/cimplot.cpp
vendored
File diff suppressed because it is too large
Load diff
527
src/external/imgui/imgui/cimplot.h
vendored
527
src/external/imgui/imgui/cimplot.h
vendored
|
@ -1,527 +0,0 @@
|
|||
//This file is automatically generated by generator.lua from https://github.com/cimgui/cimplot
|
||||
//based on implot.h file version 0.8 WIP from implot https://github.com/epezent/implot
|
||||
#ifndef CIMGUIPLOT_INCLUDED
|
||||
#define CIMGUIPLOT_INCLUDED
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
#ifdef CIMGUI_NO_EXPORT
|
||||
#define API
|
||||
#else
|
||||
#define API __declspec(dllexport)
|
||||
#endif
|
||||
#ifndef __GNUC__
|
||||
#define snprintf sprintf_s
|
||||
#endif
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
#define API __attribute__((__visibility__("default")))
|
||||
#else
|
||||
#define API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
#else
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#define CIMGUI_API EXTERN API
|
||||
#define CONST const
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef unsigned __int64 ImU64;
|
||||
#else
|
||||
//typedef unsigned long long ImU64;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
typedef struct ImPlotInputMap ImPlotInputMap;
|
||||
typedef struct ImPlotStyle ImPlotStyle;
|
||||
typedef struct ImPlotLimits ImPlotLimits;
|
||||
typedef struct ImPlotRange ImPlotRange;
|
||||
typedef struct ImPlotPoint ImPlotPoint;
|
||||
typedef struct ImPlotContext ImPlotContext;
|
||||
|
||||
struct ImPlotContext;
|
||||
typedef int ImPlotFlags;
|
||||
typedef int ImPlotAxisFlags;
|
||||
typedef int ImPlotCol;
|
||||
typedef int ImPlotStyleVar;
|
||||
typedef int ImPlotMarker;
|
||||
typedef int ImPlotColormap;
|
||||
typedef enum {
|
||||
ImPlotFlags_None = 0,
|
||||
ImPlotFlags_NoLegend = 1 << 0,
|
||||
ImPlotFlags_NoMenus = 1 << 1,
|
||||
ImPlotFlags_NoBoxSelect = 1 << 2,
|
||||
ImPlotFlags_NoMousePos = 1 << 3,
|
||||
ImPlotFlags_NoHighlight = 1 << 4,
|
||||
ImPlotFlags_NoChild = 1 << 5,
|
||||
ImPlotFlags_YAxis2 = 1 << 6,
|
||||
ImPlotFlags_YAxis3 = 1 << 7,
|
||||
ImPlotFlags_Query = 1 << 8,
|
||||
ImPlotFlags_Crosshairs = 1 << 9,
|
||||
ImPlotFlags_AntiAliased = 1 << 10,
|
||||
ImPlotFlags_CanvasOnly = ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMousePos
|
||||
}ImPlotFlags_;
|
||||
typedef enum {
|
||||
ImPlotAxisFlags_None = 0,
|
||||
ImPlotAxisFlags_NoGridLines = 1 << 0,
|
||||
ImPlotAxisFlags_NoTickMarks = 1 << 1,
|
||||
ImPlotAxisFlags_NoTickLabels = 1 << 2,
|
||||
ImPlotAxisFlags_LogScale = 1 << 3,
|
||||
ImPlotAxisFlags_Time = 1 << 4,
|
||||
ImPlotAxisFlags_Invert = 1 << 5,
|
||||
ImPlotAxisFlags_LockMin = 1 << 6,
|
||||
ImPlotAxisFlags_LockMax = 1 << 7,
|
||||
ImPlotAxisFlags_Lock = ImPlotAxisFlags_LockMin | ImPlotAxisFlags_LockMax,
|
||||
ImPlotAxisFlags_NoDecorations = ImPlotAxisFlags_NoGridLines | ImPlotAxisFlags_NoTickMarks | ImPlotAxisFlags_NoTickLabels
|
||||
}ImPlotAxisFlags_;
|
||||
typedef enum {
|
||||
ImPlotCol_Line,
|
||||
ImPlotCol_Fill,
|
||||
ImPlotCol_MarkerOutline,
|
||||
ImPlotCol_MarkerFill,
|
||||
ImPlotCol_ErrorBar,
|
||||
ImPlotCol_FrameBg,
|
||||
ImPlotCol_PlotBg,
|
||||
ImPlotCol_PlotBorder,
|
||||
ImPlotCol_LegendBg,
|
||||
ImPlotCol_LegendBorder,
|
||||
ImPlotCol_LegendText,
|
||||
ImPlotCol_TitleText,
|
||||
ImPlotCol_InlayText,
|
||||
ImPlotCol_XAxis,
|
||||
ImPlotCol_XAxisGrid,
|
||||
ImPlotCol_YAxis,
|
||||
ImPlotCol_YAxisGrid,
|
||||
ImPlotCol_YAxis2,
|
||||
ImPlotCol_YAxisGrid2,
|
||||
ImPlotCol_YAxis3,
|
||||
ImPlotCol_YAxisGrid3,
|
||||
ImPlotCol_Selection,
|
||||
ImPlotCol_Query,
|
||||
ImPlotCol_Crosshairs,
|
||||
ImPlotCol_COUNT
|
||||
}ImPlotCol_;
|
||||
typedef enum {
|
||||
ImPlotStyleVar_LineWeight,
|
||||
ImPlotStyleVar_Marker,
|
||||
ImPlotStyleVar_MarkerSize,
|
||||
ImPlotStyleVar_MarkerWeight,
|
||||
ImPlotStyleVar_FillAlpha,
|
||||
ImPlotStyleVar_ErrorBarSize,
|
||||
ImPlotStyleVar_ErrorBarWeight,
|
||||
ImPlotStyleVar_DigitalBitHeight,
|
||||
ImPlotStyleVar_DigitalBitGap,
|
||||
ImPlotStyleVar_PlotBorderSize,
|
||||
ImPlotStyleVar_MinorAlpha,
|
||||
ImPlotStyleVar_MajorTickLen,
|
||||
ImPlotStyleVar_MinorTickLen,
|
||||
ImPlotStyleVar_MajorTickSize,
|
||||
ImPlotStyleVar_MinorTickSize,
|
||||
ImPlotStyleVar_MajorGridSize,
|
||||
ImPlotStyleVar_MinorGridSize,
|
||||
ImPlotStyleVar_PlotPadding,
|
||||
ImPlotStyleVar_LabelPadding,
|
||||
ImPlotStyleVar_LegendPadding,
|
||||
ImPlotStyleVar_InfoPadding,
|
||||
ImPlotStyleVar_PlotMinSize,
|
||||
ImPlotStyleVar_COUNT
|
||||
}ImPlotStyleVar_;
|
||||
typedef enum {
|
||||
ImPlotMarker_None = -1,
|
||||
ImPlotMarker_Circle,
|
||||
ImPlotMarker_Square,
|
||||
ImPlotMarker_Diamond,
|
||||
ImPlotMarker_Up,
|
||||
ImPlotMarker_Down,
|
||||
ImPlotMarker_Left,
|
||||
ImPlotMarker_Right,
|
||||
ImPlotMarker_Cross,
|
||||
ImPlotMarker_Plus,
|
||||
ImPlotMarker_Asterisk,
|
||||
ImPlotMarker_COUNT
|
||||
}ImPlotMarker_;
|
||||
typedef enum {
|
||||
ImPlotColormap_Default = 0,
|
||||
ImPlotColormap_Deep = 1,
|
||||
ImPlotColormap_Dark = 2,
|
||||
ImPlotColormap_Pastel = 3,
|
||||
ImPlotColormap_Paired = 4,
|
||||
ImPlotColormap_Viridis = 5,
|
||||
ImPlotColormap_Plasma = 6,
|
||||
ImPlotColormap_Hot = 7,
|
||||
ImPlotColormap_Cool = 8,
|
||||
ImPlotColormap_Pink = 9,
|
||||
ImPlotColormap_Jet = 10,
|
||||
ImPlotColormap_COUNT
|
||||
}ImPlotColormap_;
|
||||
struct ImPlotPoint
|
||||
{
|
||||
double x, y;
|
||||
};
|
||||
struct ImPlotRange
|
||||
{
|
||||
double Min, Max;
|
||||
};
|
||||
struct ImPlotLimits
|
||||
{
|
||||
ImPlotRange X, Y;
|
||||
};
|
||||
struct ImPlotStyle
|
||||
{
|
||||
float LineWeight;
|
||||
int Marker;
|
||||
float MarkerSize;
|
||||
float MarkerWeight;
|
||||
float FillAlpha;
|
||||
float ErrorBarSize;
|
||||
float ErrorBarWeight;
|
||||
float DigitalBitHeight;
|
||||
float DigitalBitGap;
|
||||
float PlotBorderSize;
|
||||
float MinorAlpha;
|
||||
ImVec2 MajorTickLen;
|
||||
ImVec2 MinorTickLen;
|
||||
ImVec2 MajorTickSize;
|
||||
ImVec2 MinorTickSize;
|
||||
ImVec2 MajorGridSize;
|
||||
ImVec2 MinorGridSize;
|
||||
ImVec2 PlotPadding;
|
||||
ImVec2 LabelPadding;
|
||||
ImVec2 LegendPadding;
|
||||
ImVec2 InfoPadding;
|
||||
ImVec2 PlotMinSize;
|
||||
ImVec4 Colors[ImPlotCol_COUNT];
|
||||
bool AntiAliasedLines;
|
||||
bool UseLocalTime;
|
||||
};
|
||||
struct ImPlotInputMap
|
||||
{
|
||||
ImGuiMouseButton PanButton;
|
||||
ImGuiKeyModFlags PanMod;
|
||||
ImGuiMouseButton FitButton;
|
||||
ImGuiMouseButton ContextMenuButton;
|
||||
ImGuiMouseButton BoxSelectButton;
|
||||
ImGuiKeyModFlags BoxSelectMod;
|
||||
ImGuiMouseButton BoxSelectCancelButton;
|
||||
ImGuiMouseButton QueryButton;
|
||||
ImGuiKeyModFlags QueryMod;
|
||||
ImGuiKeyModFlags QueryToggleMod;
|
||||
ImGuiKeyModFlags HorizontalMod;
|
||||
ImGuiKeyModFlags VerticalMod;
|
||||
};
|
||||
#else
|
||||
|
||||
#endif // CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
|
||||
#ifndef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
#endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
CIMGUI_API ImPlotPoint* ImPlotPoint_ImPlotPointNil(void);
|
||||
CIMGUI_API void ImPlotPoint_destroy(ImPlotPoint* self);
|
||||
CIMGUI_API ImPlotPoint* ImPlotPoint_ImPlotPointdouble(double _x,double _y);
|
||||
CIMGUI_API ImPlotRange* ImPlotRange_ImPlotRangeNil(void);
|
||||
CIMGUI_API void ImPlotRange_destroy(ImPlotRange* self);
|
||||
CIMGUI_API ImPlotRange* ImPlotRange_ImPlotRangedouble(double _min,double _max);
|
||||
CIMGUI_API bool ImPlotRange_Contains(ImPlotRange* self,double value);
|
||||
CIMGUI_API double ImPlotRange_Size(ImPlotRange* self);
|
||||
CIMGUI_API bool ImPlotLimits_ContainsPlotPoInt(ImPlotLimits* self,const ImPlotPoint p);
|
||||
CIMGUI_API bool ImPlotLimits_Containsdouble(ImPlotLimits* self,double x,double y);
|
||||
CIMGUI_API ImPlotStyle* ImPlotStyle_ImPlotStyle(void);
|
||||
CIMGUI_API void ImPlotStyle_destroy(ImPlotStyle* self);
|
||||
CIMGUI_API ImPlotInputMap* ImPlotInputMap_ImPlotInputMap(void);
|
||||
CIMGUI_API void ImPlotInputMap_destroy(ImPlotInputMap* self);
|
||||
CIMGUI_API ImPlotContext* ImPlot_CreateContext(void);
|
||||
CIMGUI_API void ImPlot_DestroyContext(ImPlotContext* ctx);
|
||||
CIMGUI_API ImPlotContext* ImPlot_GetCurrentContext(void);
|
||||
CIMGUI_API void ImPlot_SetCurrentContext(ImPlotContext* ctx);
|
||||
CIMGUI_API bool ImPlot_BeginPlot(const char* title_id,const char* x_label,const char* y_label,const ImVec2 size,ImPlotFlags flags,ImPlotAxisFlags x_flags,ImPlotAxisFlags y_flags,ImPlotAxisFlags y2_flags,ImPlotAxisFlags y3_flags);
|
||||
CIMGUI_API void ImPlot_EndPlot(void);
|
||||
CIMGUI_API void ImPlot_PlotLineFloatPtrInt(const char* label_id,const float* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLinedoublePtrInt(const char* label_id,const double* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineS8PtrInt(const char* label_id,const ImS8* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineU8PtrInt(const char* label_id,const ImU8* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineS16PtrInt(const char* label_id,const ImS16* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineU16PtrInt(const char* label_id,const ImU16* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineS32PtrInt(const char* label_id,const ImS32* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineU32PtrInt(const char* label_id,const ImU32* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineS64PtrInt(const char* label_id,const ImS64* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineU64PtrInt(const char* label_id,const ImU64* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineFloatPtrFloatPtr(const char* label_id,const float* xs,const float* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLinedoublePtrdoublePtr(const char* label_id,const double* xs,const double* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineS8PtrS8Ptr(const char* label_id,const ImS8* xs,const ImS8* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineU8PtrU8Ptr(const char* label_id,const ImU8* xs,const ImU8* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineS16PtrS16Ptr(const char* label_id,const ImS16* xs,const ImS16* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineU16PtrU16Ptr(const char* label_id,const ImU16* xs,const ImU16* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineS32PtrS32Ptr(const char* label_id,const ImS32* xs,const ImS32* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineU32PtrU32Ptr(const char* label_id,const ImU32* xs,const ImU32* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineS64PtrS64Ptr(const char* label_id,const ImS64* xs,const ImS64* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineU64PtrU64Ptr(const char* label_id,const ImU64* xs,const ImU64* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotLineG(const char* label_id,ImPlotPoint(*getter)(void* data,int idx),void* data,int count,int offset);
|
||||
CIMGUI_API void ImPlot_PlotScatterFloatPtrInt(const char* label_id,const float* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterdoublePtrInt(const char* label_id,const double* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterS8PtrInt(const char* label_id,const ImS8* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterU8PtrInt(const char* label_id,const ImU8* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterS16PtrInt(const char* label_id,const ImS16* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterU16PtrInt(const char* label_id,const ImU16* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterS32PtrInt(const char* label_id,const ImS32* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterU32PtrInt(const char* label_id,const ImU32* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterS64PtrInt(const char* label_id,const ImS64* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterU64PtrInt(const char* label_id,const ImU64* values,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterFloatPtrFloatPtr(const char* label_id,const float* xs,const float* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterdoublePtrdoublePtr(const char* label_id,const double* xs,const double* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterS8PtrS8Ptr(const char* label_id,const ImS8* xs,const ImS8* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterU8PtrU8Ptr(const char* label_id,const ImU8* xs,const ImU8* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterS16PtrS16Ptr(const char* label_id,const ImS16* xs,const ImS16* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterU16PtrU16Ptr(const char* label_id,const ImU16* xs,const ImU16* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterS32PtrS32Ptr(const char* label_id,const ImS32* xs,const ImS32* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterU32PtrU32Ptr(const char* label_id,const ImU32* xs,const ImU32* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterS64PtrS64Ptr(const char* label_id,const ImS64* xs,const ImS64* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterU64PtrU64Ptr(const char* label_id,const ImU64* xs,const ImU64* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotScatterG(const char* label_id,ImPlotPoint(*getter)(void* data,int idx),void* data,int count,int offset);
|
||||
CIMGUI_API void ImPlot_PlotShadedFloatPtrIntdoubleInt(const char* label_id,const float* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadeddoublePtrIntdoubleInt(const char* label_id,const double* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedS8PtrIntdoubleInt(const char* label_id,const ImS8* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedU8PtrIntdoubleInt(const char* label_id,const ImU8* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedS16PtrIntdoubleInt(const char* label_id,const ImS16* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedU16PtrIntdoubleInt(const char* label_id,const ImU16* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedS32PtrIntdoubleInt(const char* label_id,const ImS32* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedU32PtrIntdoubleInt(const char* label_id,const ImU32* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedS64PtrIntdoubleInt(const char* label_id,const ImS64* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedU64PtrIntdoubleInt(const char* label_id,const ImU64* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedFloatPtrFloatPtrIntdoubleInt(const char* label_id,const float* xs,const float* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadeddoublePtrdoublePtrIntdoubleInt(const char* label_id,const double* xs,const double* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedS8PtrS8PtrIntdoubleInt(const char* label_id,const ImS8* xs,const ImS8* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedU8PtrU8PtrIntdoubleInt(const char* label_id,const ImU8* xs,const ImU8* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedS16PtrS16PtrIntdoubleInt(const char* label_id,const ImS16* xs,const ImS16* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedU16PtrU16PtrIntdoubleInt(const char* label_id,const ImU16* xs,const ImU16* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedS32PtrS32PtrIntdoubleInt(const char* label_id,const ImS32* xs,const ImS32* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedU32PtrU32PtrIntdoubleInt(const char* label_id,const ImU32* xs,const ImU32* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedS64PtrS64PtrIntdoubleInt(const char* label_id,const ImS64* xs,const ImS64* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedU64PtrU64PtrIntdoubleInt(const char* label_id,const ImU64* xs,const ImU64* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedFloatPtrFloatPtrFloatPtr(const char* label_id,const float* xs,const float* ys1,const float* ys2,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadeddoublePtrdoublePtrdoublePtr(const char* label_id,const double* xs,const double* ys1,const double* ys2,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedS8PtrS8PtrS8Ptr(const char* label_id,const ImS8* xs,const ImS8* ys1,const ImS8* ys2,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedU8PtrU8PtrU8Ptr(const char* label_id,const ImU8* xs,const ImU8* ys1,const ImU8* ys2,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedS16PtrS16PtrS16Ptr(const char* label_id,const ImS16* xs,const ImS16* ys1,const ImS16* ys2,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedU16PtrU16PtrU16Ptr(const char* label_id,const ImU16* xs,const ImU16* ys1,const ImU16* ys2,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedS32PtrS32PtrS32Ptr(const char* label_id,const ImS32* xs,const ImS32* ys1,const ImS32* ys2,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedU32PtrU32PtrU32Ptr(const char* label_id,const ImU32* xs,const ImU32* ys1,const ImU32* ys2,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedS64PtrS64PtrS64Ptr(const char* label_id,const ImS64* xs,const ImS64* ys1,const ImS64* ys2,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedU64PtrU64PtrU64Ptr(const char* label_id,const ImU64* xs,const ImU64* ys1,const ImU64* ys2,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotShadedG(const char* label_id,ImPlotPoint(*getter1)(void* data,int idx),void* data1,ImPlotPoint(*getter2)(void* data,int idx),void* data2,int count,int offset);
|
||||
CIMGUI_API void ImPlot_PlotBarsFloatPtrInt(const char* label_id,const float* values,int count,double width,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsdoublePtrInt(const char* label_id,const double* values,int count,double width,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsS8PtrInt(const char* label_id,const ImS8* values,int count,double width,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsU8PtrInt(const char* label_id,const ImU8* values,int count,double width,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsS16PtrInt(const char* label_id,const ImS16* values,int count,double width,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsU16PtrInt(const char* label_id,const ImU16* values,int count,double width,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsS32PtrInt(const char* label_id,const ImS32* values,int count,double width,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsU32PtrInt(const char* label_id,const ImU32* values,int count,double width,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsS64PtrInt(const char* label_id,const ImS64* values,int count,double width,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsU64PtrInt(const char* label_id,const ImU64* values,int count,double width,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsFloatPtrFloatPtr(const char* label_id,const float* xs,const float* ys,int count,double width,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsdoublePtrdoublePtr(const char* label_id,const double* xs,const double* ys,int count,double width,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsS8PtrS8Ptr(const char* label_id,const ImS8* xs,const ImS8* ys,int count,double width,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsU8PtrU8Ptr(const char* label_id,const ImU8* xs,const ImU8* ys,int count,double width,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsS16PtrS16Ptr(const char* label_id,const ImS16* xs,const ImS16* ys,int count,double width,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsU16PtrU16Ptr(const char* label_id,const ImU16* xs,const ImU16* ys,int count,double width,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsS32PtrS32Ptr(const char* label_id,const ImS32* xs,const ImS32* ys,int count,double width,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsU32PtrU32Ptr(const char* label_id,const ImU32* xs,const ImU32* ys,int count,double width,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsS64PtrS64Ptr(const char* label_id,const ImS64* xs,const ImS64* ys,int count,double width,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsU64PtrU64Ptr(const char* label_id,const ImU64* xs,const ImU64* ys,int count,double width,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsG(const char* label_id,ImPlotPoint(*getter)(void* data,int idx),void* data,int count,double width,int offset);
|
||||
CIMGUI_API void ImPlot_PlotBarsHFloatPtrInt(const char* label_id,const float* values,int count,double height,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHdoublePtrInt(const char* label_id,const double* values,int count,double height,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHS8PtrInt(const char* label_id,const ImS8* values,int count,double height,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHU8PtrInt(const char* label_id,const ImU8* values,int count,double height,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHS16PtrInt(const char* label_id,const ImS16* values,int count,double height,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHU16PtrInt(const char* label_id,const ImU16* values,int count,double height,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHS32PtrInt(const char* label_id,const ImS32* values,int count,double height,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHU32PtrInt(const char* label_id,const ImU32* values,int count,double height,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHS64PtrInt(const char* label_id,const ImS64* values,int count,double height,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHU64PtrInt(const char* label_id,const ImU64* values,int count,double height,double shift,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHFloatPtrFloatPtr(const char* label_id,const float* xs,const float* ys,int count,double height,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHdoublePtrdoublePtr(const char* label_id,const double* xs,const double* ys,int count,double height,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHS8PtrS8Ptr(const char* label_id,const ImS8* xs,const ImS8* ys,int count,double height,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHU8PtrU8Ptr(const char* label_id,const ImU8* xs,const ImU8* ys,int count,double height,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHS16PtrS16Ptr(const char* label_id,const ImS16* xs,const ImS16* ys,int count,double height,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHU16PtrU16Ptr(const char* label_id,const ImU16* xs,const ImU16* ys,int count,double height,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHS32PtrS32Ptr(const char* label_id,const ImS32* xs,const ImS32* ys,int count,double height,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHU32PtrU32Ptr(const char* label_id,const ImU32* xs,const ImU32* ys,int count,double height,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHS64PtrS64Ptr(const char* label_id,const ImS64* xs,const ImS64* ys,int count,double height,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHU64PtrU64Ptr(const char* label_id,const ImU64* xs,const ImU64* ys,int count,double height,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotBarsHG(const char* label_id,ImPlotPoint(*getter)(void* data,int idx),void* data,int count,double height,int offset);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsFloatPtrFloatPtrFloatPtrInt(const char* label_id,const float* xs,const float* ys,const float* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsdoublePtrdoublePtrdoublePtrInt(const char* label_id,const double* xs,const double* ys,const double* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsS8PtrS8PtrS8PtrInt(const char* label_id,const ImS8* xs,const ImS8* ys,const ImS8* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsU8PtrU8PtrU8PtrInt(const char* label_id,const ImU8* xs,const ImU8* ys,const ImU8* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsS16PtrS16PtrS16PtrInt(const char* label_id,const ImS16* xs,const ImS16* ys,const ImS16* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsU16PtrU16PtrU16PtrInt(const char* label_id,const ImU16* xs,const ImU16* ys,const ImU16* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsS32PtrS32PtrS32PtrInt(const char* label_id,const ImS32* xs,const ImS32* ys,const ImS32* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsU32PtrU32PtrU32PtrInt(const char* label_id,const ImU32* xs,const ImU32* ys,const ImU32* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsS64PtrS64PtrS64PtrInt(const char* label_id,const ImS64* xs,const ImS64* ys,const ImS64* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsU64PtrU64PtrU64PtrInt(const char* label_id,const ImU64* xs,const ImU64* ys,const ImU64* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsFloatPtrFloatPtrFloatPtrFloatPtr(const char* label_id,const float* xs,const float* ys,const float* neg,const float* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsdoublePtrdoublePtrdoublePtrdoublePtr(const char* label_id,const double* xs,const double* ys,const double* neg,const double* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsS8PtrS8PtrS8PtrS8Ptr(const char* label_id,const ImS8* xs,const ImS8* ys,const ImS8* neg,const ImS8* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsU8PtrU8PtrU8PtrU8Ptr(const char* label_id,const ImU8* xs,const ImU8* ys,const ImU8* neg,const ImU8* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsS16PtrS16PtrS16PtrS16Ptr(const char* label_id,const ImS16* xs,const ImS16* ys,const ImS16* neg,const ImS16* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsU16PtrU16PtrU16PtrU16Ptr(const char* label_id,const ImU16* xs,const ImU16* ys,const ImU16* neg,const ImU16* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsS32PtrS32PtrS32PtrS32Ptr(const char* label_id,const ImS32* xs,const ImS32* ys,const ImS32* neg,const ImS32* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsU32PtrU32PtrU32PtrU32Ptr(const char* label_id,const ImU32* xs,const ImU32* ys,const ImU32* neg,const ImU32* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsS64PtrS64PtrS64PtrS64Ptr(const char* label_id,const ImS64* xs,const ImS64* ys,const ImS64* neg,const ImS64* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsU64PtrU64PtrU64PtrU64Ptr(const char* label_id,const ImU64* xs,const ImU64* ys,const ImU64* neg,const ImU64* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHFloatPtrFloatPtrFloatPtrInt(const char* label_id,const float* xs,const float* ys,const float* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHdoublePtrdoublePtrdoublePtrInt(const char* label_id,const double* xs,const double* ys,const double* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHS8PtrS8PtrS8PtrInt(const char* label_id,const ImS8* xs,const ImS8* ys,const ImS8* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHU8PtrU8PtrU8PtrInt(const char* label_id,const ImU8* xs,const ImU8* ys,const ImU8* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHS16PtrS16PtrS16PtrInt(const char* label_id,const ImS16* xs,const ImS16* ys,const ImS16* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHU16PtrU16PtrU16PtrInt(const char* label_id,const ImU16* xs,const ImU16* ys,const ImU16* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHS32PtrS32PtrS32PtrInt(const char* label_id,const ImS32* xs,const ImS32* ys,const ImS32* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHU32PtrU32PtrU32PtrInt(const char* label_id,const ImU32* xs,const ImU32* ys,const ImU32* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHS64PtrS64PtrS64PtrInt(const char* label_id,const ImS64* xs,const ImS64* ys,const ImS64* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHU64PtrU64PtrU64PtrInt(const char* label_id,const ImU64* xs,const ImU64* ys,const ImU64* err,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHFloatPtrFloatPtrFloatPtrFloatPtr(const char* label_id,const float* xs,const float* ys,const float* neg,const float* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHdoublePtrdoublePtrdoublePtrdoublePtr(const char* label_id,const double* xs,const double* ys,const double* neg,const double* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHS8PtrS8PtrS8PtrS8Ptr(const char* label_id,const ImS8* xs,const ImS8* ys,const ImS8* neg,const ImS8* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHU8PtrU8PtrU8PtrU8Ptr(const char* label_id,const ImU8* xs,const ImU8* ys,const ImU8* neg,const ImU8* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHS16PtrS16PtrS16PtrS16Ptr(const char* label_id,const ImS16* xs,const ImS16* ys,const ImS16* neg,const ImS16* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHU16PtrU16PtrU16PtrU16Ptr(const char* label_id,const ImU16* xs,const ImU16* ys,const ImU16* neg,const ImU16* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHS32PtrS32PtrS32PtrS32Ptr(const char* label_id,const ImS32* xs,const ImS32* ys,const ImS32* neg,const ImS32* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHU32PtrU32PtrU32PtrU32Ptr(const char* label_id,const ImU32* xs,const ImU32* ys,const ImU32* neg,const ImU32* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHS64PtrS64PtrS64PtrS64Ptr(const char* label_id,const ImS64* xs,const ImS64* ys,const ImS64* neg,const ImS64* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotErrorBarsHU64PtrU64PtrU64PtrU64Ptr(const char* label_id,const ImU64* xs,const ImU64* ys,const ImU64* neg,const ImU64* pos,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsFloatPtrInt(const char* label_id,const float* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsdoublePtrInt(const char* label_id,const double* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsS8PtrInt(const char* label_id,const ImS8* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsU8PtrInt(const char* label_id,const ImU8* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsS16PtrInt(const char* label_id,const ImS16* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsU16PtrInt(const char* label_id,const ImU16* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsS32PtrInt(const char* label_id,const ImS32* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsU32PtrInt(const char* label_id,const ImU32* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsS64PtrInt(const char* label_id,const ImS64* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsU64PtrInt(const char* label_id,const ImU64* values,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsFloatPtrFloatPtr(const char* label_id,const float* xs,const float* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsdoublePtrdoublePtr(const char* label_id,const double* xs,const double* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsS8PtrS8Ptr(const char* label_id,const ImS8* xs,const ImS8* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsU8PtrU8Ptr(const char* label_id,const ImU8* xs,const ImU8* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsS16PtrS16Ptr(const char* label_id,const ImS16* xs,const ImS16* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsU16PtrU16Ptr(const char* label_id,const ImU16* xs,const ImU16* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsS32PtrS32Ptr(const char* label_id,const ImS32* xs,const ImS32* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsU32PtrU32Ptr(const char* label_id,const ImU32* xs,const ImU32* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsS64PtrS64Ptr(const char* label_id,const ImS64* xs,const ImS64* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotStemsU64PtrU64Ptr(const char* label_id,const ImU64* xs,const ImU64* ys,int count,double y_ref,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotPieChartFloatPtr(const char* const label_ids[],const float* values,int count,double x,double y,double radius,bool normalize,const char* label_fmt,double angle0);
|
||||
CIMGUI_API void ImPlot_PlotPieChartdoublePtr(const char* const label_ids[],const double* values,int count,double x,double y,double radius,bool normalize,const char* label_fmt,double angle0);
|
||||
CIMGUI_API void ImPlot_PlotPieChartS8Ptr(const char* const label_ids[],const ImS8* values,int count,double x,double y,double radius,bool normalize,const char* label_fmt,double angle0);
|
||||
CIMGUI_API void ImPlot_PlotPieChartU8Ptr(const char* const label_ids[],const ImU8* values,int count,double x,double y,double radius,bool normalize,const char* label_fmt,double angle0);
|
||||
CIMGUI_API void ImPlot_PlotPieChartS16Ptr(const char* const label_ids[],const ImS16* values,int count,double x,double y,double radius,bool normalize,const char* label_fmt,double angle0);
|
||||
CIMGUI_API void ImPlot_PlotPieChartU16Ptr(const char* const label_ids[],const ImU16* values,int count,double x,double y,double radius,bool normalize,const char* label_fmt,double angle0);
|
||||
CIMGUI_API void ImPlot_PlotPieChartS32Ptr(const char* const label_ids[],const ImS32* values,int count,double x,double y,double radius,bool normalize,const char* label_fmt,double angle0);
|
||||
CIMGUI_API void ImPlot_PlotPieChartU32Ptr(const char* const label_ids[],const ImU32* values,int count,double x,double y,double radius,bool normalize,const char* label_fmt,double angle0);
|
||||
CIMGUI_API void ImPlot_PlotPieChartS64Ptr(const char* const label_ids[],const ImS64* values,int count,double x,double y,double radius,bool normalize,const char* label_fmt,double angle0);
|
||||
CIMGUI_API void ImPlot_PlotPieChartU64Ptr(const char* const label_ids[],const ImU64* values,int count,double x,double y,double radius,bool normalize,const char* label_fmt,double angle0);
|
||||
CIMGUI_API void ImPlot_PlotHeatmapFloatPtr(const char* label_id,const float* values,int rows,int cols,double scale_min,double scale_max,const char* label_fmt,const ImPlotPoint bounds_min,const ImPlotPoint bounds_max);
|
||||
CIMGUI_API void ImPlot_PlotHeatmapdoublePtr(const char* label_id,const double* values,int rows,int cols,double scale_min,double scale_max,const char* label_fmt,const ImPlotPoint bounds_min,const ImPlotPoint bounds_max);
|
||||
CIMGUI_API void ImPlot_PlotHeatmapS8Ptr(const char* label_id,const ImS8* values,int rows,int cols,double scale_min,double scale_max,const char* label_fmt,const ImPlotPoint bounds_min,const ImPlotPoint bounds_max);
|
||||
CIMGUI_API void ImPlot_PlotHeatmapU8Ptr(const char* label_id,const ImU8* values,int rows,int cols,double scale_min,double scale_max,const char* label_fmt,const ImPlotPoint bounds_min,const ImPlotPoint bounds_max);
|
||||
CIMGUI_API void ImPlot_PlotHeatmapS16Ptr(const char* label_id,const ImS16* values,int rows,int cols,double scale_min,double scale_max,const char* label_fmt,const ImPlotPoint bounds_min,const ImPlotPoint bounds_max);
|
||||
CIMGUI_API void ImPlot_PlotHeatmapU16Ptr(const char* label_id,const ImU16* values,int rows,int cols,double scale_min,double scale_max,const char* label_fmt,const ImPlotPoint bounds_min,const ImPlotPoint bounds_max);
|
||||
CIMGUI_API void ImPlot_PlotHeatmapS32Ptr(const char* label_id,const ImS32* values,int rows,int cols,double scale_min,double scale_max,const char* label_fmt,const ImPlotPoint bounds_min,const ImPlotPoint bounds_max);
|
||||
CIMGUI_API void ImPlot_PlotHeatmapU32Ptr(const char* label_id,const ImU32* values,int rows,int cols,double scale_min,double scale_max,const char* label_fmt,const ImPlotPoint bounds_min,const ImPlotPoint bounds_max);
|
||||
CIMGUI_API void ImPlot_PlotHeatmapS64Ptr(const char* label_id,const ImS64* values,int rows,int cols,double scale_min,double scale_max,const char* label_fmt,const ImPlotPoint bounds_min,const ImPlotPoint bounds_max);
|
||||
CIMGUI_API void ImPlot_PlotHeatmapU64Ptr(const char* label_id,const ImU64* values,int rows,int cols,double scale_min,double scale_max,const char* label_fmt,const ImPlotPoint bounds_min,const ImPlotPoint bounds_max);
|
||||
CIMGUI_API void ImPlot_PlotDigitalFloatPtr(const char* label_id,const float* xs,const float* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotDigitaldoublePtr(const char* label_id,const double* xs,const double* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotDigitalS8Ptr(const char* label_id,const ImS8* xs,const ImS8* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotDigitalU8Ptr(const char* label_id,const ImU8* xs,const ImU8* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotDigitalS16Ptr(const char* label_id,const ImS16* xs,const ImS16* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotDigitalU16Ptr(const char* label_id,const ImU16* xs,const ImU16* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotDigitalS32Ptr(const char* label_id,const ImS32* xs,const ImS32* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotDigitalU32Ptr(const char* label_id,const ImU32* xs,const ImU32* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotDigitalS64Ptr(const char* label_id,const ImS64* xs,const ImS64* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotDigitalU64Ptr(const char* label_id,const ImU64* xs,const ImU64* ys,int count,int offset,int stride);
|
||||
CIMGUI_API void ImPlot_PlotDigitalG(const char* label_id,ImPlotPoint(*getter)(void* data,int idx),void* data,int count,int offset);
|
||||
CIMGUI_API void ImPlot_PlotText(const char* text,double x,double y,bool vertical,const ImVec2 pixel_offset);
|
||||
CIMGUI_API void ImPlot_SetNextPlotLimits(double xmin,double xmax,double ymin,double ymax,ImGuiCond cond);
|
||||
CIMGUI_API void ImPlot_SetNextPlotLimitsX(double xmin,double xmax,ImGuiCond cond);
|
||||
CIMGUI_API void ImPlot_SetNextPlotLimitsY(double ymin,double ymax,ImGuiCond cond,int y_axis);
|
||||
CIMGUI_API void ImPlot_LinkNextPlotLimits(double* xmin,double* xmax,double* ymin,double* ymax,double* ymin2,double* ymax2,double* ymin3,double* ymax3);
|
||||
CIMGUI_API void ImPlot_FitNextPlotAxes(bool x,bool y,bool y2,bool y3);
|
||||
CIMGUI_API void ImPlot_SetNextPlotTicksXdoublePtr(const double* values,int n_ticks,const char* const labels[],bool show_default);
|
||||
CIMGUI_API void ImPlot_SetNextPlotTicksXdouble(double x_min,double x_max,int n_ticks,const char* const labels[],bool show_default);
|
||||
CIMGUI_API void ImPlot_SetNextPlotTicksYdoublePtr(const double* values,int n_ticks,const char* const labels[],bool show_default,int y_axis);
|
||||
CIMGUI_API void ImPlot_SetNextPlotTicksYdouble(double y_min,double y_max,int n_ticks,const char* const labels[],bool show_default,int y_axis);
|
||||
CIMGUI_API void ImPlot_SetPlotYAxis(int y_axis);
|
||||
CIMGUI_API void ImPlot_PixelsToPlotVec2(ImPlotPoint *pOut,const ImVec2 pix,int y_axis);
|
||||
CIMGUI_API void ImPlot_PixelsToPlotFloat(ImPlotPoint *pOut,float x,float y,int y_axis);
|
||||
CIMGUI_API void ImPlot_PlotToPixelsPlotPoInt(ImVec2 *pOut,const ImPlotPoint plt,int y_axis);
|
||||
CIMGUI_API void ImPlot_PlotToPixelsdouble(ImVec2 *pOut,double x,double y,int y_axis);
|
||||
CIMGUI_API void ImPlot_GetPlotPos(ImVec2 *pOut);
|
||||
CIMGUI_API void ImPlot_GetPlotSize(ImVec2 *pOut);
|
||||
CIMGUI_API bool ImPlot_IsPlotHovered(void);
|
||||
CIMGUI_API bool ImPlot_IsPlotXAxisHovered(void);
|
||||
CIMGUI_API bool ImPlot_IsPlotYAxisHovered(int y_axis);
|
||||
CIMGUI_API void ImPlot_GetPlotMousePos(ImPlotPoint *pOut,int y_axis);
|
||||
CIMGUI_API void ImPlot_GetPlotLimits(ImPlotLimits *pOut,int y_axis);
|
||||
CIMGUI_API bool ImPlot_IsPlotQueried(void);
|
||||
CIMGUI_API void ImPlot_GetPlotQuery(ImPlotLimits *pOut,int y_axis);
|
||||
CIMGUI_API ImPlotStyle* ImPlot_GetStyle(void);
|
||||
CIMGUI_API void ImPlot_StyleColorsAuto(ImPlotStyle* dst);
|
||||
CIMGUI_API void ImPlot_StyleColorsClassic(ImPlotStyle* dst);
|
||||
CIMGUI_API void ImPlot_StyleColorsDark(ImPlotStyle* dst);
|
||||
CIMGUI_API void ImPlot_StyleColorsLight(ImPlotStyle* dst);
|
||||
CIMGUI_API void ImPlot_PushStyleColorU32(ImPlotCol idx,ImU32 col);
|
||||
CIMGUI_API void ImPlot_PushStyleColorVec4(ImPlotCol idx,const ImVec4 col);
|
||||
CIMGUI_API void ImPlot_PopStyleColor(int count);
|
||||
CIMGUI_API void ImPlot_PushStyleVarFloat(ImPlotStyleVar idx,float val);
|
||||
CIMGUI_API void ImPlot_PushStyleVarInt(ImPlotStyleVar idx,int val);
|
||||
CIMGUI_API void ImPlot_PushStyleVarVec2(ImPlotStyleVar idx,const ImVec2 val);
|
||||
CIMGUI_API void ImPlot_PopStyleVar(int count);
|
||||
CIMGUI_API void ImPlot_SetNextLineStyle(const ImVec4 col,float weight);
|
||||
CIMGUI_API void ImPlot_SetNextFillStyle(const ImVec4 col,float alpha_mod);
|
||||
CIMGUI_API void ImPlot_SetNextMarkerStyle(ImPlotMarker marker,float size,const ImVec4 fill,float weight,const ImVec4 outline);
|
||||
CIMGUI_API void ImPlot_SetNextErrorBarStyle(const ImVec4 col,float size,float weight);
|
||||
CIMGUI_API const char* ImPlot_GetStyleColorName(ImPlotCol color);
|
||||
CIMGUI_API const char* ImPlot_GetMarkerName(ImPlotMarker marker);
|
||||
CIMGUI_API void ImPlot_PushColormapPlotColormap(ImPlotColormap colormap);
|
||||
CIMGUI_API void ImPlot_PushColormapVec4Ptr(const ImVec4* colormap,int size);
|
||||
CIMGUI_API void ImPlot_PopColormap(int count);
|
||||
CIMGUI_API void ImPlot_SetColormapVec4Ptr(const ImVec4* colormap,int size);
|
||||
CIMGUI_API void ImPlot_SetColormapPlotColormap(ImPlotColormap colormap,int samples);
|
||||
CIMGUI_API int ImPlot_GetColormapSize(void);
|
||||
CIMGUI_API void ImPlot_GetColormapColor(ImVec4 *pOut,int index);
|
||||
CIMGUI_API void ImPlot_LerpColormap(ImVec4 *pOut,float t);
|
||||
CIMGUI_API void ImPlot_NextColormapColor(ImVec4 *pOut);
|
||||
CIMGUI_API void ImPlot_ShowColormapScale(double scale_min,double scale_max,float height);
|
||||
CIMGUI_API const char* ImPlot_GetColormapName(ImPlotColormap colormap);
|
||||
CIMGUI_API bool ImPlot_IsLegendEntryHovered(const char* label_id);
|
||||
CIMGUI_API bool ImPlot_BeginLegendDragDropSource(const char* label_id,ImGuiDragDropFlags flags);
|
||||
CIMGUI_API void ImPlot_EndLegendDragDropSource(void);
|
||||
CIMGUI_API bool ImPlot_BeginLegendPopup(const char* label_id,ImGuiMouseButton mouse_button);
|
||||
CIMGUI_API void ImPlot_EndLegendPopup(void);
|
||||
CIMGUI_API ImPlotInputMap* ImPlot_GetInputMap(void);
|
||||
CIMGUI_API ImDrawList* ImPlot_GetPlotDrawList(void);
|
||||
CIMGUI_API void ImPlot_PushPlotClipRect(void);
|
||||
CIMGUI_API void ImPlot_PopPlotClipRect(void);
|
||||
CIMGUI_API bool ImPlot_ShowStyleSelector(const char* label);
|
||||
CIMGUI_API void ImPlot_ShowStyleEditor(ImPlotStyle* ref);
|
||||
CIMGUI_API void ImPlot_ShowUserGuide(void);
|
||||
CIMGUI_API void ImPlot_SetImGuiContext(ImGuiContext* ctx);
|
||||
CIMGUI_API void ImPlot_ShowDemoWindow(bool* p_open);
|
||||
|
||||
|
||||
|
||||
#endif //CIMGUIPLOT_INCLUDED
|
||||
|
||||
|
||||
|
||||
|
96
src/external/imgui/imgui/imconfig.h
vendored
96
src/external/imgui/imgui/imconfig.h
vendored
|
@ -1,111 +1,131 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// COMPILE-TIME OPTIONS FOR DEAR IMGUI
|
||||
// DEAR IMGUI COMPILE-TIME OPTIONS
|
||||
// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
|
||||
// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
|
||||
//-----------------------------------------------------------------------------
|
||||
// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/branch with your modifications to imconfig.h)
|
||||
// B) or add configuration directives in your own file and compile with #define IMGUI_USER_CONFIG "myfilename.h"
|
||||
// If you do so you need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include
|
||||
// the imgui*.cpp files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
|
||||
// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it)
|
||||
// B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template.
|
||||
//-----------------------------------------------------------------------------
|
||||
// You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp
|
||||
// files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
|
||||
// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
|
||||
// Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using.
|
||||
// Call IMGUI_CHECKVERSION() from your .cpp file to verify that the data structures your files are using are matching the ones imgui.cpp is using.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
//---- Monado specific things
|
||||
#define IMGUI_IMPL_OPENGL_LOADER_CUSTOM "glad/gl.h"
|
||||
|
||||
//---- Define assertion handler. Defaults to calling assert().
|
||||
// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
|
||||
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
|
||||
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
|
||||
|
||||
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows
|
||||
// Using dear imgui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
|
||||
// Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
|
||||
// DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions()
|
||||
// for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details.
|
||||
//#define IMGUI_API __declspec( dllexport )
|
||||
//#define IMGUI_API __declspec( dllimport )
|
||||
|
||||
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
|
||||
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to clean your code of obsolete function/names.
|
||||
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
//#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87+ disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This is automatically done by IMGUI_DISABLE_OBSOLETE_FUNCTIONS.
|
||||
|
||||
//---- Disable all of Dear ImGui or don't implement standard windows.
|
||||
// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
|
||||
//---- Disable all of Dear ImGui or don't implement standard windows/tools.
|
||||
// It is very strongly recommended to NOT disable the demo windows and debug tool during development. They are extremely useful in day to day work. Please read comments in imgui_demo.cpp.
|
||||
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
|
||||
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended.
|
||||
//#define IMGUI_DISABLE_METRICS_WINDOW // Disable debug/metrics window: ShowMetricsWindow() will be empty.
|
||||
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty.
|
||||
//#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowIDStackToolWindow() will be empty.
|
||||
|
||||
//---- Don't implement some functions to reduce linkage requirements.
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc.
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow.
|
||||
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a)
|
||||
//#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with Visual Studio] Implement default IME handler (require imm32.lib/.a, auto-link for Visual Studio, -limm32 on command-line for MinGW)
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a)
|
||||
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, IME).
|
||||
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
|
||||
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
|
||||
//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
|
||||
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
|
||||
//#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies)
|
||||
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
|
||||
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
|
||||
//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available
|
||||
|
||||
//---- Include imgui_user.h at the end of imgui.h as a convenience
|
||||
// May be convenient for some users to only explicitly include vanilla imgui.h and have extra stuff included.
|
||||
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
||||
//#define IMGUI_USER_H_FILENAME "my_folder/my_imgui_user.h"
|
||||
|
||||
//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
|
||||
//#define IMGUI_USE_BGRA_PACKED_COLOR
|
||||
|
||||
//---- Use 32-bit for ImWchar (default is 16-bit) to support full unicode code points.
|
||||
//---- Use 32-bit for ImWchar (default is 16-bit) to support Unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
|
||||
//#define IMGUI_USE_WCHAR32
|
||||
|
||||
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
|
||||
// By default the embedded implementations are declared static and not available outside of imgui cpp files.
|
||||
// By default the embedded implementations are declared static and not available outside of Dear ImGui sources files.
|
||||
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
|
||||
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
|
||||
//#define IMGUI_STB_SPRINTF_FILENAME "my_folder/stb_sprintf.h" // only used if IMGUI_USE_STB_SPRINTF is defined.
|
||||
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
|
||||
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
|
||||
//#define IMGUI_DISABLE_STB_SPRINTF_IMPLEMENTATION // only disabled if IMGUI_USE_STB_SPRINTF is defined.
|
||||
|
||||
//---- Unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined, use the much faster STB sprintf library implementation of vsnprintf instead of the one from the default C library.
|
||||
// Note that stb_sprintf.h is meant to be provided by the user and available in the include path at compile time. Also, the compatibility checks of the arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf.
|
||||
// #define IMGUI_USE_STB_SPRINTF
|
||||
//---- Use stb_sprintf.h for a faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined)
|
||||
// Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by stb_sprintf.h.
|
||||
//#define IMGUI_USE_STB_SPRINTF
|
||||
|
||||
//---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui)
|
||||
// Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided).
|
||||
// On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'.
|
||||
//#define IMGUI_ENABLE_FREETYPE
|
||||
|
||||
//---- Use FreeType+lunasvg library to render OpenType SVG fonts (SVGinOT)
|
||||
// Requires lunasvg headers to be available in the include path + program to be linked with the lunasvg library (not provided).
|
||||
// Only works in combination with IMGUI_ENABLE_FREETYPE.
|
||||
// (implementation is based on Freetype's rsvg-port.c which is licensed under CeCILL-C Free Software License Agreement)
|
||||
//#define IMGUI_ENABLE_FREETYPE_LUNASVG
|
||||
|
||||
//---- Use stb_truetype to build and rasterize the font atlas (default)
|
||||
// The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend.
|
||||
//#define IMGUI_ENABLE_STB_TRUETYPE
|
||||
|
||||
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
|
||||
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
|
||||
/*
|
||||
#define IM_VEC2_CLASS_EXTRA \
|
||||
ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
|
||||
#define IM_VEC2_CLASS_EXTRA \
|
||||
constexpr ImVec2(const MyVec2& f) : x(f.x), y(f.y) {} \
|
||||
operator MyVec2() const { return MyVec2(x,y); }
|
||||
|
||||
#define IM_VEC4_CLASS_EXTRA \
|
||||
ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \
|
||||
#define IM_VEC4_CLASS_EXTRA \
|
||||
constexpr ImVec4(const MyVec4& f) : x(f.x), y(f.y), z(f.z), w(f.w) {} \
|
||||
operator MyVec4() const { return MyVec4(x,y,z,w); }
|
||||
*/
|
||||
//---- ...Or use Dear ImGui's own very basic math operators.
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
|
||||
//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
|
||||
// Your renderer back-end will need to support it (most example renderer back-ends support both 16/32-bit indices).
|
||||
// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices).
|
||||
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
|
||||
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
|
||||
//#define ImDrawIdx unsigned int
|
||||
|
||||
//---- Override ImDrawCallback signature (will need to modify renderer back-ends accordingly)
|
||||
//---- Override ImDrawCallback signature (will need to modify renderer backends accordingly)
|
||||
//struct ImDrawList;
|
||||
//struct ImDrawCmd;
|
||||
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
|
||||
//#define ImDrawCallback MyImDrawCallback
|
||||
|
||||
//---- Debug Tools: Macro to break in Debugger
|
||||
//---- Debug Tools: Macro to break in Debugger (we provide a default implementation of this in the codebase)
|
||||
// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
|
||||
//#define IM_DEBUG_BREAK IM_ASSERT(0)
|
||||
//#define IM_DEBUG_BREAK __debugbreak()
|
||||
|
||||
//---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(),
|
||||
// (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.)
|
||||
// This adds a small runtime cost which is why it is not enabled by default.
|
||||
//#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
|
||||
|
||||
//---- Debug Tools: Enable slower asserts
|
||||
//#define IMGUI_DEBUG_PARANOID
|
||||
|
||||
//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
|
||||
//---- Tip: You can add extra functions within the ImGui:: namespace from anywhere (e.g. your own sources/header files)
|
||||
/*
|
||||
namespace ImGui
|
||||
{
|
||||
void MyFunction(const char* name, const MyMatrix44& v);
|
||||
void MyFunction(const char* name, MyMatrix44* mtx);
|
||||
}
|
||||
*/
|
||||
|
|
18931
src/external/imgui/imgui/imgui.cpp
vendored
18931
src/external/imgui/imgui/imgui.cpp
vendored
File diff suppressed because it is too large
Load diff
2709
src/external/imgui/imgui/imgui.h
vendored
2709
src/external/imgui/imgui/imgui.h
vendored
File diff suppressed because it is too large
Load diff
5850
src/external/imgui/imgui/imgui_demo.cpp
vendored
5850
src/external/imgui/imgui/imgui_demo.cpp
vendored
File diff suppressed because it is too large
Load diff
1818
src/external/imgui/imgui/imgui_draw.cpp
vendored
1818
src/external/imgui/imgui/imgui_draw.cpp
vendored
File diff suppressed because it is too large
Load diff
682
src/external/imgui/imgui/imgui_impl_opengl3.cpp
vendored
682
src/external/imgui/imgui/imgui_impl_opengl3.cpp
vendored
|
@ -1,682 +0,0 @@
|
|||
// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
|
||||
// - Desktop GL: 2.x 3.x 4.x
|
||||
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
|
||||
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||
// [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||
|
||||
// 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.
|
||||
// https://github.com/ocornut/imgui
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2020-07-10: OpenGL: Added support for glad2 OpenGL loader.
|
||||
// 2020-05-08: OpenGL: Made default GLSL version 150 (instead of 130) on OSX.
|
||||
// 2020-04-21: OpenGL: Fixed handling of glClipControl(GL_UPPER_LEFT) by inverting projection matrix.
|
||||
// 2020-04-12: OpenGL: Fixed context version check mistakenly testing for 4.0+ instead of 3.2+ to enable ImGuiBackendFlags_RendererHasVtxOffset.
|
||||
// 2020-03-24: OpenGL: Added support for glbinding 2.x OpenGL loader.
|
||||
// 2020-01-07: OpenGL: Added support for glbinding 3.x OpenGL loader.
|
||||
// 2019-10-25: OpenGL: Using a combination of GL define and runtime GL version to decide whether to use glDrawElementsBaseVertex(). Fix building with pre-3.2 GL loaders.
|
||||
// 2019-09-22: OpenGL: Detect default GL loader using __has_include compiler facility.
|
||||
// 2019-09-16: OpenGL: Tweak initialization code to allow application calling ImGui_ImplOpenGL3_CreateFontsTexture() before the first NewFrame() call.
|
||||
// 2019-05-29: OpenGL: Desktop GL only: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
||||
// 2019-04-30: OpenGL: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||
// 2019-03-29: OpenGL: Not calling glBindBuffer more than necessary in the render loop.
|
||||
// 2019-03-15: OpenGL: Added a GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized GL function loaders early.
|
||||
// 2019-03-03: OpenGL: Fix support for ES 2.0 (WebGL 1.0).
|
||||
// 2019-02-20: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN even if defined by the headers/loader.
|
||||
// 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).
|
||||
// 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) / GL_CLIP_ORIGIN.
|
||||
// 2018-08-29: OpenGL: Added support for more OpenGL loaders: glew and glad, with comments indicative that any loader can be used.
|
||||
// 2018-08-09: OpenGL: Default to OpenGL ES 3 on iOS and Android. GLSL version default to "#version 300 ES".
|
||||
// 2018-07-30: OpenGL: Support for GLSL 300 ES and 410 core. Fixes for Emscripten compilation.
|
||||
// 2018-07-10: OpenGL: Support for more GLSL versions (based on the GLSL version string). Added error output when shaders fail to compile/link.
|
||||
// 2018-06-08: Misc: Extracted imgui_impl_opengl3.cpp/.h away from the old combined GLFW/SDL+OpenGL3 examples.
|
||||
// 2018-06-08: OpenGL: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
|
||||
// 2018-05-25: OpenGL: Removed unnecessary backup/restore of GL_ELEMENT_ARRAY_BUFFER_BINDING since this is part of the VAO state.
|
||||
// 2018-05-14: OpenGL: Making the call to glBindSampler() optional so 3.2 context won't fail if the function is a NULL pointer.
|
||||
// 2018-03-06: OpenGL: Added const char* glsl_version parameter to ImGui_ImplOpenGL3_Init() so user can override the GLSL version e.g. "#version 150".
|
||||
// 2018-02-23: OpenGL: Create the VAO in the render function so the setup can more easily be used with multiple shared GL context.
|
||||
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplSdlGL3_RenderDrawData() in the .h file so you can call it yourself.
|
||||
// 2018-01-07: OpenGL: Changed GLSL shader version from 330 to 150.
|
||||
// 2017-09-01: OpenGL: Save and restore current bound sampler. Save and restore current polygon mode.
|
||||
// 2017-05-01: OpenGL: Fixed save and restore of current blend func state.
|
||||
// 2017-05-01: OpenGL: Fixed save and restore of current GL_ACTIVE_TEXTURE.
|
||||
// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
|
||||
// 2016-07-29: OpenGL: Explicitly setting GL_UNPACK_ROW_LENGTH to reduce issues because SDL changes it. (#752)
|
||||
|
||||
//----------------------------------------
|
||||
// OpenGL GLSL GLSL
|
||||
// version version string
|
||||
//----------------------------------------
|
||||
// 2.0 110 "#version 110"
|
||||
// 2.1 120 "#version 120"
|
||||
// 3.0 130 "#version 130"
|
||||
// 3.1 140 "#version 140"
|
||||
// 3.2 150 "#version 150"
|
||||
// 3.3 330 "#version 330 core"
|
||||
// 4.0 400 "#version 400 core"
|
||||
// 4.1 410 "#version 410 core"
|
||||
// 4.2 420 "#version 410 core"
|
||||
// 4.3 430 "#version 430 core"
|
||||
// ES 2.0 100 "#version 100" = WebGL 1.0
|
||||
// ES 3.0 300 "#version 300 es" = WebGL 2.0
|
||||
//----------------------------------------
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_opengl3.h"
|
||||
#include <stdio.h>
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
||||
#include <stddef.h> // intptr_t
|
||||
#else
|
||||
#include <stdint.h> // intptr_t
|
||||
#endif
|
||||
|
||||
|
||||
// GL includes
|
||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||
#include <GLES2/gl2.h>
|
||||
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
||||
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV))
|
||||
#include <OpenGLES/ES3/gl.h> // Use GL ES 3
|
||||
#else
|
||||
#include <GLES3/gl3.h> // Use GL ES 3
|
||||
#endif
|
||||
#else
|
||||
// About Desktop OpenGL function loaders:
|
||||
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
|
||||
// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
|
||||
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
|
||||
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
|
||||
#include <GL/gl3w.h> // Needs to be initialized with gl3wInit() in user's code
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
|
||||
#include <GL/glew.h> // Needs to be initialized with glewInit() in user's code.
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||
#include <glad/glad.h> // Needs to be initialized with gladLoadGL() in user's code.
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2)
|
||||
#include <glad/gl.h> // Needs to be initialized with gladLoadGL(...) or gladLoaderLoadGL() in user's code.
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
||||
#ifndef GLFW_INCLUDE_NONE
|
||||
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
||||
#endif
|
||||
#include <glbinding/Binding.h> // Needs to be initialized with glbinding::Binding::initialize() in user's code.
|
||||
#include <glbinding/gl/gl.h>
|
||||
using namespace gl;
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
|
||||
#ifndef GLFW_INCLUDE_NONE
|
||||
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
||||
#endif
|
||||
#include <glbinding/glbinding.h>// Needs to be initialized with glbinding::initialize() in user's code.
|
||||
#include <glbinding/gl/gl.h>
|
||||
using namespace gl;
|
||||
#else
|
||||
#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
|
||||
#if defined(IMGUI_IMPL_OPENGL_ES2) || defined(IMGUI_IMPL_OPENGL_ES3) || !defined(GL_VERSION_3_2)
|
||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET 0
|
||||
#else
|
||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET 1
|
||||
#endif
|
||||
|
||||
// OpenGL Data
|
||||
static GLuint g_GlVersion = 0; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries (e.g. 320 for GL 3.2)
|
||||
static char g_GlslVersionString[32] = ""; // Specified by user or detected based on compile time GL settings.
|
||||
static GLuint g_FontTexture = 0;
|
||||
static GLuint g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
|
||||
static GLint g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; // Uniforms location
|
||||
static GLuint g_AttribLocationVtxPos = 0, g_AttribLocationVtxUV = 0, g_AttribLocationVtxColor = 0; // Vertex attributes location
|
||||
static unsigned int g_VboHandle = 0, g_ElementsHandle = 0;
|
||||
|
||||
// Functions
|
||||
bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
||||
{
|
||||
// Query for GL version (e.g. 320 for GL 3.2)
|
||||
#if !defined(IMGUI_IMPL_OPENGL_ES2)
|
||||
GLint major, minor;
|
||||
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
||||
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
||||
g_GlVersion = (GLuint)(major * 100 + minor * 10);
|
||||
#else
|
||||
g_GlVersion = 200; // GLES 2
|
||||
#endif
|
||||
|
||||
// Setup back-end capabilities flags
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.BackendRendererName = "imgui_impl_opengl3";
|
||||
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||
if (g_GlVersion >= 320)
|
||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||
#endif
|
||||
|
||||
// Store GLSL version string so we can refer to it later in case we recreate shaders.
|
||||
// Note: GLSL version is NOT the same as GL version. Leave this to NULL if unsure.
|
||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||
if (glsl_version == NULL)
|
||||
glsl_version = "#version 100";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
||||
if (glsl_version == NULL)
|
||||
glsl_version = "#version 300 es";
|
||||
#elif defined(__APPLE__)
|
||||
if (glsl_version == NULL)
|
||||
glsl_version = "#version 150";
|
||||
#else
|
||||
if (glsl_version == NULL)
|
||||
glsl_version = "#version 130";
|
||||
#endif
|
||||
IM_ASSERT((int)strlen(glsl_version) + 2 < IM_ARRAYSIZE(g_GlslVersionString));
|
||||
strcpy(g_GlslVersionString, glsl_version);
|
||||
strcat(g_GlslVersionString, "\n");
|
||||
|
||||
// Debugging construct to make it easily visible in the IDE and debugger which GL loader has been selected.
|
||||
// The code actually never uses the 'gl_loader' variable! It is only here so you can read it!
|
||||
// If auto-detection fails or doesn't select the same GL loader file as used by your application,
|
||||
// you are likely to get a crash below.
|
||||
// You can explicitly select a loader by using '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
|
||||
const char* gl_loader = "Unknown";
|
||||
IM_UNUSED(gl_loader);
|
||||
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
|
||||
gl_loader = "GL3W";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
|
||||
gl_loader = "GLEW";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||
gl_loader = "GLAD";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2)
|
||||
gl_loader = "GLAD2";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
||||
gl_loader = "glbinding2";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
|
||||
gl_loader = "glbinding3";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
|
||||
gl_loader = "custom";
|
||||
#else
|
||||
gl_loader = "none";
|
||||
#endif
|
||||
|
||||
// Make an arbitrary GL call (we don't actually need the result)
|
||||
// IF YOU GET A CRASH HERE: it probably means that you haven't initialized the OpenGL function loader used by this code.
|
||||
// Desktop OpenGL 3/4 need a function loader. See the IMGUI_IMPL_OPENGL_LOADER_xxx explanation above.
|
||||
GLint current_texture;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_Shutdown()
|
||||
{
|
||||
ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_NewFrame()
|
||||
{
|
||||
if (!g_ShaderHandle)
|
||||
ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||
}
|
||||
|
||||
static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height, GLuint vertex_array_object)
|
||||
{
|
||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
#ifdef GL_POLYGON_MODE
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
#endif
|
||||
|
||||
// Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
|
||||
bool clip_origin_lower_left = true;
|
||||
#if defined(GL_CLIP_ORIGIN) && !defined(__APPLE__)
|
||||
GLenum current_clip_origin = 0; glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)¤t_clip_origin);
|
||||
if (current_clip_origin == GL_UPPER_LEFT)
|
||||
clip_origin_lower_left = false;
|
||||
#endif
|
||||
|
||||
// Setup viewport, orthographic projection matrix
|
||||
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
||||
glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
|
||||
float L = draw_data->DisplayPos.x;
|
||||
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
|
||||
float T = draw_data->DisplayPos.y;
|
||||
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
|
||||
if (!clip_origin_lower_left) { float tmp = T; T = B; B = tmp; } // Swap top and bottom if origin is upper left
|
||||
const float ortho_projection[4][4] =
|
||||
{
|
||||
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 2.0f/(T-B), 0.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, -1.0f, 0.0f },
|
||||
{ (R+L)/(L-R), (T+B)/(B-T), 0.0f, 1.0f },
|
||||
};
|
||||
glUseProgram(g_ShaderHandle);
|
||||
glUniform1i(g_AttribLocationTex, 0);
|
||||
glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
||||
#ifdef GL_SAMPLER_BINDING
|
||||
glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.
|
||||
#endif
|
||||
|
||||
(void)vertex_array_object;
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
glBindVertexArray(vertex_array_object);
|
||||
#endif
|
||||
|
||||
// Bind vertex/index buffers and setup attributes for ImDrawVert
|
||||
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
|
||||
glEnableVertexAttribArray(g_AttribLocationVtxPos);
|
||||
glEnableVertexAttribArray(g_AttribLocationVtxUV);
|
||||
glEnableVertexAttribArray(g_AttribLocationVtxColor);
|
||||
glVertexAttribPointer(g_AttribLocationVtxPos, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, pos));
|
||||
glVertexAttribPointer(g_AttribLocationVtxUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv));
|
||||
glVertexAttribPointer(g_AttribLocationVtxColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col));
|
||||
}
|
||||
|
||||
// OpenGL3 Render function.
|
||||
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
||||
// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
|
||||
void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||
{
|
||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||
if (fb_width <= 0 || fb_height <= 0)
|
||||
return;
|
||||
|
||||
// Backup GL state
|
||||
GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program);
|
||||
GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture);
|
||||
#ifdef GL_SAMPLER_BINDING
|
||||
GLuint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler);
|
||||
#endif
|
||||
GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer);
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object);
|
||||
#endif
|
||||
#ifdef GL_POLYGON_MODE
|
||||
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
|
||||
#endif
|
||||
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
|
||||
GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
|
||||
GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb);
|
||||
GLenum last_blend_dst_rgb; glGetIntegerv(GL_BLEND_DST_RGB, (GLint*)&last_blend_dst_rgb);
|
||||
GLenum last_blend_src_alpha; glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*)&last_blend_src_alpha);
|
||||
GLenum last_blend_dst_alpha; glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*)&last_blend_dst_alpha);
|
||||
GLenum last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*)&last_blend_equation_rgb);
|
||||
GLenum last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*)&last_blend_equation_alpha);
|
||||
GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
|
||||
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
|
||||
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
|
||||
GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
|
||||
|
||||
// Setup desired GL state
|
||||
// Recreate the VAO every time (this is to easily allow multiple GL contexts to be rendered to. VAO are not shared among GL contexts)
|
||||
// The renderer would actually work without any VAO bound, but then our VertexAttrib calls would overwrite the default one currently bound.
|
||||
GLuint vertex_array_object = 0;
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
glGenVertexArrays(1, &vertex_array_object);
|
||||
#endif
|
||||
ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object);
|
||||
|
||||
// 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
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
|
||||
// Upload vertex/index buffers
|
||||
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * (int)sizeof(ImDrawVert), (const GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * (int)sizeof(ImDrawIdx), (const GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
|
||||
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||
{
|
||||
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
||||
if (pcmd->UserCallback != NULL)
|
||||
{
|
||||
// User callback, registered via ImDrawList::AddCallback()
|
||||
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||
ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object);
|
||||
else
|
||||
pcmd->UserCallback(cmd_list, pcmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
// Apply scissor/clipping rectangle
|
||||
glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y));
|
||||
|
||||
// Bind texture, Draw
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
||||
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||
if (g_GlVersion >= 320)
|
||||
glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset);
|
||||
else
|
||||
#endif
|
||||
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Destroy the temporary VAO
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
glDeleteVertexArrays(1, &vertex_array_object);
|
||||
#endif
|
||||
|
||||
// Restore modified GL state
|
||||
glUseProgram(last_program);
|
||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||
#ifdef GL_SAMPLER_BINDING
|
||||
glBindSampler(0, last_sampler);
|
||||
#endif
|
||||
glActiveTexture(last_active_texture);
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
glBindVertexArray(last_vertex_array_object);
|
||||
#endif
|
||||
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||
glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha);
|
||||
glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha);
|
||||
if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND);
|
||||
if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE);
|
||||
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
|
||||
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
|
||||
#ifdef GL_POLYGON_MODE
|
||||
glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
|
||||
#endif
|
||||
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
|
||||
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
||||
}
|
||||
|
||||
bool ImGui_ImplOpenGL3_CreateFontsTexture()
|
||||
{
|
||||
// Build texture atlas
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
unsigned char* pixels;
|
||||
int width, height;
|
||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
|
||||
|
||||
// Upload texture to graphics system
|
||||
GLint last_texture;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||
glGenTextures(1, &g_FontTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, g_FontTexture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
#ifdef GL_UNPACK_ROW_LENGTH
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
#endif
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
||||
|
||||
// Store our identifier
|
||||
io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture;
|
||||
|
||||
// Restore state
|
||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_DestroyFontsTexture()
|
||||
{
|
||||
if (g_FontTexture)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
glDeleteTextures(1, &g_FontTexture);
|
||||
io.Fonts->TexID = 0;
|
||||
g_FontTexture = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// If you get an error please report on github. You may try different GL context version or GLSL version. See GL<>GLSL version table at the top of this file.
|
||||
static bool CheckShader(GLuint handle, const char* desc)
|
||||
{
|
||||
GLint status = 0, log_length = 0;
|
||||
glGetShaderiv(handle, GL_COMPILE_STATUS, &status);
|
||||
glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &log_length);
|
||||
if ((GLboolean)status == GL_FALSE)
|
||||
fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile %s!\n", desc);
|
||||
if (log_length > 1)
|
||||
{
|
||||
ImVector<char> buf;
|
||||
buf.resize((int)(log_length + 1));
|
||||
glGetShaderInfoLog(handle, log_length, NULL, (GLchar*)buf.begin());
|
||||
fprintf(stderr, "%s\n", buf.begin());
|
||||
}
|
||||
return (GLboolean)status == GL_TRUE;
|
||||
}
|
||||
|
||||
// If you get an error please report on GitHub. You may try different GL context version or GLSL version.
|
||||
static bool CheckProgram(GLuint handle, const char* desc)
|
||||
{
|
||||
GLint status = 0, log_length = 0;
|
||||
glGetProgramiv(handle, GL_LINK_STATUS, &status);
|
||||
glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length);
|
||||
if ((GLboolean)status == GL_FALSE)
|
||||
fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link %s! (with GLSL '%s')\n", desc, g_GlslVersionString);
|
||||
if (log_length > 1)
|
||||
{
|
||||
ImVector<char> buf;
|
||||
buf.resize((int)(log_length + 1));
|
||||
glGetProgramInfoLog(handle, log_length, NULL, (GLchar*)buf.begin());
|
||||
fprintf(stderr, "%s\n", buf.begin());
|
||||
}
|
||||
return (GLboolean)status == GL_TRUE;
|
||||
}
|
||||
|
||||
bool ImGui_ImplOpenGL3_CreateDeviceObjects()
|
||||
{
|
||||
// Backup GL state
|
||||
GLint last_texture, last_array_buffer;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
GLint last_vertex_array;
|
||||
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
||||
#endif
|
||||
|
||||
// Parse GLSL version string
|
||||
int glsl_version = 130;
|
||||
sscanf(g_GlslVersionString, "#version %d", &glsl_version);
|
||||
|
||||
const GLchar* vertex_shader_glsl_120 =
|
||||
"uniform mat4 ProjMtx;\n"
|
||||
"attribute vec2 Position;\n"
|
||||
"attribute vec2 UV;\n"
|
||||
"attribute vec4 Color;\n"
|
||||
"varying vec2 Frag_UV;\n"
|
||||
"varying vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Frag_UV = UV;\n"
|
||||
" Frag_Color = Color;\n"
|
||||
" gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* vertex_shader_glsl_130 =
|
||||
"uniform mat4 ProjMtx;\n"
|
||||
"in vec2 Position;\n"
|
||||
"in vec2 UV;\n"
|
||||
"in vec4 Color;\n"
|
||||
"out vec2 Frag_UV;\n"
|
||||
"out vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Frag_UV = UV;\n"
|
||||
" Frag_Color = Color;\n"
|
||||
" gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* vertex_shader_glsl_300_es =
|
||||
"precision mediump float;\n"
|
||||
"layout (location = 0) in vec2 Position;\n"
|
||||
"layout (location = 1) in vec2 UV;\n"
|
||||
"layout (location = 2) in vec4 Color;\n"
|
||||
"uniform mat4 ProjMtx;\n"
|
||||
"out vec2 Frag_UV;\n"
|
||||
"out vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Frag_UV = UV;\n"
|
||||
" Frag_Color = Color;\n"
|
||||
" gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* vertex_shader_glsl_410_core =
|
||||
"layout (location = 0) in vec2 Position;\n"
|
||||
"layout (location = 1) in vec2 UV;\n"
|
||||
"layout (location = 2) in vec4 Color;\n"
|
||||
"uniform mat4 ProjMtx;\n"
|
||||
"out vec2 Frag_UV;\n"
|
||||
"out vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Frag_UV = UV;\n"
|
||||
" Frag_Color = Color;\n"
|
||||
" gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* fragment_shader_glsl_120 =
|
||||
"#ifdef GL_ES\n"
|
||||
" precision mediump float;\n"
|
||||
"#endif\n"
|
||||
"uniform sampler2D Texture;\n"
|
||||
"varying vec2 Frag_UV;\n"
|
||||
"varying vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_FragColor = Frag_Color * texture2D(Texture, Frag_UV.st);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* fragment_shader_glsl_130 =
|
||||
"uniform sampler2D Texture;\n"
|
||||
"in vec2 Frag_UV;\n"
|
||||
"in vec4 Frag_Color;\n"
|
||||
"out vec4 Out_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* fragment_shader_glsl_300_es =
|
||||
"precision mediump float;\n"
|
||||
"uniform sampler2D Texture;\n"
|
||||
"in vec2 Frag_UV;\n"
|
||||
"in vec4 Frag_Color;\n"
|
||||
"layout (location = 0) out vec4 Out_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* fragment_shader_glsl_410_core =
|
||||
"in vec2 Frag_UV;\n"
|
||||
"in vec4 Frag_Color;\n"
|
||||
"uniform sampler2D Texture;\n"
|
||||
"layout (location = 0) out vec4 Out_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
|
||||
"}\n";
|
||||
|
||||
// Select shaders matching our GLSL versions
|
||||
const GLchar* vertex_shader = NULL;
|
||||
const GLchar* fragment_shader = NULL;
|
||||
if (glsl_version < 130)
|
||||
{
|
||||
vertex_shader = vertex_shader_glsl_120;
|
||||
fragment_shader = fragment_shader_glsl_120;
|
||||
}
|
||||
else if (glsl_version >= 410)
|
||||
{
|
||||
vertex_shader = vertex_shader_glsl_410_core;
|
||||
fragment_shader = fragment_shader_glsl_410_core;
|
||||
}
|
||||
else if (glsl_version == 300)
|
||||
{
|
||||
vertex_shader = vertex_shader_glsl_300_es;
|
||||
fragment_shader = fragment_shader_glsl_300_es;
|
||||
}
|
||||
else
|
||||
{
|
||||
vertex_shader = vertex_shader_glsl_130;
|
||||
fragment_shader = fragment_shader_glsl_130;
|
||||
}
|
||||
|
||||
// Create shaders
|
||||
const GLchar* vertex_shader_with_version[2] = { g_GlslVersionString, vertex_shader };
|
||||
g_VertHandle = glCreateShader(GL_VERTEX_SHADER);
|
||||
glShaderSource(g_VertHandle, 2, vertex_shader_with_version, NULL);
|
||||
glCompileShader(g_VertHandle);
|
||||
CheckShader(g_VertHandle, "vertex shader");
|
||||
|
||||
const GLchar* fragment_shader_with_version[2] = { g_GlslVersionString, fragment_shader };
|
||||
g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
glShaderSource(g_FragHandle, 2, fragment_shader_with_version, NULL);
|
||||
glCompileShader(g_FragHandle);
|
||||
CheckShader(g_FragHandle, "fragment shader");
|
||||
|
||||
g_ShaderHandle = glCreateProgram();
|
||||
glAttachShader(g_ShaderHandle, g_VertHandle);
|
||||
glAttachShader(g_ShaderHandle, g_FragHandle);
|
||||
glLinkProgram(g_ShaderHandle);
|
||||
CheckProgram(g_ShaderHandle, "shader program");
|
||||
|
||||
g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture");
|
||||
g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx");
|
||||
g_AttribLocationVtxPos = (GLuint)glGetAttribLocation(g_ShaderHandle, "Position");
|
||||
g_AttribLocationVtxUV = (GLuint)glGetAttribLocation(g_ShaderHandle, "UV");
|
||||
g_AttribLocationVtxColor = (GLuint)glGetAttribLocation(g_ShaderHandle, "Color");
|
||||
|
||||
// Create buffers
|
||||
glGenBuffers(1, &g_VboHandle);
|
||||
glGenBuffers(1, &g_ElementsHandle);
|
||||
|
||||
ImGui_ImplOpenGL3_CreateFontsTexture();
|
||||
|
||||
// Restore modified GL state
|
||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
glBindVertexArray(last_vertex_array);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_DestroyDeviceObjects()
|
||||
{
|
||||
if (g_VboHandle) { glDeleteBuffers(1, &g_VboHandle); g_VboHandle = 0; }
|
||||
if (g_ElementsHandle) { glDeleteBuffers(1, &g_ElementsHandle); g_ElementsHandle = 0; }
|
||||
if (g_ShaderHandle && g_VertHandle) { glDetachShader(g_ShaderHandle, g_VertHandle); }
|
||||
if (g_ShaderHandle && g_FragHandle) { glDetachShader(g_ShaderHandle, g_FragHandle); }
|
||||
if (g_VertHandle) { glDeleteShader(g_VertHandle); g_VertHandle = 0; }
|
||||
if (g_FragHandle) { glDeleteShader(g_FragHandle); g_FragHandle = 0; }
|
||||
if (g_ShaderHandle) { glDeleteProgram(g_ShaderHandle); g_ShaderHandle = 0; }
|
||||
|
||||
ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||
}
|
87
src/external/imgui/imgui/imgui_impl_opengl3.h
vendored
87
src/external/imgui/imgui/imgui_impl_opengl3.h
vendored
|
@ -1,87 +0,0 @@
|
|||
// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
|
||||
// - Desktop GL: 2.x 3.x 4.x
|
||||
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
|
||||
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||
// [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||
|
||||
// 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.
|
||||
// https://github.com/ocornut/imgui
|
||||
|
||||
// About Desktop OpenGL function loaders:
|
||||
// Modern Desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
|
||||
// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
|
||||
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
|
||||
|
||||
// About GLSL version:
|
||||
// The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string.
|
||||
// On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es"
|
||||
// Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
|
||||
|
||||
#pragma once
|
||||
#include "imgui.h" // IMGUI_IMPL_API
|
||||
|
||||
// Backend API
|
||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL);
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
|
||||
|
||||
// (Optional) Called by Init/NewFrame/Shutdown
|
||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
||||
|
||||
// Specific OpenGL ES versions
|
||||
//#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten
|
||||
//#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android
|
||||
|
||||
// Attempt to auto-detect the default Desktop GL loader based on available header files.
|
||||
// If auto-detection fails or doesn't select the same GL loader file as used by your application,
|
||||
// you are likely to get a crash in ImGui_ImplOpenGL3_Init().
|
||||
// You can explicitly select a loader by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
|
||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_ES3) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
|
||||
|
||||
// Try to detect GLES on matching platforms
|
||||
#if defined(__APPLE__)
|
||||
#include "TargetConditionals.h"
|
||||
#endif
|
||||
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
|
||||
#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
|
||||
|
||||
// Otherwise try to detect supported Desktop OpenGL loaders..
|
||||
#elif defined(__has_include)
|
||||
#if __has_include(<GL/glew.h>)
|
||||
#define IMGUI_IMPL_OPENGL_LOADER_GLEW
|
||||
#elif __has_include(<glad/glad.h>)
|
||||
#define IMGUI_IMPL_OPENGL_LOADER_GLAD
|
||||
#elif __has_include(<glad/gl.h>)
|
||||
#define IMGUI_IMPL_OPENGL_LOADER_GLAD2
|
||||
#elif __has_include(<GL/gl3w.h>)
|
||||
#define IMGUI_IMPL_OPENGL_LOADER_GL3W
|
||||
#elif __has_include(<glbinding/glbinding.h>)
|
||||
#define IMGUI_IMPL_OPENGL_LOADER_GLBINDING3
|
||||
#elif __has_include(<glbinding/Binding.h>)
|
||||
#define IMGUI_IMPL_OPENGL_LOADER_GLBINDING2
|
||||
#else
|
||||
#error "Cannot detect OpenGL loader!"
|
||||
#endif
|
||||
#else
|
||||
#define IMGUI_IMPL_OPENGL_LOADER_GL3W // Default to GL3W embedded in our repository
|
||||
#endif
|
||||
|
||||
#endif
|
370
src/external/imgui/imgui/imgui_impl_sdl.cpp
vendored
370
src/external/imgui/imgui/imgui_impl_sdl.cpp
vendored
|
@ -1,370 +0,0 @@
|
|||
// dear imgui: Platform Binding for SDL2
|
||||
// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
|
||||
// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
|
||||
// (Requires: SDL 2.0. Prefer SDL 2.0.4+ for full feature support.)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||
// [X] Platform: Clipboard support.
|
||||
// [X] Platform: Keyboard arrays indexed using SDL_SCANCODE_* codes, e.g. ImGui::IsKeyPressed(SDL_SCANCODE_SPACE).
|
||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||
// Missing features:
|
||||
// [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
|
||||
|
||||
// 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.
|
||||
// https://github.com/ocornut/imgui
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2020-05-25: Misc: Report a zero display-size when window is minimized, to be consistent with other backends.
|
||||
// 2020-02-20: Inputs: Fixed mapping for ImGuiKey_KeyPadEnter (using SDL_SCANCODE_KP_ENTER instead of SDL_SCANCODE_RETURN2).
|
||||
// 2019-12-17: Inputs: On Wayland, use SDL_GetMouseState (because there is no global mouse state).
|
||||
// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
|
||||
// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter.
|
||||
// 2019-04-23: Inputs: Added support for SDL_GameController (if ImGuiConfigFlags_NavEnableGamepad is set by user application).
|
||||
// 2019-03-12: Misc: Preserve DisplayFramebufferScale when main window is minimized.
|
||||
// 2018-12-21: Inputs: Workaround for Android/iOS which don't seem to handle focus related calls.
|
||||
// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
|
||||
// 2018-11-14: Changed the signature of ImGui_ImplSDL2_ProcessEvent() to take a 'const SDL_Event*'.
|
||||
// 2018-08-01: Inputs: Workaround for Emscripten which doesn't seem to handle focus related calls.
|
||||
// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor.
|
||||
// 2018-06-08: Misc: Extracted imgui_impl_sdl.cpp/.h away from the old combined SDL2+OpenGL/Vulkan examples.
|
||||
// 2018-06-08: Misc: ImGui_ImplSDL2_InitForOpenGL() now takes a SDL_GLContext parameter.
|
||||
// 2018-05-09: Misc: Fixed clipboard paste memory leak (we didn't call SDL_FreeMemory on the data returned by SDL_GetClipboardText).
|
||||
// 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoMouseCursorChange flag.
|
||||
// 2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
|
||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
|
||||
// 2018-02-05: Misc: Using SDL_GetPerformanceCounter() instead of SDL_GetTicks() to be able to handle very high framerate (1000+ FPS).
|
||||
// 2018-02-05: Inputs: Keyboard mapping is using scancodes everywhere instead of a confusing mixture of keycodes and scancodes.
|
||||
// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
|
||||
// 2018-01-19: Inputs: When available (SDL 2.0.4+) using SDL_CaptureMouse() to retrieve coordinates outside of client area when dragging. Otherwise (SDL 2.0.3 and before) testing for SDL_WINDOW_INPUT_FOCUS instead of SDL_WINDOW_MOUSE_FOCUS.
|
||||
// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
|
||||
// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
|
||||
// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_sdl.h"
|
||||
|
||||
// SDL
|
||||
#include <SDL.h>
|
||||
#include <SDL_syswm.h>
|
||||
#if defined(__APPLE__)
|
||||
#include "TargetConditionals.h"
|
||||
#endif
|
||||
|
||||
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE SDL_VERSION_ATLEAST(2,0,4)
|
||||
#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
|
||||
|
||||
// Data
|
||||
static SDL_Window* g_Window = NULL;
|
||||
static Uint64 g_Time = 0;
|
||||
static bool g_MousePressed[3] = { false, false, false };
|
||||
static SDL_Cursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
|
||||
static char* g_ClipboardTextData = NULL;
|
||||
static bool g_MouseCanUseGlobalState = true;
|
||||
|
||||
static const char* ImGui_ImplSDL2_GetClipboardText(void*)
|
||||
{
|
||||
if (g_ClipboardTextData)
|
||||
SDL_free(g_ClipboardTextData);
|
||||
g_ClipboardTextData = SDL_GetClipboardText();
|
||||
return g_ClipboardTextData;
|
||||
}
|
||||
|
||||
static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
|
||||
{
|
||||
SDL_SetClipboardText(text);
|
||||
}
|
||||
|
||||
// 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.
|
||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
||||
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||
// If you have multiple SDL events and some of them are not meant to be used by dear imgui, you may need to filter events based on their windowID field.
|
||||
bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
switch (event->type)
|
||||
{
|
||||
case SDL_MOUSEWHEEL:
|
||||
{
|
||||
if (event->wheel.x > 0) io.MouseWheelH += 1;
|
||||
if (event->wheel.x < 0) io.MouseWheelH -= 1;
|
||||
if (event->wheel.y > 0) io.MouseWheel += 1;
|
||||
if (event->wheel.y < 0) io.MouseWheel -= 1;
|
||||
return true;
|
||||
}
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
{
|
||||
if (event->button.button == SDL_BUTTON_LEFT) g_MousePressed[0] = true;
|
||||
if (event->button.button == SDL_BUTTON_RIGHT) g_MousePressed[1] = true;
|
||||
if (event->button.button == SDL_BUTTON_MIDDLE) g_MousePressed[2] = true;
|
||||
return true;
|
||||
}
|
||||
case SDL_TEXTINPUT:
|
||||
{
|
||||
io.AddInputCharactersUTF8(event->text.text);
|
||||
return true;
|
||||
}
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
{
|
||||
int key = event->key.keysym.scancode;
|
||||
IM_ASSERT(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown));
|
||||
io.KeysDown[key] = (event->type == SDL_KEYDOWN);
|
||||
io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
|
||||
io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
|
||||
io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);
|
||||
#ifdef _WIN32
|
||||
io.KeySuper = false;
|
||||
#else
|
||||
io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ImGui_ImplSDL2_Init(SDL_Window* window)
|
||||
{
|
||||
g_Window = window;
|
||||
|
||||
// Setup back-end capabilities flags
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||
io.BackendPlatformName = "imgui_impl_sdl";
|
||||
|
||||
// Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
|
||||
io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
|
||||
io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
|
||||
io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
|
||||
io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
|
||||
io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
|
||||
io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
|
||||
io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
|
||||
io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
|
||||
io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
|
||||
io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT;
|
||||
io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
|
||||
io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
|
||||
io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
|
||||
io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
|
||||
io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
|
||||
io.KeyMap[ImGuiKey_KeyPadEnter] = SDL_SCANCODE_KP_ENTER;
|
||||
io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
|
||||
io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
|
||||
io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
|
||||
io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
|
||||
io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
|
||||
io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;
|
||||
|
||||
io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
|
||||
io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
|
||||
io.ClipboardUserData = NULL;
|
||||
|
||||
// Load mouse cursors
|
||||
g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
|
||||
g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
|
||||
g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
|
||||
g_MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
|
||||
g_MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
|
||||
g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
|
||||
g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
|
||||
g_MouseCursors[ImGuiMouseCursor_Hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
|
||||
g_MouseCursors[ImGuiMouseCursor_NotAllowed] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO);
|
||||
|
||||
// Check and store if we are on Wayland
|
||||
g_MouseCanUseGlobalState = strncmp(SDL_GetCurrentVideoDriver(), "wayland", 7) != 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
SDL_SysWMinfo wmInfo;
|
||||
SDL_VERSION(&wmInfo.version);
|
||||
SDL_GetWindowWMInfo(window, &wmInfo);
|
||||
io.ImeWindowHandle = wmInfo.info.win.window;
|
||||
#else
|
||||
(void)window;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
|
||||
{
|
||||
(void)sdl_gl_context; // Viewport branch will need this.
|
||||
return ImGui_ImplSDL2_Init(window);
|
||||
}
|
||||
|
||||
bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
|
||||
{
|
||||
#if !SDL_HAS_VULKAN
|
||||
IM_ASSERT(0 && "Unsupported");
|
||||
#endif
|
||||
return ImGui_ImplSDL2_Init(window);
|
||||
}
|
||||
|
||||
bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window)
|
||||
{
|
||||
#if !defined(_WIN32)
|
||||
IM_ASSERT(0 && "Unsupported");
|
||||
#endif
|
||||
return ImGui_ImplSDL2_Init(window);
|
||||
}
|
||||
|
||||
bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window)
|
||||
{
|
||||
return ImGui_ImplSDL2_Init(window);
|
||||
}
|
||||
|
||||
void ImGui_ImplSDL2_Shutdown()
|
||||
{
|
||||
g_Window = NULL;
|
||||
|
||||
// Destroy last known clipboard data
|
||||
if (g_ClipboardTextData)
|
||||
SDL_free(g_ClipboardTextData);
|
||||
g_ClipboardTextData = NULL;
|
||||
|
||||
// Destroy SDL mouse cursors
|
||||
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
||||
SDL_FreeCursor(g_MouseCursors[cursor_n]);
|
||||
memset(g_MouseCursors, 0, sizeof(g_MouseCursors));
|
||||
}
|
||||
|
||||
static void ImGui_ImplSDL2_UpdateMousePosAndButtons()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
// Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
||||
if (io.WantSetMousePos)
|
||||
SDL_WarpMouseInWindow(g_Window, (int)io.MousePos.x, (int)io.MousePos.y);
|
||||
else
|
||||
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
|
||||
int mx, my;
|
||||
Uint32 mouse_buttons = SDL_GetMouseState(&mx, &my);
|
||||
io.MouseDown[0] = g_MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
|
||||
io.MouseDown[1] = g_MousePressed[1] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
|
||||
io.MouseDown[2] = g_MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
|
||||
g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false;
|
||||
|
||||
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS)
|
||||
SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
||||
if (g_Window == focused_window)
|
||||
{
|
||||
if (g_MouseCanUseGlobalState)
|
||||
{
|
||||
// SDL_GetMouseState() gives mouse position seemingly based on the last window entered/focused(?)
|
||||
// The creation of a new windows at runtime and SDL_CaptureMouse both seems to severely mess up with that, so we retrieve that position globally.
|
||||
// Won't use this workaround when on Wayland, as there is no global mouse position.
|
||||
int wx, wy;
|
||||
SDL_GetWindowPosition(focused_window, &wx, &wy);
|
||||
SDL_GetGlobalMouseState(&mx, &my);
|
||||
mx -= wx;
|
||||
my -= wy;
|
||||
}
|
||||
io.MousePos = ImVec2((float)mx, (float)my);
|
||||
}
|
||||
|
||||
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger the OS window resize cursor.
|
||||
// The function is only supported from SDL 2.0.4 (released Jan 2016)
|
||||
bool any_mouse_button_down = ImGui::IsAnyMouseDown();
|
||||
SDL_CaptureMouse(any_mouse_button_down ? SDL_TRUE : SDL_FALSE);
|
||||
#else
|
||||
if (SDL_GetWindowFlags(g_Window) & SDL_WINDOW_INPUT_FOCUS)
|
||||
io.MousePos = ImVec2((float)mx, (float)my);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ImGui_ImplSDL2_UpdateMouseCursor()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)
|
||||
return;
|
||||
|
||||
ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
|
||||
if (io.MouseDrawCursor || imgui_cursor == ImGuiMouseCursor_None)
|
||||
{
|
||||
// Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
|
||||
SDL_ShowCursor(SDL_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show OS mouse cursor
|
||||
SDL_SetCursor(g_MouseCursors[imgui_cursor] ? g_MouseCursors[imgui_cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
|
||||
SDL_ShowCursor(SDL_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static void ImGui_ImplSDL2_UpdateGamepads()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
memset(io.NavInputs, 0, sizeof(io.NavInputs));
|
||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
||||
return;
|
||||
|
||||
// Get gamepad
|
||||
SDL_GameController* game_controller = SDL_GameControllerOpen(0);
|
||||
if (!game_controller)
|
||||
{
|
||||
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
||||
return;
|
||||
}
|
||||
|
||||
// Update gamepad inputs
|
||||
#define MAP_BUTTON(NAV_NO, BUTTON_NO) { io.NavInputs[NAV_NO] = (SDL_GameControllerGetButton(game_controller, BUTTON_NO) != 0) ? 1.0f : 0.0f; }
|
||||
#define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) { float vn = (float)(SDL_GameControllerGetAxis(game_controller, AXIS_NO) - V0) / (float)(V1 - V0); if (vn > 1.0f) vn = 1.0f; if (vn > 0.0f && io.NavInputs[NAV_NO] < vn) io.NavInputs[NAV_NO] = vn; }
|
||||
const int thumb_dead_zone = 8000; // SDL_gamecontroller.h suggests using this value.
|
||||
MAP_BUTTON(ImGuiNavInput_Activate, SDL_CONTROLLER_BUTTON_A); // Cross / A
|
||||
MAP_BUTTON(ImGuiNavInput_Cancel, SDL_CONTROLLER_BUTTON_B); // Circle / B
|
||||
MAP_BUTTON(ImGuiNavInput_Menu, SDL_CONTROLLER_BUTTON_X); // Square / X
|
||||
MAP_BUTTON(ImGuiNavInput_Input, SDL_CONTROLLER_BUTTON_Y); // Triangle / Y
|
||||
MAP_BUTTON(ImGuiNavInput_DpadLeft, SDL_CONTROLLER_BUTTON_DPAD_LEFT); // D-Pad Left
|
||||
MAP_BUTTON(ImGuiNavInput_DpadRight, SDL_CONTROLLER_BUTTON_DPAD_RIGHT); // D-Pad Right
|
||||
MAP_BUTTON(ImGuiNavInput_DpadUp, SDL_CONTROLLER_BUTTON_DPAD_UP); // D-Pad Up
|
||||
MAP_BUTTON(ImGuiNavInput_DpadDown, SDL_CONTROLLER_BUTTON_DPAD_DOWN); // D-Pad Down
|
||||
MAP_BUTTON(ImGuiNavInput_FocusPrev, SDL_CONTROLLER_BUTTON_LEFTSHOULDER); // L1 / LB
|
||||
MAP_BUTTON(ImGuiNavInput_FocusNext, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); // R1 / RB
|
||||
MAP_BUTTON(ImGuiNavInput_TweakSlow, SDL_CONTROLLER_BUTTON_LEFTSHOULDER); // L1 / LB
|
||||
MAP_BUTTON(ImGuiNavInput_TweakFast, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); // R1 / RB
|
||||
MAP_ANALOG(ImGuiNavInput_LStickLeft, SDL_CONTROLLER_AXIS_LEFTX, -thumb_dead_zone, -32768);
|
||||
MAP_ANALOG(ImGuiNavInput_LStickRight, SDL_CONTROLLER_AXIS_LEFTX, +thumb_dead_zone, +32767);
|
||||
MAP_ANALOG(ImGuiNavInput_LStickUp, SDL_CONTROLLER_AXIS_LEFTY, -thumb_dead_zone, -32767);
|
||||
MAP_ANALOG(ImGuiNavInput_LStickDown, SDL_CONTROLLER_AXIS_LEFTY, +thumb_dead_zone, +32767);
|
||||
|
||||
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
||||
#undef MAP_BUTTON
|
||||
#undef MAP_ANALOG
|
||||
}
|
||||
|
||||
void ImGui_ImplSDL2_NewFrame(SDL_Window* window)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");
|
||||
|
||||
// Setup display size (every frame to accommodate for window resizing)
|
||||
int w, h;
|
||||
int display_w, display_h;
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)
|
||||
w = h = 0;
|
||||
SDL_GL_GetDrawableSize(window, &display_w, &display_h);
|
||||
io.DisplaySize = ImVec2((float)w, (float)h);
|
||||
if (w > 0 && h > 0)
|
||||
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
||||
|
||||
// Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
|
||||
static Uint64 frequency = SDL_GetPerformanceFrequency();
|
||||
Uint64 current_time = SDL_GetPerformanceCounter();
|
||||
io.DeltaTime = g_Time > 0 ? (float)((double)(current_time - g_Time) / frequency) : (float)(1.0f / 60.0f);
|
||||
g_Time = current_time;
|
||||
|
||||
ImGui_ImplSDL2_UpdateMousePosAndButtons();
|
||||
ImGui_ImplSDL2_UpdateMouseCursor();
|
||||
|
||||
// Update game controllers (if enabled and available)
|
||||
ImGui_ImplSDL2_UpdateGamepads();
|
||||
}
|
29
src/external/imgui/imgui/imgui_impl_sdl.h
vendored
29
src/external/imgui/imgui/imgui_impl_sdl.h
vendored
|
@ -1,29 +0,0 @@
|
|||
// dear imgui: Platform Binding for SDL2
|
||||
// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
|
||||
// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||
// [X] Platform: Clipboard support.
|
||||
// [X] Platform: Keyboard arrays indexed using SDL_SCANCODE_* codes, e.g. ImGui::IsKeyPressed(SDL_SCANCODE_SPACE).
|
||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||
// Missing features:
|
||||
// [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
|
||||
|
||||
// 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.
|
||||
// https://github.com/ocornut/imgui
|
||||
|
||||
#pragma once
|
||||
#include "imgui.h" // IMGUI_IMPL_API
|
||||
|
||||
struct SDL_Window;
|
||||
typedef union SDL_Event SDL_Event;
|
||||
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window);
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window);
|
||||
IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame(SDL_Window* window);
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
3277
src/external/imgui/imgui/imgui_internal.h
vendored
3277
src/external/imgui/imgui/imgui_internal.h
vendored
File diff suppressed because it is too large
Load diff
4448
src/external/imgui/imgui/imgui_tables.cpp
vendored
Normal file
4448
src/external/imgui/imgui/imgui_tables.cpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
5367
src/external/imgui/imgui/imgui_widgets.cpp
vendored
5367
src/external/imgui/imgui/imgui_widgets.cpp
vendored
File diff suppressed because it is too large
Load diff
3622
src/external/imgui/imgui/implot.cpp
vendored
3622
src/external/imgui/imgui/implot.cpp
vendored
File diff suppressed because it is too large
Load diff
601
src/external/imgui/imgui/implot.h
vendored
601
src/external/imgui/imgui/implot.h
vendored
|
@ -1,601 +0,0 @@
|
|||
// MIT License
|
||||
|
||||
// Copyright (c) 2020 Evan Pezent
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// ImPlot v0.8 WIP
|
||||
|
||||
#pragma once
|
||||
#include "imgui.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Macros and Defines
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Define attributes of all API symbols declarations (e.g. for DLL under Windows)
|
||||
// Using ImPlot via a shared library is not recommended, because we don't guarantee
|
||||
// backward nor forward ABI compatibility and also function call overhead. If you
|
||||
// do use ImPlot as a DLL, be sure to call SetImGuiContext (details below).
|
||||
#ifndef IMPLOT_API
|
||||
#define IMPLOT_API
|
||||
#endif
|
||||
|
||||
// ImPlot version string
|
||||
#define IMPLOT_VERSION "0.8 WIP"
|
||||
// Indicates variable should deduced automatically.
|
||||
#define IMPLOT_AUTO -1
|
||||
// Special color used to indicate that a color should be deduced automatically.
|
||||
#define IMPLOT_AUTO_COL ImVec4(0,0,0,-1)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward Declarations and Basic Types
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Forward declarations
|
||||
struct ImPlotContext; // ImPlot context (opaque struct, see implot_internal.h)
|
||||
|
||||
// Enums/Flags
|
||||
typedef int ImPlotFlags; // -> enum ImPlotFlags_
|
||||
typedef int ImPlotAxisFlags; // -> enum ImPlotAxisFlags_
|
||||
typedef int ImPlotCol; // -> enum ImPlotCol_
|
||||
typedef int ImPlotStyleVar; // -> enum ImPlotStyleVar_
|
||||
typedef int ImPlotMarker; // -> enum ImPlotMarker_
|
||||
typedef int ImPlotColormap; // -> enum ImPlotColormap_
|
||||
|
||||
// Options for plots.
|
||||
enum ImPlotFlags_ {
|
||||
ImPlotFlags_None = 0, // default
|
||||
ImPlotFlags_NoLegend = 1 << 0, // the top-left legend will not be displayed
|
||||
ImPlotFlags_NoMenus = 1 << 1, // the user will not be able to open context menus with double-right click
|
||||
ImPlotFlags_NoBoxSelect = 1 << 2, // the user will not be able to box-select with right-mouse
|
||||
ImPlotFlags_NoMousePos = 1 << 3, // the mouse position, in plot coordinates, will not be displayed in the bottom-right
|
||||
ImPlotFlags_NoHighlight = 1 << 4, // plot items will not be highlighted when their legend entry is hovered
|
||||
ImPlotFlags_NoChild = 1 << 5, // a child window region will not be used to capture mouse scroll (can boost performance for single ImGui window applications)
|
||||
ImPlotFlags_YAxis2 = 1 << 6, // enable a 2nd y-axis on the right side
|
||||
ImPlotFlags_YAxis3 = 1 << 7, // enable a 3rd y-axis on the right side
|
||||
ImPlotFlags_Query = 1 << 8, // the user will be able to draw query rects with middle-mouse
|
||||
ImPlotFlags_Crosshairs = 1 << 9, // the default mouse cursor will be replaced with a crosshair when hovered
|
||||
ImPlotFlags_AntiAliased = 1 << 10, // plot lines will be software anti-aliased (not recommended for density plots, prefer MSAA)
|
||||
ImPlotFlags_CanvasOnly = ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMousePos
|
||||
};
|
||||
|
||||
// Options for plot axes (X and Y).
|
||||
enum ImPlotAxisFlags_ {
|
||||
ImPlotAxisFlags_None = 0, // default
|
||||
ImPlotAxisFlags_NoGridLines = 1 << 0, // no grid lines will be displayed
|
||||
ImPlotAxisFlags_NoTickMarks = 1 << 1, // no tick marks will be displayed
|
||||
ImPlotAxisFlags_NoTickLabels = 1 << 2, // no text labels will be displayed
|
||||
ImPlotAxisFlags_LogScale = 1 << 3, // a logartithmic (base 10) axis scale will be used (mutually exclusive with ImPlotAxisFlags_Time)
|
||||
ImPlotAxisFlags_Time = 1 << 4, // axis will display date/time formatted labels (mutually exclusive with ImPlotAxisFlags_LogScale)
|
||||
ImPlotAxisFlags_Invert = 1 << 5, // the axis will be inverted
|
||||
ImPlotAxisFlags_LockMin = 1 << 6, // the axis minimum value will be locked when panning/zooming
|
||||
ImPlotAxisFlags_LockMax = 1 << 7, // the axis maximum value will be locked when panning/zooming
|
||||
ImPlotAxisFlags_Lock = ImPlotAxisFlags_LockMin | ImPlotAxisFlags_LockMax,
|
||||
ImPlotAxisFlags_NoDecorations = ImPlotAxisFlags_NoGridLines | ImPlotAxisFlags_NoTickMarks | ImPlotAxisFlags_NoTickLabels
|
||||
};
|
||||
|
||||
// Plot styling colors.
|
||||
enum ImPlotCol_ {
|
||||
// item styling colors
|
||||
ImPlotCol_Line, // plot line/outline color (defaults to next unused color in current colormap)
|
||||
ImPlotCol_Fill, // plot fill color for bars (defaults to the current line color)
|
||||
ImPlotCol_MarkerOutline, // marker outline color (defaults to the current line color)
|
||||
ImPlotCol_MarkerFill, // marker fill color (defaults to the current line color)
|
||||
ImPlotCol_ErrorBar, // error bar color (defaults to ImGuiCol_Text)
|
||||
// plot styling colors
|
||||
ImPlotCol_FrameBg, // plot frame background color (defaults to ImGuiCol_FrameBg)
|
||||
ImPlotCol_PlotBg, // plot area background color (defaults to ImGuiCol_WindowBg)
|
||||
ImPlotCol_PlotBorder, // plot area border color (defaults to ImGuiCol_Border)
|
||||
ImPlotCol_LegendBg, // legend background color (defaults to ImGuiCol_PopupBg)
|
||||
ImPlotCol_LegendBorder, // legend border color (defaults to ImPlotCol_PlotBorder)
|
||||
ImPlotCol_LegendText, // legend text color (defaults to ImPlotCol_InlayText)
|
||||
ImPlotCol_TitleText, // plot title text color (defaults to ImGuiCol_Text)
|
||||
ImPlotCol_InlayText, // color of text appearing inside of plots (defaults to ImGuiCol_Text)
|
||||
ImPlotCol_XAxis, // x-axis label and tick lables color (defaults to ImGuiCol_Text)
|
||||
ImPlotCol_XAxisGrid, // x-axis grid color (defaults to 25% ImPlotCol_XAxis)
|
||||
ImPlotCol_YAxis, // y-axis label and tick labels color (defaults to ImGuiCol_Text)
|
||||
ImPlotCol_YAxisGrid, // y-axis grid color (defaults to 25% ImPlotCol_YAxis)
|
||||
ImPlotCol_YAxis2, // 2nd y-axis label and tick labels color (defaults to ImGuiCol_Text)
|
||||
ImPlotCol_YAxisGrid2, // 2nd y-axis grid/label color (defaults to 25% ImPlotCol_YAxis2)
|
||||
ImPlotCol_YAxis3, // 3rd y-axis label and tick labels color (defaults to ImGuiCol_Text)
|
||||
ImPlotCol_YAxisGrid3, // 3rd y-axis grid/label color (defaults to 25% ImPlotCol_YAxis3)
|
||||
ImPlotCol_Selection, // box-selection color (defaults to yellow)
|
||||
ImPlotCol_Query, // box-query color (defaults to green)
|
||||
ImPlotCol_Crosshairs, // crosshairs color (defaults to ImPlotCol_PlotBorder)
|
||||
ImPlotCol_COUNT
|
||||
};
|
||||
|
||||
// Plot styling variables.
|
||||
enum ImPlotStyleVar_ {
|
||||
// item styling variables
|
||||
ImPlotStyleVar_LineWeight, // float, plot item line weight in pixels
|
||||
ImPlotStyleVar_Marker, // int, marker specification
|
||||
ImPlotStyleVar_MarkerSize, // float, marker size in pixels (roughly the marker's "radius")
|
||||
ImPlotStyleVar_MarkerWeight, // float, plot outline weight of markers in pixels
|
||||
ImPlotStyleVar_FillAlpha, // float, alpha modifier applied to all plot item fills
|
||||
ImPlotStyleVar_ErrorBarSize, // float, error bar whisker width in pixels
|
||||
ImPlotStyleVar_ErrorBarWeight, // float, error bar whisker weight in pixels
|
||||
ImPlotStyleVar_DigitalBitHeight, // float, digital channels bit height (at 1) in pixels
|
||||
ImPlotStyleVar_DigitalBitGap, // float, digital channels bit padding gap in pixels
|
||||
// plot styling variables
|
||||
ImPlotStyleVar_PlotBorderSize, // float, thickness of border around plot area
|
||||
ImPlotStyleVar_MinorAlpha, // float, alpha multiplier applied to minor axis grid lines
|
||||
ImPlotStyleVar_MajorTickLen, // ImVec2, major tick lengths for X and Y axes
|
||||
ImPlotStyleVar_MinorTickLen, // ImVec2, minor tick lengths for X and Y axes
|
||||
ImPlotStyleVar_MajorTickSize, // ImVec2, line thickness of major ticks
|
||||
ImPlotStyleVar_MinorTickSize, // ImVec2, line thickness of minor ticks
|
||||
ImPlotStyleVar_MajorGridSize, // ImVec2, line thickness of major grid lines
|
||||
ImPlotStyleVar_MinorGridSize, // ImVec2, line thickness of minor grid lines
|
||||
ImPlotStyleVar_PlotPadding, // ImVec2, padding between widget frame and plot area and/or labels
|
||||
ImPlotStyleVar_LabelPadding, // ImVec2, padding between axes labels, tick labels, and plot edge
|
||||
ImPlotStyleVar_LegendPadding, // ImVec2, legend padding from top-left of plot
|
||||
ImPlotStyleVar_InfoPadding, // ImVec2, padding between plot edge and interior info text
|
||||
ImPlotStyleVar_PlotMinSize, // ImVec2, minimum size plot frame can be when shrunk
|
||||
ImPlotStyleVar_COUNT
|
||||
};
|
||||
|
||||
// Marker specifications.
|
||||
enum ImPlotMarker_ {
|
||||
ImPlotMarker_None = -1, // no marker
|
||||
ImPlotMarker_Circle, // a circle marker
|
||||
ImPlotMarker_Square, // a square maker
|
||||
ImPlotMarker_Diamond, // a diamond marker
|
||||
ImPlotMarker_Up, // an upward-pointing triangle marker
|
||||
ImPlotMarker_Down, // an downward-pointing triangle marker
|
||||
ImPlotMarker_Left, // an leftward-pointing triangle marker
|
||||
ImPlotMarker_Right, // an rightward-pointing triangle marker
|
||||
ImPlotMarker_Cross, // a cross marker (not fillable)
|
||||
ImPlotMarker_Plus, // a plus marker (not fillable)
|
||||
ImPlotMarker_Asterisk, // a asterisk marker (not fillable)
|
||||
ImPlotMarker_COUNT
|
||||
};
|
||||
|
||||
// Built-in colormaps
|
||||
enum ImPlotColormap_ {
|
||||
ImPlotColormap_Default = 0, // ImPlot default colormap (n=10)
|
||||
ImPlotColormap_Deep = 1, // a.k.a. seaborn deep (n=10)
|
||||
ImPlotColormap_Dark = 2, // a.k.a. matplotlib "Set1" (n=9)
|
||||
ImPlotColormap_Pastel = 3, // a.k.a. matplotlib "Pastel1" (n=9)
|
||||
ImPlotColormap_Paired = 4, // a.k.a. matplotlib "Paired" (n=12)
|
||||
ImPlotColormap_Viridis = 5, // a.k.a. matplotlib "viridis" (n=11)
|
||||
ImPlotColormap_Plasma = 6, // a.k.a. matplotlib "plasma" (n=11)
|
||||
ImPlotColormap_Hot = 7, // a.k.a. matplotlib/MATLAB "hot" (n=11)
|
||||
ImPlotColormap_Cool = 8, // a.k.a. matplotlib/MATLAB "cool" (n=11)
|
||||
ImPlotColormap_Pink = 9, // a.k.a. matplotlib/MATLAB "pink" (n=11)
|
||||
ImPlotColormap_Jet = 10, // a.k.a. MATLAB "jet" (n=11)
|
||||
ImPlotColormap_COUNT
|
||||
};
|
||||
|
||||
// Double precision version of ImVec2 used by ImPlot. Extensible by end users.
|
||||
struct ImPlotPoint {
|
||||
double x, y;
|
||||
ImPlotPoint() { x = y = 0.0; }
|
||||
ImPlotPoint(double _x, double _y) { x = _x; y = _y; }
|
||||
double operator[] (size_t idx) const { return (&x)[idx]; }
|
||||
double& operator[] (size_t idx) { return (&x)[idx]; }
|
||||
#ifdef IMPLOT_POINT_CLASS_EXTRA
|
||||
IMPLOT_POINT_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h
|
||||
// to convert back and forth between your math types and ImPlotPoint.
|
||||
#endif
|
||||
};
|
||||
|
||||
// A range defined by a min/max value. Used for plot axes ranges.
|
||||
struct ImPlotRange {
|
||||
double Min, Max;
|
||||
ImPlotRange() { Min = 0; Max = 0; }
|
||||
ImPlotRange(double _min, double _max) { Min = _min; Max = _max; }
|
||||
bool Contains(double value) const { return value >= Min && value <= Max; };
|
||||
double Size() const { return Max - Min; };
|
||||
};
|
||||
|
||||
// Combination of two ranges for X and Y axes.
|
||||
struct ImPlotLimits {
|
||||
ImPlotRange X, Y;
|
||||
bool Contains(const ImPlotPoint& p) const { return Contains(p.x, p.y); }
|
||||
bool Contains(double x, double y) const { return X.Contains(x) && Y.Contains(y); }
|
||||
};
|
||||
|
||||
// Plot style structure
|
||||
struct ImPlotStyle {
|
||||
// item styling variables
|
||||
float LineWeight; // = 1, item line weight in pixels
|
||||
int Marker; // = ImPlotMarker_None, marker specification
|
||||
float MarkerSize; // = 4, marker size in pixels (roughly the marker's "radius")
|
||||
float MarkerWeight; // = 1, outline weight of markers in pixels
|
||||
float FillAlpha; // = 1, alpha modifier applied to plot fills
|
||||
float ErrorBarSize; // = 5, error bar whisker width in pixels
|
||||
float ErrorBarWeight; // = 1.5, error bar whisker weight in pixels
|
||||
float DigitalBitHeight; // = 8, digital channels bit height (at y = 1.0f) in pixels
|
||||
float DigitalBitGap; // = 4, digital channels bit padding gap in pixels
|
||||
// plot styling variables
|
||||
float PlotBorderSize; // = 1, line thickness of border around plot area
|
||||
float MinorAlpha; // = 0.25 alpha multiplier applied to minor axis grid lines
|
||||
ImVec2 MajorTickLen; // = 10,10 major tick lengths for X and Y axes
|
||||
ImVec2 MinorTickLen; // = 5,5 minor tick lengths for X and Y axes
|
||||
ImVec2 MajorTickSize; // = 1,1 line thickness of major ticks
|
||||
ImVec2 MinorTickSize; // = 1,1 line thickness of minor ticks
|
||||
ImVec2 MajorGridSize; // = 1,1 line thickness of major grid lines
|
||||
ImVec2 MinorGridSize; // = 1,1 line thickness of minor grid lines
|
||||
ImVec2 PlotPadding; // = 8,8 padding between widget frame and plot area and/or labels
|
||||
ImVec2 LabelPadding; // = 5,5 padding between axes labels, tick labels, and plot edge
|
||||
ImVec2 LegendPadding; // = 10,10 legend padding from top-left of plot
|
||||
ImVec2 InfoPadding; // = 10,10 padding between plot edge and interior info text
|
||||
ImVec2 PlotMinSize; // = 300,225 minimum size plot frame can be when shrunk
|
||||
// colors
|
||||
ImVec4 Colors[ImPlotCol_COUNT]; // array of plot specific colors
|
||||
// settings/flags
|
||||
bool AntiAliasedLines; // = false, enable global anti-aliasing on plot lines (overrides ImPlotFlags_AntiAliased)
|
||||
bool UseLocalTime; // = false, axis labels will be formatted for your timezone when ImPlotAxisFlag_Time is enabled
|
||||
IMPLOT_API ImPlotStyle();
|
||||
};
|
||||
|
||||
// Input mapping structure, default values listed in the comments.
|
||||
struct ImPlotInputMap {
|
||||
ImGuiMouseButton PanButton; // LMB enables panning when held
|
||||
ImGuiKeyModFlags PanMod; // none optional modifier that must be held for panning
|
||||
ImGuiMouseButton FitButton; // LMB fits visible data when double clicked
|
||||
ImGuiMouseButton ContextMenuButton; // RMB opens plot context menu (if enabled) when double clicked
|
||||
ImGuiMouseButton BoxSelectButton; // RMB begins box selection when pressed and confirms selection when released
|
||||
ImGuiKeyModFlags BoxSelectMod; // none optional modifier that must be held for box selection
|
||||
ImGuiMouseButton BoxSelectCancelButton; // LMB cancels active box selection when pressed
|
||||
ImGuiMouseButton QueryButton; // MMB begins query selection when pressed and end query selection when released
|
||||
ImGuiKeyModFlags QueryMod; // none optional modifier that must be held for query selection
|
||||
ImGuiKeyModFlags QueryToggleMod; // Ctrl when held, active box selections turn into queries
|
||||
ImGuiKeyModFlags HorizontalMod; // Alt expands active box selection/query horizontally to plot edge when held
|
||||
ImGuiKeyModFlags VerticalMod; // Shift expands active box selection/query vertically to plot edge when held
|
||||
IMPLOT_API ImPlotInputMap();
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ImPlot End-User API
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace ImPlot {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ImPlot Context
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Creates a new ImPlot context. Call this after ImGui::CreateContext.
|
||||
IMPLOT_API ImPlotContext* CreateContext();
|
||||
// Destroys an ImPlot context. Call this before ImGui::DestroyContext. NULL = destroy current context
|
||||
IMPLOT_API void DestroyContext(ImPlotContext* ctx = NULL);
|
||||
// Returns the current ImPlot context. NULL if no context has ben set.
|
||||
IMPLOT_API ImPlotContext* GetCurrentContext();
|
||||
// Sets the current ImPlot context.
|
||||
IMPLOT_API void SetCurrentContext(ImPlotContext* ctx);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Begin/End Plot
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Starts a 2D plotting context. If this function returns true, EndPlot() must
|
||||
// be called, e.g. "if (BeginPlot(...)) { ... EndPlot(); }". #title_id must
|
||||
// be unique. If you need to avoid ID collisions or don't want to display a
|
||||
// title in the plot, use double hashes (e.g. "MyPlot##Hidden" or "##NoTitle").
|
||||
// If #x_label and/or #y_label are provided, axes labels will be displayed.
|
||||
IMPLOT_API bool BeginPlot(const char* title_id,
|
||||
const char* x_label = NULL,
|
||||
const char* y_label = NULL,
|
||||
const ImVec2& size = ImVec2(-1,0),
|
||||
ImPlotFlags flags = ImPlotFlags_None,
|
||||
ImPlotAxisFlags x_flags = ImPlotAxisFlags_None,
|
||||
ImPlotAxisFlags y_flags = ImPlotAxisFlags_None,
|
||||
ImPlotAxisFlags y2_flags = ImPlotAxisFlags_NoGridLines,
|
||||
ImPlotAxisFlags y3_flags = ImPlotAxisFlags_NoGridLines);
|
||||
|
||||
// Only call EndPlot() if BeginPlot() returns true! Typically called at the end
|
||||
// of an if statement conditioned on BeginPlot().
|
||||
IMPLOT_API void EndPlot();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Plot Items
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// The template functions below are explicitly instantiated in implot_items.cpp.
|
||||
// They are not intended to be used generically with custom types. You will get
|
||||
// a linker error if you try! All functions support the following scalar types:
|
||||
//
|
||||
// float, double, ImS8, ImU8, ImS16, ImU16, ImS32, ImU32, ImS64, ImU64
|
||||
//
|
||||
//
|
||||
// If you need to plot custom or non-homogenous data you have a few options:
|
||||
//
|
||||
// 1. If your data is a simple struct/class (e.g. Vector2f), you can use striding.
|
||||
// This is the most performant option if applicable.
|
||||
//
|
||||
// struct Vector2f { float X, Y; };
|
||||
// ...
|
||||
// Vector2f data[42];
|
||||
// ImPlot::PlotLine("line", &data[0].x, &data[0].y, 42, 0, sizeof(Vector2f)); // or sizeof(float)*2
|
||||
//
|
||||
// 2. Write a custom getter function or C++ lambda and pass it and your data to
|
||||
// an ImPlot function post-fixed with a G (e.g. PlotScatterG). This has a
|
||||
// slight performance cost, but probably not enough to worry about.
|
||||
//
|
||||
// ImPlotPoint MyDataGetter(void* data, int idx) {
|
||||
// MyData* my_data = (MyData*)data;
|
||||
// ImPlotPoint p;
|
||||
// p.x = my_data->GetTime(idx);
|
||||
// p.y = my_data->GetValue(idx);
|
||||
// return p
|
||||
// }
|
||||
// ...
|
||||
// MyData my_data;
|
||||
// ImPlot::PlotScatterG("scatter", MyDataGetter, &my_data, my_data.Size());
|
||||
//
|
||||
// NB: All types are converted to double before plotting. You may loose information
|
||||
// if you try plotting extremely large 64-bit integral types. Proceed with caution!
|
||||
|
||||
// Plots a standard 2D line plot.
|
||||
template <typename T> IMPLOT_API void PlotLine(const char* label_id, const T* values, int count, int offset = 0, int stride = sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotLine(const char* label_id, const T* xs, const T* ys, int count, int offset = 0, int stride = sizeof(T));
|
||||
IMPLOT_API void PlotLineG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0);
|
||||
|
||||
// Plots a standard 2D scatter plot. Default marker is ImPlotMarker_Circle.
|
||||
template <typename T> IMPLOT_API void PlotScatter(const char* label_id, const T* values, int count, int offset = 0, int stride = sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotScatter(const char* label_id, const T* xs, const T* ys, int count, int offset = 0, int stride = sizeof(T));
|
||||
IMPLOT_API void PlotScatterG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0);
|
||||
|
||||
// Plots a shaded (filled) region between two lines, or a line and a horizontal reference.
|
||||
template <typename T> IMPLOT_API void PlotShaded(const char* label_id, const T* values, int count, double y_ref = 0, int offset = 0, int stride = sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotShaded(const char* label_id, const T* xs, const T* ys, int count, double y_ref = 0, int offset = 0, int stride = sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotShaded(const char* label_id, const T* xs, const T* ys1, const T* ys2, int count, int offset = 0, int stride = sizeof(T));
|
||||
IMPLOT_API void PlotShadedG(const char* label_id, ImPlotPoint (*getter1)(void* data, int idx), void* data1, ImPlotPoint (*getter2)(void* data, int idx), void* data2, int count, int offset = 0);
|
||||
|
||||
// Plots a vertical bar graph. #width and #shift are in X units.
|
||||
template <typename T> IMPLOT_API void PlotBars(const char* label_id, const T* values, int count, double width = 0.67, double shift = 0, int offset = 0, int stride = sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotBars(const char* label_id, const T* xs, const T* ys, int count, double width, int offset = 0, int stride = sizeof(T));
|
||||
IMPLOT_API void PlotBarsG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, double width, int offset = 0);
|
||||
|
||||
// Plots a horizontal bar graph. #height and #shift are in Y units.
|
||||
template <typename T> IMPLOT_API void PlotBarsH(const char* label_id, const T* values, int count, double height = 0.67, double shift = 0, int offset = 0, int stride = sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotBarsH(const char* label_id, const T* xs, const T* ys, int count, double height, int offset = 0, int stride = sizeof(T));
|
||||
IMPLOT_API void PlotBarsHG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, double height, int offset = 0);
|
||||
|
||||
// Plots vertical error bar. The label_id should be the same as the label_id of the associated line or bar plot.
|
||||
template <typename T> IMPLOT_API void PlotErrorBars(const char* label_id, const T* xs, const T* ys, const T* err, int count, int offset = 0, int stride = sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotErrorBars(const char* label_id, const T* xs, const T* ys, const T* neg, const T* pos, int count, int offset = 0, int stride = sizeof(T));
|
||||
|
||||
// Plots horizontal error bars. The label_id should be the same as the label_id of the associated line or bar plot.
|
||||
template <typename T> IMPLOT_API void PlotErrorBarsH(const char* label_id, const T* xs, const T* ys, const T* err, int count, int offset = 0, int stride = sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotErrorBarsH(const char* label_id, const T* xs, const T* ys, const T* neg, const T* pos, int count, int offset = 0, int stride = sizeof(T));
|
||||
|
||||
/// Plots vertical stems.
|
||||
template <typename T> IMPLOT_API void PlotStems(const char* label_id, const T* values, int count, double y_ref = 0, int offset = 0, int stride = sizeof(T));
|
||||
template <typename T> IMPLOT_API void PlotStems(const char* label_id, const T* xs, const T* ys, int count, double y_ref = 0, int offset = 0, int stride = sizeof(T));
|
||||
|
||||
// Plots a pie chart. If the sum of values > 1 or normalize is true, each value will be normalized. Center and radius are in plot units. #label_fmt can be set to NULL for no labels.
|
||||
template <typename T> IMPLOT_API void PlotPieChart(const char* const label_ids[], const T* values, int count, double x, double y, double radius, bool normalize = false, const char* label_fmt = "%.1f", double angle0 = 90);
|
||||
|
||||
// Plots a 2D heatmap chart. Values are expected to be in row-major order. #label_fmt can be set to NULL for no labels.
|
||||
template <typename T> IMPLOT_API void PlotHeatmap(const char* label_id, const T* values, int rows, int cols, double scale_min, double scale_max, const char* label_fmt = "%.1f", const ImPlotPoint& bounds_min = ImPlotPoint(0,0), const ImPlotPoint& bounds_max = ImPlotPoint(1,1));
|
||||
|
||||
// Plots digital data. Digital plots do not respond to y drag or zoom, and are always referenced to the bottom of the plot.
|
||||
template <typename T> IMPLOT_API void PlotDigital(const char* label_id, const T* xs, const T* ys, int count, int offset = 0, int stride = sizeof(T));
|
||||
IMPLOT_API void PlotDigitalG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0);
|
||||
|
||||
// Plots a centered text label at point x,y with optional pixel offset. Text color can be changed with ImPlot::PushStyleColor(ImPlotCol_InlayText, ...).
|
||||
IMPLOT_API void PlotText(const char* text, double x, double y, bool vertical = false, const ImVec2& pixel_offset = ImVec2(0,0));
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Plot Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Set the axes range limits of the next plot. Call right before BeginPlot(). If ImGuiCond_Always is used, the axes limits will be locked.
|
||||
IMPLOT_API void SetNextPlotLimits(double xmin, double xmax, double ymin, double ymax, ImGuiCond cond = ImGuiCond_Once);
|
||||
// Set the X axis range limits of the next plot. Call right before BeginPlot(). If ImGuiCond_Always is used, the X axis limits will be locked.
|
||||
IMPLOT_API void SetNextPlotLimitsX(double xmin, double xmax, ImGuiCond cond = ImGuiCond_Once);
|
||||
// Set the Y axis range limits of the next plot. Call right before BeginPlot(). If ImGuiCond_Always is used, the Y axis limits will be locked.
|
||||
IMPLOT_API void SetNextPlotLimitsY(double ymin, double ymax, ImGuiCond cond = ImGuiCond_Once, int y_axis = 0);
|
||||
// Links the next plot limits to external values. Set to NULL for no linkage. The pointer data must remain valid until the matching call EndPlot.
|
||||
IMPLOT_API void LinkNextPlotLimits(double* xmin, double* xmax, double* ymin, double* ymax, double* ymin2 = NULL, double* ymax2 = NULL, double* ymin3 = NULL, double* ymax3 = NULL);
|
||||
// Fits the next plot axes to all plotted data if they are unlocked (equivalent to double-clicks).
|
||||
IMPLOT_API void FitNextPlotAxes(bool x = true, bool y = true, bool y2 = true, bool y3 = true);
|
||||
|
||||
// Set the X axis ticks and optionally the labels for the next plot.
|
||||
IMPLOT_API void SetNextPlotTicksX(const double* values, int n_ticks, const char* const labels[] = NULL, bool show_default = false);
|
||||
IMPLOT_API void SetNextPlotTicksX(double x_min, double x_max, int n_ticks, const char* const labels[] = NULL, bool show_default = false);
|
||||
|
||||
// Set the Y axis ticks and optionally the labels for the next plot.
|
||||
IMPLOT_API void SetNextPlotTicksY(const double* values, int n_ticks, const char* const labels[] = NULL, bool show_default = false, int y_axis = 0);
|
||||
IMPLOT_API void SetNextPlotTicksY(double y_min, double y_max, int n_ticks, const char* const labels[] = NULL, bool show_default = false, int y_axis = 0);
|
||||
|
||||
// Select which Y axis will be used for subsequent plot elements. The default is '0', or the first (left) Y axis. Enable 2nd and 3rd axes with ImPlotFlags_YAxisX.
|
||||
IMPLOT_API void SetPlotYAxis(int y_axis);
|
||||
|
||||
// Convert pixels to a position in the current plot's coordinate system. A negative y_axis uses the current value of SetPlotYAxis (0 initially).
|
||||
IMPLOT_API ImPlotPoint PixelsToPlot(const ImVec2& pix, int y_axis = IMPLOT_AUTO);
|
||||
IMPLOT_API ImPlotPoint PixelsToPlot(float x, float y, int y_axis = IMPLOT_AUTO);
|
||||
|
||||
// Convert a position in the current plot's coordinate system to pixels. A negative y_axis uses the current value of SetPlotYAxis (0 initially).
|
||||
IMPLOT_API ImVec2 PlotToPixels(const ImPlotPoint& plt, int y_axis = IMPLOT_AUTO);
|
||||
IMPLOT_API ImVec2 PlotToPixels(double x, double y, int y_axis = IMPLOT_AUTO);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Plot Queries
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Use these functions to retrieve information about the current plot. They
|
||||
// MUST be called between BeginPlot and EndPlot!
|
||||
|
||||
// Get the current Plot position (top-left) in pixels.
|
||||
IMPLOT_API ImVec2 GetPlotPos();
|
||||
// Get the curent Plot size in pixels.
|
||||
IMPLOT_API ImVec2 GetPlotSize();
|
||||
// Returns true if the plot area in the current plot is hovered.
|
||||
IMPLOT_API bool IsPlotHovered();
|
||||
// Returns true if the XAxis plot area in the current plot is hovered.
|
||||
IMPLOT_API bool IsPlotXAxisHovered();
|
||||
// Returns true if the YAxis[n] plot area in the current plot is hovered.
|
||||
IMPLOT_API bool IsPlotYAxisHovered(int y_axis = 0);
|
||||
// Returns the mouse position in x,y coordinates of the current plot. A negative y_axis uses the current value of SetPlotYAxis (0 initially).
|
||||
IMPLOT_API ImPlotPoint GetPlotMousePos(int y_axis = IMPLOT_AUTO);
|
||||
// Returns the current plot axis range. A negative y_axis uses the current value of SetPlotYAxis (0 initially).
|
||||
IMPLOT_API ImPlotLimits GetPlotLimits(int y_axis = IMPLOT_AUTO);
|
||||
// Returns true if the current plot is being queried.
|
||||
IMPLOT_API bool IsPlotQueried();
|
||||
// Returns the current plot query bounds.
|
||||
IMPLOT_API ImPlotLimits GetPlotQuery(int y_axis = IMPLOT_AUTO);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Plot and Item Styling
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Provides access to plot style structure for permanant modifications to colors, sizes, etc.
|
||||
IMPLOT_API ImPlotStyle& GetStyle();
|
||||
|
||||
// Style colors for current ImGui style (default).
|
||||
IMPLOT_API void StyleColorsAuto(ImPlotStyle* dst = NULL);
|
||||
// Style colors for ImGui "Classic".
|
||||
IMPLOT_API void StyleColorsClassic(ImPlotStyle* dst = NULL);
|
||||
// Style colors for ImGui "Dark".
|
||||
IMPLOT_API void StyleColorsDark(ImPlotStyle* dst = NULL);
|
||||
// Style colors for ImGui "Light".
|
||||
IMPLOT_API void StyleColorsLight(ImPlotStyle* dst = NULL);
|
||||
|
||||
// Use PushStyleX to temporarily modify your ImPlotStyle. The modification
|
||||
// will last until the matching call to PopStyleX. You MUST call a pop for
|
||||
// every push, otherwise you will leak memory! This behaves just like ImGui.
|
||||
|
||||
// Temporarily modify a plot color. Don't forget to call PopStyleColor!
|
||||
IMPLOT_API void PushStyleColor(ImPlotCol idx, ImU32 col);
|
||||
IMPLOT_API void PushStyleColor(ImPlotCol idx, const ImVec4& col);
|
||||
// Undo temporary color modification. Undo multiple pushes at once by increasing count.
|
||||
IMPLOT_API void PopStyleColor(int count = 1);
|
||||
|
||||
// Temporarily modify a style variable of float type. Don't forget to call PopStyleVar!
|
||||
IMPLOT_API void PushStyleVar(ImPlotStyleVar idx, float val);
|
||||
// Temporarily modify a style variable of int type. Don't forget to call PopStyleVar!
|
||||
IMPLOT_API void PushStyleVar(ImPlotStyleVar idx, int val);
|
||||
// Temporarily modify a style variable of ImVec2 type. Don't forget to call PopStyleVar!
|
||||
IMPLOT_API void PushStyleVar(ImPlotStyleVar idx, const ImVec2& val);
|
||||
// Undo temporary style modification. Undo multiple pushes at once by increasing count.
|
||||
IMPLOT_API void PopStyleVar(int count = 1);
|
||||
|
||||
// The following can be used to modify the style of the next plot item ONLY. They do
|
||||
// NOT require calls to PopStyleX. Leave style attributes you don't want modified to
|
||||
// IMPLOT_AUTO or IMPLOT_AUTO_COL. Automatic styles will be deduced from the current
|
||||
// values in your ImPlotStyle or from Colormap data.
|
||||
|
||||
// Set the line color and weight for the next item only.
|
||||
IMPLOT_API void SetNextLineStyle(const ImVec4& col = IMPLOT_AUTO_COL, float weight = IMPLOT_AUTO);
|
||||
// Set the fill color for the next item only.
|
||||
IMPLOT_API void SetNextFillStyle(const ImVec4& col = IMPLOT_AUTO_COL, float alpha_mod = IMPLOT_AUTO);
|
||||
// Set the marker style for the next item only.
|
||||
IMPLOT_API void SetNextMarkerStyle(ImPlotMarker marker = IMPLOT_AUTO, float size = IMPLOT_AUTO, const ImVec4& fill = IMPLOT_AUTO_COL, float weight = IMPLOT_AUTO, const ImVec4& outline = IMPLOT_AUTO_COL);
|
||||
// Set the error bar style for the next item only.
|
||||
IMPLOT_API void SetNextErrorBarStyle(const ImVec4& col = IMPLOT_AUTO_COL, float size = IMPLOT_AUTO, float weight = IMPLOT_AUTO);
|
||||
|
||||
// Returns the null terminated string name for an ImPlotCol.
|
||||
IMPLOT_API const char* GetStyleColorName(ImPlotCol color);
|
||||
// Returns the null terminated string name for an ImPlotMarker.
|
||||
IMPLOT_API const char* GetMarkerName(ImPlotMarker marker);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Colormaps
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Item styling is based on Colormaps when the relevant ImPlotCol is set to
|
||||
// IMPLOT_AUTO_COL (default). Several built in colormaps are available and can be
|
||||
// toggled in the demo. You can push/pop or set your own colormaps as well.
|
||||
|
||||
// The Colormap data will be ignored and a custom color will be used if you have either:
|
||||
// 1) Modified an item style color in your ImPlotStyle to anything but IMPLOT_AUTO_COL.
|
||||
// 2) Pushed an item style color using PushStyleColor().
|
||||
// 3) Set the next item style with a SetNextXStyle function.
|
||||
|
||||
// Temporarily switch to one of the built-in colormaps.
|
||||
IMPLOT_API void PushColormap(ImPlotColormap colormap);
|
||||
// Temporarily switch to your custom colormap. The pointer data must persist until the matching call to PopColormap!
|
||||
IMPLOT_API void PushColormap(const ImVec4* colormap, int size);
|
||||
// Undo temporary colormap modification.
|
||||
IMPLOT_API void PopColormap(int count = 1);
|
||||
|
||||
// Permanently sets a custom colormap. The colors will be copied to internal memory. Prefer PushColormap instead of calling this each frame.
|
||||
IMPLOT_API void SetColormap(const ImVec4* colormap, int size);
|
||||
// Permanently switch to one of the built-in colormaps. If samples is greater than 1, the map will be linearly resampled. Don't call this each frame.
|
||||
IMPLOT_API void SetColormap(ImPlotColormap colormap, int samples = 0);
|
||||
|
||||
// Returns the size of the current colormap.
|
||||
IMPLOT_API int GetColormapSize();
|
||||
// Returns a color from the Color map given an index >= 0 (modulo will be performed).
|
||||
IMPLOT_API ImVec4 GetColormapColor(int index);
|
||||
// Linearly interpolates a color from the current colormap given t between 0 and 1.
|
||||
IMPLOT_API ImVec4 LerpColormap(float t);
|
||||
// Returns the next unused colormap color and advances the colormap. Can be used to skip colors if desired.
|
||||
IMPLOT_API ImVec4 NextColormapColor();
|
||||
|
||||
// Renders a vertical color scale using the current color map. Call this outside of Begin/EndPlot.
|
||||
IMPLOT_API void ShowColormapScale(double scale_min, double scale_max, float height);
|
||||
|
||||
// Returns a null terminated string name for a built-in colormap.
|
||||
IMPLOT_API const char* GetColormapName(ImPlotColormap colormap);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Legend Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Returns true if a plot item legend entry is hovered.
|
||||
IMPLOT_API bool IsLegendEntryHovered(const char* label_id);
|
||||
// Begin a drag and drop source from a legend entry. The only supported flag is SourceNoPreviewTooltip
|
||||
IMPLOT_API bool BeginLegendDragDropSource(const char* label_id, ImGuiDragDropFlags flags = 0);
|
||||
// End legend drag and drop source.
|
||||
IMPLOT_API void EndLegendDragDropSource();
|
||||
// Begin a popup for a legend entry.
|
||||
IMPLOT_API bool BeginLegendPopup(const char* label_id, ImGuiMouseButton mouse_button = 1);
|
||||
// End a popup for a legend entry.
|
||||
IMPLOT_API void EndLegendPopup();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Miscellaneous
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Allows changing how keyboard/mouse interaction works.
|
||||
IMPLOT_API ImPlotInputMap& GetInputMap();
|
||||
|
||||
// Get the plot draw list for rendering to the current plot area.
|
||||
IMPLOT_API ImDrawList* GetPlotDrawList();
|
||||
// Push clip rect for rendering to current plot area.
|
||||
IMPLOT_API void PushPlotClipRect();
|
||||
// Pop plot clip rect.
|
||||
IMPLOT_API void PopPlotClipRect();
|
||||
|
||||
// Shows ImPlot style selector dropdown menu.
|
||||
IMPLOT_API bool ShowStyleSelector(const char* label);
|
||||
// Shows ImPlot style editor block (not a window).
|
||||
IMPLOT_API void ShowStyleEditor(ImPlotStyle* ref = NULL);
|
||||
// Add basic help/info block (not a window): how to manipulate ImPlot as an end-user.
|
||||
IMPLOT_API void ShowUserGuide();
|
||||
|
||||
// Sets the current _ImGui_ context. This is ONLY necessary if you are compiling
|
||||
// ImPlot as a DLL (not recommended) separate from your ImGui compilation. It
|
||||
// sets the global variable GImGui, which is not shared across DLL boundaries.
|
||||
// See GImGui documentation in imgui.cpp for more details.
|
||||
IMPLOT_API void SetImGuiContext(ImGuiContext* ctx);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Demo (add implot_demo.cpp to your sources!)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Shows the ImPlot demo. Pass the current ImGui context if ImPlot is a DLL.
|
||||
IMPLOT_API void ShowDemoWindow(bool* p_open = NULL);
|
||||
|
||||
} // namespace ImPlot
|
1552
src/external/imgui/imgui/implot_demo.cpp
vendored
1552
src/external/imgui/imgui/implot_demo.cpp
vendored
File diff suppressed because it is too large
Load diff
871
src/external/imgui/imgui/implot_internal.h
vendored
871
src/external/imgui/imgui/implot_internal.h
vendored
|
@ -1,871 +0,0 @@
|
|||
// MIT License
|
||||
|
||||
// Copyright (c) 2020 Evan Pezent
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// ImPlot v0.8 WIP
|
||||
|
||||
// You may use this file to debug, understand or extend ImPlot features but we
|
||||
// don't provide any guarantee of forward compatibility!
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Header Mess
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
#include "imgui_internal.h"
|
||||
|
||||
#ifndef IMPLOT_VERSION
|
||||
#error Must include implot.h before implot_internal.h
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Forward Declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct ImPlotTick;
|
||||
struct ImPlotAxis;
|
||||
struct ImPlotAxisState;
|
||||
struct ImPlotAxisColor;
|
||||
struct ImPlotItem;
|
||||
struct ImPlotState;
|
||||
struct ImPlotNextPlotData;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Context Pointer
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern IMPLOT_API ImPlotContext* GImPlot; // Current implicit context pointer
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Macros and Constants
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Constants can be changed unless stated otherwise. We may move some of these
|
||||
// to ImPlotStyleVar_ over time.
|
||||
|
||||
// Default plot frame width when requested width is auto (i.e. 0). This is not the plot area width!
|
||||
#define IMPLOT_DEFAULT_W 400
|
||||
// Default plot frame height when requested height is auto (i.e. 0). This is not the plot area height!
|
||||
#define IMPLOT_DEFAULT_H 300
|
||||
// The maximum number of supported y-axes (DO NOT CHANGE THIS)
|
||||
#define IMPLOT_Y_AXES 3
|
||||
// The number of times to subdivided grid divisions (best if a multiple of 1, 2, and 5)
|
||||
#define IMPLOT_SUB_DIV 10
|
||||
// Zoom rate for scroll (e.g. 0.1f = 10% plot range every scroll click)
|
||||
#define IMPLOT_ZOOM_RATE 0.1f
|
||||
// Maximum allowable timestamp value 01/01/3000 @ 12:00am (UTC)
|
||||
#define IMPLOT_MIN_TIME 0
|
||||
// Maximum allowable timestamp value 01/01/3000 @ 12:00am (UTC)
|
||||
#define IMPLOT_MAX_TIME 32503680000
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Generic Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Computes the common (base-10) logarithm
|
||||
static inline float ImLog10(float x) { return log10f(x); }
|
||||
static inline double ImLog10(double x) { return log10(x); }
|
||||
// Returns true if a flag is set
|
||||
template <typename TSet, typename TFlag>
|
||||
inline bool ImHasFlag(TSet set, TFlag flag) { return (set & flag) == flag; }
|
||||
// Flips a flag in a flagset
|
||||
template <typename TSet, typename TFlag>
|
||||
inline void ImFlipFlag(TSet& set, TFlag flag) { ImHasFlag(set, flag) ? set &= ~flag : set |= flag; }
|
||||
// Linearly remaps x from [x0 x1] to [y0 y1].
|
||||
template <typename T>
|
||||
inline T ImRemap(T x, T x0, T x1, T y0, T y1) { return y0 + (x - x0) * (y1 - y0) / (x1 - x0); }
|
||||
// Returns always positive modulo (assumes r != 0)
|
||||
inline int ImPosMod(int l, int r) { return (l % r + r) % r; }
|
||||
// Returns true if val is NAN or INFINITY
|
||||
inline bool ImNanOrInf(double val) { return val == HUGE_VAL || val == -HUGE_VAL || isnan(val); }
|
||||
// Turns NANs to 0s
|
||||
inline double ImConstrainNan(double val) { return isnan(val) ? 0 : val; }
|
||||
// Turns infinity to floating point maximums
|
||||
inline double ImConstrainInf(double val) { return val == HUGE_VAL ? DBL_MAX : val == -HUGE_VAL ? - DBL_MAX : val; }
|
||||
// Turns numbers less than or equal to 0 to 0.001 (sort of arbitrary, is there a better way?)
|
||||
inline double ImConstrainLog(double val) { return val <= 0 ? 0.001f : val; }
|
||||
// Turns numbers less than 0 to zero
|
||||
inline double ImConstrainTime(double val) { return val < IMPLOT_MIN_TIME ? IMPLOT_MIN_TIME : (val > IMPLOT_MAX_TIME ? IMPLOT_MAX_TIME : val); }
|
||||
|
||||
// Offset calculator helper
|
||||
template <int Count>
|
||||
struct ImOffsetCalculator {
|
||||
ImOffsetCalculator(const int* sizes) {
|
||||
Offsets[0] = 0;
|
||||
for (int i = 1; i < Count; ++i)
|
||||
Offsets[i] = Offsets[i-1] + sizes[i-1];
|
||||
}
|
||||
int Offsets[Count];
|
||||
};
|
||||
|
||||
// Character buffer writer helper
|
||||
struct ImBufferWriter
|
||||
{
|
||||
char* Buffer;
|
||||
int Size;
|
||||
int Pos;
|
||||
|
||||
ImBufferWriter(char* buffer, int size) {
|
||||
Buffer = buffer;
|
||||
Size = size;
|
||||
Pos = 0;
|
||||
}
|
||||
|
||||
void Write(const char* fmt, ...) IM_FMTARGS(2) {
|
||||
va_list argp;
|
||||
va_start(argp, fmt);
|
||||
const int written = ::vsnprintf(&Buffer[Pos], Size - Pos - 1, fmt, argp);
|
||||
if (written > 0)
|
||||
Pos += ImMin(written, Size-Pos-1);
|
||||
va_end(argp);
|
||||
}
|
||||
};
|
||||
|
||||
// Fixed size point array
|
||||
template <int N>
|
||||
struct ImPlotPointArray {
|
||||
inline ImPlotPoint& operator[](int i) { return Data[i]; }
|
||||
inline const ImPlotPoint& operator[](int i) const { return Data[i]; }
|
||||
inline int Size() { return N; }
|
||||
ImPlotPoint Data[N];
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] ImPlot Enums
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef int ImPlotScale; // -> enum ImPlotScale_
|
||||
typedef int ImPlotTimeUnit; // -> enum ImPlotTimeUnit_
|
||||
typedef int ImPlotTimeFmt; // -> enum ImPlotTimeFmt_
|
||||
|
||||
// XY axes scaling combinations
|
||||
enum ImPlotScale_ {
|
||||
ImPlotScale_LinLin, // linear x, linear y
|
||||
ImPlotScale_LogLin, // log x, linear y
|
||||
ImPlotScale_LinLog, // linear x, log y
|
||||
ImPlotScale_LogLog // log x, log y
|
||||
};
|
||||
|
||||
enum ImPlotTimeUnit_ {
|
||||
ImPlotTimeUnit_Us, // microsecond
|
||||
ImPlotTimeUnit_Ms, // millisecond
|
||||
ImPlotTimeUnit_S, // second
|
||||
ImPlotTimeUnit_Min, // minute
|
||||
ImPlotTimeUnit_Hr, // hour
|
||||
ImPlotTimeUnit_Day, // day
|
||||
ImPlotTimeUnit_Mo, // month
|
||||
ImPlotTimeUnit_Yr, // year
|
||||
ImPlotTimeUnit_COUNT
|
||||
};
|
||||
|
||||
enum ImPlotTimeFmt_ {
|
||||
ImPlotTimeFmt_Us, // .428 552
|
||||
ImPlotTimeFmt_SUs, // :29.428 552
|
||||
ImPlotTimeFmt_SMs, // :29.428
|
||||
ImPlotTimeFmt_S, // :29
|
||||
ImPlotTimeFmt_HrMinS, // 7:21:29pm
|
||||
ImPlotTimeFmt_HrMin, // 7:21pm
|
||||
ImPlotTimeFmt_Hr, // 7pm
|
||||
ImPlotTimeFmt_DayMo, // 10/3
|
||||
ImPlotTimeFmt_DayMoHr, // 10/3 7pm
|
||||
ImPlotTimeFmt_DayMoHrMin, // 10/3 7:21pm
|
||||
ImPlotTimeFmt_DayMoYr, // 10/3/91
|
||||
ImPlotTimeFmt_DayMoYrHrMin, // 10/3/91 7:21pm
|
||||
ImPlotTimeFmt_DayMoYrHrMinS, // 10/3/91 7:21:29pm
|
||||
ImPlotTimeFmt_DayMoYrHrMinSUs, // 10/3/1991 7:21:29.123456pm
|
||||
ImPlotTimeFmt_MoYr, // Oct 1991
|
||||
ImPlotTimeFmt_Mo, // Oct
|
||||
ImPlotTimeFmt_Yr // 1991
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] ImPlot Structs
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/// Two part timestamp struct.
|
||||
struct ImPlotTime {
|
||||
time_t S; // second part
|
||||
int Us; // microsecond part
|
||||
ImPlotTime() { S = 0; Us = 0; }
|
||||
ImPlotTime(time_t s, int us = 0) { S = s + us / 1000000; Us = us % 1000000; }
|
||||
void RollOver() { S = S + Us / 1000000; Us = Us % 1000000; }
|
||||
double ToDouble() const { return (double)S + (double)Us / 1000000.0; }
|
||||
static ImPlotTime FromDouble(double t) { return ImPlotTime((time_t)t, (int)(t * 1000000 - floor(t) * 1000000)); }
|
||||
};
|
||||
|
||||
static inline ImPlotTime operator+(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||
{ return ImPlotTime(lhs.S + rhs.S, lhs.Us + rhs.Us); }
|
||||
static inline ImPlotTime operator-(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||
{ return ImPlotTime(lhs.S - rhs.S, lhs.Us - rhs.Us); }
|
||||
static inline bool operator==(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||
{ return lhs.S == rhs.S && lhs.Us == rhs.Us; }
|
||||
static inline bool operator<(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||
{ return lhs.S == rhs.S ? lhs.Us < rhs.Us : lhs.S < rhs.S; }
|
||||
static inline bool operator>(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||
{ return rhs < lhs; }
|
||||
static inline bool operator<=(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||
{ return lhs < rhs || lhs == rhs; }
|
||||
static inline bool operator>=(const ImPlotTime& lhs, const ImPlotTime& rhs)
|
||||
{ return lhs > rhs || lhs == rhs; }
|
||||
|
||||
// Storage for colormap modifiers
|
||||
struct ImPlotColormapMod {
|
||||
ImPlotColormapMod(const ImVec4* colormap, int colormap_size) {
|
||||
Colormap = colormap;
|
||||
ColormapSize = colormap_size;
|
||||
}
|
||||
const ImVec4* Colormap;
|
||||
int ColormapSize;
|
||||
};
|
||||
|
||||
// ImPlotPoint with positive/negative error values
|
||||
struct ImPlotPointError
|
||||
{
|
||||
double X, Y, Neg, Pos;
|
||||
|
||||
ImPlotPointError(double x, double y, double neg, double pos) {
|
||||
X = x; Y = y; Neg = neg; Pos = pos;
|
||||
}
|
||||
};
|
||||
|
||||
// Tick mark info
|
||||
struct ImPlotTick
|
||||
{
|
||||
double PlotPos;
|
||||
float PixelPos;
|
||||
ImVec2 LabelSize;
|
||||
int BufferOffset;
|
||||
bool Major;
|
||||
bool ShowLabel;
|
||||
int Level;
|
||||
|
||||
ImPlotTick(double value, bool major, bool show_label) {
|
||||
PlotPos = value;
|
||||
Major = major;
|
||||
ShowLabel = show_label;
|
||||
BufferOffset = -1;
|
||||
Level = 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Collection of ticks
|
||||
struct ImPlotTickCollection {
|
||||
ImVector<ImPlotTick> Ticks;
|
||||
ImGuiTextBuffer Labels;
|
||||
float TotalWidth;
|
||||
float TotalHeight;
|
||||
float MaxWidth;
|
||||
float MaxHeight;
|
||||
int Size;
|
||||
|
||||
void AddTick(const ImPlotTick& tick) {
|
||||
if (tick.ShowLabel) {
|
||||
TotalWidth += tick.ShowLabel ? tick.LabelSize.x : 0;
|
||||
TotalHeight += tick.ShowLabel ? tick.LabelSize.y : 0;
|
||||
MaxWidth = tick.LabelSize.x > MaxWidth ? tick.LabelSize.x : MaxWidth;
|
||||
MaxHeight = tick.LabelSize.y > MaxHeight ? tick.LabelSize.y : MaxHeight;
|
||||
}
|
||||
Ticks.push_back(tick);
|
||||
Size++;
|
||||
}
|
||||
|
||||
void AddTick(double value, bool major, bool show_label, void (*labeler)(ImPlotTick& tick, ImGuiTextBuffer& buf)) {
|
||||
ImPlotTick tick(value, major, show_label);
|
||||
if (labeler)
|
||||
labeler(tick, Labels);
|
||||
AddTick(tick);
|
||||
}
|
||||
|
||||
const char* GetLabel(int idx) {
|
||||
return Labels.Buf.Data + Ticks[idx].BufferOffset;
|
||||
}
|
||||
|
||||
void Reset() {
|
||||
Ticks.shrink(0);
|
||||
Labels.Buf.shrink(0);
|
||||
TotalWidth = TotalHeight = MaxWidth = MaxHeight = 0;
|
||||
Size = 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Axis state information that must persist after EndPlot
|
||||
struct ImPlotAxis
|
||||
{
|
||||
ImPlotAxisFlags Flags;
|
||||
ImPlotAxisFlags PreviousFlags;
|
||||
ImPlotRange Range;
|
||||
bool Dragging;
|
||||
bool HoveredExt;
|
||||
bool HoveredTot;
|
||||
double* LinkedMin;
|
||||
double* LinkedMax;
|
||||
ImPlotTime PickerTimeMin, PickerTimeMax;
|
||||
int PickerLevel;
|
||||
|
||||
ImPlotAxis() {
|
||||
Flags = PreviousFlags = ImPlotAxisFlags_None;
|
||||
Range.Min = 0;
|
||||
Range.Max = 1;
|
||||
Dragging = false;
|
||||
HoveredExt = false;
|
||||
HoveredTot = false;
|
||||
LinkedMin = LinkedMax = NULL;
|
||||
PickerLevel = 0;
|
||||
}
|
||||
|
||||
bool SetMin(double _min) {
|
||||
_min = ImConstrainNan(ImConstrainInf(_min));
|
||||
if (ImHasFlag(Flags, ImPlotAxisFlags_LogScale))
|
||||
_min = ImConstrainLog(_min);
|
||||
if (ImHasFlag(Flags, ImPlotAxisFlags_Time))
|
||||
_min = ImConstrainTime(_min);
|
||||
if (_min >= Range.Max)
|
||||
return false;
|
||||
Range.Min = _min;
|
||||
PickerTimeMin = ImPlotTime::FromDouble(Range.Min);
|
||||
return true;
|
||||
};
|
||||
|
||||
bool SetMax(double _max) {
|
||||
_max = ImConstrainNan(ImConstrainInf(_max));
|
||||
if (ImHasFlag(Flags, ImPlotAxisFlags_LogScale))
|
||||
_max = ImConstrainLog(_max);
|
||||
if (ImHasFlag(Flags, ImPlotAxisFlags_Time))
|
||||
_max = ImConstrainTime(_max);
|
||||
if (_max <= Range.Min)
|
||||
return false;
|
||||
Range.Max = _max;
|
||||
PickerTimeMax = ImPlotTime::FromDouble(Range.Max);
|
||||
return true;
|
||||
};
|
||||
|
||||
void SetRange(double _min, double _max) {
|
||||
Range.Min = _min;
|
||||
Range.Max = _max;
|
||||
Constrain();
|
||||
PickerTimeMin = ImPlotTime::FromDouble(Range.Min);
|
||||
PickerTimeMax = ImPlotTime::FromDouble(Range.Max);
|
||||
}
|
||||
|
||||
void SetRange(const ImPlotRange& range) {
|
||||
SetRange(range.Min, range.Max);
|
||||
}
|
||||
|
||||
void Constrain() {
|
||||
Range.Min = ImConstrainNan(ImConstrainInf(Range.Min));
|
||||
Range.Max = ImConstrainNan(ImConstrainInf(Range.Max));
|
||||
if (ImHasFlag(Flags, ImPlotAxisFlags_LogScale)) {
|
||||
Range.Min = ImConstrainLog(Range.Min);
|
||||
Range.Max = ImConstrainLog(Range.Max);
|
||||
}
|
||||
if (ImHasFlag(Flags, ImPlotAxisFlags_Time)) {
|
||||
Range.Min = ImConstrainTime(Range.Min);
|
||||
Range.Max = ImConstrainTime(Range.Max);
|
||||
}
|
||||
if (Range.Max <= Range.Min)
|
||||
Range.Max = Range.Min + DBL_EPSILON;
|
||||
}
|
||||
};
|
||||
|
||||
// Axis state information only needed between BeginPlot/EndPlot
|
||||
struct ImPlotAxisState
|
||||
{
|
||||
ImPlotAxis* Axis;
|
||||
ImGuiCond RangeCond;
|
||||
bool HasRange;
|
||||
bool Present;
|
||||
bool HasLabels;
|
||||
bool Invert;
|
||||
bool LockMin;
|
||||
bool LockMax;
|
||||
bool Lock;
|
||||
bool IsTime;
|
||||
|
||||
ImPlotAxisState(ImPlotAxis* axis, bool has_range, ImGuiCond range_cond, bool present) {
|
||||
Axis = axis;
|
||||
HasRange = has_range;
|
||||
RangeCond = range_cond;
|
||||
Present = present;
|
||||
HasLabels = !ImHasFlag(Axis->Flags, ImPlotAxisFlags_NoTickLabels);
|
||||
Invert = ImHasFlag(Axis->Flags, ImPlotAxisFlags_Invert);
|
||||
LockMin = ImHasFlag(Axis->Flags, ImPlotAxisFlags_LockMin) || (HasRange && RangeCond == ImGuiCond_Always);
|
||||
LockMax = ImHasFlag(Axis->Flags, ImPlotAxisFlags_LockMax) || (HasRange && RangeCond == ImGuiCond_Always);
|
||||
Lock = !Present || ((LockMin && LockMax) || (HasRange && RangeCond == ImGuiCond_Always));
|
||||
IsTime = ImHasFlag(Axis->Flags, ImPlotAxisFlags_Time);
|
||||
}
|
||||
|
||||
ImPlotAxisState() { }
|
||||
};
|
||||
|
||||
struct ImPlotAxisColor
|
||||
{
|
||||
ImU32 Major, Minor, MajTxt, MinTxt;
|
||||
ImPlotAxisColor() { Major = Minor = MajTxt = MinTxt = 0; }
|
||||
};
|
||||
|
||||
// State information for Plot items
|
||||
struct ImPlotItem
|
||||
{
|
||||
ImGuiID ID;
|
||||
ImVec4 Color;
|
||||
int NameOffset;
|
||||
bool Show;
|
||||
bool LegendHovered;
|
||||
bool SeenThisFrame;
|
||||
|
||||
ImPlotItem() {
|
||||
ID = 0;
|
||||
Color = ImPlot::NextColormapColor();
|
||||
NameOffset = -1;
|
||||
Show = true;
|
||||
SeenThisFrame = false;
|
||||
LegendHovered = false;
|
||||
}
|
||||
|
||||
~ImPlotItem() { ID = 0; }
|
||||
};
|
||||
|
||||
// Holds Plot state information that must persist after EndPlot
|
||||
struct ImPlotState
|
||||
{
|
||||
ImPlotFlags Flags;
|
||||
ImPlotFlags PreviousFlags;
|
||||
ImPlotAxis XAxis;
|
||||
ImPlotAxis YAxis[IMPLOT_Y_AXES];
|
||||
ImPool<ImPlotItem> Items;
|
||||
ImVec2 SelectStart;
|
||||
ImVec2 QueryStart;
|
||||
ImRect QueryRect;
|
||||
ImRect BB_Legend;
|
||||
bool Selecting;
|
||||
bool Querying;
|
||||
bool Queried;
|
||||
bool DraggingQuery;
|
||||
int ColormapIdx;
|
||||
int CurrentYAxis;
|
||||
|
||||
ImPlotState() {
|
||||
Flags = PreviousFlags = ImPlotFlags_None;
|
||||
SelectStart = QueryStart = ImVec2(0,0);
|
||||
Selecting = Querying = Queried = DraggingQuery = false;
|
||||
ColormapIdx = CurrentYAxis = 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Temporary data storage for upcoming plot
|
||||
struct ImPlotNextPlotData
|
||||
{
|
||||
ImGuiCond XRangeCond;
|
||||
ImGuiCond YRangeCond[IMPLOT_Y_AXES];
|
||||
ImPlotRange X;
|
||||
ImPlotRange Y[IMPLOT_Y_AXES];
|
||||
bool HasXRange;
|
||||
bool HasYRange[IMPLOT_Y_AXES];
|
||||
bool ShowDefaultTicksX;
|
||||
bool ShowDefaultTicksY[IMPLOT_Y_AXES];
|
||||
bool FitX;
|
||||
bool FitY[IMPLOT_Y_AXES];
|
||||
double* LinkedXmin;
|
||||
double* LinkedXmax;
|
||||
double* LinkedYmin[IMPLOT_Y_AXES];
|
||||
double* LinkedYmax[IMPLOT_Y_AXES];
|
||||
|
||||
ImPlotNextPlotData() {
|
||||
HasXRange = false;
|
||||
ShowDefaultTicksX = true;
|
||||
FitX = false;
|
||||
LinkedXmin = LinkedXmax = NULL;
|
||||
for (int i = 0; i < IMPLOT_Y_AXES; ++i) {
|
||||
HasYRange[i] = false;
|
||||
ShowDefaultTicksY[i] = true;
|
||||
FitY[i] = false;
|
||||
LinkedYmin[i] = LinkedYmax[i] = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Temporary data storage for upcoming item
|
||||
struct ImPlotItemStyle {
|
||||
ImVec4 Colors[5]; // ImPlotCol_Line, ImPlotCol_Fill, ImPlotCol_MarkerOutline, ImPlotCol_MarkerFill, ImPlotCol_ErrorBar
|
||||
float LineWeight;
|
||||
ImPlotMarker Marker;
|
||||
float MarkerSize;
|
||||
float MarkerWeight;
|
||||
float FillAlpha;
|
||||
float ErrorBarSize;
|
||||
float ErrorBarWeight;
|
||||
float DigitalBitHeight;
|
||||
float DigitalBitGap;
|
||||
bool RenderLine;
|
||||
bool RenderFill;
|
||||
bool RenderMarkerLine;
|
||||
bool RenderMarkerFill;
|
||||
ImPlotItemStyle() {
|
||||
for (int i = 0; i < 5; ++i)
|
||||
Colors[i] = IMPLOT_AUTO_COL;
|
||||
LineWeight = MarkerSize = MarkerWeight = FillAlpha = ErrorBarSize = ErrorBarWeight = DigitalBitHeight = DigitalBitGap = IMPLOT_AUTO;
|
||||
Marker = IMPLOT_AUTO;
|
||||
}
|
||||
};
|
||||
|
||||
// Holds state information that must persist between calls to BeginPlot()/EndPlot()
|
||||
struct ImPlotContext {
|
||||
// Plot States
|
||||
ImPool<ImPlotState> Plots;
|
||||
ImPlotState* CurrentPlot;
|
||||
ImPlotItem* CurrentItem;
|
||||
|
||||
// Legend
|
||||
ImVector<int> LegendIndices;
|
||||
ImGuiTextBuffer LegendLabels;
|
||||
|
||||
// Bounding Boxes
|
||||
ImRect BB_Frame;
|
||||
ImRect BB_Canvas;
|
||||
ImRect BB_Plot;
|
||||
|
||||
// Axis States
|
||||
ImPlotAxisColor Col_X;
|
||||
ImPlotAxisColor Col_Y[IMPLOT_Y_AXES];
|
||||
ImPlotAxisState X;
|
||||
ImPlotAxisState Y[IMPLOT_Y_AXES];
|
||||
|
||||
// Tick Marks and Labels
|
||||
ImPlotTickCollection XTicks;
|
||||
ImPlotTickCollection YTicks[IMPLOT_Y_AXES];
|
||||
float YAxisReference[IMPLOT_Y_AXES];
|
||||
|
||||
// Transformations and Data Extents
|
||||
ImPlotScale Scales[IMPLOT_Y_AXES];
|
||||
ImRect PixelRange[IMPLOT_Y_AXES];
|
||||
double Mx;
|
||||
double My[IMPLOT_Y_AXES];
|
||||
double LogDenX;
|
||||
double LogDenY[IMPLOT_Y_AXES];
|
||||
ImPlotRange ExtentsX;
|
||||
ImPlotRange ExtentsY[IMPLOT_Y_AXES];
|
||||
|
||||
// Data Fitting Flags
|
||||
bool FitThisFrame;
|
||||
bool FitX;
|
||||
bool FitY[IMPLOT_Y_AXES];
|
||||
|
||||
// Hover states
|
||||
bool Hov_Frame;
|
||||
bool Hov_Plot;
|
||||
|
||||
// Axis Rendering Flags
|
||||
bool RenderX;
|
||||
bool RenderY[IMPLOT_Y_AXES];
|
||||
|
||||
// Axis Locking Flags
|
||||
bool LockPlot;
|
||||
bool ChildWindowMade;
|
||||
|
||||
// Style and Colormaps
|
||||
ImPlotStyle Style;
|
||||
ImVector<ImGuiColorMod> ColorModifiers;
|
||||
ImVector<ImGuiStyleMod> StyleModifiers;
|
||||
const ImVec4* Colormap;
|
||||
int ColormapSize;
|
||||
ImVector<ImPlotColormapMod> ColormapModifiers;
|
||||
|
||||
// Time
|
||||
tm Tm;
|
||||
|
||||
// Misc
|
||||
int VisibleItemCount;
|
||||
int DigitalPlotItemCnt;
|
||||
int DigitalPlotOffset;
|
||||
ImPlotNextPlotData NextPlotData;
|
||||
ImPlotItemStyle NextItemStyle;
|
||||
ImPlotInputMap InputMap;
|
||||
ImPlotPoint MousePos[IMPLOT_Y_AXES];
|
||||
};
|
||||
|
||||
struct ImPlotAxisScale
|
||||
{
|
||||
ImPlotPoint Min, Max;
|
||||
|
||||
ImPlotAxisScale(int y_axis, float tx, float ty, float zoom_rate) {
|
||||
ImPlotContext& gp = *GImPlot;
|
||||
Min = ImPlot::PixelsToPlot(gp.BB_Plot.Min - gp.BB_Plot.GetSize() * ImVec2(tx * zoom_rate, ty * zoom_rate), y_axis);
|
||||
Max = ImPlot::PixelsToPlot(gp.BB_Plot.Max + gp.BB_Plot.GetSize() * ImVec2((1 - tx) * zoom_rate, (1 - ty) * zoom_rate), y_axis);
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Internal API
|
||||
// No guarantee of forward compatibility here!
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace ImPlot {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Context Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Initializes an ImPlotContext
|
||||
IMPLOT_API void Initialize(ImPlotContext* ctx);
|
||||
// Resets an ImPlot context for the next call to BeginPlot
|
||||
IMPLOT_API void Reset(ImPlotContext* ctx);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Plot Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Gets a plot from the current ImPlotContext
|
||||
IMPLOT_API ImPlotState* GetPlot(const char* title);
|
||||
// Gets the current plot from the current ImPlotContext
|
||||
IMPLOT_API ImPlotState* GetCurrentPlot();
|
||||
// Busts the cache for every plot in the current context
|
||||
IMPLOT_API void BustPlotCache();
|
||||
|
||||
// Shows a plot's context menu.
|
||||
IMPLOT_API void ShowPlotContextMenu(ImPlotState& plot);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Item Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Begins a new item. Returns false if the item should not be plotted. Pushes PlotClipRect.
|
||||
IMPLOT_API bool BeginItem(const char* label_id, ImPlotCol recolor_from = -1);
|
||||
// Ends an item (call only if BeginItem returns true). Pops PlotClipRect.
|
||||
IMPLOT_API void EndItem();
|
||||
|
||||
// Register or get an existing item from the current plot
|
||||
IMPLOT_API ImPlotItem* RegisterOrGetItem(const char* label_id);
|
||||
// Get the ith plot item from the current plot
|
||||
IMPLOT_API ImPlotItem* GetItem(int i);
|
||||
// Get a plot item from the current plot
|
||||
IMPLOT_API ImPlotItem* GetItem(const char* label_id);
|
||||
// Gets a plot item from a specific plot
|
||||
IMPLOT_API ImPlotItem* GetItem(const char* plot_title, const char* item_label_id);
|
||||
// Gets the current item
|
||||
IMPLOT_API ImPlotItem* GetCurrentItem();
|
||||
// Busts the cache for every item for every plot in the current context.
|
||||
IMPLOT_API void BustItemCache();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Axis Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Gets the current y-axis for the current plot
|
||||
inline int GetCurrentYAxis() { return GImPlot->CurrentPlot->CurrentYAxis; }
|
||||
// Updates axis ticks, lins, and label colors
|
||||
IMPLOT_API void UpdateAxisColors(int axis_flag, ImPlotAxisColor* col);
|
||||
|
||||
// Updates plot-to-pixel space transformation variables for the current plot.
|
||||
IMPLOT_API void UpdateTransformCache();
|
||||
// Gets the XY scale for the current plot and y-axis
|
||||
inline ImPlotScale GetCurrentScale() { return GImPlot->Scales[GetCurrentYAxis()]; }
|
||||
|
||||
// Returns true if the user has requested data to be fit.
|
||||
inline bool FitThisFrame() { return GImPlot->FitThisFrame; }
|
||||
// Extends the current plots axes so that it encompasses point p
|
||||
IMPLOT_API void FitPoint(const ImPlotPoint& p);
|
||||
|
||||
// Returns true if two ranges overlap
|
||||
inline bool RangesOverlap(const ImPlotRange& r1, const ImPlotRange& r2)
|
||||
{ return r1.Min <= r2.Max && r2.Min <= r1.Max; }
|
||||
|
||||
// Updates pointers for linked axes from axis internal range.
|
||||
IMPLOT_API void PushLinkedAxis(ImPlotAxis& axis);
|
||||
// Updates axis internal range from points for linked axes.
|
||||
IMPLOT_API void PullLinkedAxis(ImPlotAxis& axis);
|
||||
|
||||
// Shows an axis's context menu.
|
||||
IMPLOT_API void ShowAxisContextMenu(ImPlotAxisState& state, bool time_allowed = false);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Legend Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Returns the number of entries in the current legend
|
||||
IMPLOT_API int GetLegendCount();
|
||||
// Gets the ith entry string for the current legend
|
||||
IMPLOT_API const char* GetLegendLabel(int i);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Tick Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Label a tick with default formatting.
|
||||
IMPLOT_API void LabelTickDefault(ImPlotTick& tick, ImGuiTextBuffer& buffer);
|
||||
// Label a tick with scientific formating.
|
||||
IMPLOT_API void LabelTickScientific(ImPlotTick& tick, ImGuiTextBuffer& buffer);
|
||||
// Label a tick with time formatting.
|
||||
IMPLOT_API void LabelTickTime(ImPlotTick& tick, ImGuiTextBuffer& buffer, const ImPlotTime& t, ImPlotTimeFmt fmt);
|
||||
|
||||
// Populates a list of ImPlotTicks with normal spaced and formatted ticks
|
||||
IMPLOT_API void AddTicksDefault(const ImPlotRange& range, int nMajor, int nMinor, ImPlotTickCollection& ticks);
|
||||
// Populates a list of ImPlotTicks with logarithmic space and formatted ticks
|
||||
IMPLOT_API void AddTicksLogarithmic(const ImPlotRange& range, int nMajor, ImPlotTickCollection& ticks);
|
||||
// Populates a list of ImPlotTicks with time formatted ticks.
|
||||
IMPLOT_API void AddTicksTime(const ImPlotRange& range, int nMajor, ImPlotTickCollection& ticks);
|
||||
// Populates a list of ImPlotTicks with custom spaced and labeled ticks
|
||||
IMPLOT_API void AddTicksCustom(const double* values, const char* const labels[], int n, ImPlotTickCollection& ticks);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Styling Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Get styling data for next item (call between Begin/EndItem)
|
||||
inline const ImPlotItemStyle& GetItemStyle() { return GImPlot->NextItemStyle; }
|
||||
|
||||
// Returns true if a color is set to be automatically determined
|
||||
inline bool IsColorAuto(const ImVec4& col) { return col.w == -1; }
|
||||
// Returns true if a style color is set to be automaticaly determined
|
||||
inline bool IsColorAuto(ImPlotCol idx) { return IsColorAuto(GImPlot->Style.Colors[idx]); }
|
||||
// Returns the automatically deduced style color
|
||||
IMPLOT_API ImVec4 GetAutoColor(ImPlotCol idx);
|
||||
|
||||
// Returns the style color whether it is automatic or custom set
|
||||
inline ImVec4 GetStyleColorVec4(ImPlotCol idx) { return IsColorAuto(idx) ? GetAutoColor(idx) : GImPlot->Style.Colors[idx]; }
|
||||
inline ImU32 GetStyleColorU32(ImPlotCol idx) { return ImGui::ColorConvertFloat4ToU32(GetStyleColorVec4(idx)); }
|
||||
|
||||
// Get built-in colormap data and size
|
||||
IMPLOT_API const ImVec4* GetColormap(ImPlotColormap colormap, int* size_out);
|
||||
// Linearly interpolates a color from the current colormap given t between 0 and 1.
|
||||
IMPLOT_API ImVec4 LerpColormap(const ImVec4* colormap, int size, float t);
|
||||
// Resamples a colormap. #size_out must be greater than 1.
|
||||
IMPLOT_API void ResampleColormap(const ImVec4* colormap_in, int size_in, ImVec4* colormap_out, int size_out);
|
||||
|
||||
// Draws vertical text. The position is the bottom left of the text rect.
|
||||
IMPLOT_API void AddTextVertical(ImDrawList *DrawList, ImVec2 pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
|
||||
// Calculates the size of vertical text
|
||||
inline ImVec2 CalcTextSizeVertical(const char *text) { ImVec2 sz = ImGui::CalcTextSize(text); return ImVec2(sz.y, sz.x); }
|
||||
// Returns white or black text given background color
|
||||
inline ImU32 CalcTextColor(const ImVec4& bg) { return (bg.x * 0.299 + bg.y * 0.587 + bg.z * 0.114) > 0.729 ? IM_COL32_BLACK : IM_COL32_WHITE; }
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Math and Misc Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Rounds x to powers of 2,5 and 10 for generating axis labels (from Graphics Gems 1 Chapter 11.2)
|
||||
IMPLOT_API double NiceNum(double x, bool round);
|
||||
// Computes order of magnitude of double.
|
||||
inline int OrderOfMagnitude(double val) { return val == 0 ? 0 : (int)(floor(log10(fabs(val)))); }
|
||||
// Returns the precision required for a order of magnitude.
|
||||
inline int OrderToPrecision(int order) { return order > 0 ? 0 : 1 - order; }
|
||||
// Returns a floating point precision to use given a value
|
||||
inline int Precision(double val) { return OrderToPrecision(OrderOfMagnitude(val)); }
|
||||
|
||||
// Returns the intersection point of two lines A and B (assumes they are not parallel!)
|
||||
inline ImVec2 Intersection(const ImVec2& a1, const ImVec2& a2, const ImVec2& b1, const ImVec2& b2) {
|
||||
float v1 = (a1.x * a2.y - a1.y * a2.x); float v2 = (b1.x * b2.y - b1.y * b2.x);
|
||||
float v3 = ((a1.x - a2.x) * (b1.y - b2.y) - (a1.y - a2.y) * (b1.x - b2.x));
|
||||
return ImVec2((v1 * (b1.x - b2.x) - v2 * (a1.x - a2.x)) / v3, (v1 * (b1.y - b2.y) - v2 * (a1.y - a2.y)) / v3);
|
||||
}
|
||||
|
||||
// Fills a buffer with n samples linear interpolated from vmin to vmax
|
||||
template <typename T>
|
||||
void FillRange(ImVector<T>& buffer, int n, T vmin, T vmax) {
|
||||
buffer.resize(n);
|
||||
T step = (vmax - vmin) / (n - 1);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
buffer[i] = vmin + i * step;
|
||||
}
|
||||
}
|
||||
|
||||
// Offsets and strides a data buffer
|
||||
template <typename T>
|
||||
inline T OffsetAndStride(const T* data, int idx, int count, int offset, int stride) {
|
||||
idx = ImPosMod(offset + idx, count);
|
||||
return *(const T*)(const void*)((const unsigned char*)data + (size_t)idx * stride);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Time Utils
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Returns true if year is leap year (366 days long)
|
||||
inline bool IsLeapYear(int year) {
|
||||
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
|
||||
}
|
||||
// Returns the number of days in a month, accounting for Feb. leap years. #month is zero indexed.
|
||||
inline int GetDaysInMonth(int year, int month) {
|
||||
static const int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
return days[month] + (int)(month == 1 && IsLeapYear(year));
|
||||
}
|
||||
|
||||
// Make a UNIX timestamp from a tm struct expressed in UTC time (i.e. GMT timezone).
|
||||
IMPLOT_API ImPlotTime MkGmtTime(struct tm *ptm);
|
||||
// Make a tm struct expressed in UTC time (i.e. GMT timezone) from a UNIX timestamp.
|
||||
IMPLOT_API tm* GetGmtTime(const ImPlotTime& t, tm* ptm);
|
||||
|
||||
// Make a UNIX timestamp from a tm struct expressed in local time.
|
||||
IMPLOT_API ImPlotTime MkLocTime(struct tm *ptm);
|
||||
// Make a tm struct expressed in local time from a UNIX timestamp.
|
||||
IMPLOT_API tm* GetLocTime(const ImPlotTime& t, tm* ptm);
|
||||
|
||||
// NB: The following functions only work if there is a current ImPlotContext because the
|
||||
// internal tm struct is owned by the context! They are aware of ImPlotStyle.UseLocalTime.
|
||||
|
||||
// Make a timestamp from time components.
|
||||
// year[1970-3000], month[0-11], day[1-31], hour[0-23], min[0-59], sec[0-59], us[0,999999]
|
||||
IMPLOT_API ImPlotTime MakeTime(int year, int month = 0, int day = 1, int hour = 0, int min = 0, int sec = 0, int us = 0);
|
||||
// Get year component from timestamp [1970-3000]
|
||||
IMPLOT_API int GetYear(const ImPlotTime& t);
|
||||
|
||||
// Adds or subtracts time from a timestamp. #count > 0 to add, < 0 to subtract.
|
||||
IMPLOT_API ImPlotTime AddTime(const ImPlotTime& t, ImPlotTimeUnit unit, int count);
|
||||
// Rounds a timestamp down to nearest unit.
|
||||
IMPLOT_API ImPlotTime FloorTime(const ImPlotTime& t, ImPlotTimeUnit unit);
|
||||
// Rounds a timestamp up to the nearest unit.
|
||||
IMPLOT_API ImPlotTime CeilTime(const ImPlotTime& t, ImPlotTimeUnit unit);
|
||||
// Rounds a timestamp up or down to the nearest unit.
|
||||
IMPLOT_API ImPlotTime RoundTime(const ImPlotTime& t, ImPlotTimeUnit unit);
|
||||
// Combines the date of one timestamp with the time-of-day of another timestamp.
|
||||
IMPLOT_API ImPlotTime CombineDateTime(const ImPlotTime& date_part, const ImPlotTime& time_part);
|
||||
|
||||
// Formulates a timestamp t into a buffer according to fmt.
|
||||
IMPLOT_API int FormatTime(const ImPlotTime& t, char* buffer, int size, ImPlotTimeFmt fmt);
|
||||
// Prints a timestamp to console
|
||||
IMPLOT_API void PrintTime(const ImPlotTime& t, ImPlotTimeFmt fmt = ImPlotTimeFmt_DayMoYrHrMinSUs);
|
||||
|
||||
// Shows a date picker widget block (year/month/day).
|
||||
// #level = 0 for day, 1 for month, 2 for year. Modified by user interaction.
|
||||
// #t will be set when a day is clicked and the function will return true.
|
||||
// #t1 and #t2 are optional dates to highlight.
|
||||
IMPLOT_API bool ShowDatePicker(const char* id, int* level, ImPlotTime* t, const ImPlotTime* t1 = NULL, const ImPlotTime* t2 = NULL);
|
||||
// Shows a time picker widget block (hour/min/sec).
|
||||
// #t will be set when a new hour, minute, or sec is selected or am/pm is toggled, and the function will return true.
|
||||
IMPLOT_API bool ShowTimePicker(const char* id, ImPlotTime* t);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Internal / Experimental Plotters
|
||||
// No guarantee of forward compatibility here!
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Plots axis-aligned, filled rectangles. Every two consecutive points defines opposite corners of a single rectangle.
|
||||
IMPLOT_API void PlotRects(const char* label_id, const float* xs, const float* ys, int count, int offset = 0, int stride = sizeof(float));
|
||||
IMPLOT_API void PlotRects(const char* label_id, const double* xs, const double* ys, int count, int offset = 0, int stride = sizeof(double));
|
||||
IMPLOT_API void PlotRects(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0);
|
||||
|
||||
} // namespace ImPlot
|
1749
src/external/imgui/imgui/implot_items.cpp
vendored
1749
src/external/imgui/imgui/implot_items.cpp
vendored
File diff suppressed because it is too large
Load diff
94
src/external/imgui/imgui/imstb_rectpack.h
vendored
94
src/external/imgui/imgui/imstb_rectpack.h
vendored
|
@ -1,15 +1,19 @@
|
|||
// [DEAR IMGUI]
|
||||
// This is a slightly modified version of stb_rect_pack.h 1.00.
|
||||
// Those changes would need to be pushed into nothings/stb:
|
||||
// - Added STBRP__CDECL
|
||||
// This is a slightly modified version of stb_rect_pack.h 1.01.
|
||||
// Grep for [DEAR IMGUI] to find the changes.
|
||||
|
||||
// stb_rect_pack.h - v1.00 - public domain - rectangle packing
|
||||
//
|
||||
// stb_rect_pack.h - v1.01 - public domain - rectangle packing
|
||||
// Sean Barrett 2014
|
||||
//
|
||||
// Useful for e.g. packing rectangular textures into an atlas.
|
||||
// Does not do rotation.
|
||||
//
|
||||
// Before #including,
|
||||
//
|
||||
// #define STB_RECT_PACK_IMPLEMENTATION
|
||||
//
|
||||
// in the file that you want to have the implementation.
|
||||
//
|
||||
// Not necessarily the awesomest packing method, but better than
|
||||
// the totally naive one in stb_truetype (which is primarily what
|
||||
// this is meant to replace).
|
||||
|
@ -34,13 +38,14 @@
|
|||
// Minor features
|
||||
// Martins Mozeiko
|
||||
// github:IntellectualKitty
|
||||
//
|
||||
//
|
||||
// Bugfixes / warning fixes
|
||||
// Jeremy Jaussaud
|
||||
// Fabian Giesen
|
||||
//
|
||||
// Version history:
|
||||
//
|
||||
// 1.01 (2021-07-11) always use large rect mode, expose STBRP__MAXVAL in public section
|
||||
// 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles
|
||||
// 0.99 (2019-02-07) warning fixes
|
||||
// 0.11 (2017-03-03) return packing success/fail result
|
||||
|
@ -81,11 +86,10 @@ typedef struct stbrp_context stbrp_context;
|
|||
typedef struct stbrp_node stbrp_node;
|
||||
typedef struct stbrp_rect stbrp_rect;
|
||||
|
||||
#ifdef STBRP_LARGE_RECTS
|
||||
typedef int stbrp_coord;
|
||||
#else
|
||||
typedef unsigned short stbrp_coord;
|
||||
#endif
|
||||
|
||||
#define STBRP__MAXVAL 0x7fffffff
|
||||
// Mostly for internal use, but this is the maximum supported coordinate value.
|
||||
|
||||
STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);
|
||||
// Assign packed locations to rectangles. The rectangles are of type
|
||||
|
@ -213,10 +217,9 @@ struct stbrp_context
|
|||
#define STBRP_ASSERT assert
|
||||
#endif
|
||||
|
||||
// [DEAR IMGUI] Added STBRP__CDECL
|
||||
#ifdef _MSC_VER
|
||||
#define STBRP__NOTUSED(v) (void)(v)
|
||||
#define STBRP__CDECL __cdecl
|
||||
#define STBRP__CDECL __cdecl
|
||||
#else
|
||||
#define STBRP__NOTUSED(v) (void)sizeof(v)
|
||||
#define STBRP__CDECL
|
||||
|
@ -262,9 +265,6 @@ STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_ou
|
|||
STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes)
|
||||
{
|
||||
int i;
|
||||
#ifndef STBRP_LARGE_RECTS
|
||||
STBRP_ASSERT(width <= 0xffff && height <= 0xffff);
|
||||
#endif
|
||||
|
||||
for (i=0; i < num_nodes-1; ++i)
|
||||
nodes[i].next = &nodes[i+1];
|
||||
|
@ -283,11 +283,7 @@ STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height,
|
|||
context->extra[0].y = 0;
|
||||
context->extra[0].next = &context->extra[1];
|
||||
context->extra[1].x = (stbrp_coord) width;
|
||||
#ifdef STBRP_LARGE_RECTS
|
||||
context->extra[1].y = (1<<30);
|
||||
#else
|
||||
context->extra[1].y = 65535;
|
||||
#endif
|
||||
context->extra[1].next = NULL;
|
||||
}
|
||||
|
||||
|
@ -433,7 +429,7 @@ static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int widt
|
|||
if (y <= best_y) {
|
||||
if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
|
||||
best_x = xpos;
|
||||
STBRP_ASSERT(y <= best_y);
|
||||
//STBRP_ASSERT(y <= best_y); [DEAR IMGUI]
|
||||
best_y = y;
|
||||
best_waste = waste;
|
||||
best = prev;
|
||||
|
@ -441,7 +437,7 @@ static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int widt
|
|||
}
|
||||
}
|
||||
tail = tail->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fr.prev_link = best;
|
||||
|
@ -529,7 +525,6 @@ static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, i
|
|||
return res;
|
||||
}
|
||||
|
||||
// [DEAR IMGUI] Added STBRP__CDECL
|
||||
static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
|
||||
{
|
||||
const stbrp_rect *p = (const stbrp_rect *) a;
|
||||
|
@ -541,7 +536,6 @@ static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
|
|||
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)
|
||||
{
|
||||
const stbrp_rect *p = (const stbrp_rect *) a;
|
||||
|
@ -549,12 +543,6 @@ static int STBRP__CDECL rect_original_order(const void *a, const void *b)
|
|||
return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
|
||||
}
|
||||
|
||||
#ifdef STBRP_LARGE_RECTS
|
||||
#define STBRP__MAXVAL 0xffffffff
|
||||
#else
|
||||
#define STBRP__MAXVAL 0xffff
|
||||
#endif
|
||||
|
||||
STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
|
||||
{
|
||||
int i, all_rects_packed = 1;
|
||||
|
@ -602,38 +590,38 @@ This software is available under 2 licenses -- choose whichever you prefer.
|
|||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE A - MIT License
|
||||
Copyright (c) 2017 Sean Barrett
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||
This is free and unencumbered software released into the public domain.
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||
software, either in source code form or as a compiled binary, for any purpose,
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||
software, either in source code form or as a compiled binary, for any purpose,
|
||||
commercial or non-commercial, and by any means.
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||
software dedicate any and all copyright interest in the software to the public
|
||||
domain. We make this dedication for the benefit of the public at large and to
|
||||
the detriment of our heirs and successors. We intend this dedication to be an
|
||||
overt act of relinquishment in perpetuity of all present and future rights to
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||
software dedicate any and all copyright interest in the software to the public
|
||||
domain. We make this dedication for the benefit of the public at large and to
|
||||
the detriment of our heirs and successors. We intend this dedication to be an
|
||||
overt act of relinquishment in perpetuity of all present and future rights to
|
||||
this software under copyright law.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
*/
|
||||
|
|
350
src/external/imgui/imgui/imstb_textedit.h
vendored
350
src/external/imgui/imgui/imstb_textedit.h
vendored
|
@ -1,10 +1,12 @@
|
|||
// [DEAR IMGUI]
|
||||
// This is a slightly modified version of stb_textedit.h 1.13.
|
||||
// This is a slightly modified version of stb_textedit.h 1.14.
|
||||
// Those changes would need to be pushed into nothings/stb:
|
||||
// - Fix in stb_textedit_discard_redo (see https://github.com/nothings/stb/issues/321)
|
||||
// - Fix in stb_textedit_find_charpos to handle last line (see https://github.com/ocornut/imgui/issues/6000 + #6783)
|
||||
// Grep for [DEAR IMGUI] to find the changes.
|
||||
// - Also renamed macros used or defined outside of IMSTB_TEXTEDIT_IMPLEMENTATION block from STB_TEXTEDIT_* to IMSTB_TEXTEDIT_*
|
||||
|
||||
// stb_textedit.h - v1.13 - public domain - Sean Barrett
|
||||
// stb_textedit.h - v1.14 - public domain - Sean Barrett
|
||||
// Development of this library was sponsored by RAD Game Tools
|
||||
//
|
||||
// This C header file implements the guts of a multi-line text-editing
|
||||
|
@ -19,7 +21,7 @@
|
|||
// texts, as its performance does not scale and it has limited undo).
|
||||
//
|
||||
// Non-trivial behaviors are modelled after Windows text controls.
|
||||
//
|
||||
//
|
||||
//
|
||||
// LICENSE
|
||||
//
|
||||
|
@ -29,16 +31,17 @@
|
|||
// DEPENDENCIES
|
||||
//
|
||||
// Uses the C runtime function 'memmove', which you can override
|
||||
// by defining STB_TEXTEDIT_memmove before the implementation.
|
||||
// by defining IMSTB_TEXTEDIT_memmove before the implementation.
|
||||
// Uses no other functions. Performs no runtime allocations.
|
||||
//
|
||||
//
|
||||
// VERSION HISTORY
|
||||
//
|
||||
// 1.14 (2021-07-11) page up/down, various fixes
|
||||
// 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.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) suppress warnings about casting away const with -Wcast-qual
|
||||
// 1.9 (2016-08-27) customizable move-by-word
|
||||
// 1.8 (2016-04-02) better keyboard handling when mouse button is down
|
||||
// 1.7 (2015-09-13) change y range handling in case baseline is non-0
|
||||
|
@ -58,6 +61,7 @@
|
|||
// Ulf Winklemann: move-by-word in 1.1
|
||||
// Fabian Giesen: secondary key inputs in 1.5
|
||||
// Martins Mozeiko: STB_TEXTEDIT_memmove in 1.6
|
||||
// Louis Schnellbach: page up/down in 1.14
|
||||
//
|
||||
// Bugfixes:
|
||||
// Scott Graham
|
||||
|
@ -93,8 +97,8 @@
|
|||
// moderate sizes. The undo system does no memory allocations, so
|
||||
// it grows STB_TexteditState by the worst-case storage which is (in bytes):
|
||||
//
|
||||
// [4 + 3 * sizeof(STB_TEXTEDIT_POSITIONTYPE)] * STB_TEXTEDIT_UNDOSTATE_COUNT
|
||||
// + sizeof(STB_TEXTEDIT_CHARTYPE) * STB_TEXTEDIT_UNDOCHAR_COUNT
|
||||
// [4 + 3 * sizeof(STB_TEXTEDIT_POSITIONTYPE)] * STB_TEXTEDIT_UNDOSTATECOUNT
|
||||
// + sizeof(STB_TEXTEDIT_CHARTYPE) * STB_TEXTEDIT_UNDOCHARCOUNT
|
||||
//
|
||||
//
|
||||
// Implementation mode:
|
||||
|
@ -148,6 +152,8 @@
|
|||
// STB_TEXTEDIT_K_RIGHT keyboard input to move cursor right
|
||||
// STB_TEXTEDIT_K_UP keyboard input to move cursor up
|
||||
// STB_TEXTEDIT_K_DOWN keyboard input to move cursor down
|
||||
// STB_TEXTEDIT_K_PGUP keyboard input to move cursor up a page
|
||||
// STB_TEXTEDIT_K_PGDOWN keyboard input to move cursor down a page
|
||||
// STB_TEXTEDIT_K_LINESTART keyboard input to move cursor to start of line // e.g. HOME
|
||||
// STB_TEXTEDIT_K_LINEEND keyboard input to move cursor to end of line // e.g. END
|
||||
// STB_TEXTEDIT_K_TEXTSTART keyboard input to move cursor to start of text // e.g. ctrl-HOME
|
||||
|
@ -170,14 +176,10 @@
|
|||
// STB_TEXTEDIT_K_TEXTSTART2 secondary keyboard input to move cursor to start of text
|
||||
// STB_TEXTEDIT_K_TEXTEND2 secondary keyboard input to move cursor to end of text
|
||||
//
|
||||
// Todo:
|
||||
// STB_TEXTEDIT_K_PGUP keyboard input to move cursor up a page
|
||||
// STB_TEXTEDIT_K_PGDOWN keyboard input to move cursor down a page
|
||||
//
|
||||
// Keyboard input must be encoded as a single integer value; e.g. a character code
|
||||
// and some bitflags that represent shift states. to simplify the interface, SHIFT must
|
||||
// be a bitflag, so we can test the shifted state of cursor movements to allow selection,
|
||||
// i.e. (STB_TEXTED_K_RIGHT|STB_TEXTEDIT_K_SHIFT) should be shifted right-arrow.
|
||||
// i.e. (STB_TEXTEDIT_K_RIGHT|STB_TEXTEDIT_K_SHIFT) should be shifted right-arrow.
|
||||
//
|
||||
// You can encode other things, such as CONTROL or ALT, in additional bits, and
|
||||
// then test for their presence in e.g. STB_TEXTEDIT_K_WORDLEFT. For example,
|
||||
|
@ -219,20 +221,20 @@
|
|||
// call this with the mouse x,y on a mouse down; it will update the cursor
|
||||
// and reset the selection start/end to the cursor point. the x,y must
|
||||
// be relative to the text widget, with (0,0) being the top left.
|
||||
//
|
||||
//
|
||||
// drag:
|
||||
// call this with the mouse x,y on a mouse drag/up; it will update the
|
||||
// cursor and the selection end point
|
||||
//
|
||||
//
|
||||
// cut:
|
||||
// call this to delete the current selection; returns true if there was
|
||||
// one. you should FIRST copy the current selection to the system paste buffer.
|
||||
// (To copy, just copy the current selection out of the string yourself.)
|
||||
//
|
||||
//
|
||||
// paste:
|
||||
// call this to paste text at the current cursor point or over the current
|
||||
// selection if there is one.
|
||||
//
|
||||
//
|
||||
// key:
|
||||
// call this for keyboard inputs sent to the textfield. you can use it
|
||||
// for "key down" events or for "translated" key events. if you need to
|
||||
|
@ -243,7 +245,7 @@
|
|||
// clear. STB_TEXTEDIT_KEYTYPE defaults to int, but you can #define it to
|
||||
// anything other type you wante before including.
|
||||
//
|
||||
//
|
||||
//
|
||||
// When rendering, you can read the cursor position and selection state from
|
||||
// the STB_TexteditState.
|
||||
//
|
||||
|
@ -273,8 +275,8 @@
|
|||
////
|
||||
////
|
||||
|
||||
#ifndef INCLUDE_STB_TEXTEDIT_H
|
||||
#define INCLUDE_STB_TEXTEDIT_H
|
||||
#ifndef INCLUDE_IMSTB_TEXTEDIT_H
|
||||
#define INCLUDE_IMSTB_TEXTEDIT_H
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -285,33 +287,33 @@
|
|||
// and undo state.
|
||||
//
|
||||
|
||||
#ifndef STB_TEXTEDIT_UNDOSTATECOUNT
|
||||
#define STB_TEXTEDIT_UNDOSTATECOUNT 99
|
||||
#ifndef IMSTB_TEXTEDIT_UNDOSTATECOUNT
|
||||
#define IMSTB_TEXTEDIT_UNDOSTATECOUNT 99
|
||||
#endif
|
||||
#ifndef STB_TEXTEDIT_UNDOCHARCOUNT
|
||||
#define STB_TEXTEDIT_UNDOCHARCOUNT 999
|
||||
#ifndef IMSTB_TEXTEDIT_UNDOCHARCOUNT
|
||||
#define IMSTB_TEXTEDIT_UNDOCHARCOUNT 999
|
||||
#endif
|
||||
#ifndef STB_TEXTEDIT_CHARTYPE
|
||||
#define STB_TEXTEDIT_CHARTYPE int
|
||||
#ifndef IMSTB_TEXTEDIT_CHARTYPE
|
||||
#define IMSTB_TEXTEDIT_CHARTYPE int
|
||||
#endif
|
||||
#ifndef STB_TEXTEDIT_POSITIONTYPE
|
||||
#define STB_TEXTEDIT_POSITIONTYPE int
|
||||
#ifndef IMSTB_TEXTEDIT_POSITIONTYPE
|
||||
#define IMSTB_TEXTEDIT_POSITIONTYPE int
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// private data
|
||||
STB_TEXTEDIT_POSITIONTYPE where;
|
||||
STB_TEXTEDIT_POSITIONTYPE insert_length;
|
||||
STB_TEXTEDIT_POSITIONTYPE delete_length;
|
||||
IMSTB_TEXTEDIT_POSITIONTYPE where;
|
||||
IMSTB_TEXTEDIT_POSITIONTYPE insert_length;
|
||||
IMSTB_TEXTEDIT_POSITIONTYPE delete_length;
|
||||
int char_storage;
|
||||
} StbUndoRecord;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// private data
|
||||
StbUndoRecord undo_rec [STB_TEXTEDIT_UNDOSTATECOUNT];
|
||||
STB_TEXTEDIT_CHARTYPE undo_char[STB_TEXTEDIT_UNDOCHARCOUNT];
|
||||
StbUndoRecord undo_rec [IMSTB_TEXTEDIT_UNDOSTATECOUNT];
|
||||
IMSTB_TEXTEDIT_CHARTYPE undo_char[IMSTB_TEXTEDIT_UNDOCHARCOUNT];
|
||||
short undo_point, redo_point;
|
||||
int undo_char_point, redo_char_point;
|
||||
} StbUndoState;
|
||||
|
@ -337,6 +339,10 @@ typedef struct
|
|||
// each textfield keeps its own insert mode state. to keep an app-wide
|
||||
// insert mode, copy this value in/out of the app state
|
||||
|
||||
int row_count_per_page;
|
||||
// page size in number of row.
|
||||
// this value MUST be set to >0 for pageup or pagedown in multilines documents.
|
||||
|
||||
/////////////////////
|
||||
//
|
||||
// private data
|
||||
|
@ -366,7 +372,7 @@ typedef struct
|
|||
float ymin,ymax; // height of row above and below baseline
|
||||
int num_chars;
|
||||
} StbTexteditRow;
|
||||
#endif //INCLUDE_STB_TEXTEDIT_H
|
||||
#endif //INCLUDE_IMSTB_TEXTEDIT_H
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -379,11 +385,11 @@ typedef struct
|
|||
|
||||
// implementation isn't include-guarded, since it might have indirectly
|
||||
// included just the "header" portion
|
||||
#ifdef STB_TEXTEDIT_IMPLEMENTATION
|
||||
#ifdef IMSTB_TEXTEDIT_IMPLEMENTATION
|
||||
|
||||
#ifndef STB_TEXTEDIT_memmove
|
||||
#ifndef IMSTB_TEXTEDIT_memmove
|
||||
#include <string.h>
|
||||
#define STB_TEXTEDIT_memmove memmove
|
||||
#define IMSTB_TEXTEDIT_memmove memmove
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -393,7 +399,7 @@ typedef struct
|
|||
//
|
||||
|
||||
// traverse the layout to locate the nearest character to a display position
|
||||
static int stb_text_locate_coord(STB_TEXTEDIT_STRING *str, float x, float y)
|
||||
static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
|
||||
{
|
||||
StbTexteditRow r;
|
||||
int n = STB_TEXTEDIT_STRINGLEN(str);
|
||||
|
@ -453,7 +459,7 @@ static int stb_text_locate_coord(STB_TEXTEDIT_STRING *str, float x, float y)
|
|||
}
|
||||
|
||||
// API click: on mouse down, move the cursor to the clicked location, and reset the selection
|
||||
static void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)
|
||||
static void stb_textedit_click(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)
|
||||
{
|
||||
// In single-line mode, just always make y = 0. This lets the drag keep working if the mouse
|
||||
// goes off the top or bottom of the text
|
||||
|
@ -471,7 +477,7 @@ static void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *stat
|
|||
}
|
||||
|
||||
// API drag: on mouse drag, move the cursor and selection endpoint to the clicked location
|
||||
static void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)
|
||||
static void stb_textedit_drag(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)
|
||||
{
|
||||
int p = 0;
|
||||
|
||||
|
@ -497,11 +503,11 @@ static void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state
|
|||
//
|
||||
|
||||
// forward declarations
|
||||
static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state);
|
||||
static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state);
|
||||
static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length);
|
||||
static void stb_text_undo(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state);
|
||||
static void stb_text_redo(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state);
|
||||
static void stb_text_makeundo_delete(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length);
|
||||
static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length);
|
||||
static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length);
|
||||
static void stb_text_makeundo_replace(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -513,36 +519,21 @@ typedef struct
|
|||
|
||||
// find the x/y location of a character, and remember info about the previous row in
|
||||
// case we get a move-up event (for page up, we'll have to rescan)
|
||||
static void stb_textedit_find_charpos(StbFindState *find, STB_TEXTEDIT_STRING *str, int n, int single_line)
|
||||
static void stb_textedit_find_charpos(StbFindState *find, IMSTB_TEXTEDIT_STRING *str, int n, int single_line)
|
||||
{
|
||||
StbTexteditRow r;
|
||||
int prev_start = 0;
|
||||
int z = STB_TEXTEDIT_STRINGLEN(str);
|
||||
int i=0, first;
|
||||
|
||||
if (n == z) {
|
||||
// if it's at the end, then find the last line -- simpler than trying to
|
||||
// explicitly handle this case in the regular code
|
||||
if (single_line) {
|
||||
STB_TEXTEDIT_LAYOUTROW(&r, str, 0);
|
||||
find->y = 0;
|
||||
find->first_char = 0;
|
||||
find->length = z;
|
||||
find->height = r.ymax - r.ymin;
|
||||
find->x = r.x1;
|
||||
} else {
|
||||
find->y = 0;
|
||||
find->x = 0;
|
||||
find->height = 1;
|
||||
while (i < z) {
|
||||
STB_TEXTEDIT_LAYOUTROW(&r, str, i);
|
||||
prev_start = i;
|
||||
i += r.num_chars;
|
||||
}
|
||||
find->first_char = i;
|
||||
find->length = 0;
|
||||
find->prev_first = prev_start;
|
||||
}
|
||||
if (n == z && single_line) {
|
||||
// special case if it's at the end (may not be needed?)
|
||||
STB_TEXTEDIT_LAYOUTROW(&r, str, 0);
|
||||
find->y = 0;
|
||||
find->first_char = 0;
|
||||
find->length = z;
|
||||
find->height = r.ymax - r.ymin;
|
||||
find->x = r.x1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -553,9 +544,16 @@ static void stb_textedit_find_charpos(StbFindState *find, STB_TEXTEDIT_STRING *s
|
|||
STB_TEXTEDIT_LAYOUTROW(&r, str, i);
|
||||
if (n < i + r.num_chars)
|
||||
break;
|
||||
if (i + r.num_chars == z && z > 0 && STB_TEXTEDIT_GETCHAR(str, z - 1) != STB_TEXTEDIT_NEWLINE) // [DEAR IMGUI] special handling for last line
|
||||
break; // [DEAR IMGUI]
|
||||
prev_start = i;
|
||||
i += r.num_chars;
|
||||
find->y += r.baseline_y_delta;
|
||||
if (i == z) // [DEAR IMGUI]
|
||||
{
|
||||
r.num_chars = 0; // [DEAR IMGUI]
|
||||
break; // [DEAR IMGUI]
|
||||
}
|
||||
}
|
||||
|
||||
find->first_char = first = i;
|
||||
|
@ -572,7 +570,7 @@ static void stb_textedit_find_charpos(StbFindState *find, STB_TEXTEDIT_STRING *s
|
|||
#define STB_TEXT_HAS_SELECTION(s) ((s)->select_start != (s)->select_end)
|
||||
|
||||
// make the selection/cursor state valid if client altered the string
|
||||
static void stb_textedit_clamp(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||
static void stb_textedit_clamp(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||
{
|
||||
int n = STB_TEXTEDIT_STRINGLEN(str);
|
||||
if (STB_TEXT_HAS_SELECTION(state)) {
|
||||
|
@ -586,7 +584,7 @@ static void stb_textedit_clamp(STB_TEXTEDIT_STRING *str, STB_TexteditState *stat
|
|||
}
|
||||
|
||||
// delete characters while updating undo
|
||||
static void stb_textedit_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int len)
|
||||
static void stb_textedit_delete(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int len)
|
||||
{
|
||||
stb_text_makeundo_delete(str, state, where, len);
|
||||
STB_TEXTEDIT_DELETECHARS(str, where, len);
|
||||
|
@ -594,7 +592,7 @@ static void stb_textedit_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *sta
|
|||
}
|
||||
|
||||
// delete the section
|
||||
static void stb_textedit_delete_selection(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||
static void stb_textedit_delete_selection(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||
{
|
||||
stb_textedit_clamp(str, state);
|
||||
if (STB_TEXT_HAS_SELECTION(state)) {
|
||||
|
@ -631,7 +629,7 @@ static void stb_textedit_move_to_first(STB_TexteditState *state)
|
|||
}
|
||||
|
||||
// move cursor to last character of selection
|
||||
static void stb_textedit_move_to_last(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||
static void stb_textedit_move_to_last(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||
{
|
||||
if (STB_TEXT_HAS_SELECTION(state)) {
|
||||
stb_textedit_sortselection(state);
|
||||
|
@ -643,13 +641,13 @@ static void stb_textedit_move_to_last(STB_TEXTEDIT_STRING *str, STB_TexteditStat
|
|||
}
|
||||
|
||||
#ifdef STB_TEXTEDIT_IS_SPACE
|
||||
static int is_word_boundary( STB_TEXTEDIT_STRING *str, int idx )
|
||||
static int is_word_boundary( IMSTB_TEXTEDIT_STRING *str, int idx )
|
||||
{
|
||||
return idx > 0 ? (STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str,idx-1) ) && !STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str, idx) ) ) : 1;
|
||||
}
|
||||
|
||||
#ifndef STB_TEXTEDIT_MOVEWORDLEFT
|
||||
static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *str, int c )
|
||||
static int stb_textedit_move_to_word_previous( IMSTB_TEXTEDIT_STRING *str, int c )
|
||||
{
|
||||
--c; // always move at least one character
|
||||
while( c >= 0 && !is_word_boundary( str, c ) )
|
||||
|
@ -664,7 +662,7 @@ static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *str, int c )
|
|||
#endif
|
||||
|
||||
#ifndef STB_TEXTEDIT_MOVEWORDRIGHT
|
||||
static int stb_textedit_move_to_word_next( STB_TEXTEDIT_STRING *str, int c )
|
||||
static int stb_textedit_move_to_word_next( IMSTB_TEXTEDIT_STRING *str, int c )
|
||||
{
|
||||
const int len = STB_TEXTEDIT_STRINGLEN(str);
|
||||
++c; // always move at least one character
|
||||
|
@ -691,7 +689,7 @@ static void stb_textedit_prep_selection_at_cursor(STB_TexteditState *state)
|
|||
}
|
||||
|
||||
// API cut: delete selection
|
||||
static int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||
static int stb_textedit_cut(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||
{
|
||||
if (STB_TEXT_HAS_SELECTION(state)) {
|
||||
stb_textedit_delete_selection(str,state); // implicitly clamps
|
||||
|
@ -702,7 +700,7 @@ static int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
|||
}
|
||||
|
||||
// API paste: replace existing selection with passed-in text
|
||||
static int stb_textedit_paste_internal(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE *text, int len)
|
||||
static int stb_textedit_paste_internal(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, IMSTB_TEXTEDIT_CHARTYPE *text, int len)
|
||||
{
|
||||
// if there's a selection, the paste should delete it
|
||||
stb_textedit_clamp(str, state);
|
||||
|
@ -714,9 +712,7 @@ static int stb_textedit_paste_internal(STB_TEXTEDIT_STRING *str, STB_TexteditSta
|
|||
state->has_preferred_x = 0;
|
||||
return 1;
|
||||
}
|
||||
// remove the undo since we didn't actually insert the characters
|
||||
if (state->undostate.undo_point)
|
||||
--state->undostate.undo_point;
|
||||
// note: paste failure will leave deleted selection, may be restored with an undo (see https://github.com/nothings/stb/issues/734 for details)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -725,14 +721,14 @@ static int stb_textedit_paste_internal(STB_TEXTEDIT_STRING *str, STB_TexteditSta
|
|||
#endif
|
||||
|
||||
// API key: process a keyboard input
|
||||
static void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_KEYTYPE key)
|
||||
static void stb_textedit_key(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_KEYTYPE key)
|
||||
{
|
||||
retry:
|
||||
switch (key) {
|
||||
default: {
|
||||
int c = STB_TEXTEDIT_KEYTOTEXT(key);
|
||||
if (c > 0) {
|
||||
STB_TEXTEDIT_CHARTYPE ch = (STB_TEXTEDIT_CHARTYPE) c;
|
||||
IMSTB_TEXTEDIT_CHARTYPE ch = (IMSTB_TEXTEDIT_CHARTYPE) c;
|
||||
|
||||
// can't add newline in single-line mode
|
||||
if (c == '\n' && state->single_line)
|
||||
|
@ -762,7 +758,7 @@ retry:
|
|||
state->insert_mode = !state->insert_mode;
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
case STB_TEXTEDIT_K_UNDO:
|
||||
stb_text_undo(str, state);
|
||||
state->has_preferred_x = 0;
|
||||
|
@ -777,7 +773,7 @@ retry:
|
|||
// if currently there's a selection, move cursor to start of selection
|
||||
if (STB_TEXT_HAS_SELECTION(state))
|
||||
stb_textedit_move_to_first(state);
|
||||
else
|
||||
else
|
||||
if (state->cursor > 0)
|
||||
--state->cursor;
|
||||
state->has_preferred_x = 0;
|
||||
|
@ -826,7 +822,7 @@ retry:
|
|||
|
||||
#ifdef STB_TEXTEDIT_MOVEWORDRIGHT
|
||||
case STB_TEXTEDIT_K_WORDRIGHT:
|
||||
if (STB_TEXT_HAS_SELECTION(state))
|
||||
if (STB_TEXT_HAS_SELECTION(state))
|
||||
stb_textedit_move_to_last(str, state);
|
||||
else {
|
||||
state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor);
|
||||
|
@ -855,12 +851,16 @@ retry:
|
|||
break;
|
||||
|
||||
case STB_TEXTEDIT_K_DOWN:
|
||||
case STB_TEXTEDIT_K_DOWN | STB_TEXTEDIT_K_SHIFT: {
|
||||
case STB_TEXTEDIT_K_DOWN | STB_TEXTEDIT_K_SHIFT:
|
||||
case STB_TEXTEDIT_K_PGDOWN:
|
||||
case STB_TEXTEDIT_K_PGDOWN | STB_TEXTEDIT_K_SHIFT: {
|
||||
StbFindState find;
|
||||
StbTexteditRow row;
|
||||
int i, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0;
|
||||
int i, j, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0;
|
||||
int is_page = (key & ~STB_TEXTEDIT_K_SHIFT) == STB_TEXTEDIT_K_PGDOWN;
|
||||
int row_count = is_page ? state->row_count_per_page : 1;
|
||||
|
||||
if (state->single_line) {
|
||||
if (!is_page && state->single_line) {
|
||||
// on windows, up&down in single-line behave like left&right
|
||||
key = STB_TEXTEDIT_K_RIGHT | (key & STB_TEXTEDIT_K_SHIFT);
|
||||
goto retry;
|
||||
|
@ -869,24 +869,32 @@ retry:
|
|||
if (sel)
|
||||
stb_textedit_prep_selection_at_cursor(state);
|
||||
else if (STB_TEXT_HAS_SELECTION(state))
|
||||
stb_textedit_move_to_last(str,state);
|
||||
stb_textedit_move_to_last(str, state);
|
||||
|
||||
// compute current position of cursor point
|
||||
stb_textedit_clamp(str, state);
|
||||
stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
|
||||
|
||||
// now find character position down a row
|
||||
if (find.length) {
|
||||
float goal_x = state->has_preferred_x ? state->preferred_x : find.x;
|
||||
float x;
|
||||
for (j = 0; j < row_count; ++j) {
|
||||
float x, goal_x = state->has_preferred_x ? state->preferred_x : find.x;
|
||||
int start = find.first_char + find.length;
|
||||
|
||||
if (find.length == 0)
|
||||
break;
|
||||
|
||||
// [DEAR IMGUI]
|
||||
// going down while being on the last line shouldn't bring us to that line end
|
||||
if (STB_TEXTEDIT_GETCHAR(str, find.first_char + find.length - 1) != STB_TEXTEDIT_NEWLINE)
|
||||
break;
|
||||
|
||||
// now find character position down a row
|
||||
state->cursor = start;
|
||||
STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor);
|
||||
x = row.x0;
|
||||
for (i=0; i < row.num_chars; ++i) {
|
||||
float dx = STB_TEXTEDIT_GETWIDTH(str, start, i);
|
||||
#ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE
|
||||
if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE)
|
||||
#ifdef IMSTB_TEXTEDIT_GETWIDTH_NEWLINE
|
||||
if (dx == IMSTB_TEXTEDIT_GETWIDTH_NEWLINE)
|
||||
break;
|
||||
#endif
|
||||
x += dx;
|
||||
|
@ -901,17 +909,25 @@ retry:
|
|||
|
||||
if (sel)
|
||||
state->select_end = state->cursor;
|
||||
|
||||
// go to next line
|
||||
find.first_char = find.first_char + find.length;
|
||||
find.length = row.num_chars;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case STB_TEXTEDIT_K_UP:
|
||||
case STB_TEXTEDIT_K_UP | STB_TEXTEDIT_K_SHIFT: {
|
||||
case STB_TEXTEDIT_K_UP | STB_TEXTEDIT_K_SHIFT:
|
||||
case STB_TEXTEDIT_K_PGUP:
|
||||
case STB_TEXTEDIT_K_PGUP | STB_TEXTEDIT_K_SHIFT: {
|
||||
StbFindState find;
|
||||
StbTexteditRow row;
|
||||
int i, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0;
|
||||
int i, j, prev_scan, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0;
|
||||
int is_page = (key & ~STB_TEXTEDIT_K_SHIFT) == STB_TEXTEDIT_K_PGUP;
|
||||
int row_count = is_page ? state->row_count_per_page : 1;
|
||||
|
||||
if (state->single_line) {
|
||||
if (!is_page && state->single_line) {
|
||||
// on windows, up&down become left&right
|
||||
key = STB_TEXTEDIT_K_LEFT | (key & STB_TEXTEDIT_K_SHIFT);
|
||||
goto retry;
|
||||
|
@ -926,18 +942,21 @@ retry:
|
|||
stb_textedit_clamp(str, state);
|
||||
stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
|
||||
|
||||
// can only go up if there's a previous row
|
||||
if (find.prev_first != find.first_char) {
|
||||
for (j = 0; j < row_count; ++j) {
|
||||
float x, goal_x = state->has_preferred_x ? state->preferred_x : find.x;
|
||||
|
||||
// can only go up if there's a previous row
|
||||
if (find.prev_first == find.first_char)
|
||||
break;
|
||||
|
||||
// now find character position up a row
|
||||
float goal_x = state->has_preferred_x ? state->preferred_x : find.x;
|
||||
float x;
|
||||
state->cursor = find.prev_first;
|
||||
STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor);
|
||||
x = row.x0;
|
||||
for (i=0; i < row.num_chars; ++i) {
|
||||
float dx = STB_TEXTEDIT_GETWIDTH(str, find.prev_first, i);
|
||||
#ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE
|
||||
if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE)
|
||||
#ifdef IMSTB_TEXTEDIT_GETWIDTH_NEWLINE
|
||||
if (dx == IMSTB_TEXTEDIT_GETWIDTH_NEWLINE)
|
||||
break;
|
||||
#endif
|
||||
x += dx;
|
||||
|
@ -952,6 +971,14 @@ retry:
|
|||
|
||||
if (sel)
|
||||
state->select_end = state->cursor;
|
||||
|
||||
// go to previous line
|
||||
// (we need to scan previous line the hard way. maybe we could expose this as a new API function?)
|
||||
prev_scan = find.prev_first > 0 ? find.prev_first - 1 : 0;
|
||||
while (prev_scan > 0 && STB_TEXTEDIT_GETCHAR(str, prev_scan - 1) != STB_TEXTEDIT_NEWLINE)
|
||||
--prev_scan;
|
||||
find.first_char = find.prev_first;
|
||||
find.prev_first = prev_scan;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -981,7 +1008,7 @@ retry:
|
|||
}
|
||||
state->has_preferred_x = 0;
|
||||
break;
|
||||
|
||||
|
||||
#ifdef STB_TEXTEDIT_K_TEXTSTART2
|
||||
case STB_TEXTEDIT_K_TEXTSTART2:
|
||||
#endif
|
||||
|
@ -998,7 +1025,7 @@ retry:
|
|||
state->select_start = state->select_end = 0;
|
||||
state->has_preferred_x = 0;
|
||||
break;
|
||||
|
||||
|
||||
#ifdef STB_TEXTEDIT_K_TEXTSTART2
|
||||
case STB_TEXTEDIT_K_TEXTSTART2 | STB_TEXTEDIT_K_SHIFT:
|
||||
#endif
|
||||
|
@ -1075,10 +1102,6 @@ retry:
|
|||
state->has_preferred_x = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// @TODO:
|
||||
// STB_TEXTEDIT_K_PGUP - move cursor up a page
|
||||
// STB_TEXTEDIT_K_PGDOWN - move cursor down a page
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1090,8 +1113,8 @@ retry:
|
|||
|
||||
static void stb_textedit_flush_redo(StbUndoState *state)
|
||||
{
|
||||
state->redo_point = STB_TEXTEDIT_UNDOSTATECOUNT;
|
||||
state->redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT;
|
||||
state->redo_point = IMSTB_TEXTEDIT_UNDOSTATECOUNT;
|
||||
state->redo_char_point = IMSTB_TEXTEDIT_UNDOCHARCOUNT;
|
||||
}
|
||||
|
||||
// discard the oldest entry in the undo list
|
||||
|
@ -1103,13 +1126,13 @@ static void stb_textedit_discard_undo(StbUndoState *state)
|
|||
int n = state->undo_rec[0].insert_length, i;
|
||||
// delete n characters from all other records
|
||||
state->undo_char_point -= n;
|
||||
STB_TEXTEDIT_memmove(state->undo_char, state->undo_char + n, (size_t) (state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE)));
|
||||
IMSTB_TEXTEDIT_memmove(state->undo_char, state->undo_char + n, (size_t) (state->undo_char_point*sizeof(IMSTB_TEXTEDIT_CHARTYPE)));
|
||||
for (i=0; i < state->undo_point; ++i)
|
||||
if (state->undo_rec[i].char_storage >= 0)
|
||||
state->undo_rec[i].char_storage -= n; // @OPTIMIZE: get rid of char_storage and infer it
|
||||
}
|
||||
--state->undo_point;
|
||||
STB_TEXTEDIT_memmove(state->undo_rec, state->undo_rec+1, (size_t) (state->undo_point*sizeof(state->undo_rec[0])));
|
||||
IMSTB_TEXTEDIT_memmove(state->undo_rec, state->undo_rec+1, (size_t) (state->undo_point*sizeof(state->undo_rec[0])));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1119,7 +1142,7 @@ static void stb_textedit_discard_undo(StbUndoState *state)
|
|||
// fill up even though the undo buffer didn't
|
||||
static void stb_textedit_discard_redo(StbUndoState *state)
|
||||
{
|
||||
int k = STB_TEXTEDIT_UNDOSTATECOUNT-1;
|
||||
int k = IMSTB_TEXTEDIT_UNDOSTATECOUNT-1;
|
||||
|
||||
if (state->redo_point <= k) {
|
||||
// if the k'th undo state has characters, clean those up
|
||||
|
@ -1127,20 +1150,20 @@ static void stb_textedit_discard_redo(StbUndoState *state)
|
|||
int n = state->undo_rec[k].insert_length, i;
|
||||
// move the remaining redo character data to the end of the buffer
|
||||
state->redo_char_point += n;
|
||||
STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((STB_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE)));
|
||||
IMSTB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((IMSTB_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point)*sizeof(IMSTB_TEXTEDIT_CHARTYPE)));
|
||||
// adjust the position of all the other records to account for above memmove
|
||||
for (i=state->redo_point; i < k; ++i)
|
||||
if (state->undo_rec[i].char_storage >= 0)
|
||||
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'
|
||||
// {DEAR IMGUI]
|
||||
size_t move_size = (size_t)((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point - 1) * sizeof(state->undo_rec[0]));
|
||||
// [DEAR IMGUI]
|
||||
size_t move_size = (size_t)((IMSTB_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_end = (char*)state->undo_rec + sizeof(state->undo_rec); (void)buf_end;
|
||||
IM_ASSERT(((char*)(state->undo_rec + state->redo_point)) >= buf_begin);
|
||||
IM_ASSERT(((char*)(state->undo_rec + state->redo_point + 1) + move_size) <= buf_end);
|
||||
STB_TEXTEDIT_memmove(state->undo_rec + state->redo_point+1, state->undo_rec + state->redo_point, move_size);
|
||||
IMSTB_TEXTEDIT_memmove(state->undo_rec + state->redo_point+1, state->undo_rec + state->redo_point, move_size);
|
||||
|
||||
// now move redo_point to point to the new one
|
||||
++state->redo_point;
|
||||
|
@ -1154,32 +1177,32 @@ static StbUndoRecord *stb_text_create_undo_record(StbUndoState *state, int numch
|
|||
|
||||
// if we have no free records, we have to make room, by sliding the
|
||||
// existing records down
|
||||
if (state->undo_point == STB_TEXTEDIT_UNDOSTATECOUNT)
|
||||
if (state->undo_point == IMSTB_TEXTEDIT_UNDOSTATECOUNT)
|
||||
stb_textedit_discard_undo(state);
|
||||
|
||||
// if the characters to store won't possibly fit in the buffer, we can't undo
|
||||
if (numchars > STB_TEXTEDIT_UNDOCHARCOUNT) {
|
||||
if (numchars > IMSTB_TEXTEDIT_UNDOCHARCOUNT) {
|
||||
state->undo_point = 0;
|
||||
state->undo_char_point = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// if we don't have enough free characters in the buffer, we have to make room
|
||||
while (state->undo_char_point + numchars > STB_TEXTEDIT_UNDOCHARCOUNT)
|
||||
while (state->undo_char_point + numchars > IMSTB_TEXTEDIT_UNDOCHARCOUNT)
|
||||
stb_textedit_discard_undo(state);
|
||||
|
||||
return &state->undo_rec[state->undo_point++];
|
||||
}
|
||||
|
||||
static STB_TEXTEDIT_CHARTYPE *stb_text_createundo(StbUndoState *state, int pos, int insert_len, int delete_len)
|
||||
static IMSTB_TEXTEDIT_CHARTYPE *stb_text_createundo(StbUndoState *state, int pos, int insert_len, int delete_len)
|
||||
{
|
||||
StbUndoRecord *r = stb_text_create_undo_record(state, insert_len);
|
||||
if (r == NULL)
|
||||
return NULL;
|
||||
|
||||
r->where = pos;
|
||||
r->insert_length = (STB_TEXTEDIT_POSITIONTYPE) insert_len;
|
||||
r->delete_length = (STB_TEXTEDIT_POSITIONTYPE) delete_len;
|
||||
r->insert_length = (IMSTB_TEXTEDIT_POSITIONTYPE) insert_len;
|
||||
r->delete_length = (IMSTB_TEXTEDIT_POSITIONTYPE) delete_len;
|
||||
|
||||
if (insert_len == 0) {
|
||||
r->char_storage = -1;
|
||||
|
@ -1191,7 +1214,7 @@ static STB_TEXTEDIT_CHARTYPE *stb_text_createundo(StbUndoState *state, int pos,
|
|||
}
|
||||
}
|
||||
|
||||
static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||
static void stb_text_undo(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||
{
|
||||
StbUndoState *s = &state->undostate;
|
||||
StbUndoRecord u, *r;
|
||||
|
@ -1218,7 +1241,7 @@ static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
|||
// characters stored for *undoing* don't leave room for redo
|
||||
// if the last is true, we have to bail
|
||||
|
||||
if (s->undo_char_point + u.delete_length >= STB_TEXTEDIT_UNDOCHARCOUNT) {
|
||||
if (s->undo_char_point + u.delete_length >= IMSTB_TEXTEDIT_UNDOCHARCOUNT) {
|
||||
// the undo records take up too much character space; there's no space to store the redo characters
|
||||
r->insert_length = 0;
|
||||
} else {
|
||||
|
@ -1227,7 +1250,7 @@ static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
|||
// there's definitely room to store the characters eventually
|
||||
while (s->undo_char_point + u.delete_length > s->redo_char_point) {
|
||||
// should never happen:
|
||||
if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT)
|
||||
if (s->redo_point == IMSTB_TEXTEDIT_UNDOSTATECOUNT)
|
||||
return;
|
||||
// there's currently not enough room, so discard a redo record
|
||||
stb_textedit_discard_redo(s);
|
||||
|
@ -1259,11 +1282,11 @@ static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
|||
s->redo_point--;
|
||||
}
|
||||
|
||||
static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||
static void stb_text_redo(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||
{
|
||||
StbUndoState *s = &state->undostate;
|
||||
StbUndoRecord *u, r;
|
||||
if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT)
|
||||
if (s->redo_point == IMSTB_TEXTEDIT_UNDOSTATECOUNT)
|
||||
return;
|
||||
|
||||
// we need to do two things: apply the redo record, and create an undo record
|
||||
|
@ -1315,20 +1338,20 @@ static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int le
|
|||
stb_text_createundo(&state->undostate, where, 0, length);
|
||||
}
|
||||
|
||||
static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length)
|
||||
static void stb_text_makeundo_delete(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length)
|
||||
{
|
||||
int i;
|
||||
STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, length, 0);
|
||||
IMSTB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, length, 0);
|
||||
if (p) {
|
||||
for (i=0; i < length; ++i)
|
||||
p[i] = STB_TEXTEDIT_GETCHAR(str, where+i);
|
||||
}
|
||||
}
|
||||
|
||||
static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length)
|
||||
static void stb_text_makeundo_replace(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length)
|
||||
{
|
||||
int i;
|
||||
STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, old_length, new_length);
|
||||
IMSTB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, old_length, new_length);
|
||||
if (p) {
|
||||
for (i=0; i < old_length; ++i)
|
||||
p[i] = STB_TEXTEDIT_GETCHAR(str, where+i);
|
||||
|
@ -1340,8 +1363,8 @@ static void stb_textedit_clear_state(STB_TexteditState *state, int is_single_lin
|
|||
{
|
||||
state->undostate.undo_point = 0;
|
||||
state->undostate.undo_char_point = 0;
|
||||
state->undostate.redo_point = STB_TEXTEDIT_UNDOSTATECOUNT;
|
||||
state->undostate.redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT;
|
||||
state->undostate.redo_point = IMSTB_TEXTEDIT_UNDOSTATECOUNT;
|
||||
state->undostate.redo_char_point = IMSTB_TEXTEDIT_UNDOCHARCOUNT;
|
||||
state->select_end = state->select_start = 0;
|
||||
state->cursor = 0;
|
||||
state->has_preferred_x = 0;
|
||||
|
@ -1350,6 +1373,7 @@ static void stb_textedit_clear_state(STB_TexteditState *state, int is_single_lin
|
|||
state->initialized = 1;
|
||||
state->single_line = (unsigned char) is_single_line;
|
||||
state->insert_mode = 0;
|
||||
state->row_count_per_page = 0;
|
||||
}
|
||||
|
||||
// API initialize
|
||||
|
@ -1363,16 +1387,16 @@ static void stb_textedit_initialize_state(STB_TexteditState *state, int is_singl
|
|||
#pragma GCC diagnostic ignored "-Wcast-qual"
|
||||
#endif
|
||||
|
||||
static int stb_textedit_paste(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE const *ctext, int len)
|
||||
static int stb_textedit_paste(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, IMSTB_TEXTEDIT_CHARTYPE const *ctext, int len)
|
||||
{
|
||||
return stb_textedit_paste_internal(str, state, (STB_TEXTEDIT_CHARTYPE *) ctext, len);
|
||||
return stb_textedit_paste_internal(str, state, (IMSTB_TEXTEDIT_CHARTYPE *) ctext, len);
|
||||
}
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif//STB_TEXTEDIT_IMPLEMENTATION
|
||||
#endif//IMSTB_TEXTEDIT_IMPLEMENTATION
|
||||
|
||||
/*
|
||||
------------------------------------------------------------------------------
|
||||
|
@ -1380,38 +1404,38 @@ This software is available under 2 licenses -- choose whichever you prefer.
|
|||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE A - MIT License
|
||||
Copyright (c) 2017 Sean Barrett
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||
This is free and unencumbered software released into the public domain.
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||
software, either in source code form or as a compiled binary, for any purpose,
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||
software, either in source code form or as a compiled binary, for any purpose,
|
||||
commercial or non-commercial, and by any means.
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||
software dedicate any and all copyright interest in the software to the public
|
||||
domain. We make this dedication for the benefit of the public at large and to
|
||||
the detriment of our heirs and successors. We intend this dedication to be an
|
||||
overt act of relinquishment in perpetuity of all present and future rights to
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||
software dedicate any and all copyright interest in the software to the public
|
||||
domain. We make this dedication for the benefit of the public at large and to
|
||||
the detriment of our heirs and successors. We intend this dedication to be an
|
||||
overt act of relinquishment in perpetuity of all present and future rights to
|
||||
this software under copyright law.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
*/
|
||||
|
|
890
src/external/imgui/imgui/imstb_truetype.h
vendored
890
src/external/imgui/imgui/imstb_truetype.h
vendored
File diff suppressed because it is too large
Load diff
|
@ -91,7 +91,7 @@ static void PlotTimings(const char *label,
|
|||
ItemSize(total_bb, style.FramePadding.y);
|
||||
if (!ItemAdd(total_bb, 0, &frame_bb))
|
||||
return;
|
||||
const bool hovered = ItemHoverable(frame_bb, id);
|
||||
const bool hovered = ItemHoverable(frame_bb, id, g.LastItemData.InFlags);
|
||||
|
||||
float v_min = FLT_MAX;
|
||||
float v_max = -FLT_MAX;
|
||||
|
|
21
src/external/imgui/implot/LICENSE
vendored
Normal file
21
src/external/imgui/implot/LICENSE
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 Evan Pezent
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
5885
src/external/imgui/implot/implot.cpp
vendored
Normal file
5885
src/external/imgui/implot/implot.cpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
1297
src/external/imgui/implot/implot.h
vendored
Normal file
1297
src/external/imgui/implot/implot.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
2479
src/external/imgui/implot/implot_demo.cpp
vendored
Normal file
2479
src/external/imgui/implot/implot_demo.cpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
1669
src/external/imgui/implot/implot_internal.h
vendored
Normal file
1669
src/external/imgui/implot/implot_internal.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
2808
src/external/imgui/implot/implot_items.cpp
vendored
Normal file
2808
src/external/imgui/implot/implot_items.cpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -158,7 +158,7 @@ sdl2_loop_events(struct u_debug_gui *p)
|
|||
SDL_Event event;
|
||||
|
||||
while (SDL_PollEvent(&event)) {
|
||||
igImGui_ImplSDL2_ProcessEvent(&event);
|
||||
ImGui_ImplSDL2_ProcessEvent(&event);
|
||||
|
||||
#ifdef XRT_BUILD_DRIVER_QWERTY
|
||||
// Caution here, qwerty driver is being accessed by the main thread as well
|
||||
|
@ -179,13 +179,13 @@ sdl2_loop_events(struct u_debug_gui *p)
|
|||
}
|
||||
|
||||
static void
|
||||
sdl2_loop_new_frame(struct u_debug_gui *p)
|
||||
sdl2_loop_new_frame(void)
|
||||
{
|
||||
XRT_TRACE_MARKER();
|
||||
|
||||
// Start the Dear ImGui frame
|
||||
igImGui_ImplOpenGL3_NewFrame();
|
||||
igImGui_ImplSDL2_NewFrame(p->win);
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame();
|
||||
|
||||
// Start new frame.
|
||||
igNewFrame();
|
||||
|
@ -223,7 +223,7 @@ sdl2_loop_render(struct u_debug_gui *p, struct gui_imgui *gui, ImGuiIO *io)
|
|||
glClearColor(gui->clear.r, gui->clear.g, gui->clear.b, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
igImGui_ImplOpenGL3_RenderDrawData(igGetDrawData());
|
||||
ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData());
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -247,8 +247,8 @@ sdl2_loop(struct u_debug_gui *p)
|
|||
}
|
||||
|
||||
// Setup Platform/Renderer bindings
|
||||
igImGui_ImplSDL2_InitForOpenGL(p->win, p->ctx);
|
||||
igImGui_ImplOpenGL3_Init(NULL);
|
||||
ImGui_ImplSDL2_InitForOpenGL(p->win, p->ctx);
|
||||
ImGui_ImplOpenGL3_Init(NULL);
|
||||
|
||||
// Setup Dear ImGui style
|
||||
igStyleColorsDark(NULL);
|
||||
|
@ -280,7 +280,7 @@ sdl2_loop(struct u_debug_gui *p)
|
|||
|
||||
sdl2_loop_events(p);
|
||||
|
||||
sdl2_loop_new_frame(p);
|
||||
sdl2_loop_new_frame();
|
||||
|
||||
sdl2_loop_show_scene(p, &gui);
|
||||
|
||||
|
@ -297,8 +297,8 @@ sdl2_loop(struct u_debug_gui *p)
|
|||
// Cleanup
|
||||
u_var_remove_root(&gui);
|
||||
ImPlot_DestroyContext(plot_ctx);
|
||||
igImGui_ImplOpenGL3_Shutdown();
|
||||
igImGui_ImplSDL2_Shutdown();
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplSDL2_Shutdown();
|
||||
igDestroyContext(NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#pragma once
|
||||
|
||||
#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
#include "imgui/cimgui.h"
|
||||
#include "imgui/cimplot.h"
|
||||
#include "cimgui/cimgui.h"
|
||||
#include "cimgui/cimgui_impl.h"
|
||||
#include "cimplot/cimplot.h"
|
||||
#include "imgui_monado/cimgui_monado.h"
|
||||
|
|
|
@ -91,6 +91,6 @@ gui_ogl_draw_background(uint32_t width, uint32_t height, uint32_t tex_id, bool r
|
|||
ImVec2 p_min = {translate_x, translate_y};
|
||||
ImVec2 p_max = {translate_x + inside_w, translate_y + inside_h};
|
||||
|
||||
ImDrawList *bg = igGetBackgroundDrawList();
|
||||
ImDrawList *bg = igGetBackgroundDrawList_Nil();
|
||||
ImDrawList_AddImage(bg, id, p_min, p_max, uv0, uv1, white);
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ draw_texture(struct gui_ogl_texture *tex, bool header)
|
|||
}
|
||||
|
||||
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_None;
|
||||
if (header && !igCollapsingHeaderBoolPtr(tex->name, NULL, flags)) {
|
||||
if (header && !igCollapsingHeader_BoolPtr(tex->name, NULL, flags)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -231,8 +231,8 @@ scene_render_select(struct gui_scene *scene, struct gui_program *p)
|
|||
#ifdef XRT_HAVE_OPENCV
|
||||
igBegin("Params", NULL, 0);
|
||||
|
||||
igComboStr("Type", (int *)&cs->settings->camera_type,
|
||||
"Regular Mono\0Regular Stereo (Side-by-Side)\0SLAM Stereo\0PS4\0Leap Motion Controller\0\0", -1);
|
||||
igCombo_Str("Type", (int *)&cs->settings->camera_type,
|
||||
"Regular Mono\0Regular Stereo (Side-by-Side)\0SLAM Stereo\0PS4\0Leap Motion Controller\0\0", -1);
|
||||
|
||||
switch (cs->settings->camera_type) {
|
||||
case XRT_SETTINGS_CAMERA_TYPE_REGULAR_MONO:
|
||||
|
@ -274,8 +274,8 @@ scene_render_select(struct gui_scene *scene, struct gui_program *p)
|
|||
igInputInt("Collect in groups of #", &cs->params.num_collect_restart, 1, 5, 0);
|
||||
|
||||
igSeparator();
|
||||
igComboStr("Board type", (int *)&cs->params.pattern, "Checkers\0Corners SB\0Circles\0Asymmetric Circles\0\0",
|
||||
3);
|
||||
igCombo_Str("Board type", (int *)&cs->params.pattern, "Checkers\0Corners SB\0Circles\0Asymmetric Circles\0\0",
|
||||
3);
|
||||
switch (cs->params.pattern) {
|
||||
case T_BOARD_CHECKERS:
|
||||
igInputInt("Checkerboard Rows", &cs->params.checkers.rows, 1, 5, 0);
|
||||
|
|
|
@ -237,27 +237,27 @@ draw_native_images_to_background(struct u_var_info *var, struct draw_state *stat
|
|||
*/
|
||||
|
||||
#define PLOT_HELPER(elm) \
|
||||
static ImPlotPoint plot_vec3_f32_##elm(void *ptr, int index) \
|
||||
static void *plot_vec3_f32_##elm(void *ptr, int index, ImPlotPoint *point) \
|
||||
{ \
|
||||
struct plot_state *state = (struct plot_state *)ptr; \
|
||||
struct xrt_vec3 value; \
|
||||
uint64_t timestamp; \
|
||||
m_ff_vec3_f32_get(state->ff, index, &value, ×tamp); \
|
||||
ImPlotPoint point = {time_ns_to_s(state->now - timestamp), value.elm}; \
|
||||
return point; \
|
||||
*point = (ImPlotPoint){time_ns_to_s(state->now - timestamp), value.elm}; \
|
||||
return NULL; \
|
||||
}
|
||||
|
||||
PLOT_HELPER(x)
|
||||
PLOT_HELPER(y)
|
||||
PLOT_HELPER(z)
|
||||
|
||||
static ImPlotPoint
|
||||
plot_curve_point(void *ptr, int i)
|
||||
static void *
|
||||
plot_curve_point(void *ptr, int i, ImPlotPoint *point)
|
||||
{
|
||||
struct u_var_curve *c = (struct u_var_curve *)ptr;
|
||||
struct u_var_curve_point point = c->getter(c->data, i);
|
||||
ImPlotPoint implot_point = {point.x, point.y};
|
||||
return implot_point;
|
||||
struct u_var_curve_point p = c->getter(c->data, i);
|
||||
*point = (ImPlotPoint){p.x, p.y};
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static float
|
||||
|
@ -302,13 +302,15 @@ on_f32_arr(const char *name, void *ptr)
|
|||
int length = f32_arr->length;
|
||||
float *arr = (float *)f32_arr->data;
|
||||
|
||||
float w = igGetWindowContentRegionWidth();
|
||||
ImVec2 graph_size = {w, 200};
|
||||
ImVec2 min, max;
|
||||
igGetWindowContentRegionMin(&min);
|
||||
igGetWindowContentRegionMax(&max);
|
||||
ImVec2 graph_size = {max.x - min.x, 200};
|
||||
|
||||
float stats_min = FLT_MAX;
|
||||
float stats_max = FLT_MAX;
|
||||
|
||||
igPlotLinesFnFloatPtr( //
|
||||
igPlotLines_FnFloatPtr( //
|
||||
name, //
|
||||
plot_f32_array_value, //
|
||||
arr, //
|
||||
|
@ -329,9 +331,10 @@ on_timing(const char *name, void *ptr)
|
|||
int length = f32_arr->length;
|
||||
float *arr = (float *)f32_arr->data;
|
||||
|
||||
float w = igGetWindowContentRegionWidth();
|
||||
ImVec2 graph_size = {w, 200};
|
||||
|
||||
ImVec2 min, max;
|
||||
igGetWindowContentRegionMin(&min);
|
||||
igGetWindowContentRegionMax(&max);
|
||||
ImVec2 graph_size = {max.x - min.x, 200};
|
||||
|
||||
float stats_min = FLT_MAX;
|
||||
float stats_max = 0;
|
||||
|
@ -401,18 +404,19 @@ on_ff_vec3_var(struct u_var_info *info, struct gui_program *p)
|
|||
*/
|
||||
|
||||
struct plot_state state = {ff, os_monotonic_get_ns()};
|
||||
ImPlotFlags flags = 0;
|
||||
ImPlotAxisFlags x_flags = 0;
|
||||
ImPlotAxisFlags y_flags = 0;
|
||||
ImPlotAxisFlags y2_flags = 0;
|
||||
ImPlotAxisFlags y3_flags = 0;
|
||||
|
||||
ImVec2 size = {igGetWindowContentRegionWidth(), 256};
|
||||
bool shown = ImPlot_BeginPlot(name, "time", "value", size, flags, x_flags, y_flags, y2_flags, y3_flags);
|
||||
ImVec2 min, max;
|
||||
igGetWindowContentRegionMin(&min);
|
||||
igGetWindowContentRegionMax(&max);
|
||||
ImVec2 size = {max.x - min.x, 256};
|
||||
bool shown = ImPlot_BeginPlot(name, size, 0);
|
||||
if (!shown) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImPlot_SetupAxis(ImAxis_X1, "time", 0);
|
||||
ImPlot_SetupAxis(ImAxis_Y1, "value", 0);
|
||||
|
||||
size_t num = m_ff_vec3_f32_get_num(ff);
|
||||
ImPlot_PlotLineG("z", plot_vec3_f32_z, &state, num, 0); // ZXY order to match RGB colors with default color map
|
||||
ImPlot_PlotLineG("x", plot_vec3_f32_x, &state, num, 0);
|
||||
|
@ -433,7 +437,7 @@ on_sink_debug_var(const char *name, void *ptr, struct draw_state *state)
|
|||
|
||||
if (gui_header) {
|
||||
const ImGuiTreeNodeFlags_ flags = ImGuiTreeNodeFlags_DefaultOpen;
|
||||
if (!igCollapsingHeaderBoolPtr(name, NULL, flags)) {
|
||||
if (!igCollapsingHeader_BoolPtr(name, NULL, flags)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -451,7 +455,7 @@ on_native_images_debug_var(const char *name, void *ptr, struct draw_state *state
|
|||
|
||||
if (gui_header) {
|
||||
const ImGuiTreeNodeFlags_ flags = ImGuiTreeNodeFlags_DefaultOpen;
|
||||
if (!igCollapsingHeaderBoolPtr(name, NULL, flags)) {
|
||||
if (!igCollapsingHeader_BoolPtr(name, NULL, flags)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -474,7 +478,7 @@ on_button_var(const char *name, void *ptr)
|
|||
bool disabled = btn->disabled;
|
||||
|
||||
if (disabled) {
|
||||
igPushStyleVarFloat(ImGuiStyleVar_Alpha, 0.6f);
|
||||
igPushStyleVar_Float(ImGuiStyleVar_Alpha, 0.6f);
|
||||
igPushItemFlag(ImGuiItemFlags_Disabled, true);
|
||||
}
|
||||
|
||||
|
@ -492,7 +496,7 @@ static void
|
|||
on_combo_var(const char *name, void *ptr)
|
||||
{
|
||||
struct u_var_combo *combo = (struct u_var_combo *)ptr;
|
||||
igComboStr(name, combo->value, combo->options, combo->count);
|
||||
igCombo_Str(name, combo->value, combo->options, combo->count);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -500,20 +504,27 @@ on_histogram_f32_var(const char *name, void *ptr)
|
|||
{
|
||||
struct u_var_histogram_f32 *h = (struct u_var_histogram_f32 *)ptr;
|
||||
ImVec2 zero = {h->width, h->height};
|
||||
igPlotHistogramFloatPtr(name, h->values, h->count, 0, NULL, FLT_MAX, FLT_MAX, zero, sizeof(float));
|
||||
igPlotHistogram_FloatPtr(name, h->values, h->count, 0, NULL, FLT_MAX, FLT_MAX, zero, sizeof(float));
|
||||
}
|
||||
|
||||
static void
|
||||
on_curve_var(const char *name, void *ptr)
|
||||
{
|
||||
struct u_var_curve *c = (struct u_var_curve *)ptr;
|
||||
ImVec2 size = {igGetWindowContentRegionWidth(), 256};
|
||||
|
||||
bool shown = ImPlot_BeginPlot(name, c->xlabel, c->ylabel, size, 0, 0, 0, 0, 0);
|
||||
ImVec2 min, max;
|
||||
igGetWindowContentRegionMin(&min);
|
||||
igGetWindowContentRegionMax(&max);
|
||||
ImVec2 size = {max.x - min.x, 256};
|
||||
|
||||
bool shown = ImPlot_BeginPlot(name, size, 0);
|
||||
if (!shown) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImPlot_SetupAxis(ImAxis_X1, c->xlabel, 0);
|
||||
ImPlot_SetupAxis(ImAxis_Y1, c->ylabel, 0);
|
||||
|
||||
ImPlot_PlotLineG(c->label, plot_curve_point, c, c->count, 0);
|
||||
ImPlot_EndPlot();
|
||||
}
|
||||
|
@ -522,13 +533,19 @@ static void
|
|||
on_curves_var(const char *name, void *ptr)
|
||||
{
|
||||
struct u_var_curves *cs = (struct u_var_curves *)ptr;
|
||||
ImVec2 size = {igGetWindowContentRegionWidth(), 256};
|
||||
ImVec2 min, max;
|
||||
igGetWindowContentRegionMin(&min);
|
||||
igGetWindowContentRegionMax(&max);
|
||||
ImVec2 size = {max.x - min.x, 256};
|
||||
|
||||
bool shown = ImPlot_BeginPlot(name, cs->xlabel, cs->ylabel, size, 0, 0, 0, 0, 0);
|
||||
bool shown = ImPlot_BeginPlot(name, size, 0);
|
||||
if (!shown) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImPlot_SetupAxis(ImAxis_X1, cs->xlabel, 0);
|
||||
ImPlot_SetupAxis(ImAxis_Y1, cs->ylabel, 0);
|
||||
|
||||
for (int i = 0; i < cs->curve_count; i++) {
|
||||
struct u_var_curve *c = &cs->curves[i];
|
||||
ImPlot_PlotLineG(c->label, plot_curve_point, c, c->count, 0);
|
||||
|
@ -555,13 +572,13 @@ on_gui_header(const char *name, struct draw_state *state)
|
|||
{
|
||||
|
||||
assert(state->vis_i == 0 && "Do not mix GUI_HEADER with GUI_HEADER_BEGIN/END");
|
||||
state->vis_stack[state->vis_i] = igCollapsingHeaderBoolPtr(name, NULL, 0);
|
||||
state->vis_stack[state->vis_i] = igCollapsingHeader_BoolPtr(name, NULL, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
on_gui_header_begin(const char *name, struct draw_state *state)
|
||||
{
|
||||
bool is_open = igCollapsingHeaderBoolPtr(name, NULL, 0);
|
||||
bool is_open = igCollapsingHeader_BoolPtr(name, NULL, 0);
|
||||
state->vis_stack[state->vis_i] = is_open;
|
||||
if (is_open) {
|
||||
igIndent(8.0f);
|
||||
|
@ -639,7 +656,7 @@ on_elem(struct u_var_info *info, void *priv)
|
|||
case U_VAR_KIND_TIMING: on_timing(name, ptr); break;
|
||||
case U_VAR_KIND_VEC3_F32: igInputFloat3(name, (float *)ptr, "%+f", i_flags); break;
|
||||
case U_VAR_KIND_POSE: on_pose(name, ptr); break;
|
||||
case U_VAR_KIND_LOG_LEVEL: igComboStr(name, (int *)ptr, "Trace\0Debug\0Info\0Warn\0Error\0\0", 5); break;
|
||||
case U_VAR_KIND_LOG_LEVEL: igCombo_Str(name, (int *)ptr, "Trace\0Debug\0Info\0Warn\0Error\0\0", 5); break;
|
||||
case U_VAR_KIND_RO_TEXT: igText("%s: '%s'", name, (char *)ptr); break;
|
||||
case U_VAR_KIND_RO_FTEXT: igText(ptr ? (char *)ptr : "%s", name); break;
|
||||
case U_VAR_KIND_RO_I32: igInputScalar(name, ImGuiDataType_S32, ptr, NULL, NULL, NULL, ro_i_flags); break;
|
||||
|
|
|
@ -109,7 +109,7 @@ static bool
|
|||
handle_downable_button(const char *name)
|
||||
{
|
||||
igButton(name, zero_dims);
|
||||
return igIsItemHovered(ImGuiHoveredFlags_RectOnly) && igIsMouseDown(ImGuiMouseButton_Left);
|
||||
return igIsItemHovered(ImGuiHoveredFlags_RectOnly) && igIsMouseDown_Nil(ImGuiMouseButton_Left);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -346,18 +346,18 @@ on_connected(struct gui_remote *gr, struct gui_program *p)
|
|||
const struct r_remote_data *r = &gr->reset;
|
||||
struct r_remote_data *d = &gr->data;
|
||||
|
||||
igPushIDPtr(&d->head); // Make all IDs unique.
|
||||
igPushID_Ptr(&d->head); // Make all IDs unique.
|
||||
POSE(head.center);
|
||||
igPopID(); // Pop unique IDs
|
||||
|
||||
igPushIDPtr(&d->left); // Make all IDs unique.
|
||||
igPushID_Ptr(&d->left); // Make all IDs unique.
|
||||
POSE(left.pose);
|
||||
LIN_ANG(left);
|
||||
BUTTONS(left);
|
||||
HAND(left);
|
||||
igPopID(); // Pop unique IDs
|
||||
|
||||
igPushIDPtr(&d->right); // Make all IDs unique.
|
||||
igPushID_Ptr(&d->right); // Make all IDs unique.
|
||||
POSE(right.pose);
|
||||
LIN_ANG(right);
|
||||
BUTTONS(right);
|
||||
|
|
|
@ -262,7 +262,7 @@ scene_render(struct gui_scene *scene, struct gui_program *p)
|
|||
igText("Existing Overrides");
|
||||
for (size_t i = 0; i < ts->num_overrides; i++) {
|
||||
// make the delete buttons work
|
||||
igPushIDInt(i);
|
||||
igPushID_Int(i);
|
||||
|
||||
igSeparator();
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ gui_widget_native_images_render(struct gui_widget_native_images *gwni, struct gu
|
|||
return;
|
||||
}
|
||||
|
||||
igPushIDPtr(gwni);
|
||||
igPushID_Ptr(gwni);
|
||||
|
||||
window_draw_misc(gwni);
|
||||
|
||||
|
|
|
@ -162,19 +162,18 @@ draw_gst(struct gui_record_window *rw)
|
|||
{
|
||||
static ImVec2 button_dims = {0, 0};
|
||||
|
||||
if (!igCollapsingHeaderBoolPtr("Record", NULL, ImGuiTreeNodeFlags_None)) {
|
||||
if (!igCollapsingHeader_BoolPtr("Record", NULL, ImGuiTreeNodeFlags_None)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
os_mutex_lock(&rw->gst.mutex);
|
||||
bool recording = rw->gst.gp != NULL;
|
||||
os_mutex_unlock(&rw->gst.mutex);
|
||||
|
||||
igComboStr("Pipeline", (int *)&rw->gst.pipeline,
|
||||
"SW Ultrafast\0SW Veryfast\0SW Fast\0SW Medium\0SW Slow\0SW Veryslow\0VAAPI H264\0\0", 5);
|
||||
igComboStr("Bitrate", (int *)&rw->gst.bitrate, "32768bps (Be careful!)\0004096bps\0002048bps\0001024bps\0\0",
|
||||
3);
|
||||
igCombo_Str("Pipeline", (int *)&rw->gst.pipeline,
|
||||
"SW Ultrafast\0SW Veryfast\0SW Fast\0SW Medium\0SW Slow\0SW Veryslow\0VAAPI H264\0\0", 5);
|
||||
igCombo_Str("Bitrate", (int *)&rw->gst.bitrate, "32768bps (Be careful!)\0004096bps\0002048bps\0001024bps\0\0",
|
||||
3);
|
||||
|
||||
igInputText("Filename", rw->gst.filename, sizeof(rw->gst.filename), 0, NULL, NULL);
|
||||
|
||||
|
@ -325,7 +324,7 @@ void
|
|||
gui_window_record_render(struct gui_record_window *rw, struct gui_program *p)
|
||||
{
|
||||
// Make all IDs unique.
|
||||
igPushIDPtr(rw);
|
||||
igPushID_Ptr(rw);
|
||||
|
||||
gui_ogl_sink_update(rw->texture.ogl);
|
||||
|
||||
|
|
|
@ -67,8 +67,8 @@ gui_sdl2_imgui_loop(struct sdl2_program *p)
|
|||
}
|
||||
|
||||
// Setup Platform/Renderer bindings
|
||||
igImGui_ImplSDL2_InitForOpenGL(p->win, p->ctx);
|
||||
igImGui_ImplOpenGL3_Init(NULL);
|
||||
ImGui_ImplSDL2_InitForOpenGL(p->win, p->ctx);
|
||||
ImGui_ImplOpenGL3_Init(NULL);
|
||||
|
||||
// Setup Dear ImGui style
|
||||
igStyleColorsDark(NULL);
|
||||
|
@ -92,7 +92,7 @@ gui_sdl2_imgui_loop(struct sdl2_program *p)
|
|||
SDL_Event event;
|
||||
|
||||
while (SDL_PollEvent(&event)) {
|
||||
igImGui_ImplSDL2_ProcessEvent(&event);
|
||||
ImGui_ImplSDL2_ProcessEvent(&event);
|
||||
|
||||
if (event.type == SDL_QUIT) {
|
||||
p->base.stopped = true;
|
||||
|
@ -105,8 +105,8 @@ gui_sdl2_imgui_loop(struct sdl2_program *p)
|
|||
}
|
||||
|
||||
// Start the Dear ImGui frame
|
||||
igImGui_ImplOpenGL3_NewFrame();
|
||||
igImGui_ImplSDL2_NewFrame(p->win);
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame();
|
||||
|
||||
// Start new frame.
|
||||
igNewFrame();
|
||||
|
@ -132,7 +132,7 @@ gui_sdl2_imgui_loop(struct sdl2_program *p)
|
|||
glClearColor(gui.clear.r, gui.clear.g, gui.clear.b, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
igImGui_ImplOpenGL3_RenderDrawData(igGetDrawData());
|
||||
ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData());
|
||||
|
||||
SDL_GL_SwapWindow(p->win);
|
||||
|
||||
|
@ -142,7 +142,7 @@ gui_sdl2_imgui_loop(struct sdl2_program *p)
|
|||
// Cleanup
|
||||
u_var_remove_root(&gui);
|
||||
ImPlot_DestroyContext(plot_ctx);
|
||||
igImGui_ImplOpenGL3_Shutdown();
|
||||
igImGui_ImplSDL2_Shutdown();
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplSDL2_Shutdown();
|
||||
igDestroyContext(NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue