mirror of
https://github.com/ocornut/imgui.git
synced 2025-09-08 12:28:24 +00:00
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_sdl3.cpp # backends/imgui_impl_sdl3.h # docs/CHANGELOG.txt # imgui_internal.h
This commit is contained in:
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -489,12 +489,12 @@ jobs:
|
|||||||
popd
|
popd
|
||||||
make -C examples/example_sdl2_opengl3 -f Makefile.emscripten
|
make -C examples/example_sdl2_opengl3 -f Makefile.emscripten
|
||||||
|
|
||||||
- name: Build example_emscripten_wgpu
|
- name: Build example_glfw_wgpu
|
||||||
run: |
|
run: |
|
||||||
pushd emsdk-master
|
pushd emsdk-master
|
||||||
source ./emsdk_env.sh
|
source ./emsdk_env.sh
|
||||||
popd
|
popd
|
||||||
make -C examples/example_emscripten_wgpu -f Makefile.emscripten
|
make -C examples/example_glfw_wgpu -f Makefile.emscripten
|
||||||
|
|
||||||
Android:
|
Android:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -40,8 +40,9 @@ examples/*.o.tmp
|
|||||||
examples/*.out.js
|
examples/*.out.js
|
||||||
examples/*.out.wasm
|
examples/*.out.wasm
|
||||||
examples/example_glfw_opengl3/web/*
|
examples/example_glfw_opengl3/web/*
|
||||||
|
examples/example_glfw_wgpu/web/*
|
||||||
|
examples/example_glfw_wgpu/external/*
|
||||||
examples/example_sdl2_opengl3/web/*
|
examples/example_sdl2_opengl3/web/*
|
||||||
examples/example_emscripten_wgpu/web/*
|
|
||||||
|
|
||||||
## JetBrains IDE artifacts
|
## JetBrains IDE artifacts
|
||||||
.idea
|
.idea
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
// Issues:
|
// Issues:
|
||||||
// [ ] Platform: Multi-viewport: Minimized windows seems to break mouse wheel events (at least under Windows).
|
// [ ] 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).
|
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
|
||||||
// [x] Platform: Basic IME support. Position somehow broken in SDL3 + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
// [ ] Platform: IME SUPPORT IS BROKEN IN SDL3 BECAUSE INPUTS GETS SENT TO BOTH APP AND IME + 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.
|
// 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.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2024-04-15: Inputs: Re-enable calling SDL_StartTextInput()/SDL_StopTextInput() as SDL3 no longer enables it by default and should play nicer with IME.
|
||||||
// 2024-02-13: Inputs: Fixed gamepad support. Handle gamepad disconnection. Added ImGui_ImplSDL3_SetGamepadMode().
|
// 2024-02-13: Inputs: Fixed gamepad support. Handle gamepad disconnection. Added ImGui_ImplSDL3_SetGamepadMode().
|
||||||
// 2023-11-13: Updated for recent SDL3 API changes.
|
// 2023-11-13: Updated for recent SDL3 API changes.
|
||||||
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
||||||
@@ -129,6 +130,11 @@ static void ImGui_ImplSDL3_SetPlatformImeData(ImGuiViewport* viewport, ImGuiPlat
|
|||||||
r.w = 1;
|
r.w = 1;
|
||||||
r.h = (int)data->InputLineHeight;
|
r.h = (int)data->InputLineHeight;
|
||||||
SDL_SetTextInputRect(&r);
|
SDL_SetTextInputRect(&r);
|
||||||
|
SDL_StartTextInput();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDL_StopTextInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
// [ ] Platform: Multi-viewport: Minimized windows seems to break mouse wheel events (at least under Windows).
|
// [ ] 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).
|
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
|
||||||
// [x] Platform: Basic IME support. Position somehow broken in SDL3 + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
// [x] Platform: Basic IME support. Position somehow broken in SDL3 + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
||||||
|
// [ ] Platform: IME SUPPORT IS BROKEN IN SDL3 BECAUSE INPUTS GETS SENT TO BOTH APP AND IME + 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.
|
// 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.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@@ -753,7 +753,7 @@ bool ImGui_ImplWGPU_Init(ImGui_ImplWGPU_InitInfo* init_info)
|
|||||||
|
|
||||||
// Create buffers with a default size (they will later be grown as needed)
|
// Create buffers with a default size (they will later be grown as needed)
|
||||||
bd->pFrameResources = new FrameResources[bd->numFramesInFlight];
|
bd->pFrameResources = new FrameResources[bd->numFramesInFlight];
|
||||||
for (int i = 0; i < bd->numFramesInFlight; i++)
|
for (unsigned int i = 0; i < bd->numFramesInFlight; i++)
|
||||||
{
|
{
|
||||||
FrameResources* fr = &bd->pFrameResources[i];
|
FrameResources* fr = &bd->pFrameResources[i];
|
||||||
fr->IndexBuffer = nullptr;
|
fr->IndexBuffer = nullptr;
|
||||||
|
@@ -79,14 +79,14 @@ List of Renderer Backends:
|
|||||||
imgui_impl_sdlrenderer2.cpp ; SDL_Renderer (optional component of SDL2 available from SDL 2.0.18+)
|
imgui_impl_sdlrenderer2.cpp ; SDL_Renderer (optional component of SDL2 available from SDL 2.0.18+)
|
||||||
imgui_impl_sdlrenderer3.cpp ; SDL_Renderer (optional component of SDL3 available from SDL 3.0.0+)
|
imgui_impl_sdlrenderer3.cpp ; SDL_Renderer (optional component of SDL3 available from SDL 3.0.0+)
|
||||||
imgui_impl_vulkan.cpp ; Vulkan
|
imgui_impl_vulkan.cpp ; Vulkan
|
||||||
imgui_impl_wgpu.cpp ; WebGPU
|
imgui_impl_wgpu.cpp ; WebGPU (web and desktop)
|
||||||
|
|
||||||
List of high-level Frameworks Backends (combining Platform + Renderer):
|
List of high-level Frameworks Backends (combining Platform + Renderer):
|
||||||
|
|
||||||
imgui_impl_allegro5.cpp
|
imgui_impl_allegro5.cpp
|
||||||
|
|
||||||
Emscripten is also supported!
|
Emscripten is also supported!
|
||||||
The SDL+GL, GLFW+GL and SDL+WebGPU examples are all ready to build and run with Emscripten.
|
The SDL+GL, GLFW+GL and GLFW+WebGPU examples are all ready to build and run with Emscripten.
|
||||||
|
|
||||||
### Backends for third-party frameworks, graphics API or other languages
|
### Backends for third-party frameworks, graphics API or other languages
|
||||||
|
|
||||||
|
@@ -43,6 +43,16 @@ Breaking changes:
|
|||||||
|
|
||||||
Other changes:
|
Other changes:
|
||||||
|
|
||||||
|
- Fonts: Fixed font ascent and descent calculation when a font hits exact integer values.
|
||||||
|
It is possible that some prior manual use of ImFontConfig::GlyphOffset may become
|
||||||
|
duplicate with this fix. (#7399, #7404) [@GamingMinds-DanielC]
|
||||||
|
- Text, DrawList: Improved handling of long single-line wrapped text. Faster and
|
||||||
|
mitigitate issues with reading vertex indexing limits with 16-bit indices. (#7496, #5720)
|
||||||
|
- Backends: SDL3: Fixed text inputs. Re-enable calling SDL_StartTextInput()/SDL_StopTextInput()
|
||||||
|
as SDL3 no longer enables it by default. (#7452, #6306, #6071, #1953) [@Green-Sky]
|
||||||
|
- Examples: GLFW+WebGPU: Added support for WebGPU-native/Dawn (#7435, #7132) [@eliasdaler, @Zelif]
|
||||||
|
- Examples: GLFW+WebGPU: Renamed example_emscripten_wgpu/ to example_glfw_wgpu/. (#7435, #7132)
|
||||||
|
|
||||||
Docking+Viewports Branch:
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
- Docking: when io.ConfigDockingWithShift is enabled, fixed help tooltip erroneously
|
- Docking: when io.ConfigDockingWithShift is enabled, fixed help tooltip erroneously
|
||||||
|
@@ -104,8 +104,8 @@ OSX + OpenGL2 example. <BR>
|
|||||||
(NB: imgui_impl_osx.mm is currently not as feature complete as other platforms backends.
|
(NB: imgui_impl_osx.mm is currently not as feature complete as other platforms backends.
|
||||||
You may prefer to use the GLFW Or SDL backends, which will also support Windows and Linux.)
|
You may prefer to use the GLFW Or SDL backends, which will also support Windows and Linux.)
|
||||||
|
|
||||||
[example_emscripten_wgpu/](https://github.com/ocornut/imgui/blob/master/examples/example_emscripten_wgpu/) <BR>
|
[example_glfw_wgpu/](https://github.com/ocornut/imgui/blob/master/examples/example_glfw_wgpu/) <BR>
|
||||||
Emcripten + GLFW + WebGPU example. <BR>
|
GLFW + WebGPU example. Supports Emscripten (web) or Dawn (desktop) <BR>
|
||||||
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_wgpu.cpp
|
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_wgpu.cpp
|
||||||
Note that the 'example_glfw_opengl3' and 'example_sdl2_opengl3' examples also supports Emscripten!
|
Note that the 'example_glfw_opengl3' and 'example_sdl2_opengl3' examples also supports Emscripten!
|
||||||
|
|
||||||
|
100
examples/example_glfw_wgpu/CMakeLists.txt
Normal file
100
examples/example_glfw_wgpu/CMakeLists.txt
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
# Building for desktop (WebGPU-native) with Dawn:
|
||||||
|
# 1. git clone https://github.com/google/dawn dawn
|
||||||
|
# 2. cmake -B build -DIMGUI_DAWN_DIR=dawn
|
||||||
|
# 3. cmake --build build
|
||||||
|
# The resulting binary will be found at one of the following locations:
|
||||||
|
# * build/Debug/example_glfw_wgpu[.exe]
|
||||||
|
# * build/example_glfw_wgpu[.exe]
|
||||||
|
|
||||||
|
# Building for Emscripten:
|
||||||
|
# 1. Install Emscripten SDK following the instructions: https://emscripten.org/docs/getting_started/downloads.html
|
||||||
|
# 2. Install Ninja build system
|
||||||
|
# 3. emcmake cmake -G Ninja -B build
|
||||||
|
# 3. cmake --build build
|
||||||
|
# 4. emrun build/index.html
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.10.2)
|
||||||
|
project(imgui_example_glfw_wgpu C CXX)
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17) # Dawn requires C++17
|
||||||
|
|
||||||
|
# Dear ImGui
|
||||||
|
set(IMGUI_DIR ../../)
|
||||||
|
|
||||||
|
# Libraries
|
||||||
|
if(EMSCRIPTEN)
|
||||||
|
set(LIBRARIES glfw)
|
||||||
|
add_compile_options(-sDISABLE_EXCEPTION_CATCHING=1 -DIMGUI_DISABLE_FILE_FUNCTIONS=1)
|
||||||
|
else()
|
||||||
|
# Dawn wgpu desktop
|
||||||
|
set(DAWN_FETCH_DEPENDENCIES ON)
|
||||||
|
set(IMGUI_DAWN_DIR CACHE PATH "Path to Dawn repository")
|
||||||
|
if (NOT IMGUI_DAWN_DIR)
|
||||||
|
message(FATAL_ERROR "Please specify the Dawn repository by setting IMGUI_DAWN_DIR")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(DAWN_FETCH_DEPENDENCIES "Use fetch_dawn_dependencies.py as an alternative to using depot_tools" ON)
|
||||||
|
|
||||||
|
# Dawn builds many things by default - disable things we don't need
|
||||||
|
option(DAWN_BUILD_SAMPLES "Enables building Dawn's samples" OFF)
|
||||||
|
option(TINT_BUILD_CMD_TOOLS "Build the Tint command line tools" OFF)
|
||||||
|
option(TINT_BUILD_DOCS "Build documentation" OFF)
|
||||||
|
option(TINT_BUILD_TESTS "Build tests" OFF)
|
||||||
|
if (NOT APPLE)
|
||||||
|
option(TINT_BUILD_MSL_WRITER "Build the MSL output writer" OFF)
|
||||||
|
endif()
|
||||||
|
if(WIN32)
|
||||||
|
option(TINT_BUILD_SPV_READER "Build the SPIR-V input reader" OFF)
|
||||||
|
option(TINT_BUILD_WGSL_READER "Build the WGSL input reader" ON)
|
||||||
|
option(TINT_BUILD_GLSL_WRITER "Build the GLSL output writer" OFF)
|
||||||
|
option(TINT_BUILD_GLSL_VALIDATOR "Build the GLSL output validator" OFF)
|
||||||
|
option(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" OFF)
|
||||||
|
option(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory("${IMGUI_DAWN_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/dawn" EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
|
set(LIBRARIES webgpu_dawn webgpu_cpp webgpu_glfw glfw)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_executable(example_glfw_wgpu
|
||||||
|
main.cpp
|
||||||
|
# backend files
|
||||||
|
${IMGUI_DIR}/backends/imgui_impl_glfw.cpp
|
||||||
|
${IMGUI_DIR}/backends/imgui_impl_wgpu.cpp
|
||||||
|
# Dear ImGui files
|
||||||
|
${IMGUI_DIR}/imgui.cpp
|
||||||
|
${IMGUI_DIR}/imgui_draw.cpp
|
||||||
|
${IMGUI_DIR}/imgui_demo.cpp
|
||||||
|
${IMGUI_DIR}/imgui_tables.cpp
|
||||||
|
${IMGUI_DIR}/imgui_widgets.cpp
|
||||||
|
)
|
||||||
|
target_include_directories(example_glfw_wgpu PUBLIC
|
||||||
|
${IMGUI_DIR}
|
||||||
|
${IMGUI_DIR}/backends
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(example_glfw_wgpu PUBLIC ${LIBRARIES})
|
||||||
|
|
||||||
|
# Emscripten settings
|
||||||
|
if(EMSCRIPTEN)
|
||||||
|
target_link_options(example_glfw_wgpu PRIVATE
|
||||||
|
"-sUSE_WEBGPU=1"
|
||||||
|
"-sUSE_GLFW=3"
|
||||||
|
"-sWASM=1"
|
||||||
|
"-sALLOW_MEMORY_GROWTH=1"
|
||||||
|
"-sNO_EXIT_RUNTIME=0"
|
||||||
|
"-sASSERTIONS=1"
|
||||||
|
"-sDISABLE_EXCEPTION_CATCHING=1"
|
||||||
|
"-sNO_FILESYSTEM=1"
|
||||||
|
)
|
||||||
|
set_target_properties(example_glfw_wgpu PROPERTIES OUTPUT_NAME "index")
|
||||||
|
# copy our custom index.html to build directory
|
||||||
|
add_custom_command(TARGET example_glfw_wgpu POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/web/index.html" $<TARGET_FILE_DIR:example_glfw_wgpu>
|
||||||
|
)
|
||||||
|
endif()
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
- You may also refer to our [Continuous Integration setup](https://github.com/ocornut/imgui/tree/master/.github/workflows) for Emscripten setup.
|
- You may also refer to our [Continuous Integration setup](https://github.com/ocornut/imgui/tree/master/.github/workflows) for Emscripten setup.
|
||||||
|
|
||||||
- Then build using `make -f Makefile.emscripten` while in the `example_emscripten_wgpu/` directory.
|
- Then build using `make -f Makefile.emscripten` while in the `example_glfw_wgpu/` directory.
|
||||||
|
|
||||||
- Requires recent Emscripten as WGPU is still a work-in-progress API.
|
- Requires recent Emscripten as WGPU is still a work-in-progress API.
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ To run on a local machine:
|
|||||||
- Otherwise, generally you will need a local webserver:
|
- Otherwise, generally you will need a local webserver:
|
||||||
- Quoting [https://emscripten.org/docs/getting_started](https://emscripten.org/docs/getting_started/Tutorial.html#generating-html):<br>
|
- Quoting [https://emscripten.org/docs/getting_started](https://emscripten.org/docs/getting_started/Tutorial.html#generating-html):<br>
|
||||||
_"Unfortunately several browsers (including Chrome, Safari, and Internet Explorer) do not support file:// [XHR](https://emscripten.org/docs/site/glossary.html#term-xhr) requests, and can’t load extra files needed by the HTML (like a .wasm file, or packaged file data as mentioned lower down). For these browsers you’ll need to serve the files using a [local webserver](https://emscripten.org/docs/getting_started/FAQ.html#faq-local-webserver) and then open http://localhost:8000/hello.html."_
|
_"Unfortunately several browsers (including Chrome, Safari, and Internet Explorer) do not support file:// [XHR](https://emscripten.org/docs/site/glossary.html#term-xhr) requests, and can’t load extra files needed by the HTML (like a .wasm file, or packaged file data as mentioned lower down). For these browsers you’ll need to serve the files using a [local webserver](https://emscripten.org/docs/getting_started/FAQ.html#faq-local-webserver) and then open http://localhost:8000/hello.html."_
|
||||||
- Emscripten SDK has a handy `emrun` command: `emrun web/example_emscripten_opengl3.html --browser firefox` which will spawn a temporary local webserver (in Firefox). See https://emscripten.org/docs/compiling/Running-html-files-with-emrun.html for details.
|
- Emscripten SDK has a handy `emrun` command: `emrun web/example_glfw_wgpu.html --browser firefox` which will spawn a temporary local webserver (in Firefox). See https://emscripten.org/docs/compiling/Running-html-files-with-emrun.html for details.
|
||||||
- You may use Python 3 builtin webserver: `python -m http.server -d web` (this is what `make serve` uses).
|
- You may use Python 3 builtin webserver: `python -m http.server -d web` (this is what `make serve` uses).
|
||||||
- You may use Python 2 builtin webserver: `cd web && python -m SimpleHTTPServer`.
|
- You may use Python 2 builtin webserver: `cd web && python -m SimpleHTTPServer`.
|
||||||
- If you are accessing the files over a network, certain browsers, such as Firefox, will restrict Gamepad API access to secure contexts only (e.g. https only).
|
- If you are accessing the files over a network, certain browsers, such as Firefox, will restrict Gamepad API access to secure contexts only (e.g. https only).
|
@@ -1,5 +1,6 @@
|
|||||||
// Dear ImGui: standalone example application for Emscripten, using GLFW + WebGPU
|
// Dear ImGui: standalone example application for using GLFW + WebGPU
|
||||||
// (Emscripten is a C++-to-javascript compiler, used to publish executables for the web. See https://emscripten.org/)
|
// - Emscripten is supported for publishing on web. See https://emscripten.org.
|
||||||
|
// - Dawn is used as a WebGPU implementation on desktop.
|
||||||
|
|
||||||
// Learn about Dear ImGui:
|
// Learn about Dear ImGui:
|
||||||
// - FAQ https://dearimgui.com/faq
|
// - FAQ https://dearimgui.com/faq
|
||||||
@@ -11,11 +12,15 @@
|
|||||||
#include "imgui_impl_glfw.h"
|
#include "imgui_impl_glfw.h"
|
||||||
#include "imgui_impl_wgpu.h"
|
#include "imgui_impl_wgpu.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
#include <emscripten.h>
|
#include <emscripten.h>
|
||||||
#include <emscripten/html5.h>
|
#include <emscripten/html5.h>
|
||||||
#include <emscripten/html5_webgpu.h>
|
#include <emscripten/html5_webgpu.h>
|
||||||
|
#else
|
||||||
|
#include <webgpu/webgpu_glfw.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <webgpu/webgpu.h>
|
#include <webgpu/webgpu.h>
|
||||||
#include <webgpu/webgpu_cpp.h>
|
#include <webgpu/webgpu_cpp.h>
|
||||||
@@ -26,15 +31,16 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Global WebGPU required states
|
// Global WebGPU required states
|
||||||
|
static WGPUInstance wgpu_instance = nullptr;
|
||||||
static WGPUDevice wgpu_device = nullptr;
|
static WGPUDevice wgpu_device = nullptr;
|
||||||
static WGPUSurface wgpu_surface = nullptr;
|
static WGPUSurface wgpu_surface = nullptr;
|
||||||
static WGPUTextureFormat wgpu_preferred_fmt = WGPUTextureFormat_RGBA8Unorm;
|
static WGPUTextureFormat wgpu_preferred_fmt = WGPUTextureFormat_RGBA8Unorm;
|
||||||
static WGPUSwapChain wgpu_swap_chain = nullptr;
|
static WGPUSwapChain wgpu_swap_chain = nullptr;
|
||||||
static int wgpu_swap_chain_width = 0;
|
static int wgpu_swap_chain_width = 1280;
|
||||||
static int wgpu_swap_chain_height = 0;
|
static int wgpu_swap_chain_height = 720;
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
static bool InitWGPU();
|
static bool InitWGPU(GLFWwindow* window);
|
||||||
static void CreateSwapChain(int width, int height);
|
static void CreateSwapChain(int width, int height);
|
||||||
|
|
||||||
static void glfw_error_callback(int error, const char* description)
|
static void glfw_error_callback(int error, const char* description)
|
||||||
@@ -66,18 +72,19 @@ int main(int, char**)
|
|||||||
// Make sure GLFW does not initialize any graphics context.
|
// Make sure GLFW does not initialize any graphics context.
|
||||||
// This needs to be done explicitly later.
|
// This needs to be done explicitly later.
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||||
GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+WebGPU example", nullptr, nullptr);
|
GLFWwindow* window = glfwCreateWindow(wgpu_swap_chain_width, wgpu_swap_chain_height, "Dear ImGui GLFW+WebGPU example", nullptr, nullptr);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// Initialize the WebGPU environment
|
// Initialize the WebGPU environment
|
||||||
if (!InitWGPU())
|
if (!InitWGPU(window))
|
||||||
{
|
{
|
||||||
if (window)
|
if (window)
|
||||||
glfwDestroyWindow(window);
|
glfwDestroyWindow(window);
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
CreateSwapChain(wgpu_swap_chain_width, wgpu_swap_chain_height);
|
||||||
glfwShowWindow(window);
|
glfwShowWindow(window);
|
||||||
|
|
||||||
// Setup Dear ImGui context
|
// Setup Dear ImGui context
|
||||||
@@ -115,7 +122,7 @@ int main(int, char**)
|
|||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
#ifndef IMGUI_DISABLE_FILE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_FILE_FUNCTIONS
|
||||||
//io.Fonts->AddFontFromFileTTF("fonts/segoeui.ttf", 18.0f);
|
//io.Fonts->AddFontFromFileTTF("fonts/segoeui.ttf", 18.0f);
|
||||||
io.Fonts->AddFontFromFileTTF("fonts/DroidSans.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("fonts/DroidSans.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("fonts/Cousine-Regular.ttf", 15.0f);
|
//io.Fonts->AddFontFromFileTTF("fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("fonts/ProggyTiny.ttf", 10.0f);
|
//io.Fonts->AddFontFromFileTTF("fonts/ProggyTiny.ttf", 10.0f);
|
||||||
@@ -148,7 +155,7 @@ int main(int, char**)
|
|||||||
// React to changes in screen size
|
// React to changes in screen size
|
||||||
int width, height;
|
int width, height;
|
||||||
glfwGetFramebufferSize((GLFWwindow*)window, &width, &height);
|
glfwGetFramebufferSize((GLFWwindow*)window, &width, &height);
|
||||||
if (width != wgpu_swap_chain_width && height != wgpu_swap_chain_height)
|
if (width != wgpu_swap_chain_width || height != wgpu_swap_chain_height)
|
||||||
{
|
{
|
||||||
ImGui_ImplWGPU_InvalidateDeviceObjects();
|
ImGui_ImplWGPU_InvalidateDeviceObjects();
|
||||||
CreateSwapChain(width, height);
|
CreateSwapChain(width, height);
|
||||||
@@ -200,6 +207,11 @@ int main(int, char**)
|
|||||||
// Rendering
|
// Rendering
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
|
||||||
|
#ifndef __EMSCRIPTEN__
|
||||||
|
// Tick needs to be called in Dawn to display validation errors
|
||||||
|
wgpuDeviceTick(wgpu_device);
|
||||||
|
#endif
|
||||||
|
|
||||||
WGPURenderPassColorAttachment color_attachments = {};
|
WGPURenderPassColorAttachment color_attachments = {};
|
||||||
color_attachments.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED;
|
color_attachments.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED;
|
||||||
color_attachments.loadOp = WGPULoadOp_Clear;
|
color_attachments.loadOp = WGPULoadOp_Clear;
|
||||||
@@ -223,6 +235,15 @@ int main(int, char**)
|
|||||||
WGPUCommandBuffer cmd_buffer = wgpuCommandEncoderFinish(encoder, &cmd_buffer_desc);
|
WGPUCommandBuffer cmd_buffer = wgpuCommandEncoderFinish(encoder, &cmd_buffer_desc);
|
||||||
WGPUQueue queue = wgpuDeviceGetQueue(wgpu_device);
|
WGPUQueue queue = wgpuDeviceGetQueue(wgpu_device);
|
||||||
wgpuQueueSubmit(queue, 1, &cmd_buffer);
|
wgpuQueueSubmit(queue, 1, &cmd_buffer);
|
||||||
|
|
||||||
|
#ifndef __EMSCRIPTEN__
|
||||||
|
wgpuSwapChainPresent(wgpu_swap_chain);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wgpuTextureViewRelease(color_attachments.view);
|
||||||
|
wgpuRenderPassEncoderRelease(pass);
|
||||||
|
wgpuCommandEncoderRelease(encoder);
|
||||||
|
wgpuCommandBufferRelease(cmd_buffer);
|
||||||
}
|
}
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
EMSCRIPTEN_MAINLOOP_END;
|
EMSCRIPTEN_MAINLOOP_END;
|
||||||
@@ -239,29 +260,72 @@ int main(int, char**)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool InitWGPU()
|
#ifndef __EMSCRIPTEN__
|
||||||
|
static WGPUAdapter RequestAdapter(WGPUInstance instance)
|
||||||
{
|
{
|
||||||
|
auto onAdapterRequestEnded = [](WGPURequestAdapterStatus status, WGPUAdapter adapter, const char* message, void* pUserData)
|
||||||
|
{
|
||||||
|
if (status == WGPURequestAdapterStatus_Success)
|
||||||
|
*(WGPUAdapter*)(pUserData) = adapter;
|
||||||
|
else
|
||||||
|
printf("Could not get WebGPU adapter: %s\n", message);
|
||||||
|
};
|
||||||
|
WGPUAdapter adapter;
|
||||||
|
wgpuInstanceRequestAdapter(instance, nullptr, onAdapterRequestEnded, (void*)&adapter);
|
||||||
|
return adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
static WGPUDevice RequestDevice(WGPUAdapter& adapter)
|
||||||
|
{
|
||||||
|
auto onDeviceRequestEnded = [](WGPURequestDeviceStatus status, WGPUDevice device, const char* message, void* pUserData)
|
||||||
|
{
|
||||||
|
if (status == WGPURequestDeviceStatus_Success)
|
||||||
|
*(WGPUDevice*)(pUserData) = device;
|
||||||
|
else
|
||||||
|
printf("Could not get WebGPU device: %s\n", message);
|
||||||
|
};
|
||||||
|
WGPUDevice device;
|
||||||
|
wgpuAdapterRequestDevice(adapter, nullptr, onDeviceRequestEnded, (void*)&device);
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static bool InitWGPU(GLFWwindow* window)
|
||||||
|
{
|
||||||
|
wgpu::Instance instance = wgpuCreateInstance(nullptr);
|
||||||
|
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
wgpu_device = emscripten_webgpu_get_device();
|
wgpu_device = emscripten_webgpu_get_device();
|
||||||
if (!wgpu_device)
|
if (!wgpu_device)
|
||||||
return false;
|
return false;
|
||||||
|
#else
|
||||||
|
WGPUAdapter adapter = RequestAdapter(instance.Get());
|
||||||
|
if (!adapter)
|
||||||
|
return false;
|
||||||
|
wgpu_device = RequestDevice(adapter);
|
||||||
|
#endif
|
||||||
|
|
||||||
wgpuDeviceSetUncapturedErrorCallback(wgpu_device, wgpu_error_callback, nullptr);
|
#ifdef __EMSCRIPTEN__
|
||||||
|
|
||||||
// Use C++ wrapper due to misbehavior in Emscripten.
|
|
||||||
// Some offset computation for wgpuInstanceCreateSurface in JavaScript
|
|
||||||
// seem to be inline with struct alignments in the C++ structure
|
|
||||||
wgpu::SurfaceDescriptorFromCanvasHTMLSelector html_surface_desc = {};
|
wgpu::SurfaceDescriptorFromCanvasHTMLSelector html_surface_desc = {};
|
||||||
html_surface_desc.selector = "#canvas";
|
html_surface_desc.selector = "#canvas";
|
||||||
|
|
||||||
wgpu::SurfaceDescriptor surface_desc = {};
|
wgpu::SurfaceDescriptor surface_desc = {};
|
||||||
surface_desc.nextInChain = &html_surface_desc;
|
surface_desc.nextInChain = &html_surface_desc;
|
||||||
|
|
||||||
wgpu::Instance instance = wgpuCreateInstance(nullptr);
|
|
||||||
wgpu::Surface surface = instance.CreateSurface(&surface_desc);
|
wgpu::Surface surface = instance.CreateSurface(&surface_desc);
|
||||||
|
|
||||||
wgpu::Adapter adapter = {};
|
wgpu::Adapter adapter = {};
|
||||||
wgpu_preferred_fmt = (WGPUTextureFormat)surface.GetPreferredFormat(adapter);
|
wgpu_preferred_fmt = (WGPUTextureFormat)surface.GetPreferredFormat(adapter);
|
||||||
|
#else
|
||||||
|
wgpu::Surface surface = wgpu::glfw::CreateSurfaceForWindow(instance, window);
|
||||||
|
if (!surface)
|
||||||
|
return false;
|
||||||
|
wgpu_preferred_fmt = WGPUTextureFormat_BGRA8Unorm;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wgpu_instance = instance.MoveToCHandle();
|
||||||
wgpu_surface = surface.MoveToCHandle();
|
wgpu_surface = surface.MoveToCHandle();
|
||||||
|
|
||||||
|
wgpuDeviceSetUncapturedErrorCallback(wgpu_device, wgpu_error_callback, nullptr);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
|
||||||
<title>Dear ImGui Emscripten+WebGPU example</title>
|
<title>Dear ImGui Emscripten+GLFW+WebGPU example</title>
|
||||||
<style>
|
<style>
|
||||||
body { margin: 0; background-color: black }
|
body { margin: 0; background-color: black }
|
||||||
.emscripten {
|
.emscripten {
|
||||||
@@ -63,6 +63,10 @@
|
|||||||
|
|
||||||
// Initialize the graphics adapter
|
// Initialize the graphics adapter
|
||||||
{
|
{
|
||||||
|
if (!navigator.gpu) {
|
||||||
|
throw Error("WebGPU not supported.");
|
||||||
|
}
|
||||||
|
|
||||||
const adapter = await navigator.gpu.requestAdapter();
|
const adapter = await navigator.gpu.requestAdapter();
|
||||||
const device = await adapter.requestDevice();
|
const device = await adapter.requestDevice();
|
||||||
Module.preinitializedWebGPUDevice = device;
|
Module.preinitializedWebGPUDevice = device;
|
@@ -42,7 +42,7 @@ int main(int, char**)
|
|||||||
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
SDL_Renderer* renderer = SDL_CreateRenderer(window, nullptr, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
SDL_Renderer* renderer = SDL_CreateRenderer(window, nullptr, SDL_RENDERER_PRESENTVSYNC);
|
||||||
if (renderer == nullptr)
|
if (renderer == nullptr)
|
||||||
{
|
{
|
||||||
SDL_Log("Error: SDL_CreateRenderer(): %s\n", SDL_GetError());
|
SDL_Log("Error: SDL_CreateRenderer(): %s\n", SDL_GetError());
|
||||||
|
40
imgui.cpp
40
imgui.cpp
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.90.5
|
// dear imgui, v1.90.6 WIP
|
||||||
// (main code and documentation)
|
// (main code and documentation)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@@ -1042,6 +1042,7 @@ CODE
|
|||||||
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0
|
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0
|
||||||
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
|
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
|
||||||
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
||||||
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
// We disable -Wpragmas because GCC doesn't provide a has_warning equivalent and some forks/patches may not follow the warning/version association.
|
// We disable -Wpragmas because GCC doesn't provide a has_warning equivalent and some forks/patches may not follow the warning/version association.
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
@@ -4705,6 +4706,27 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
|
|||||||
io.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false;
|
io.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calling SetupDrawListSharedData() is followed by SetCurrentFont() which sets up the remaining data.
|
||||||
|
static void SetupDrawListSharedData()
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
ImRect virtual_space(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
|
||||||
|
for (ImGuiViewportP* viewport : g.Viewports)
|
||||||
|
virtual_space.Add(viewport->GetMainRect());
|
||||||
|
g.DrawListSharedData.ClipRectFullscreen = virtual_space.ToVec4();
|
||||||
|
g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol;
|
||||||
|
g.DrawListSharedData.SetCircleTessellationMaxError(g.Style.CircleTessellationMaxError);
|
||||||
|
g.DrawListSharedData.InitialFlags = ImDrawListFlags_None;
|
||||||
|
if (g.Style.AntiAliasedLines)
|
||||||
|
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLines;
|
||||||
|
if (g.Style.AntiAliasedLinesUseTex && !(g.IO.Fonts->Flags & ImFontAtlasFlags_NoBakedLines))
|
||||||
|
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLinesUseTex;
|
||||||
|
if (g.Style.AntiAliasedFill)
|
||||||
|
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedFill;
|
||||||
|
if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset)
|
||||||
|
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset;
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui::NewFrame()
|
void ImGui::NewFrame()
|
||||||
{
|
{
|
||||||
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
|
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
|
||||||
@@ -4750,23 +4772,9 @@ void ImGui::NewFrame()
|
|||||||
// Setup current font and draw list shared data
|
// Setup current font and draw list shared data
|
||||||
// FIXME-VIEWPORT: the concept of a single ClipRectFullscreen is not ideal!
|
// FIXME-VIEWPORT: the concept of a single ClipRectFullscreen is not ideal!
|
||||||
g.IO.Fonts->Locked = true;
|
g.IO.Fonts->Locked = true;
|
||||||
|
SetupDrawListSharedData();
|
||||||
SetCurrentFont(GetDefaultFont());
|
SetCurrentFont(GetDefaultFont());
|
||||||
IM_ASSERT(g.Font->IsLoaded());
|
IM_ASSERT(g.Font->IsLoaded());
|
||||||
ImRect virtual_space(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
|
|
||||||
for (ImGuiViewportP* viewport : g.Viewports)
|
|
||||||
virtual_space.Add(viewport->GetMainRect());
|
|
||||||
g.DrawListSharedData.ClipRectFullscreen = virtual_space.ToVec4();
|
|
||||||
g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol;
|
|
||||||
g.DrawListSharedData.SetCircleTessellationMaxError(g.Style.CircleTessellationMaxError);
|
|
||||||
g.DrawListSharedData.InitialFlags = ImDrawListFlags_None;
|
|
||||||
if (g.Style.AntiAliasedLines)
|
|
||||||
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLines;
|
|
||||||
if (g.Style.AntiAliasedLinesUseTex && !(g.Font->ContainerAtlas->Flags & ImFontAtlasFlags_NoBakedLines))
|
|
||||||
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLinesUseTex;
|
|
||||||
if (g.Style.AntiAliasedFill)
|
|
||||||
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedFill;
|
|
||||||
if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset)
|
|
||||||
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset;
|
|
||||||
|
|
||||||
// Mark rendering data as invalid to prevent user who may have a handle on it to use it.
|
// Mark rendering data as invalid to prevent user who may have a handle on it to use it.
|
||||||
for (ImGuiViewportP* viewport : g.Viewports)
|
for (ImGuiViewportP* viewport : g.Viewports)
|
||||||
|
7
imgui.h
7
imgui.h
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.90.5
|
// dear imgui, v1.90.6 WIP
|
||||||
// (headers)
|
// (headers)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
|
|
||||||
// Library Version
|
// Library Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||||
#define IMGUI_VERSION "1.90.5"
|
#define IMGUI_VERSION "1.90.6 WIP"
|
||||||
#define IMGUI_VERSION_NUM 19050
|
#define IMGUI_VERSION_NUM 19051
|
||||||
#define IMGUI_HAS_TABLE
|
#define IMGUI_HAS_TABLE
|
||||||
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
|
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
|
||||||
#define IMGUI_HAS_DOCK // Docking WIP branch
|
#define IMGUI_HAS_DOCK // Docking WIP branch
|
||||||
@@ -132,6 +132,7 @@ Index of this file:
|
|||||||
#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe
|
#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe
|
||||||
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
|
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
|
||||||
#pragma clang diagnostic ignored "-Wreserved-identifier" // warning: identifier '_Xxx' is reserved because it starts with '_' followed by a capital letter
|
#pragma clang diagnostic ignored "-Wreserved-identifier" // warning: identifier '_Xxx' is reserved because it starts with '_' followed by a capital letter
|
||||||
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.90.5
|
// dear imgui, v1.90.6 WIP
|
||||||
// (demo code)
|
// (demo code)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@@ -132,6 +132,7 @@ Index of this file:
|
|||||||
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
|
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
|
||||||
#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning: macro name is a reserved identifier
|
#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning: macro name is a reserved identifier
|
||||||
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
||||||
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size
|
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.90.5
|
// dear imgui, v1.90.6 WIP
|
||||||
// (drawing and font code)
|
// (drawing and font code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -65,6 +65,7 @@ Index of this file:
|
|||||||
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
|
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
|
||||||
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
||||||
#pragma clang diagnostic ignored "-Wreserved-identifier" // warning: identifier '_Xxx' is reserved because it starts with '_' followed by a capital letter
|
#pragma clang diagnostic ignored "-Wreserved-identifier" // warning: identifier '_Xxx' is reserved because it starts with '_' followed by a capital letter
|
||||||
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
|
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
|
||||||
@@ -2989,8 +2990,8 @@ static bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|||||||
int unscaled_ascent, unscaled_descent, unscaled_line_gap;
|
int unscaled_ascent, unscaled_descent, unscaled_line_gap;
|
||||||
stbtt_GetFontVMetrics(&src_tmp.FontInfo, &unscaled_ascent, &unscaled_descent, &unscaled_line_gap);
|
stbtt_GetFontVMetrics(&src_tmp.FontInfo, &unscaled_ascent, &unscaled_descent, &unscaled_line_gap);
|
||||||
|
|
||||||
const float ascent = ImTrunc(unscaled_ascent * font_scale + ((unscaled_ascent > 0.0f) ? +1 : -1));
|
const float ascent = ImCeil(unscaled_ascent * font_scale);
|
||||||
const float descent = ImTrunc(unscaled_descent * font_scale + ((unscaled_descent > 0.0f) ? +1 : -1));
|
const float descent = ImFloor(unscaled_descent * font_scale);
|
||||||
ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent);
|
ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent);
|
||||||
const float font_off_x = cfg.GlyphOffset.x;
|
const float font_off_x = cfg.GlyphOffset.x;
|
||||||
const float font_off_y = cfg.GlyphOffset.y + IM_ROUND(dst_font->Ascent);
|
const float font_off_y = cfg.GlyphOffset.y + IM_ROUND(dst_font->Ascent);
|
||||||
@@ -4085,6 +4086,8 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, Im
|
|||||||
{
|
{
|
||||||
x = start_x;
|
x = start_x;
|
||||||
y += line_height;
|
y += line_height;
|
||||||
|
if (y > clip_rect.w)
|
||||||
|
break; // break out of main loop
|
||||||
word_wrap_eol = NULL;
|
word_wrap_eol = NULL;
|
||||||
s = CalcWordWrapNextLineStartA(s, text_end); // Wrapping skips upcoming blanks
|
s = CalcWordWrapNextLineStartA(s, text_end); // Wrapping skips upcoming blanks
|
||||||
continue;
|
continue;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.90.5
|
// dear imgui, v1.90.6 WIP
|
||||||
// (internal structures/api)
|
// (internal structures/api)
|
||||||
|
|
||||||
// You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility.
|
// You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility.
|
||||||
@@ -88,6 +88,7 @@ Index of this file:
|
|||||||
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
||||||
#pragma clang diagnostic ignored "-Wmissing-noreturn" // warning: function 'xxx' could be declared with attribute 'noreturn'
|
#pragma clang diagnostic ignored "-Wmissing-noreturn" // warning: function 'xxx' could be declared with attribute 'noreturn'
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
|
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
|
||||||
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.90.5
|
// dear imgui, v1.90.6 WIP
|
||||||
// (tables and columns code)
|
// (tables and columns code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -228,6 +228,7 @@ Index of this file:
|
|||||||
#pragma clang diagnostic ignored "-Wenum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_')
|
#pragma clang diagnostic ignored "-Wenum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_')
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
|
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
|
||||||
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
||||||
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
|
#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.90.5
|
// dear imgui, v1.90.6 WIP
|
||||||
// (widgets code)
|
// (widgets code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -75,6 +75,7 @@ Index of this file:
|
|||||||
#pragma clang diagnostic ignored "-Wenum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_')
|
#pragma clang diagnostic ignored "-Wenum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_')
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
|
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
|
||||||
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
||||||
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
|
#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
|
||||||
|
Reference in New Issue
Block a user