mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-13 16:29:54 +02:00
Compare commits
331 Commits
Author | SHA1 | Date | |
---|---|---|---|
58b3e02b95 | |||
d37d25470a | |||
f694244dec | |||
bdbb2b21f5 | |||
83efdcec8d | |||
5a437f198c | |||
fc42528f13 | |||
fc41839cab | |||
fb257eef3e | |||
d9bca0d853 | |||
d19297e2fa | |||
47fab0e166 | |||
9cff4d6e5e | |||
05a49f0413 | |||
8cbb693f47 | |||
6e1f8be07b | |||
0a23582718 | |||
0e89041997 | |||
5f4dfad5b7 | |||
6c1a73774d | |||
4d4e3b97f4 | |||
b887259974 | |||
f6da5000bf | |||
5363af7f47 | |||
051ce0765e | |||
2eda3585e7 | |||
7a22767483 | |||
3fe6ae9732 | |||
0a3df4b2ce | |||
15c6abe4be | |||
8bcac7d95c | |||
e499497ec5 | |||
2478dbfdb7 | |||
6c00d1916e | |||
aa34681652 | |||
9ad4c5da7e | |||
f6d6880a61 | |||
2ebe08be40 | |||
4f7bf7e96a | |||
e2eb0b4bc4 | |||
02c2d18aa3 | |||
52334ad8df | |||
f56962cb9a | |||
ff5299e0e0 | |||
4b3c5ff5f1 | |||
f03c00bc89 | |||
97a8dc6514 | |||
ae1e3619f6 | |||
4ee7aa72e9 | |||
1eb71fc72b | |||
00c515f51a | |||
f9630e60c5 | |||
1db78b8ca7 | |||
32c33c6659 | |||
5e2329b98e | |||
e254167afd | |||
d581939387 | |||
22d7f26e06 | |||
0dd02dd90d | |||
2b10e06555 | |||
dc66f83db8 | |||
854fc08194 | |||
061650bd2a | |||
f70204f2f4 | |||
e01fb5462d | |||
a610f1da52 | |||
3831d50ab9 | |||
0f7105e156 | |||
78ff147181 | |||
9d444062f9 | |||
10fdc03a46 | |||
3a800f2dc9 | |||
43bd80a40d | |||
6fdde67be2 | |||
0e74103659 | |||
f9c26d23de | |||
e42c1e1668 | |||
697f15e339 | |||
e4a59d0025 | |||
f656e7775e | |||
6cbed03d4a | |||
03b7170dac | |||
7ff13f4ee1 | |||
b521cd357d | |||
6d9a54a904 | |||
8342e5b91a | |||
945a509773 | |||
b5cad20d79 | |||
abaf0256b8 | |||
bf6d1ba3d1 | |||
1742ca45c5 | |||
a8092085b1 | |||
f60518b430 | |||
bdce833636 | |||
26d177bc03 | |||
1615e9ea2a | |||
bbe0409942 | |||
aeb57952d6 | |||
0cb1c633ff | |||
b205ab01f2 | |||
51e2e9b239 | |||
51a02b319c | |||
ca63349eb4 | |||
a899c1e570 | |||
ecbedc8c26 | |||
4e90906b04 | |||
93efa5415f | |||
9efaf2828b | |||
ca30ef4269 | |||
7e232092a6 | |||
8f40020ca6 | |||
be05e12e21 | |||
b23dcab6e1 | |||
be436e2b0b | |||
03852470de | |||
25eee91542 | |||
b138f8cbcd | |||
7c441e37fa | |||
6e8e2c0fa9 | |||
57dc34f4e8 | |||
011d475532 | |||
037126ee0e | |||
d003674f2c | |||
a337e219b6 | |||
28f1d60de1 | |||
09b2310237 | |||
4c13807b7d | |||
3929255b77 | |||
916487a653 | |||
bff2d5d5e2 | |||
c9182424a8 | |||
c9ffa62e1f | |||
bcd752cfcc | |||
792a8631aa | |||
8fee5a4349 | |||
5006639526 | |||
5ebd4e4c6e | |||
a4420be1a2 | |||
9f979c33f4 | |||
d62a413476 | |||
6bf5aed325 | |||
c863c1f6a1 | |||
0b2d35f63f | |||
4e56de757c | |||
f002a11898 | |||
4d0c88e9e6 | |||
9b323a7ebf | |||
3c238ecae3 | |||
d5b5a81946 | |||
24e9a6e92c | |||
ec0e953cca | |||
75d540d336 | |||
be9f1e8f00 | |||
23c1ff4907 | |||
048b73dfaa | |||
7dbae8a198 | |||
6ffee0e75e | |||
eedc8f993f | |||
4de32cc87e | |||
714fe29d1a | |||
53278be61f | |||
9994f5bcbe | |||
3bbc27ebd9 | |||
5fc427a49e | |||
9d6b2b096b | |||
6892b81578 | |||
c21fdabb43 | |||
a41f0b2df4 | |||
c7bdec7e18 | |||
67e4cd5cc6 | |||
8c4dcbfa45 | |||
23eabd5991 | |||
58411033e2 | |||
1c73a0c17e | |||
cba84df7b5 | |||
aeb6481499 | |||
fc10ba8d24 | |||
378035c6ff | |||
bf746c4215 | |||
927472f5ff | |||
3b271b1847 | |||
8aad3482a4 | |||
323412dd23 | |||
73fa6509a5 | |||
f1f321d3f6 | |||
ee3373d067 | |||
ccb2a947a2 | |||
1425bec7a4 | |||
a6c3be4bda | |||
892dfb1dea | |||
a2f3dcfc97 | |||
893056a209 | |||
eb5223276c | |||
0dad3f436b | |||
c262276988 | |||
f0f5301612 | |||
688cf868ea | |||
d5efe16157 | |||
293f74e996 | |||
664f9e76b9 | |||
e100523917 | |||
ca858c084b | |||
52deb415e0 | |||
25849234f6 | |||
97691643b7 | |||
44cd8e39da | |||
80b3ab7d3e | |||
f47a0a85cc | |||
eab03f4467 | |||
a45e3b5bb3 | |||
f7468d05fe | |||
38d22bc47d | |||
accb0261b8 | |||
656c515bad | |||
9d02ed51e3 | |||
74e01e62ce | |||
098591fe4c | |||
b48dc067ae | |||
3b014d0c31 | |||
3f986e72d9 | |||
7d5a17e5e4 | |||
1c951dca97 | |||
57623c15dd | |||
45405f0dc9 | |||
404dc0367e | |||
e7e88ed413 | |||
561e7dd490 | |||
3dcf323c35 | |||
b05f6f6f50 | |||
3cf519c9cb | |||
cc288e073c | |||
c077dd4872 | |||
0537ac005f | |||
b59ec7b9b7 | |||
3f99890f40 | |||
f8d3d8d7f5 | |||
bfcdaeb610 | |||
62f75c7fb1 | |||
45a0db5979 | |||
c8418015c2 | |||
bcdb89ab07 | |||
cb538fadfe | |||
c4ff1b3578 | |||
3fb5cf3541 | |||
c4b0bf718a | |||
a856c670c1 | |||
a33cedda14 | |||
7abd41bd5f | |||
9fce278918 | |||
88bf056a9f | |||
7d2cfa6ff1 | |||
2e756d5b47 | |||
62143dff64 | |||
6cf4743f17 | |||
f624455d7b | |||
9bd7846f07 | |||
6a0d0dab5a | |||
27079e68c2 | |||
4cfaf7d89c | |||
3548fb8013 | |||
1b1e539288 | |||
5ef7445d92 | |||
494d804735 | |||
85ad8e0e2e | |||
9183e7c426 | |||
ecb9b1e2eb | |||
7a26a49f08 | |||
d057550209 | |||
824e8c53b4 | |||
baae057a03 | |||
51853292cc | |||
1820aaf444 | |||
26f14e056c | |||
dcd03f62a7 | |||
34cf00566f | |||
835b50b773 | |||
363d33f64e | |||
cbd5a21fb0 | |||
29d9394a41 | |||
f0348ddffc | |||
0f86116a69 | |||
4b44f25c9a | |||
f1ba217a92 | |||
c37f21788f | |||
b443bc0a64 | |||
4abc2a82e0 | |||
493795cdd1 | |||
047dc16af5 | |||
44336950e9 | |||
6c16ba6490 | |||
e28d20c3e2 | |||
61c7f0194e | |||
1f3feb481e | |||
ea79992d9a | |||
130b44994e | |||
e6a286b3a5 | |||
a35f42f123 | |||
3d07c7cbe4 | |||
7a9d32acee | |||
e461e7bc7a | |||
71d20abbc3 | |||
d52c6316c8 | |||
e66799f79a | |||
3436132d4b | |||
d23f1b1409 | |||
54c49b5fb1 | |||
e16564e67a | |||
58c9f8a194 | |||
da29d77253 | |||
caf119a982 | |||
2a3517a399 | |||
a89f05a10e | |||
401e05147c | |||
82711251b6 | |||
1dd322c6fb | |||
4b95e7c2f3 | |||
eb3e271c24 | |||
41e2d4b5ae | |||
f563e1a504 | |||
dd41df3e98 | |||
516c3dee80 | |||
cc4d76cc23 | |||
70fe409338 | |||
342751c89e | |||
0e37eaff8a | |||
ae2c9f7101 | |||
e9b92d1cef | |||
b82e99c032 | |||
2645a2516f | |||
af3080b81b | |||
5286ecb8a7 |
30
.gitattributes
vendored
Normal file
30
.gitattributes
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
* text=auto
|
||||||
|
|
||||||
|
*.c text
|
||||||
|
*.cpp text
|
||||||
|
*.h text
|
||||||
|
*.m text
|
||||||
|
*.mm text
|
||||||
|
*.md text
|
||||||
|
*.txt text
|
||||||
|
*.html text
|
||||||
|
*.bat text
|
||||||
|
*.frag text
|
||||||
|
*.vert text
|
||||||
|
*.mkb text
|
||||||
|
*.icf text
|
||||||
|
|
||||||
|
*.sln text eol=crlf
|
||||||
|
*.vcxproj text eol=crlf
|
||||||
|
*.vcxproj.filters text eol=crlf
|
||||||
|
*.natvis text eol=crlf
|
||||||
|
|
||||||
|
Makefile text eol=lf
|
||||||
|
*.sh text eol=lf
|
||||||
|
*.pbxproj text eol=lf
|
||||||
|
*.storyboard text eol=lf
|
||||||
|
*.plist text eol=lf
|
||||||
|
|
||||||
|
*.png binary
|
||||||
|
*.ttf binary
|
||||||
|
*.lib binary
|
@ -1,16 +1,16 @@
|
|||||||
(Click "Preview" to turn any http URL into a clickable link)
|
(Click "Preview" above ^ to turn URL into clickable links)
|
||||||
|
|
||||||
1. PLEASE CAREFULLY READ:
|
1. PLEASE CAREFULLY READ: [FAQ](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md)
|
||||||
https://github.com/ocornut/imgui/issues/2261
|
|
||||||
|
|
||||||
2. IF YOU ARE HAVING AN ISSUE COMPILING/LINKING/RUNNING/LOADING FONTS, please post on the "Getting Started" Discourse forum:
|
2. PLEASE CAREFULLY READ: [Issue Submitting Guidelines](https://github.com/ocornut/imgui/issues/2261)
|
||||||
https://discourse.dearimgui.org
|
|
||||||
|
|
||||||
3. PLEASE MAKE SURE that you have: read the FAQ in imgui.cpp; explored the contents of `ShowDemoWindow()` including the Examples menu; searched among Issues; used your IDE to search for keywords in all sources and text files; and read the link provided in (1).
|
3. FOR FIRST-TIME USERS ISSUES COMPILING/LINKING/RUNNING/LOADING FONTS, please use the [Discord server](http://discord.dearimgui.org).
|
||||||
|
|
||||||
4. Be mindful that messages are being sent to the e-mail box of "Watching" users. Try to proof-read your messages before sending them. Edits are not seen by those users.
|
4. PLEASE MAKE SURE that you have: read the FAQ; explored the contents of `ShowDemoWindow()` including the Examples menu; searched among Issues; used your IDE to search for keywords in all sources and text files; and read the link provided in (1) (2).
|
||||||
|
|
||||||
5. Delete points 1-5 and PLEASE FILL THE TEMPLATE BELOW before submitting your issue.
|
5. Be mindful that messages are being sent to the e-mail box of "Watching" users. Try to proof-read your messages before sending them. Edits are not seen by those users.
|
||||||
|
|
||||||
|
6. Delete points 1-6 and PLEASE FILL THE TEMPLATE BELOW before submitting your issue.
|
||||||
|
|
||||||
Thank you!
|
Thank you!
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ XXX _(you can drag files here)_
|
|||||||
|
|
||||||
**Standalone, minimal, complete and verifiable example:** _(see https://github.com/ocornut/imgui/issues/2261)_
|
**Standalone, minimal, complete and verifiable example:** _(see https://github.com/ocornut/imgui/issues/2261)_
|
||||||
```
|
```
|
||||||
// Please do not forget this!
|
// Here's some code anyone can copy and paste to reproduce your issue
|
||||||
ImGui::Begin("Example Bug");
|
ImGui::Begin("Example Bug");
|
||||||
MoreCodeToExplainMyIssue();
|
MoreCodeToExplainMyIssue();
|
||||||
ImGui::End();
|
ImGui::End();
|
322
.github/workflows/build.yml
vendored
Normal file
322
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,322 @@
|
|||||||
|
name: build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push: {}
|
||||||
|
pull_request: {}
|
||||||
|
schedule:
|
||||||
|
- cron: '0 9 * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Windows:
|
||||||
|
runs-on: windows-2019
|
||||||
|
env:
|
||||||
|
VS_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\
|
||||||
|
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
|
||||||
|
# Until gh-actions allow us to use env variables inside other env variables (because we need %GITHUB_WORKSPACE%) we have to use relative path to imgui/examples/example_name directory.
|
||||||
|
SDL2_DIR: ..\..\SDL2-devel-2.0.10-VC\SDL2-2.0.10\
|
||||||
|
VULKAN_SDK: ..\..\vulkan-sdk-1.1.121.2\
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
Invoke-WebRequest -Uri "https://www.libsdl.org/release/SDL2-devel-2.0.10-VC.zip" -OutFile "SDL2-devel-2.0.10-VC.zip"
|
||||||
|
Expand-Archive -Path SDL2-devel-2.0.10-VC.zip
|
||||||
|
Invoke-WebRequest -Uri "https://github.com/ocornut/imgui/files/3789205/vulkan-sdk-1.1.121.2.zip" -OutFile vulkan-sdk-1.1.121.2.zip
|
||||||
|
Expand-Archive -Path vulkan-sdk-1.1.121.2.zip
|
||||||
|
|
||||||
|
- name: Fix Projects
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
# WARNING: This will need updating if toolset/sdk change in project files!
|
||||||
|
gci -recurse -filter "*.vcxproj" | ForEach-Object {
|
||||||
|
# Fix SDK and toolset for most samples.
|
||||||
|
(Get-Content $_.FullName) -Replace "<PlatformToolset>v110</PlatformToolset>","<PlatformToolset>v142</PlatformToolset>" | Set-Content -Path $_.FullName
|
||||||
|
(Get-Content $_.FullName) -Replace "<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>","<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>" | Set-Content -Path $_.FullName
|
||||||
|
# Fix SDK and toolset for samples that require newer SDK/toolset. At the moment it is only dx12.
|
||||||
|
(Get-Content $_.FullName) -Replace "<PlatformToolset>v140</PlatformToolset>","<PlatformToolset>v142</PlatformToolset>" | Set-Content -Path $_.FullName
|
||||||
|
(Get-Content $_.FullName) -Replace "<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>","<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>" | Set-Content -Path $_.FullName
|
||||||
|
}
|
||||||
|
|
||||||
|
# Not using matrix here because it would inflate job count too much. Check out and setup is done for every job and that makes build times way too long.
|
||||||
|
- name: Build example_null (extra warnings, mingw 64-bit)
|
||||||
|
run: mingw32-make -C examples/example_null EXTRA_WARNINGS=1
|
||||||
|
|
||||||
|
- name: Build example_null (extra warnings, msvc 64-bit)
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cd examples\example_null
|
||||||
|
"%VS_PATH%\VC\Auxiliary\Build\vcvarsall.bat" x64 && .\build_win32.bat /W4
|
||||||
|
|
||||||
|
- name: Build example_null (single file build)
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
|
||||||
|
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
|
||||||
|
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
|
||||||
|
g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp
|
||||||
|
|
||||||
|
- name: Build Win32 example_glfw_opengl2
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
|
||||||
|
- name: Build Win32 example_glfw_opengl3
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build Win32 example_glfw_vulkan
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build Win32 example_sdl_vulkan
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build Win32 example_sdl_opengl2
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build Win32 example_sdl_opengl3
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
|
||||||
|
- name: Build Win32 example_sdl_directx11
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_directx11/example_sdl_directx11.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build Win32 example_win32_directx9
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx9/example_win32_directx9.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
|
||||||
|
- name: Build Win32 example_win32_directx10
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx10/example_win32_directx10.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
|
||||||
|
- name: Build Win32 example_win32_directx11
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx11/example_win32_directx11.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build x64 example_glfw_opengl2
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build x64 example_glfw_opengl3
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
|
||||||
|
- name: Build x64 example_glfw_vulkan
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
|
||||||
|
- name: Build x64 example_sdl_vulkan
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build x64 example_sdl_opengl2
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build x64 example_sdl_opengl3
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build x64 example_sdl_directx11
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_directx11/example_sdl_directx11.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
|
||||||
|
- name: Build x64 example_win32_directx9
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx9/example_win32_directx9.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build x64 example_win32_directx10
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx10/example_win32_directx10.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build x64 example_win32_directx11
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx11/example_win32_directx11.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build x64 example_win32_directx12
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx12/example_win32_directx12.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
|
||||||
|
Linux:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libglfw3-dev libsdl2-dev gcc-multilib g++-multilib
|
||||||
|
|
||||||
|
- name: Build example_null (extra warnings, gcc 32-bit)
|
||||||
|
run: |
|
||||||
|
make -C examples/example_null clean
|
||||||
|
CXXFLAGS="$CXXFLAGS -m32" make -C examples/example_null EXTRA_WARNINGS=1
|
||||||
|
|
||||||
|
- name: Build example_null (extra warnings, gcc 64-bit)
|
||||||
|
run: |
|
||||||
|
make -C examples/example_null clean
|
||||||
|
CXXFLAGS="$CXXFLAGS -m64" make -C examples/example_null EXTRA_WARNINGS=1
|
||||||
|
|
||||||
|
- name: Build example_null (extra warnings, clang 32-bit)
|
||||||
|
run: |
|
||||||
|
make -C examples/example_null clean
|
||||||
|
CXXFLAGS="$CXXFLAGS -m32" CXX=clang++ make -C examples/example_null EXTRA_WARNINGS=1
|
||||||
|
|
||||||
|
- name: Build example_null (extra warnings, clang 64-bit)
|
||||||
|
run: |
|
||||||
|
make -C examples/example_null clean
|
||||||
|
CXXFLAGS="$CXXFLAGS -m64" CXX=clang++ make -C examples/example_null EXTRA_WARNINGS=1
|
||||||
|
|
||||||
|
- name: Build example_null (single file build)
|
||||||
|
run: |
|
||||||
|
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
|
||||||
|
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
|
||||||
|
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
|
||||||
|
g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
|
||||||
|
|
||||||
|
- name: Build example_glfw_opengl2
|
||||||
|
run: make -C examples/example_glfw_opengl2
|
||||||
|
|
||||||
|
- name: Build example_glfw_opengl3
|
||||||
|
run: make -C examples/example_glfw_opengl3
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build example_sdl_opengl2
|
||||||
|
run: make -C examples/example_sdl_opengl2
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build example_sdl_opengl3
|
||||||
|
run: make -C examples/example_sdl_opengl3
|
||||||
|
|
||||||
|
MacOS:
|
||||||
|
runs-on: macOS-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: |
|
||||||
|
brew install glfw3
|
||||||
|
brew install sdl2
|
||||||
|
|
||||||
|
- name: Build example_null (extra warnings, clang 64-bit)
|
||||||
|
run: make -C examples/example_null EXTRA_WARNINGS=1
|
||||||
|
|
||||||
|
- name: Build example_null (single file build)
|
||||||
|
run: |
|
||||||
|
echo '#define IMGUI_IMPLEMENTATION' >> example_single_file.cpp
|
||||||
|
echo '#include "misc/single_file/imgui_single_file.h"' >> example_single_file.cpp
|
||||||
|
echo '#include "examples/example_null/main.cpp"' >> example_single_file.cpp
|
||||||
|
clang++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp
|
||||||
|
|
||||||
|
- name: Build example_glfw_opengl2
|
||||||
|
run: make -C examples/example_glfw_opengl2
|
||||||
|
|
||||||
|
- name: Build example_glfw_opengl3
|
||||||
|
run: make -C examples/example_glfw_opengl3
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build example_glfw_metal
|
||||||
|
run: make -C examples/example_glfw_metal
|
||||||
|
|
||||||
|
- name: Build example_sdl_opengl2
|
||||||
|
run: make -C examples/example_sdl_opengl2
|
||||||
|
if: github.event_name == 'schedule'
|
||||||
|
|
||||||
|
- name: Build example_sdl_opengl3
|
||||||
|
run: make -C examples/example_sdl_opengl3
|
||||||
|
|
||||||
|
- name: Build example_apple_metal
|
||||||
|
run: xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_macos
|
||||||
|
|
||||||
|
- name: Build example_apple_opengl2
|
||||||
|
run: xcodebuild -project examples/example_apple_opengl2/example_apple_opengl2.xcodeproj -target example_osx_opengl2
|
||||||
|
|
||||||
|
iOS:
|
||||||
|
runs-on: macOS-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Build example_apple_metal
|
||||||
|
run: |
|
||||||
|
# Code signing is required, but we disable it because it is irrelevant for CI builds.
|
||||||
|
xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_ios CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
|
||||||
|
|
||||||
|
Emscripten:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: |
|
||||||
|
wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
|
||||||
|
tar -xvf master.tar.gz
|
||||||
|
emsdk-master/emsdk update
|
||||||
|
emsdk-master/emsdk install latest-fastcomp
|
||||||
|
emsdk-master/emsdk activate latest-fastcomp
|
||||||
|
|
||||||
|
- name: Build example_emscripten
|
||||||
|
run: |
|
||||||
|
source emsdk-master/emsdk_env.sh
|
||||||
|
make -C examples/example_emscripten
|
||||||
|
|
||||||
|
Static-Analysis:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
env:
|
||||||
|
PVS_STUDIO_LICENSE: ${{ secrets.PVS_STUDIO_LICENSE }}
|
||||||
|
run: |
|
||||||
|
if [[ "$PVS_STUDIO_LICENSE" != "" ]];
|
||||||
|
then
|
||||||
|
echo "$PVS_STUDIO_LICENSE" > pvs-studio.lic
|
||||||
|
wget -q https://files.viva64.com/etc/pubkey.txt
|
||||||
|
sudo apt-key add pubkey.txt
|
||||||
|
sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.viva64.com/etc/viva64.list
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y pvs-studio
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: PVS-Studio static analysis
|
||||||
|
run: |
|
||||||
|
if [[ ! -f pvs-studio.lic ]];
|
||||||
|
then
|
||||||
|
echo "PVS Studio license is missing. No analysis will be performed."
|
||||||
|
echo "If you have a PVS Studio license please create a project secret named PVS_STUDIO_LICENSE with your license."
|
||||||
|
echo "You may use a free license. More information at https://www.viva64.com/en/b/0457/"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
cd examples/example_null
|
||||||
|
pvs-studio-analyzer trace -- make EXTRA_WARNINGS=1
|
||||||
|
pvs-studio-analyzer analyze -e ../../imstb_rectpack.h -e ../../imstb_textedit.h -e ../../imstb_truetype.h -l ../../pvs-studio.lic -o pvs-studio.log
|
||||||
|
plog-converter -a 'GA:1,2;OP:1' -t errorfile -w pvs-studio.log
|
34
.travis.yml
34
.travis.yml
@ -1,34 +0,0 @@
|
|||||||
language: cpp
|
|
||||||
sudo: required
|
|
||||||
dist: trusty
|
|
||||||
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
- osx
|
|
||||||
|
|
||||||
compiler:
|
|
||||||
- gcc
|
|
||||||
- clang
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- if [ $TRAVIS_OS_NAME == linux ]; then
|
|
||||||
sudo apt-get update -qq;
|
|
||||||
sudo apt-get install -y --no-install-recommends libxrandr-dev libxi-dev libxxf86vm-dev libsdl2-dev;
|
|
||||||
wget https://github.com/glfw/glfw/releases/download/3.2.1/glfw-3.2.1.zip;
|
|
||||||
unzip glfw-3.2.1.zip && cd glfw-3.2.1;
|
|
||||||
cmake -DBUILD_SHARED_LIBS=true -DGLFW_BUILD_EXAMPLES=false -DGLFW_BUILD_TESTS=false -DGLFW_BUILD_DOCS=false .;
|
|
||||||
sudo make -j $CPU_NUM install && cd ..;
|
|
||||||
fi
|
|
||||||
- if [ $TRAVIS_OS_NAME == osx ]; then
|
|
||||||
brew update;
|
|
||||||
brew install glfw3;
|
|
||||||
brew install sdl2;
|
|
||||||
fi
|
|
||||||
|
|
||||||
script:
|
|
||||||
- make -C examples/example_glfw_opengl2
|
|
||||||
- make -C examples/example_glfw_opengl3
|
|
||||||
- make -C examples/example_sdl_opengl3
|
|
||||||
- if [ $TRAVIS_OS_NAME == osx ]; then
|
|
||||||
xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_macos;
|
|
||||||
fi
|
|
@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2014-2019 Omar Cornut
|
Copyright (c) 2014-2020 Omar Cornut
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -8,6 +8,7 @@ Changes to the examples/bindings are included within the individual .cpp files i
|
|||||||
RELEASE NOTES: https://github.com/ocornut/imgui/releases
|
RELEASE NOTES: https://github.com/ocornut/imgui/releases
|
||||||
REPORT ISSUES, ASK QUESTIONS: https://github.com/ocornut/imgui/issues
|
REPORT ISSUES, ASK QUESTIONS: https://github.com/ocornut/imgui/issues
|
||||||
COMMITS HISTORY: https://github.com/ocornut/imgui/commits/master
|
COMMITS HISTORY: https://github.com/ocornut/imgui/commits/master
|
||||||
|
FAQ https://www.dearimgui.org/faq/
|
||||||
|
|
||||||
WHEN TO UPDATE?
|
WHEN TO UPDATE?
|
||||||
|
|
||||||
@ -29,11 +30,354 @@ HOW TO UPDATE?
|
|||||||
- Please report any issue!
|
- Please report any issue!
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.75 (Released 2020-02-10)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.75
|
||||||
|
|
||||||
|
Breaking Changes:
|
||||||
|
|
||||||
|
- Removed redirecting functions/enums names that were marked obsolete in 1.53 (December 2017):
|
||||||
|
- ShowTestWindow() -> use ShowDemoWindow()
|
||||||
|
- IsRootWindowFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootWindow)
|
||||||
|
- IsRootWindowOrAnyChildFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows)
|
||||||
|
- SetNextWindowContentWidth(w) -> use SetNextWindowContentSize(ImVec2(w, 0.0f)
|
||||||
|
- GetItemsLineHeightWithSpacing() -> use GetFrameHeightWithSpacing()
|
||||||
|
- ImGuiCol_ChildWindowBg -> use ImGuiCol_ChildBg
|
||||||
|
- ImGuiStyleVar_ChildWindowRounding -> use ImGuiStyleVar_ChildRounding
|
||||||
|
- ImGuiTreeNodeFlags_AllowOverlapMode -> use ImGuiTreeNodeFlags_AllowItemOverlap
|
||||||
|
- IMGUI_DISABLE_TEST_WINDOWS -> use IMGUI_DISABLE_DEMO_WINDOWS
|
||||||
|
If you were still using the old names, while you are cleaning up, considering enabling
|
||||||
|
IMGUI_DISABLE_OBSOLETE_FUNCTIONS in imconfig.h even temporarily to have a pass at finding
|
||||||
|
and removing up old API calls, if any remaining.
|
||||||
|
- Removed implicit default parameter to IsMouseDragging(int button = 0) to be consistent
|
||||||
|
with other mouse functions (none of the other functions have it).
|
||||||
|
- Obsoleted calling ImDrawList::PrimReserve() with a negative count (which was vaguely
|
||||||
|
documented and rarely if ever used). Instead we added an explicit PrimUnreserve() API
|
||||||
|
which can be implemented faster. Also clarified pre-existing constraints which weren't
|
||||||
|
documented (can only unreserve from the last reserve call). If you suspect you ever
|
||||||
|
used that feature before (very unlikely, but grep for call to PrimReserve in your code),
|
||||||
|
you can #define IMGUI_DEBUG_PARANOID in imconfig.h to catch existing calls. [@ShironekoBen]
|
||||||
|
- ImDrawList::AddCircle()/AddCircleFilled() functions don't accept negative radius.
|
||||||
|
- Limiting Columns()/BeginColumns() api to 64 columns with an assert. While the current code
|
||||||
|
technically supports it, future code may not so we're putting the restriction ahead.
|
||||||
|
- imgui_internal.h: changed ImRect() default constructor initializes all fields to 0.0f instead
|
||||||
|
of (FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX). If you used ImRect::Add() to create bounding boxes by
|
||||||
|
adding points into it without explicit initialization, you may need to fix your initial value.
|
||||||
|
|
||||||
|
Other Changes:
|
||||||
|
|
||||||
|
- Inputs: Added ImGuiMouseButton enum for convenience (e.g. ImGuiMouseButton_Right=1).
|
||||||
|
We forever guarantee that the existing value will not changes so existing code is free to use 0/1/2.
|
||||||
|
- Nav: Fixed a bug where the initial CTRL-Tab press while in a child window sometimes selected
|
||||||
|
the current root window instead of always selecting the previous root window. (#787)
|
||||||
|
- ColorEdit: Fix label alignment when using ImGuiColorEditFlags_NoInputs. (#2955) [@rokups]
|
||||||
|
- ColorEdit: In HSV display of a RGB stored value, attempt to locally preserve Saturation
|
||||||
|
when Value==0.0 (similar to changes done in 1.73 for Hue). Removed Hue editing lock since
|
||||||
|
those improvements in 1.73 makes them unnecessary. (#2722, #2770). [@rokups]
|
||||||
|
- ColorEdit: "Copy As" context-menu tool shows hex values with a '#' prefix instead of '0x'.
|
||||||
|
- ColorEdit: "Copy As" content-menu tool shows hex values both with/without alpha when available.
|
||||||
|
- InputText: Fix corruption or crash when executing undo after clearing input with ESC, as a
|
||||||
|
byproduct we are allowing to later undo the revert with a CTRL+Z. (#3008).
|
||||||
|
- InputText: Fix using a combination of _CallbackResize (e.g. for std::string binding), along with the
|
||||||
|
_EnterReturnsTrue flag along with the rarely used property of using an InputText without persisting
|
||||||
|
user-side storage. Previously if you had e.g. a local unsaved std::string and reading result back
|
||||||
|
from the widget, the user string object wouldn't be resized when Enter key was pressed. (#3009)
|
||||||
|
- MenuBar: Fix minor clipping issue where occasionally a menu text can overlap the right-most border.
|
||||||
|
- Window: Fix SetNextWindowBgAlpha(1.0f) failing to override alpha component. (#3007) [@Albog]
|
||||||
|
- Window: When testing for the presence of the ImGuiWindowFlags_NoBringToFrontOnFocus flag we
|
||||||
|
test both the focused/clicked window (which could be a child window) and the root window.
|
||||||
|
- ImDrawList: AddCircle(), AddCircleFilled() API can now auto-tessellate when provided a segment
|
||||||
|
count of zero. Alter tessellation quality with 'style.CircleSegmentMaxError'. [@ShironekoBen]
|
||||||
|
- ImDrawList: Add AddNgon(), AddNgonFilled() API with a guarantee on the explicit segment count.
|
||||||
|
In the current branch they are essentially the same as AddCircle(), AddCircleFilled() but as
|
||||||
|
we will rework the circle rendering functions to use textures and automatic segment count
|
||||||
|
selection, those new api can fill a gap. [@ShironekoBen]
|
||||||
|
- Columns: ImDrawList::Channels* functions now work inside columns. Added extra comments to
|
||||||
|
suggest using user-owned ImDrawListSplitter instead of ImDrawList functions. [@rokups]
|
||||||
|
- Misc: Added ImGuiMouseCursor_NotAllowed enum so it can be used by more shared widgets. [@rokups]
|
||||||
|
- Misc: Added IMGUI_DISABLE compile-time definition to make all headers and sources empty.
|
||||||
|
- Misc: Disable format checks when using stb_printf, to allow using extra formats.
|
||||||
|
Made IMGUI_USE_STB_SPRINTF a properly documented imconfig.h flag. (#2954) [@loicmolinari]
|
||||||
|
- Misc: Added misc/single_file/imgui_single_file.h, We use this to validate compiling all *.cpp
|
||||||
|
files in a same compilation unit. Actual users of that technique (also called "Unity builds")
|
||||||
|
can generally provide this themselves, so we don't really recommend you use this. [@rokups]
|
||||||
|
- CI: Added PVS-Studio static analysis on the continuous-integration server. [@rokups]
|
||||||
|
- Backends: GLFW, SDL, Win32, OSX, Allegro: Added support for ImGuiMouseCursor_NotAllowed. [@rokups]
|
||||||
|
- Backends: GLFW: Added support for the missing mouse cursors newly added in GLFW 3.4+. [@rokups]
|
||||||
|
- Backends: SDL: Wayland: use SDL_GetMouseState (because there is no global mouse state available
|
||||||
|
on Wayland). (#2800, #2802) [@NeroBurner]
|
||||||
|
- Backends: GLFW, SDL: report Windows key (io.KeySuper) as always released. Neither GLFW nor SDL can
|
||||||
|
correctly report the key release in every cases (e.g. when using Win+V) causing problems with some
|
||||||
|
widgets. The next release of GLFW (3.4+) will have a fix for it. However since it is both difficult
|
||||||
|
and discouraged to make use of this key for Windows application anyway, we just hide it. (#2976)
|
||||||
|
- Backends: Win32: Added support for #define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD to disable all
|
||||||
|
XInput using code, and IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT to disable linking with XInput,
|
||||||
|
the later may be problematic if compiling with recent Windows SDK and you want your app to run
|
||||||
|
on Windows 7. You can instead try linking with Xinput9_1_0.lib instead. (#2716)
|
||||||
|
- Backends: Glut: Improved FreeGLUT support for MinGW. (#3004) [@podsvirov]
|
||||||
|
- Backends: Emscripten: Avoid forcefully setting IMGUI_DISABLE_FILE_FUNCTIONS. (#3005) [@podsvirov]
|
||||||
|
- Examples: OpenGL: Explicitly adding -DIMGUI_IMPL_OPENGL_LOADER_GL3W to Makefile to match linking
|
||||||
|
settings (otherwise if another loader such as Glew is accessible, the OpenGL3 backend might
|
||||||
|
automatically use it). (#2919, #2798)
|
||||||
|
- Examples: OpenGL: Added support for glbindings OpenGL loader. (#2870) [@rokups]
|
||||||
|
- Examples: Emscripten: Demonstrating embedding fonts in Makefile and code. (#2953) [@Oipo]
|
||||||
|
- Examples: Metal: Wrapped main loop in @autoreleasepool block to ensure allocations get freed
|
||||||
|
even if underlying system event loop gets paused due to app nap. (#2910, #2917) [@bear24rw]
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.74 (Released 2019-11-25)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.74
|
||||||
|
|
||||||
|
Breaking Changes:
|
||||||
|
|
||||||
|
- Removed redirecting functions/enums names that were marked obsolete in 1.52 (October 2017):
|
||||||
|
- Begin() [old 5 args version] -> use Begin() [3 args], use SetNextWindowSize() SetNextWindowBgAlpha() if needed
|
||||||
|
- IsRootWindowOrAnyChildHovered() -> use IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows)
|
||||||
|
- AlignFirstTextHeightToWidgets() -> use AlignTextToFramePadding()
|
||||||
|
- SetNextWindowPosCenter() -> use SetNextWindowPos() with a pivot of (0.5f, 0.5f)
|
||||||
|
- ImFont::Glyph -> use ImFontGlyph
|
||||||
|
If you were still using the old names, read "API Breaking Changes" section of imgui.cpp to find out
|
||||||
|
the new names or equivalent features, or see how they were implemented until 1.73.
|
||||||
|
- Inputs: Fixed a miscalculation in the keyboard/mouse "typematic" repeat delay/rate calculation, used
|
||||||
|
by keys and e.g. repeating mouse buttons as well as the GetKeyPressedAmount() function.
|
||||||
|
If you were using a non-default value for io.KeyRepeatRate (previous default was 0.250), you can
|
||||||
|
add +io.KeyRepeatDelay to it to compensate for the fix.
|
||||||
|
The function was triggering on: 0.0 and (delay+rate*N) where (N>=1). Fixed formula responds to (N>=0).
|
||||||
|
Effectively it made io.KeyRepeatRate behave like it was set to (io.KeyRepeatRate + io.KeyRepeatDelay).
|
||||||
|
Fixed the code and altered default io.KeyRepeatRate,Delay from 0.250,0.050 to 0.300,0.050 to compensate.
|
||||||
|
If you never altered io.KeyRepeatRate nor used GetKeyPressedAmount() this won't affect you.
|
||||||
|
- Misc: Renamed IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS to IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS. (#1038)
|
||||||
|
- Misc: Renamed IMGUI_DISABLE_MATH_FUNCTIONS to IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS.
|
||||||
|
- Fonts: ImFontAtlas::AddCustomRectRegular() now requires an ID larger than 0x110000 (instead of 0x10000) to
|
||||||
|
conform with supporting Unicode planes 1-16 in a future update. ID below 0x110000 will now assert.
|
||||||
|
- Backends: DX12: Added extra ID3D12DescriptorHeap parameter to ImGui_ImplDX12_Init() function.
|
||||||
|
The value is unused in master branch but will be used by the multi-viewport feature. (#2851) [@obfuscate]
|
||||||
|
|
||||||
|
Other Changes:
|
||||||
|
|
||||||
|
- InputText, Nav: Fixed Home/End key broken when activating Keyboard Navigation. (#787)
|
||||||
|
- InputText: Filter out ASCII 127 (DEL) emitted by low-level OSX layer, as we are using the Key value. (#2578)
|
||||||
|
- Layout: Fixed a couple of subtle bounding box vertical positioning issues relating to the handling of text
|
||||||
|
baseline alignment. The issue would generally manifest when laying out multiple items on a same line,
|
||||||
|
with varying heights and text baseline offsets.
|
||||||
|
Some specific examples, e.g. a button with regular frame padding followed by another item with a
|
||||||
|
multi-line label and no frame padding, such as: multi-line text, small button, tree node item, etc.
|
||||||
|
The second item was correctly offset to match text baseline, and would interact/display correctly,
|
||||||
|
but it wouldn't push the contents area boundary low enough.
|
||||||
|
- Scrollbar: Fixed an issue where scrollbars wouldn't display on the frame following a frame where
|
||||||
|
all child window contents would be culled.
|
||||||
|
- ColorPicker: Fixed SV triangle gradient to block (broken in 1.73). (#2864, #2711). [@lewa-j]
|
||||||
|
- TreeNode: Fixed combination of ImGuiTreeNodeFlags_SpanFullWidth and ImGuiTreeNodeFlags_OpenOnArrow
|
||||||
|
incorrectly locating the arrow hit position to the left of the frame. (#2451, #2438, #1897)
|
||||||
|
- TreeNode: The collapsing arrow accepts click even if modifier keys are being held, facilitating
|
||||||
|
interactions with custom multi-selections patterns. (#2886, #1896, #1861)
|
||||||
|
- TreeNode: Added IsItemToggledOpen() to explicitly query if item was just open/closed, facilitating
|
||||||
|
interactions with custom multi-selections patterns. (#1896, #1861)
|
||||||
|
- DragScalar, SliderScalar, InputScalar: Added p_ prefix to parameter that are pointers to the data
|
||||||
|
to clarify how they are used, and more comments redirecting to the demo code. (#2844)
|
||||||
|
- Error handling: Assert if user mistakenly calls End() instead of EndChild() on a child window. (#1651)
|
||||||
|
- Misc: Optimized storage of window settings data (reducing allocation count).
|
||||||
|
- Misc: Windows: Do not use _wfopen() if IMGUI_DISABLE_WIN32_FUNCTIONS is defined. (#2815)
|
||||||
|
- Misc: Windows: Disabled win32 function by default when building with UWP. (#2892, #2895)
|
||||||
|
- Misc: Using static_assert() when using C++11, instead of our own construct (avoid zealous Clang warnings).
|
||||||
|
- Misc: Added IMGUI_DISABLE_FILE_FUNCTIONS/IMGUI_DISABLE_DEFAULT_FILE_FUNCTION to nullify or disable
|
||||||
|
default implementation of ImFileXXX functions linking with fopen/fclose/fread/fwrite. (#2734)
|
||||||
|
- Docs: Improved and moved FAQ to docs/FAQ.md so it can be readable on the web. [@ButternCream, @ocornut]
|
||||||
|
- Docs: Moved misc/fonts/README.txt to docs/FONTS.txt.
|
||||||
|
- Docs: Added permanent redirect from https://www.dearimgui.org/faq to FAQ page.
|
||||||
|
- Demo: Added simple item reordering demo in Widgets -> Drag and Drop section. (#2823, #143) [@rokups]
|
||||||
|
- Metrics: Show wire-frame mesh and approximate surface area when hovering ImDrawCmd. [@ShironekoBen]
|
||||||
|
- Metrics: Expose basic details of each window key/value state storage.
|
||||||
|
- Examples: DX12: Using IDXGIDebug1::ReportLiveObjects() when DX12_ENABLE_DEBUG_LAYER is enabled.
|
||||||
|
- Examples: Emscripten: Removed BINARYEN_TRAP_MODE=clamp from Makefile which was removed in Emscripten 1.39.0
|
||||||
|
but required prior to 1.39.0, making life easier for absolutely no-one. (#2877, #2878) [@podsvirov]
|
||||||
|
- Backends: OpenGL2: Explicitly backup, setup and restore GL_TEXTURE_ENV to increase compatibility with
|
||||||
|
legacy OpenGL applications. (#3000)
|
||||||
|
- Backends: OpenGL3: Fix building with pre-3.2 GL loaders which do not expose glDrawElementsBaseVertex(),
|
||||||
|
using runtime GL version to decide if we set ImGuiBackendFlags_RendererHasVtxOffset. (#2866, #2852) [@dpilawa]
|
||||||
|
- Backends: OSX: Fix using Backspace key. (#2578, #2817, #2818) [@DiligentGraphics]
|
||||||
|
- Backends: GLFW: Previously installed user callbacks are now restored on shutdown. (#2836) [@malte-v]
|
||||||
|
- CI: Set up a bunch of continuous-integration tests using GitHub Actions. We now compile many of the example
|
||||||
|
applications on Windows, Linux, MacOS, iOS, Emscripten. Removed Travis integration. (#2865) [@rokups]
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.73 (Released 2019-09-24)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.73
|
||||||
|
|
||||||
|
Other Changes:
|
||||||
|
|
||||||
|
- Nav, Scrolling: Added support for Home/End key. (#787)
|
||||||
|
- ColorEdit: Disable Hue edit when Saturation==0 instead of letting Hue values jump around.
|
||||||
|
- ColorEdit, ColorPicker: In HSV display of a RGB stored value, attempt to locally preserve Hue
|
||||||
|
when Saturation==0, which reduces accidentally lossy interactions. (#2722, #2770) [@rokups]
|
||||||
|
- ColorPicker: Made rendering aware of global style alpha of the picker can be faded out. (#2711)
|
||||||
|
Note that some elements won't accurately fade down with the same intensity, and the color wheel
|
||||||
|
when enabled will have small overlap glitches with (style.Alpha < 1.0).
|
||||||
|
- TabBar: Fixed single-tab not shrinking their width down.
|
||||||
|
- TabBar: Fixed clicking on a tab larger than tab-bar width creating a bouncing feedback loop.
|
||||||
|
- TabBar: Feed desired width (sum of unclipped tabs width) into layout system to allow for auto-resize. (#2768)
|
||||||
|
(before 1.71 tab bars fed the sum of current width which created feedback loops in certain situations).
|
||||||
|
- TabBar: Improved shrinking for large number of tabs to avoid leaving extraneous space on the right side.
|
||||||
|
Individuals tabs are given integer-rounded width and remainder is spread between tabs left-to-right.
|
||||||
|
- Columns, Separator: Fixed a bug where non-visible separators within columns would alter the next row position
|
||||||
|
differently than visible ones.
|
||||||
|
- SliderScalar: Improved assert when using U32 or U64 types with a large v_max value. (#2765) [@loicmouton]
|
||||||
|
- DragInt, DragFloat, DragScalar: Using (v_min > v_max) allows locking any edits to the value.
|
||||||
|
- DragScalar: Fixed dragging of unsigned values on ARM cpu (float to uint cast is undefined). (#2780) [@dBagrat]
|
||||||
|
- TreeNode: Added ImGuiTreeNodeFlags_SpanAvailWidth flag. (#2451, #2438, #1897) [@Melix19, @PathogenDavid]
|
||||||
|
This extends the hit-box to the right-most edge, even if the node is not framed.
|
||||||
|
(Note: this is not the default in order to allow adding other items on the same line. In the future we will
|
||||||
|
aim toward refactoring the hit-system to be front-to-back, allowing more natural overlapping of items,
|
||||||
|
and then we will be able to make this the default.)
|
||||||
|
- TreeNode: Added ImGuiTreeNodeFlags_SpanFullWidth flag. This extends the hit-box to both the left-most and
|
||||||
|
right-most edge of the working area, bypassing indentation.
|
||||||
|
- CollapsingHeader: Added support for ImGuiTreeNodeFlags_Bullet and ImGuiTreeNodeFlags_Leaf on framed nodes,
|
||||||
|
mostly for consistency. (#2159, #2160) [@goran-w]
|
||||||
|
- Selectable: Added ImGuiSelectableFlags_AllowItemOverlap flag in public api (was previously internal only).
|
||||||
|
- Style: Allow style.WindowMenuButtonPosition to be set to ImGuiDir_None to hide the collapse button. (#2634, #2639)
|
||||||
|
- Font: Better ellipsis ("...") drawing implementation. Instead of drawing three pixel-ey dots (which was glaringly
|
||||||
|
unfitting with many types of fonts) we first attempt to find a standard ellipsis glyphs within the loaded set.
|
||||||
|
Otherwise we render ellipsis using '.' from the font from where we trim excessive spacing to make it as narrow
|
||||||
|
as possible. (#2775) [@rokups]
|
||||||
|
- ImDrawList: Clarified the name of many parameters so reading the code is a little easier. (#2740)
|
||||||
|
- ImDrawListSplitter: Fixed merging channels if the last submitted draw command used a different texture. (#2506)
|
||||||
|
- Using offsetof() when available in C++11. Avoids Clang sanitizer complaining about old-style macros. (#94)
|
||||||
|
- ImVector: Added find(), find_erase(), find_erase_unsorted() helpers.
|
||||||
|
- Added a mechanism to compact/free the larger allocations of unused windows (buffers are compacted when
|
||||||
|
a window is unused for 60 seconds, as per io.ConfigWindowsMemoryCompactTimer = 60.0f). Note that memory
|
||||||
|
usage has never been reported as a problem, so this is merely a touch of overzealous luxury. (#2636)
|
||||||
|
- Documentation: Various tweaks and improvements to the README page. [@ker0chan]
|
||||||
|
- Backends: OpenGL3: Tweaked initialization code allow application calling ImGui_ImplOpenGL3_CreateFontsTexture()
|
||||||
|
before ImGui_ImplOpenGL3_NewFrame(), which sometimes can be convenient.
|
||||||
|
- Backends: OpenGL3: Attempt to automatically detect default GL loader by using __has_include. (#2798) [@o-micron]
|
||||||
|
- Backends: DX11: Fixed GSGetShader() call not passing an initialized instance count, which would
|
||||||
|
generally make the DX11 debug layer complain (bug added in 1.72).
|
||||||
|
- Backends: Vulkan: Added support for specifying multisample count. Set 'ImGui_ImplVulkan_InitInfo::MSAASamples' to
|
||||||
|
one of the VkSampleCountFlagBits values to use, default is non-multisampled as before. (#2705, #2706) [@vilya]
|
||||||
|
- Examples: OSX: Fix example_apple_opengl2/main.mm not forwarding mouse clicks and drags correctly. (#1961, #2710)
|
||||||
|
[@intonarumori, @ElectricMagic]
|
||||||
|
- Misc: Updated stb_rect_pack.h from 0.99 to 1.00 (fixes by @rygorous: off-by-1 bug in best-fit heuristic,
|
||||||
|
fix handling of rectangles too large to fit inside texture). (#2762) [@tido64]
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.72b (Released 2019-07-31)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.72b
|
||||||
|
|
||||||
|
Other Changes:
|
||||||
|
|
||||||
|
- Nav, Scrolling: Fixed programmatic scroll leading to a slightly incorrect scroll offset when
|
||||||
|
the window has decorations or a menu-bar (broken in 1.71). This was mostly noticeable when
|
||||||
|
a keyboard/gamepad movement led to scrolling the view, or using e.g. SetScrollHereY() function.
|
||||||
|
- Nav: Made hovering non-MenuItem Selectable not re-assign the source item for keyboard navigation.
|
||||||
|
- Nav: Fixed an issue with NavFlattened window flag (beta) where widgets not entirely fitting
|
||||||
|
in child window (often selectables because of their protruding sides) would be not considered
|
||||||
|
as entry points to to navigate toward the child window. (#787)
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.72 (Released 2019-07-27)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.72
|
||||||
|
|
||||||
|
Breaking Changes:
|
||||||
|
|
||||||
|
- Removed redirecting functions/enums names that were marked obsolete in 1.51 (June 2017):
|
||||||
|
- ImGuiCol_Column*, ImGuiSetCond_* enums.
|
||||||
|
- IsItemHoveredRect(), IsPosHoveringAnyWindow(), IsMouseHoveringAnyWindow(), IsMouseHoveringWindow() functions.
|
||||||
|
- IMGUI_ONCE_UPON_A_FRAME macro.
|
||||||
|
If you were still using the old names, read "API Breaking Changes" section of imgui.cpp to find out
|
||||||
|
the new names or equivalent features.
|
||||||
|
- Renamed ImFontAtlas::CustomRect to ImFontAtlasCustomRect. Kept redirection typedef (will obsolete).
|
||||||
|
- Removed TreeAdvanceToLabelPos() which is rarely used and only does SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()).
|
||||||
|
Kept redirection function (will obsolete). (#581, #324)
|
||||||
|
|
||||||
|
Other Changes:
|
||||||
|
|
||||||
|
- Scrolling: Made mouse-wheel scrolling lock the underlying window until the mouse is moved again or
|
||||||
|
until a short delay expires (~2 seconds). This allow uninterrupted scroll even if child windows are
|
||||||
|
passing under the mouse cursor. (#2604)
|
||||||
|
- Scrolling: Made it possible for mouse wheel and navigation-triggered scrolling to override a call to
|
||||||
|
SetScrollX()/SetScrollY(), making it possible to use a simpler stateless pattern for auto-scrolling:
|
||||||
|
// (Submit items..)
|
||||||
|
if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) // If scrolling at the already at the bottom..
|
||||||
|
ImGui::SetScrollHereY(1.0f); // ..make last item fully visible
|
||||||
|
- Scrolling: Added SetScrollHereX(), SetScrollFromPosX() for completeness. (#1580) [@kevreco]
|
||||||
|
- Scrolling: Mouse wheel scrolling while hovering a child window is automatically forwarded to parent window
|
||||||
|
if ScrollMax is zero on the scrolling axis.
|
||||||
|
Also still the case if ImGuiWindowFlags_NoScrollWithMouse is set (not new), but previously the forwarding
|
||||||
|
would be disabled if ImGuiWindowFlags_NoScrollbar was set on the child window, which is not the case
|
||||||
|
any more. Forwarding can still be disabled by setting ImGuiWindowFlags_NoInputs. (amend #1502, #1380).
|
||||||
|
- Window: Fixed InnerClipRect right-most coordinates using wrong padding setting (introduced in 1.71).
|
||||||
|
- Window: Fixed old SetWindowFontScale() api value from not being inherited by child window. Added
|
||||||
|
comments about the right way to scale your UI (load a font at the right side, rebuild atlas, scale style).
|
||||||
|
- Scrollbar: Avoid overlapping the opposite side when window (often a child window) is forcibly too small.
|
||||||
|
- Combo: Hide arrow when there's not enough space even for the square button.
|
||||||
|
- InputText: Testing for newly added ImGuiKey_KeyPadEnter key. (#2677, #2005) [@amc522]
|
||||||
|
- TabBar: Fixed unfocused tab bar separator color (was using ImGuiCol_Tab, should use ImGuiCol_TabUnfocusedActive).
|
||||||
|
- Columns: Fixed a regression from 1.71 where the right-side of the contents rectangle within each column
|
||||||
|
would wrongly use a WindowPadding.x instead of ItemSpacing.x like it always did. (#125, #2666)
|
||||||
|
- Columns: Made the right-most edge reaches up to the clipping rectangle (removing half of WindowPadding.x
|
||||||
|
worth of asymmetrical/extraneous padding, note that there's another half that conservatively has to offset
|
||||||
|
the right-most column, otherwise it's clipping width won't match the other columns). (#125, #2666)
|
||||||
|
- Columns: Improved honoring alignment with various values of ItemSpacing.x and WindowPadding.x. (#125, #2666)
|
||||||
|
- Columns: Made GetColumnOffset() and GetColumnWidth() behave when there's no column set, consistently with
|
||||||
|
other column functions. (#2683)
|
||||||
|
- InputTextMultiline: Fixed vertical scrolling tracking glitch.
|
||||||
|
- Word-wrapping: Fixed overzealous word-wrapping when glyph edge lands exactly on the limit. Because
|
||||||
|
of this, auto-fitting exactly unwrapped text would make it wrap. (fixes initial 1.15 commit, 78645a7d).
|
||||||
|
- Style: Attenuated default opacity of ImGuiCol_Separator in Classic and Light styles.
|
||||||
|
- Style: Added style.ColorButtonPosition (left/right, defaults to ImGuiDir_Right) to move the color button
|
||||||
|
of ColorEdit3/ColorEdit4 functions to either side of the inputs.
|
||||||
|
- IO: Added ImGuiKey_KeyPadEnter and support in various back-ends (previously back-ends would need to
|
||||||
|
specifically redirect key-pad keys to their regular counterpart). This is a temporary attenuating measure
|
||||||
|
until we actually refactor and add whole sets of keys into the ImGuiKey enum. (#2677, #2005) [@amc522]
|
||||||
|
- Misc: Made Button(), ColorButton() not trigger an "edited" event leading to IsItemDeactivatedAfterEdit()
|
||||||
|
returning true. This also effectively make ColorEdit4() not incorrect trigger IsItemDeactivatedAfterEdit()
|
||||||
|
when clicking the color button to open the picker popup. (#1875)
|
||||||
|
- Misc: Added IMGUI_DISABLE_METRICS_WINDOW imconfig.h setting to explicitly compile out ShowMetricsWindow().
|
||||||
|
- Debug, Metrics: Added "Tools->Item Picker" tool which allow clicking on a widget to break in the debugger
|
||||||
|
within the item code. The tool calls IM_DEBUG_BREAK() which can be redefined in imconfig.h if needed.
|
||||||
|
- ImDrawList: Fixed CloneOutput() helper crashing. (#1860) [@gviot]
|
||||||
|
- ImDrawList::ChannelsSplit(), ImDrawListSplitter: Fixed an issue with merging draw commands between
|
||||||
|
channel 0 and 1. (#2624)
|
||||||
|
- ImDrawListSplitter: Fixed memory leak when using low-level split api (was not affecting ImDrawList api,
|
||||||
|
also this type was added in 1.71 and not advertised as a public-facing feature).
|
||||||
|
- Fonts: binary_to_compressed_c.cpp: Display an error message if failing to open/read the input font file.
|
||||||
|
- Demo: Log, Console: Using a simpler stateless pattern for auto-scrolling.
|
||||||
|
- Demo: Widgets: Showing how to use the format parameter of Slider/Drag functions to display the name
|
||||||
|
of an enum value instead of the underlying integer value.
|
||||||
|
- Demo: Renamed the "Help" menu to "Tools" (more accurate).
|
||||||
|
- Backends: DX10/DX11: Backup, clear and restore Geometry Shader is any is bound when calling renderer.
|
||||||
|
- Backends: DX11: Clear Hull Shader, Domain Shader, Compute Shader before rendering. Not backing/restoring them.
|
||||||
|
- Backends: OSX: Disabled default native Mac clipboard copy/paste implementation in core library (added in 1.71),
|
||||||
|
because it needs application to be linked with '-framework ApplicationServices'. It can be explicitly
|
||||||
|
enabled back by using '#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS' in imconfig.h. Re-added
|
||||||
|
equivalent using NSPasteboard api in the imgui_impl_osx.mm experimental back-end. (#2546)
|
||||||
|
- Backends: SDL2: Added dummy ImGui_ImplSDL2_InitForD3D() function to make D3D support more visible.
|
||||||
|
(#2482, #2632) [@josiahmanson]
|
||||||
|
- Examples: Added SDL2+DirectX11 example application. (#2632, #2612, #2482) [@vincenthamm]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.71 (Released 2019-06-12)
|
VERSION 1.71 (Released 2019-06-12)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.71
|
||||||
|
|
||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
|
|
||||||
- IO: changed AddInputCharacter(unsigned short c) signature to AddInputCharacter(unsigned int c).
|
- IO: changed AddInputCharacter(unsigned short c) signature to AddInputCharacter(unsigned int c).
|
||||||
- Renamed SetNextTreeNodeOpen() to SetNextItemOpen(). Kept inline redirection function (will obsolete).
|
- Renamed SetNextTreeNodeOpen() to SetNextItemOpen(). Kept inline redirection function (will obsolete).
|
||||||
- Window: rendering of child windows outer decorations (e.g. bg color, border, scrollbars) is now
|
- Window: rendering of child windows outer decorations (e.g. bg color, border, scrollbars) is now
|
||||||
@ -44,6 +388,7 @@ Breaking Changes:
|
|||||||
to the creation of overlapping child windows. Please reach out if you are affected by this change!
|
to the creation of overlapping child windows. Please reach out if you are affected by this change!
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
|
|
||||||
- Window: clarified behavior of SetNextWindowContentSize(). Content size is defined as the size available
|
- Window: clarified behavior of SetNextWindowContentSize(). Content size is defined as the size available
|
||||||
after removal of WindowPadding on each sides. So SetNextWindowContentSize(ImVec2(100,100)) + auto-resize
|
after removal of WindowPadding on each sides. So SetNextWindowContentSize(ImVec2(100,100)) + auto-resize
|
||||||
will always allow submitting a 100x100 item without creating a scrollbar, regarding of WindowPadding.
|
will always allow submitting a 100x100 item without creating a scrollbar, regarding of WindowPadding.
|
||||||
@ -85,11 +430,11 @@ Other Changes:
|
|||||||
collapsing/docking button to the other side of the title bar.
|
collapsing/docking button to the other side of the title bar.
|
||||||
- Style: Made window close button cross slightly smaller.
|
- Style: Made window close button cross slightly smaller.
|
||||||
- Log/Capture: Fixed BeginTabItem() label not being included in a text log/capture.
|
- Log/Capture: Fixed BeginTabItem() label not being included in a text log/capture.
|
||||||
- ImDrawList: Added ImDrawCmd::VtxOffset value to support large meshes (64k+ vertices) using 16-bits indices.
|
- ImDrawList: Added ImDrawCmd::VtxOffset value to support large meshes (64k+ vertices) using 16-bit indices.
|
||||||
The renderer back-end needs to set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset' to enable
|
The renderer back-end needs to set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset' to enable
|
||||||
this, and honor the ImDrawCmd::VtxOffset field. Otherwise the value will always be zero.
|
this, and honor the ImDrawCmd::VtxOffset field. Otherwise the value will always be zero.
|
||||||
This has the advantage of preserving smaller index buffers and allowing to execute on hardware that do not
|
This has the advantage of preserving smaller index buffers and allowing to execute on hardware that do not
|
||||||
support 32-bits indices. Most examples back-ends have been modified to support the VtxOffset field.
|
support 32-bit indices. Most examples back-ends have been modified to support the VtxOffset field.
|
||||||
- ImDrawList: Added ImDrawCmd::IdxOffset value, equivalent to summing element count for each draw command.
|
- ImDrawList: Added ImDrawCmd::IdxOffset value, equivalent to summing element count for each draw command.
|
||||||
This is provided for convenience and consistency with VtxOffset.
|
This is provided for convenience and consistency with VtxOffset.
|
||||||
- ImDrawCallback: Allow to override the signature of ImDrawCallback by #define-ing it. This is meant to
|
- ImDrawCallback: Allow to override the signature of ImDrawCallback by #define-ing it. This is meant to
|
||||||
@ -103,7 +448,7 @@ Other Changes:
|
|||||||
dealing with Win32, and to facilitate integration in custom engines. (#2546) [@andrewwillmott]
|
dealing with Win32, and to facilitate integration in custom engines. (#2546) [@andrewwillmott]
|
||||||
- Backends: OSX: imgui_impl_osx: Added mouse cursor support. (#2585, #1873) [@actboy168]
|
- Backends: OSX: imgui_impl_osx: Added mouse cursor support. (#2585, #1873) [@actboy168]
|
||||||
- Examples/Backends: DirectX9/10/11/12, Metal, Vulkan, OpenGL3 (Desktop GL only): Added support for large meshes
|
- Examples/Backends: DirectX9/10/11/12, Metal, Vulkan, OpenGL3 (Desktop GL only): Added support for large meshes
|
||||||
(64k+ vertices) with 16-bits indices, enable 'ImGuiBackendFlags_RendererHasVtxOffset' in those back-ends.
|
(64k+ vertices) with 16-bit indices, enable 'ImGuiBackendFlags_RendererHasVtxOffset' in those back-ends.
|
||||||
- Examples/Backends: Don't filter characters under 0x10000 before calling io.AddInputCharacter(),
|
- Examples/Backends: Don't filter characters under 0x10000 before calling io.AddInputCharacter(),
|
||||||
the filtering is done in io.AddInputCharacter() itself. This is in prevision for fuller Unicode
|
the filtering is done in io.AddInputCharacter() itself. This is in prevision for fuller Unicode
|
||||||
support. (#2538, #2541)
|
support. (#2538, #2541)
|
||||||
@ -113,7 +458,10 @@ Other Changes:
|
|||||||
VERSION 1.70 (Released 2019-05-06)
|
VERSION 1.70 (Released 2019-05-06)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.70
|
||||||
|
|
||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
|
|
||||||
- ImDrawList: Improved algorithm for mitre joints on thick lines, preserving correct thickness
|
- ImDrawList: Improved algorithm for mitre joints on thick lines, preserving correct thickness
|
||||||
up to 90 degrees angles (e.g. rectangles). If you have custom rendering using thick lines,
|
up to 90 degrees angles (e.g. rectangles). If you have custom rendering using thick lines,
|
||||||
they will appear a little thicker now. (#2518) [@rmitton]
|
they will appear a little thicker now. (#2518) [@rmitton]
|
||||||
@ -126,6 +474,7 @@ Breaking Changes:
|
|||||||
on them but it is possible you have!).
|
on them but it is possible you have!).
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
|
|
||||||
- ImDrawList: Added ImDrawCallback_ResetRenderState, a special ImDrawList::AddCallback() value
|
- ImDrawList: Added ImDrawCallback_ResetRenderState, a special ImDrawList::AddCallback() value
|
||||||
to request the renderer back-end to reset its render state. (#2037, #1639, #2452)
|
to request the renderer back-end to reset its render state. (#2037, #1639, #2452)
|
||||||
Examples: Added support for ImDrawCallback_ResetRenderState in all renderer back-ends. Each
|
Examples: Added support for ImDrawCallback_ResetRenderState in all renderer back-ends. Each
|
||||||
@ -200,12 +549,14 @@ Other Changes:
|
|||||||
VERSION 1.69 (Released 2019-03-13)
|
VERSION 1.69 (Released 2019-03-13)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.69
|
||||||
|
|
||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
|
|
||||||
- Renamed ColorEdit/ColorPicker's ImGuiColorEditFlags_RGB/_HSV/_HEX flags to respectively
|
- Renamed ColorEdit/ColorPicker's ImGuiColorEditFlags_RGB/_HSV/_HEX flags to respectively
|
||||||
ImGuiColorEditFlags_DisplayRGB/_DisplayHSV/_DisplayHex. This is because the addition of
|
ImGuiColorEditFlags_DisplayRGB/_DisplayHSV/_DisplayHex. This is because the addition of
|
||||||
new flag ImGuiColorEditFlags_InputHSV makes the earlier one ambiguous.
|
new flag ImGuiColorEditFlags_InputHSV makes the earlier one ambiguous.
|
||||||
Keep redirection enum values (will obsolete). (#2384) [@haldean]
|
Kept redirection enum values (will obsolete). (#2384) [@haldean]
|
||||||
- Renamed GetOverlayDrawList() to GetForegroundDrawList(). Kept redirection function (will obsolete). (#2391)
|
- Renamed GetOverlayDrawList() to GetForegroundDrawList(). Kept redirection function (will obsolete). (#2391)
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
@ -276,6 +627,8 @@ Other Changes:
|
|||||||
VERSION 1.68 (Released 2019-02-19)
|
VERSION 1.68 (Released 2019-02-19)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.68
|
||||||
|
|
||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
|
|
||||||
- Removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already).
|
- Removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already).
|
||||||
@ -344,13 +697,15 @@ Other Changes:
|
|||||||
VERSION 1.67 (Released 2019-01-14)
|
VERSION 1.67 (Released 2019-01-14)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.67
|
||||||
|
|
||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
|
|
||||||
- Made it illegal to call Begin("") with an empty string. This somehow half-worked before but had various undesirable
|
- Made it illegal to call Begin("") with an empty string. This somehow half-worked before but had various undesirable
|
||||||
side-effect because the window would have ID zero. In particular it is causing problems in viewport/docking branches.
|
side-effect because the window would have ID zero. In particular it is causing problems in viewport/docking branches.
|
||||||
- Renamed io.ConfigResizeWindowsFromEdges to io.ConfigWindowsResizeFromEdges and removed its [Beta] mark.
|
- Renamed io.ConfigResizeWindowsFromEdges to io.ConfigWindowsResizeFromEdges and removed its [Beta] mark.
|
||||||
The addition of new configuration options in the Docking branch is pushing for a little reorganization of those names.
|
The addition of new configuration options in the Docking branch is pushing for a little reorganization of those names.
|
||||||
- Renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Keep redirection typedef (will obsolete).
|
- Renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Kept redirection typedef (will obsolete).
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
- Added BETA api for Tab Bar/Tabs widgets: (#261, #351)
|
- Added BETA api for Tab Bar/Tabs widgets: (#261, #351)
|
||||||
@ -407,6 +762,8 @@ Other Changes:
|
|||||||
VERSION 1.66b (Released 2018-12-01)
|
VERSION 1.66b (Released 2018-12-01)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.66b
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
|
|
||||||
- Fixed a text rendering/clipping bug introduced in 1.66 (on 2018-10-12, commit ede3a3b9) that affect single ImDrawList::AddText()
|
- Fixed a text rendering/clipping bug introduced in 1.66 (on 2018-10-12, commit ede3a3b9) that affect single ImDrawList::AddText()
|
||||||
@ -424,6 +781,8 @@ Other Changes:
|
|||||||
VERSION 1.66 (Released 2018-11-22)
|
VERSION 1.66 (Released 2018-11-22)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.66
|
||||||
|
|
||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
|
|
||||||
- Renamed SetScrollHere() to SetScrollHereY(). Kept redirection function (will obsolete).
|
- Renamed SetScrollHere() to SetScrollHereY(). Kept redirection function (will obsolete).
|
||||||
@ -483,6 +842,8 @@ Other Changes:
|
|||||||
VERSION 1.65 (Released 2018-09-06)
|
VERSION 1.65 (Released 2018-09-06)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.65
|
||||||
|
|
||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
|
|
||||||
- Renamed stb_truetype.h to imstb_truetype.h, stb_textedit.h to imstb_textedit.h, and
|
- Renamed stb_truetype.h to imstb_truetype.h, stb_textedit.h to imstb_textedit.h, and
|
||||||
@ -507,6 +868,8 @@ Other Changes:
|
|||||||
VERSION 1.64 (Released 2018-08-31)
|
VERSION 1.64 (Released 2018-08-31)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.64
|
||||||
|
|
||||||
Changes:
|
Changes:
|
||||||
|
|
||||||
- Moved README, CHANGELOG and TODO files to the docs/ folder.
|
- Moved README, CHANGELOG and TODO files to the docs/ folder.
|
||||||
@ -529,6 +892,8 @@ Changes:
|
|||||||
VERSION 1.63 (Released 2018-08-29)
|
VERSION 1.63 (Released 2018-08-29)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.63
|
||||||
|
|
||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
|
|
||||||
- Style: Renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features.
|
- Style: Renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features.
|
||||||
@ -621,6 +986,8 @@ Other Changes:
|
|||||||
VERSION 1.62 (Released 2018-06-22)
|
VERSION 1.62 (Released 2018-06-22)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.62
|
||||||
|
|
||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
|
|
||||||
- TreeNodeEx(): The helper ImGuiTreeNodeFlags_CollapsingHeader flag now include ImGuiTreeNodeFlags_NoTreePushOnOpen.
|
- TreeNodeEx(): The helper ImGuiTreeNodeFlags_CollapsingHeader flag now include ImGuiTreeNodeFlags_NoTreePushOnOpen.
|
||||||
@ -700,6 +1067,8 @@ Other Changes:
|
|||||||
VERSION 1.61 (Released 2018-05-14)
|
VERSION 1.61 (Released 2018-05-14)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.61
|
||||||
|
|
||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
|
|
||||||
- DragInt(): The default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally
|
- DragInt(): The default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally
|
||||||
@ -1091,7 +1460,7 @@ Breaking Changes:
|
|||||||
- Removed `IsItemRectHovered()`, `IsWindowRectHovered()` recently introduced in 1.51 which were merely the more consistent/correct names for the above functions which are now obsolete anyway. (#1382)
|
- Removed `IsItemRectHovered()`, `IsWindowRectHovered()` recently introduced in 1.51 which were merely the more consistent/correct names for the above functions which are now obsolete anyway. (#1382)
|
||||||
- Changed `IsWindowHovered()` default parameters behavior to return false if an item is active in another window (e.g. click-dragging item from another window to this window). You can use the newly introduced IsWindowHovered() flags to requests this specific behavior if you need it. (#1382)
|
- Changed `IsWindowHovered()` default parameters behavior to return false if an item is active in another window (e.g. click-dragging item from another window to this window). You can use the newly introduced IsWindowHovered() flags to requests this specific behavior if you need it. (#1382)
|
||||||
- Renamed imconfig.h's `IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS`/`IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS` to `IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS`/`IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS` for consistency.
|
- Renamed imconfig.h's `IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS`/`IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS` to `IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS`/`IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS` for consistency.
|
||||||
- Renamed ImFont::Glyph to ImFontGlyph. Keep redirection typedef (will obsolete).
|
- Renamed ImFont::Glyph to ImFontGlyph. Kept redirection typedef (will obsolete).
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
|
|
||||||
@ -1510,7 +1879,7 @@ Changes:
|
|||||||
- Fixed border rendering in various situations when using non-pixel aligned glyphs.
|
- Fixed border rendering in various situations when using non-pixel aligned glyphs.
|
||||||
- Fixed border rendering of windows to always contain the border within the window.
|
- Fixed border rendering of windows to always contain the border within the window.
|
||||||
- Fixed Shutdown() leaking font atlas data if NewFrame() was never called. (#396, #303)
|
- Fixed Shutdown() leaking font atlas data if NewFrame() was never called. (#396, #303)
|
||||||
- Fixed int>void\* warnings for 64-bits architectures with fancy warnings enabled.
|
- Fixed int>void\* warnings for 64-bit architectures with fancy warnings enabled.
|
||||||
- Renamed the dubious Color() helpers to ValueColor() - dangerously named, rarely used and probably to be made obsolete.
|
- Renamed the dubious Color() helpers to ValueColor() - dangerously named, rarely used and probably to be made obsolete.
|
||||||
- InputText(): Fixed and better handling of using keyboard while mouse button if being held and dragging. (#429)
|
- InputText(): Fixed and better handling of using keyboard while mouse button if being held and dragging. (#429)
|
||||||
- InputText(): Replace OS IME (Input Method Editor) cursor on top-left when we are not text editing.
|
- InputText(): Replace OS IME (Input Method Editor) cursor on top-left when we are not text editing.
|
||||||
|
592
docs/FAQ.md
Normal file
592
docs/FAQ.md
Normal file
@ -0,0 +1,592 @@
|
|||||||
|
# FAQ (Frequenty Asked Questions)
|
||||||
|
|
||||||
|
You may link to this document using short form:
|
||||||
|
https://www.dearimgui.org/faq
|
||||||
|
or its real address:
|
||||||
|
https://github.com/ocornut/imgui/blob/master/docs/FAQ.md
|
||||||
|
or view this file with any Markdown viewer.
|
||||||
|
|
||||||
|
|
||||||
|
## Index
|
||||||
|
|
||||||
|
| **Q&A: Basics** |
|
||||||
|
:---------------------------------------------------------- |
|
||||||
|
| [Where is the documentation?](#q-where-is-the-documentation) |
|
||||||
|
| [What is this library called?](#q-what-is-this-library-called) |
|
||||||
|
| [Which version should I get?](#q-which-version-should-i-get) |
|
||||||
|
| **Q&A: Integration** |
|
||||||
|
| **[How can I tell whether to dispatch mouse/keyboard to Dear ImGui or to my application?](#q-how-can-i-tell-whether-to-dispatch-mousekeyboard-to-dear-imgui-or-to-my-application)** |
|
||||||
|
| [How can I enable keyboard or gamepad controls?](#q-how-can-i-enable-keyboard-or-gamepad-controls) |
|
||||||
|
| [How can I use this on a machine without mouse, keyboard or screen? (input share, remote display)](#q-how-can-i-use-this-on-a-machine-without-mouse-keyboard-or-screen-input-share-remote-display) |
|
||||||
|
| [I integrated Dear ImGui in my engine and the text or lines are blurry..](#q-i-integrated-dear-imgui-in-my-engine-and-the-text-or-lines-are-blurry) |
|
||||||
|
| [I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-clipping-or-disappearing-when-i-move-windows-around) |
|
||||||
|
| **Q&A: Usage** |
|
||||||
|
| **[Why are multiple widgets reacting when I interact with a single one?<br>How can I have multiple widgets with the same label or with an empty label?](#q-why-are-multiple-widgets-reacting-when-i-interact-with-a-single-one-q-how-can-i-have-multiple-widgets-with-the-same-label-or-with-an-empty-label)** |
|
||||||
|
| [How can I display an image? What is ImTextureID, how does it work?](#q-how-can-i-display-an-image-what-is-imtextureid-how-does-it-work)|
|
||||||
|
| [How can I use my own math types instead of ImVec2/ImVec4?](#q-how-can-i-use-my-own-math-types-instead-of-imvec2imvec4) |
|
||||||
|
| [How can I interact with standard C++ types (such as std::string and std::vector)?](#q-how-can-i-interact-with-standard-c-types-such-as-stdstring-and-stdvector) |
|
||||||
|
| [How can I display custom shapes? (using low-level ImDrawList API)](#q-how-can-i-display-custom-shapes-using-low-level-imdrawlist-api) |
|
||||||
|
| **Q&A: Fonts, Text** |
|
||||||
|
| [How can I load a different font than the default?](#q-how-can-i-load-a-different-font-than-the-default) |
|
||||||
|
| [How can I easily use icons in my application?](#q-how-can-i-easily-use-icons-in-my-application) |
|
||||||
|
| [How can I load multiple fonts?](#q-how-can-i-load-multiple-fonts) |
|
||||||
|
| [How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic?](#q-how-can-i-display-and-input-non-latin-characters-such-as-chinese-japanese-korean-cyrillic) |
|
||||||
|
| **Q&A: Concerns** |
|
||||||
|
| [Who uses Dear ImGui?](#q-who-uses-dear-imgui) |
|
||||||
|
| [Can you create elaborate/serious tools with Dear ImGui?](#q-can-you-create-elaborateserious-tools-with-dear-imgui) |
|
||||||
|
| [Can you reskin the look of Dear ImGui?](#q-can-you-reskin-the-look-of-dear-imgui) |
|
||||||
|
| [Why using C++ (as opposed to C)?](#q-why-using-c-as-opposed-to-c) |
|
||||||
|
| **Q&A: Community** |
|
||||||
|
| [How can I help?](#q-how-can-i-help) |
|
||||||
|
|
||||||
|
|
||||||
|
# Q&A: Basics
|
||||||
|
|
||||||
|
### Q: Where is the documentation?
|
||||||
|
|
||||||
|
**This library is poorly documented at the moment and expects of the user to be acquainted with C/C++.**
|
||||||
|
- Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the [examples/](https://github.com/ocornut/imgui/blob/master/examples/) folder to explain how to integrate Dear ImGui with your own engine/application. You can run those applications and explore them.
|
||||||
|
- See demo code in [imgui_demo.cpp](https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp) and particularly the `ImGui::ShowDemoWindow()` function. The demo covers most features of Dear ImGui, so you can read the code and see its output.
|
||||||
|
- See documentation and comments at the top of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) + general API comments in [imgui.h](https://github.com/ocornut/imgui/blob/master/imgui.h).
|
||||||
|
- The [Wiki](https://github.com/ocornut/imgui/wiki) has many resources and links.
|
||||||
|
- The [Glossary](https://github.com/ocornut/imgui/wiki/Glossary) page may be useful.
|
||||||
|
- The [Issues](https://github.com/ocornut/imgui/issues) section can be searched for past questions and issues.
|
||||||
|
- Your programming IDE is your friend, find the type or function declaration to find comments associated to it.
|
||||||
|
- The `ImGui::ShowMetricsWindow()` function exposes lots of internal information and tools. Although it is primary designed as a debugging tool, having access to that information tends to help understands concepts.
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q. What is this library called?
|
||||||
|
|
||||||
|
**This library is called Dear ImGui**. Please refer to it as Dear ImGui (not ImGui, not IMGUI).
|
||||||
|
|
||||||
|
(The library misleadingly started its life in 2014 as "ImGui" due to the fact that I didn't give it a proper name when when I released 1.0, and had no particular expectation that it would take off. However, the term IMGUI (immediate-mode graphical user interface) was coined before and is being used in variety of other situations e.g. Unity uses it own implementation of the IMGUI paradigm. To reduce the ambiguity without affecting existing code bases, I have decided in December 2015 a fully qualified name "Dear ImGui" for this library.
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q: Which version should I get?
|
||||||
|
I occasionally tag [Releases](https://github.com/ocornut/imgui/releases) but it is generally safe and recommended to sync to master/latest. The library is fairly stable and regressions tend to be fixed fast when reported.
|
||||||
|
|
||||||
|
You may use the [docking](https://github.com/ocornut/imgui/tree/docking) branch which includes:
|
||||||
|
- [Docking features](https://github.com/ocornut/imgui/issues/2109)
|
||||||
|
- [Multi-viewport features](https://github.com/ocornut/imgui/issues/1542)
|
||||||
|
|
||||||
|
Many projects are using this branch and it is kept in sync with master regularly.
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
# Q&A: Integration
|
||||||
|
|
||||||
|
### Q: How can I tell whether to dispatch mouse/keyboard to Dear ImGui or to my application?
|
||||||
|
|
||||||
|
You can read the `io.WantCaptureMouse`, `io.WantCaptureKeyboard` and `io.WantTextInput` flags from the ImGuiIO structure.
|
||||||
|
|
||||||
|
e.g. `if (ImGui::GetIO().WantCaptureMouse) { ... }`
|
||||||
|
|
||||||
|
- When `io.WantCaptureMouse` is set, imgui wants to use your mouse state, and you may want to discard/hide the inputs from the rest of your application.
|
||||||
|
- When `io.WantCaptureKeyboard` is set, imgui wants to use your keyboard state, and you may want to discard/hide the inputs from the rest of your application.
|
||||||
|
- When `io.WantTextInput` is set to may want to notify your OS to popup an on-screen keyboard, if available (e.g. on a mobile phone, or console OS).
|
||||||
|
|
||||||
|
**Note:** You should always pass your mouse/keyboard inputs to Dear ImGui, even when the io.WantCaptureXXX flag are set false.
|
||||||
|
This is because imgui needs to detect that you clicked in the void to unfocus its own windows.
|
||||||
|
|
||||||
|
**Note:** The `io.WantCaptureMouse` is more accurate that any manual attempt to "check if the mouse is hovering a window" (don't do that!). It handle mouse dragging correctly (both dragging that started over your application or over an imgui window) and handle e.g. modal windows blocking inputs. Those flags are updated by `ImGui::NewFrame()`. Preferably read the flags after calling NewFrame() if you can afford it, but reading them before is also perfectly fine, as the bool toggle fairly rarely. If you have on a touch device, you might find use for an early call to `UpdateHoveredWindowAndCaptureFlags()`.
|
||||||
|
|
||||||
|
**Note:** Text input widget releases focus on "Return KeyDown", so the subsequent "Return KeyUp" event that your application receive will typically have `io.WantCaptureKeyboard == false`. Depending on your application logic it may or not be inconvenient. You might want to track which key-downs were targeted for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.)
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q: How can I enable keyboard or gamepad controls?
|
||||||
|
- The gamepad/keyboard navigation is fairly functional and keeps being improved. The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable. Gamepad support is particularly useful to use Dear ImGui on a game console (e.g. PS4, Switch, XB1) without a mouse connected!
|
||||||
|
- Keyboard: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard` to enable.
|
||||||
|
- Gamepad: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad` to enable (with a supporting back-end).
|
||||||
|
- See [Control Sheets for Gamepads](http://www.dearimgui.org/controls_sheets) (reference PNG/PSD for for PS4, XB1, Switch gamepads).
|
||||||
|
- See `USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) for more details.
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q: How can I use this on a machine without mouse, keyboard or screen? (input share, remote display)
|
||||||
|
- You can share your computer mouse seamlessly with your console/tablet/phone using solutions such as [Synergy](https://symless.com/synergy)
|
||||||
|
This is the preferred solution for developer productivity.
|
||||||
|
In particular, the [micro-synergy-client repository](https://github.com/symless/micro-synergy-client) has simple
|
||||||
|
and portable source code (uSynergy.c/.h) for a small embeddable client that you can use on any platform to connect
|
||||||
|
to your host computer, based on the Synergy 1.x protocol. Make sure you download the Synergy 1 server on your computer.
|
||||||
|
Console SDK also sometimes provide equivalent tooling or wrapper for Synergy-like protocols.
|
||||||
|
- Game console users: consider emulating a mouse cursor with DualShock4 touch pad or a spare analog stick as a mouse-emulation fallback.
|
||||||
|
- You may also use a third party solution such as [Remote ImGui](https://github.com/JordiRos/remoteimgui) or [imgui-ws](https://github.com/ggerganov/imgui-ws) which sends the vertices to render over the local network, allowing you to use Dear ImGui even on a screen-less machine. See [Wiki](https://github.com/ocornut/imgui/wiki) index for most details.
|
||||||
|
- For touch inputs, you can increase the hit box of widgets (via the `style.TouchPadding` setting) to accommodate for the lack of precision of touch inputs, but it is recommended you use a mouse or gamepad to allow optimizing for screen real-estate and precision.
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q: I integrated Dear ImGui in my engine and the text or lines are blurry..
|
||||||
|
In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f).
|
||||||
|
Also make sure your orthographic projection matrix and io.DisplaySize matches your actual framebuffer dimension.
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q: I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..
|
||||||
|
You are probably mishandling the clipping rectangles in your render function.
|
||||||
|
Rectangles provided by ImGui are defined as
|
||||||
|
`(x1=left,y1=top,x2=right,y2=bottom)`
|
||||||
|
and **NOT** as
|
||||||
|
`(x1,y1,width,height)`
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Q&A: Usage
|
||||||
|
|
||||||
|
### Q: Why are multiple widgets reacting when I interact with a single one? <br>Q: How can I have multiple widgets with the same label or with an empty label?
|
||||||
|
|
||||||
|
A primer on labels and the ID Stack...
|
||||||
|
|
||||||
|
Dear ImGui internally need to uniquely identify UI elements.
|
||||||
|
Elements that are typically not clickable (such as calls to the Text functions) don't need an ID.
|
||||||
|
Interactive widgets (such as calls to Button buttons) need a unique ID.
|
||||||
|
Unique ID are used internally to track active widgets and occasionally associate state to widgets.
|
||||||
|
Unique ID are implicitly built from the hash of multiple elements that identify the "path" to the UI element.
|
||||||
|
|
||||||
|
- Unique ID are often derived from a string label:
|
||||||
|
```c
|
||||||
|
Button("OK"); // Label = "OK", ID = hash of (..., "OK")
|
||||||
|
Button("Cancel"); // Label = "Cancel", ID = hash of (..., "Cancel")
|
||||||
|
```
|
||||||
|
- ID are uniquely scoped within windows, tree nodes, etc. which all pushes to the ID stack. Having
|
||||||
|
two buttons labeled "OK" in different windows or different tree locations is fine.
|
||||||
|
We used "..." above to signify whatever was already pushed to the ID stack previously:
|
||||||
|
```c
|
||||||
|
Begin("MyWindow");
|
||||||
|
Button("OK"); // Label = "OK", ID = hash of ("MyWindow", "OK")
|
||||||
|
End();
|
||||||
|
Begin("MyOtherWindow");
|
||||||
|
Button("OK"); // Label = "OK", ID = hash of ("MyOtherWindow", "OK")
|
||||||
|
End();
|
||||||
|
```
|
||||||
|
- If you have a same ID twice in the same location, you'll have a conflict:
|
||||||
|
```c
|
||||||
|
Button("OK");
|
||||||
|
Button("OK"); // ID collision! Interacting with either button will trigger the first one.
|
||||||
|
```
|
||||||
|
Fear not! this is easy to solve and there are many ways to solve it!
|
||||||
|
|
||||||
|
- Solving ID conflict in a simple/local context:
|
||||||
|
When passing a label you can optionally specify extra ID information within string itself.
|
||||||
|
Use "##" to pass a complement to the ID that won't be visible to the end-user.
|
||||||
|
This helps solving the simple collision cases when you know e.g. at compilation time which items
|
||||||
|
are going to be created:
|
||||||
|
```c
|
||||||
|
Begin("MyWindow");
|
||||||
|
Button("Play"); // Label = "Play", ID = hash of ("MyWindow", "Play")
|
||||||
|
Button("Play##foo1"); // Label = "Play", ID = hash of ("MyWindow", "Play##foo1") // Different from above
|
||||||
|
Button("Play##foo2"); // Label = "Play", ID = hash of ("MyWindow", "Play##foo2") // Different from above
|
||||||
|
End();
|
||||||
|
```
|
||||||
|
- If you want to completely hide the label, but still need an ID:
|
||||||
|
```c
|
||||||
|
Checkbox("##On", &b); // Label = "", ID = hash of (..., "##On") // No visible label, just a checkbox!
|
||||||
|
```
|
||||||
|
- Occasionally/rarely you might want change a label while preserving a constant ID. This allows
|
||||||
|
you to animate labels. For example you may want to include varying information in a window title bar,
|
||||||
|
but windows are uniquely identified by their ID. Use "###" to pass a label that isn't part of ID:
|
||||||
|
```c
|
||||||
|
Button("Hello###ID"); // Label = "Hello", ID = hash of (..., "###ID")
|
||||||
|
Button("World###ID"); // Label = "World", ID = hash of (..., "###ID") // Same as above, even if the label looks different
|
||||||
|
|
||||||
|
sprintf(buf, "My game (%f FPS)###MyGame", fps);
|
||||||
|
Begin(buf); // Variable title, ID = hash of "MyGame"
|
||||||
|
```
|
||||||
|
- Solving ID conflict in a more general manner:
|
||||||
|
Use PushID() / PopID() to create scopes and manipulate the ID stack, as to avoid ID conflicts
|
||||||
|
within the same window. This is the most convenient way of distinguishing ID when iterating and
|
||||||
|
creating many UI elements programmatically.
|
||||||
|
You can push a pointer, a string or an integer value into the ID stack.
|
||||||
|
Remember that ID are formed from the concatenation of _everything_ pushed into the ID stack.
|
||||||
|
At each level of the stack we store the seed used for items at this level of the ID stack.
|
||||||
|
```c
|
||||||
|
Begin("Window");
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
PushID(i); // Push i to the id tack
|
||||||
|
Button("Click"); // Label = "Click", ID = hash of ("Window", i, "Click")
|
||||||
|
PopID();
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
MyObject* obj = Objects[i];
|
||||||
|
PushID(obj);
|
||||||
|
Button("Click"); // Label = "Click", ID = hash of ("Window", obj pointer, "Click")
|
||||||
|
PopID();
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
MyObject* obj = Objects[i];
|
||||||
|
PushID(obj->Name);
|
||||||
|
Button("Click"); // Label = "Click", ID = hash of ("Window", obj->Name, "Click")
|
||||||
|
PopID();
|
||||||
|
}
|
||||||
|
End();
|
||||||
|
```
|
||||||
|
- You can stack multiple prefixes into the ID stack:
|
||||||
|
```c
|
||||||
|
Button("Click"); // Label = "Click", ID = hash of (..., "Click")
|
||||||
|
PushID("node");
|
||||||
|
Button("Click"); // Label = "Click", ID = hash of (..., "node", "Click")
|
||||||
|
PushID(my_ptr);
|
||||||
|
Button("Click"); // Label = "Click", ID = hash of (..., "node", my_ptr, "Click")
|
||||||
|
PopID();
|
||||||
|
PopID();
|
||||||
|
```
|
||||||
|
- Tree nodes implicitly creates a scope for you by calling PushID().
|
||||||
|
```c
|
||||||
|
Button("Click"); // Label = "Click", ID = hash of (..., "Click")
|
||||||
|
if (TreeNode("node")) // <-- this function call will do a PushID() for you (unless instructed not to, with a special flag)
|
||||||
|
{
|
||||||
|
Button("Click"); // Label = "Click", ID = hash of (..., "node", "Click")
|
||||||
|
TreePop();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- When working with trees, ID are used to preserve the open/close state of each tree node.
|
||||||
|
Depending on your use cases you may want to use strings, indices or pointers as ID.
|
||||||
|
e.g. when following a single pointer that may change over time, using a static string as ID
|
||||||
|
will preserve your node open/closed state when the targeted object change.
|
||||||
|
e.g. when displaying a list of objects, using indices or pointers as ID will preserve the
|
||||||
|
node open/closed state differently. See what makes more sense in your situation!
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q: How can I display an image? What is ImTextureID, how does it work?
|
||||||
|
|
||||||
|
Short explanation:
|
||||||
|
- Refer to [Image Loading and Displaying Examples](https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples) on the [Wiki](https://github.com/ocornut/imgui/wiki).
|
||||||
|
- You may use functions such as `ImGui::Image()`, `ImGui::ImageButton()` or lower-level `ImDrawList::AddImage()` to emit draw calls that will use your own textures.
|
||||||
|
- Actual textures are identified in a way that is up to the user/engine. Those identifiers are stored and passed as ImTextureID (void*) value.
|
||||||
|
- Loading image files from the disk and turning them into a texture is not within the scope of Dear ImGui (for a good reason).
|
||||||
|
|
||||||
|
**Please read documentations or tutorials on your graphics API to understand how to display textures on the screen before moving onward.**
|
||||||
|
|
||||||
|
Long explanation:
|
||||||
|
- Dear ImGui's job is to create "meshes", defined in a renderer-agnostic format made of draw commands and vertices. At the end of the frame those meshes (ImDrawList) will be displayed by your rendering function. They are made up of textured polygons and the code to render them is generally fairly short (a few dozen lines). In the examples/ folder we provide functions for popular graphics API (OpenGL, DirectX, etc.).
|
||||||
|
- Each rendering function decides on a data type to represent "textures". The concept of what is a "texture" is entirely tied to your underlying engine/graphics API.
|
||||||
|
We carry the information to identify a "texture" in the ImTextureID type.
|
||||||
|
ImTextureID is nothing more that a void*, aka 4/8 bytes worth of data: just enough to store 1 pointer or 1 integer of your choice.
|
||||||
|
Dear ImGui doesn't know or understand what you are storing in ImTextureID, it merely pass ImTextureID values until they reach your rendering function.
|
||||||
|
- In the [examples/](https://github.com/ocornut/imgui/tree/master/examples) bindings, for each graphics API binding we decided on a type that is likely to be a good representation for specifying an image from the end-user perspective. This is what the _examples_ rendering functions are using:
|
||||||
|
```
|
||||||
|
OpenGL:
|
||||||
|
- ImTextureID = GLuint
|
||||||
|
- See ImGui_ImplOpenGL3_RenderDrawData() function in imgui_impl_opengl3.cpp
|
||||||
|
```
|
||||||
|
```
|
||||||
|
DirectX9:
|
||||||
|
- ImTextureID = LPDIRECT3DTEXTURE9
|
||||||
|
- See ImGui_ImplDX9_RenderDrawData() function in imgui_impl_dx9.cpp
|
||||||
|
```
|
||||||
|
```
|
||||||
|
DirectX11:
|
||||||
|
- ImTextureID = ID3D11ShaderResourceView*
|
||||||
|
- See ImGui_ImplDX11_RenderDrawData() function in imgui_impl_dx11.cpp
|
||||||
|
```
|
||||||
|
```
|
||||||
|
DirectX12:
|
||||||
|
- ImTextureID = D3D12_GPU_DESCRIPTOR_HANDLE
|
||||||
|
- See ImGui_ImplDX12_RenderDrawData() function in imgui_impl_dx12.cpp
|
||||||
|
```
|
||||||
|
For example, in the OpenGL example binding we store raw OpenGL texture identifier (GLuint) inside ImTextureID.
|
||||||
|
Whereas in the DirectX11 example binding we store a pointer to ID3D11ShaderResourceView inside ImTextureID, which is a higher-level structure tying together both the texture and information about its format and how to read it.
|
||||||
|
|
||||||
|
- If you have a custom engine built over e.g. OpenGL, instead of passing GLuint around you may decide to use a high-level data type to carry information about the texture as well as how to display it (shaders, etc.). The decision of what to use as ImTextureID can always be made better knowing how your codebase is designed. If your engine has high-level data types for "textures" and "material" then you may want to use them.
|
||||||
|
If you are starting with OpenGL or DirectX or Vulkan and haven't built much of a rendering engine over them, keeping the default ImTextureID representation suggested by the example bindings is probably the best choice.
|
||||||
|
(Advanced users may also decide to keep a low-level type in ImTextureID, and use ImDrawList callback and pass information to their renderer)
|
||||||
|
|
||||||
|
User code may do:
|
||||||
|
```cpp
|
||||||
|
// Cast our texture type to ImTextureID / void*
|
||||||
|
MyTexture* texture = g_CoffeeTableTexture;
|
||||||
|
ImGui::Image((void*)texture, ImVec2(texture->Width, texture->Height));
|
||||||
|
```
|
||||||
|
The renderer function called after ImGui::Render() will receive that same value that the user code passed:
|
||||||
|
```cpp
|
||||||
|
// Cast ImTextureID / void* stored in the draw command as our texture type
|
||||||
|
MyTexture* texture = (MyTexture*)pcmd->TextureId;
|
||||||
|
MyEngineBindTexture2D(texture);
|
||||||
|
```
|
||||||
|
Once you understand this design you will understand that loading image files and turning them into displayable textures is not within the scope of Dear ImGui.
|
||||||
|
This is by design and is actually a good thing, because it means your code has full control over your data types and how you display them.
|
||||||
|
If you want to display an image file (e.g. PNG file) into the screen, please refer to documentation and tutorials for the graphics API you are using.
|
||||||
|
|
||||||
|
Refer to [Image Loading and Displaying Examples](https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples) on the [Wiki](https://github.com/ocornut/imgui/wiki) to find simplified examples for loading textures with OpenGL, DirectX9 and DirectX11.
|
||||||
|
|
||||||
|
C/C++ tip: a void* is pointer-sized storage. You may safely store any pointer or integer into it by casting your value to ImTextureID / void*, and vice-versa.
|
||||||
|
Because both end-points (user code and rendering function) are under your control, you know exactly what is stored inside the ImTextureID / void*.
|
||||||
|
Examples:
|
||||||
|
```cpp
|
||||||
|
GLuint my_tex = XXX;
|
||||||
|
void* my_void_ptr;
|
||||||
|
my_void_ptr = (void*)(intptr_t)my_tex; // cast a GLuint into a void* (we don't take its address! we literally store the value inside the pointer)
|
||||||
|
my_tex = (GLuint)(intptr_t)my_void_ptr; // cast a void* into a GLuint
|
||||||
|
|
||||||
|
ID3D11ShaderResourceView* my_dx11_srv = XXX;
|
||||||
|
void* my_void_ptr;
|
||||||
|
my_void_ptr = (void*)my_dx11_srv; // cast a ID3D11ShaderResourceView* into an opaque void*
|
||||||
|
my_dx11_srv = (ID3D11ShaderResourceView*)my_void_ptr; // cast a void* into a ID3D11ShaderResourceView*
|
||||||
|
```
|
||||||
|
Finally, you may call `ImGui::ShowMetricsWindow()` to explore/visualize/understand how the ImDrawList are generated.
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q: How can I use my own math types instead of ImVec2/ImVec4?
|
||||||
|
|
||||||
|
You can edit [imconfig.h](https://github.com/ocornut/imgui/blob/master/imconfig.h) and setup the `IM_VEC2_CLASS_EXTRA`/`IM_VEC4_CLASS_EXTRA` macros to add implicit type conversions.
|
||||||
|
This way you'll be able to use your own types everywhere, e.g. passing `MyVector2` or `glm::vec2` to ImGui functions instead of `ImVec2`.
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q: How can I interact with standard C++ types (such as std::string and std::vector)?
|
||||||
|
- Being highly portable (bindings for several languages, frameworks, programming style, obscure or older platforms/compilers), and aiming for compatibility & performance suitable for every modern real-time game engines, dear imgui does not use any of std C++ types. We use raw types (e.g. char* instead of std::string) because they adapt to more use cases.
|
||||||
|
- To use ImGui::InputText() with a std::string or any resizable string class, see [misc/cpp/imgui_stdlib.h](https://github.com/ocornut/imgui/blob/master/misc/cpp/imgui_stdlib.h).
|
||||||
|
- To use combo boxes and list boxes with `std::vector` or any other data structure: the `BeginCombo()/EndCombo()` API
|
||||||
|
lets you iterate and submit items yourself, so does the `ListBoxHeader()/ListBoxFooter()` API.
|
||||||
|
Prefer using them over the old and awkward `Combo()/ListBox()` api.
|
||||||
|
- Generally for most high-level types you should be able to access the underlying data type.
|
||||||
|
You may write your own one-liner wrappers to facilitate user code (tip: add new functions in ImGui:: namespace from your code).
|
||||||
|
- Dear ImGui applications often need to make intensive use of strings. It is expected that many of the strings you will pass
|
||||||
|
to the API are raw literals (free in C/C++) or allocated in a manner that won't incur a large cost on your application.
|
||||||
|
Please bear in mind that using `std::string` on applications with large amount of UI may incur unsatisfactory performances.
|
||||||
|
Modern implementations of `std::string` often include small-string optimization (which is often a local buffer) but those
|
||||||
|
are not configurable and not the same across implementations.
|
||||||
|
- If you are finding your UI traversal cost to be too large, make sure your string usage is not leading to excessive amount
|
||||||
|
of heap allocations. Consider using literals, statically sized buffers and your own helper functions. A common pattern
|
||||||
|
is that you will need to build lots of strings on the fly, and their maximum length can be easily be scoped ahead.
|
||||||
|
One possible implementation of a helper to facilitate printf-style building of strings: https://github.com/ocornut/Str
|
||||||
|
This is a small helper where you can instance strings with configurable local buffers length. Many game engines will
|
||||||
|
provide similar or better string helpers.
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q: How can I display custom shapes? (using low-level ImDrawList API)
|
||||||
|
|
||||||
|
- You can use the low-level `ImDrawList` api to render shapes within a window.
|
||||||
|
|
||||||
|
```
|
||||||
|
ImGui::Begin("My shapes");
|
||||||
|
|
||||||
|
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||||
|
|
||||||
|
// Get the current ImGui cursor position
|
||||||
|
ImVec2 p = ImGui::GetCursorScreenPos();
|
||||||
|
|
||||||
|
// Draw a red circle
|
||||||
|
draw_list->AddCircleFilled(ImVec2(p.x + 50, p.y + 50), 30.0f, IM_COL32(255, 0, 0, 255), 16);
|
||||||
|
|
||||||
|
// Draw a 3 pixel thick yellow line
|
||||||
|
draw_list->AddLine(ImVec2(p.x, p.y), ImVec2(p.x + 100.0f, p.y + 100.0f), IM_COL32(255, 255, 0, 255), 3.0f);
|
||||||
|
|
||||||
|
// Advance the ImGui cursor to claim space in the window (otherwise the window will appears small and needs to be resized)
|
||||||
|
ImGui::Dummy(ImVec2(200, 200));
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
```
|
||||||
|

|
||||||
|
|
||||||
|
- Refer to "Demo > Examples > Custom Rendering" in the demo window and read the code of `ShowExampleAppCustomRendering()` in `imgui_demo.cpp` from more examples.
|
||||||
|
- To generate colors: you can use the macro `IM_COL32(255,255,255,255)` to generate them at compile time, or use `ImGui::GetColorU32(IM_COL32(255,255,255,255))` or `ImGui::GetColorU32(ImVec4(1.0f,1.0f,1.0f,1.0f))` to generate a color that is multiplied by the current value of `style.Alpha`.
|
||||||
|
- Math operators: if you have setup `IM_VEC2_CLASS_EXTRA` in `imconfig.h` to bind your own math types, you can use your own math types and their natural operators instead of ImVec2. ImVec2 by default doesn't export any math operators in the public API. You may use `#define IMGUI_DEFINE_MATH_OPERATORS` `#include "imgui_internal.h"` to use the internally defined math operators, but instead prefer using your own math library and set it up in `imconfig.h`.
|
||||||
|
- You can use `ImGui::GetBackgroundDrawList()` or `ImGui::GetForegroundDrawList()` to access draw lists which will be displayed behind and over every other dear imgui windows (one bg/fg drawlist per viewport). This is very convenient if you need to quickly display something on the screen that is not associated to a dear imgui window.
|
||||||
|
- You can also create your own dummy window and draw inside it. Call Begin() with the NoBackground | NoDecoration | NoSavedSettings | NoInputs flags (The `ImGuiWindowFlags_NoDecoration` flag itself is a shortcut for NoTitleBar | NoResize | NoScrollbar | NoCollapse). Then you can retrieve the ImDrawList* via GetWindowDrawList() and draw to it in any way you like.
|
||||||
|
- You can create your own ImDrawList instance. You'll need to initialize them with `ImGui::GetDrawListSharedData()`, or create your own instancing ImDrawListSharedData, and then call your renderer function with your own ImDrawList or ImDrawData data.
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Q&A: Fonts, Text
|
||||||
|
|
||||||
|
### Q: How can I load a different font than the default?
|
||||||
|
Use the font atlas to load the TTF/OTF file you want:
|
||||||
|
|
||||||
|
```c
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels);
|
||||||
|
io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8()
|
||||||
|
```
|
||||||
|
|
||||||
|
Default is ProggyClean.ttf, monospace, rendered at size 13, embedded in dear imgui's source code.
|
||||||
|
|
||||||
|
(Tip: monospace fonts are convenient because they allow to facilitate horizontal alignment directly at the string level.)
|
||||||
|
|
||||||
|
(Read the [docs/FONTS.txt](https://github.com/ocornut/imgui/blob/master/docs/FONTS.txt) file for more details about font loading.)
|
||||||
|
|
||||||
|
New programmers: remember that in C/C++ and most programming languages if you want to use a
|
||||||
|
backslash \ within a string literal, you need to write it double backslash "\\":
|
||||||
|
|
||||||
|
```c
|
||||||
|
io.Fonts->AddFontFromFileTTF("MyFolder\MyFont.ttf", size); // WRONG (you are escaping the M here!)
|
||||||
|
io.Fonts->AddFontFromFileTTF("MyFolder\\MyFont.ttf", size; // CORRECT
|
||||||
|
io.Fonts->AddFontFromFileTTF("MyFolder/MyFont.ttf", size); // ALSO CORRECT
|
||||||
|
```
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q: How can I easily use icons in my application?
|
||||||
|
The most convenient and practical way is to merge an icon font such as FontAwesome inside you
|
||||||
|
main font. Then you can refer to icons within your strings.
|
||||||
|
You may want to see `ImFontConfig::GlyphMinAdvanceX` to make your icon look monospace to facilitate alignment.
|
||||||
|
(Read the [docs/FONTS.txt](https://github.com/ocornut/imgui/blob/master/docs/FONTS.txt) file for more details about icons font loading.)
|
||||||
|
With some extra effort, you may use colorful icon by registering custom rectangle space inside the font atlas,
|
||||||
|
and copying your own graphics data into it. See docs/FONTS.txt about using the AddCustomRectFontGlyph API.
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q: How can I load multiple fonts?
|
||||||
|
Use the font atlas to pack them into a single texture:
|
||||||
|
(Read the [docs/FONTS.txt](https://github.com/ocornut/imgui/blob/master/docs/FONTS.txt) file and the code in ImFontAtlas for more details.)
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImFont* font0 = io.Fonts->AddFontDefault();
|
||||||
|
ImFont* font1 = io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels);
|
||||||
|
ImFont* font2 = io.Fonts->AddFontFromFileTTF("myfontfile2.ttf", size_in_pixels);
|
||||||
|
io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8()
|
||||||
|
// the first loaded font gets used by default
|
||||||
|
// use ImGui::PushFont()/ImGui::PopFont() to change the font at runtime
|
||||||
|
|
||||||
|
// Options
|
||||||
|
ImFontConfig config;
|
||||||
|
config.OversampleH = 2;
|
||||||
|
config.OversampleV = 1;
|
||||||
|
config.GlyphOffset.y -= 1.0f; // Move everything by 1 pixels up
|
||||||
|
config.GlyphExtraSpacing.x = 1.0f; // Increase spacing between characters
|
||||||
|
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_pixels, &config);
|
||||||
|
|
||||||
|
// Combine multiple fonts into one (e.g. for icon fonts)
|
||||||
|
static ImWchar ranges[] = { 0xf000, 0xf3ff, 0 };
|
||||||
|
ImFontConfig config;
|
||||||
|
config.MergeMode = true;
|
||||||
|
io.Fonts->AddFontDefault();
|
||||||
|
io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 16.0f, &config, ranges); // Merge icon font
|
||||||
|
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_pixels, NULL, &config, io.Fonts->GetGlyphRangesJapanese()); // Merge japanese glyphs
|
||||||
|
```
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic?
|
||||||
|
When loading a font, pass custom Unicode ranges to specify the glyphs to load.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// Add default Japanese ranges
|
||||||
|
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, io.Fonts->GetGlyphRangesJapanese());
|
||||||
|
|
||||||
|
// Or create your own custom ranges (e.g. for a game you can feed your entire game script and only build the characters the game need)
|
||||||
|
ImVector<ImWchar> ranges;
|
||||||
|
ImFontGlyphRangesBuilder builder;
|
||||||
|
builder.AddText("Hello world"); // Add a string (here "Hello world" contains 7 unique characters)
|
||||||
|
builder.AddChar(0x7262); // Add a specific character
|
||||||
|
builder.AddRanges(io.Fonts->GetGlyphRangesJapanese()); // Add one of the default ranges
|
||||||
|
builder.BuildRanges(&ranges); // Build the final result (ordered ranges with all the unique characters submitted)
|
||||||
|
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", 16.0f, NULL, ranges.Data);
|
||||||
|
```
|
||||||
|
|
||||||
|
All your strings needs to use UTF-8 encoding. In C++11 you can encode a string literal in UTF-8
|
||||||
|
by using the u8"hello" syntax. Specifying literal in your source code using a local code page
|
||||||
|
(such as CP-923 for Japanese or CP-1251 for Cyrillic) will NOT work!
|
||||||
|
Otherwise you can convert yourself to UTF-8 or load text data from file already saved as UTF-8.
|
||||||
|
|
||||||
|
Text input: it is up to your application to pass the right character code by calling `io.AddInputCharacter()`.
|
||||||
|
The applications in examples/ are doing that.
|
||||||
|
Windows: you can use the WM_CHAR or WM_UNICHAR or WM_IME_CHAR message (depending if your app is built using Unicode or MultiByte mode).
|
||||||
|
You may also use MultiByteToWideChar() or ToUnicode() to retrieve Unicode codepoints from MultiByte characters or keyboard state.
|
||||||
|
Windows: if your language is relying on an Input Method Editor (IME), you copy the HWND of your window to io.ImeWindowHandle in order for
|
||||||
|
the default implementation of io.ImeSetInputScreenPosFn() to set your Microsoft IME position correctly.
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Q&A: Concerns
|
||||||
|
|
||||||
|
### Q: Who uses Dear ImGui?
|
||||||
|
|
||||||
|
You may take a look at:
|
||||||
|
|
||||||
|
- [Quotes](https://github.com/ocornut/imgui/wiki/Quotes)
|
||||||
|
- [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui)
|
||||||
|
- [Gallery](https://github.com/ocornut/imgui/issues/2847)
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q: Can you create elaborate/serious tools with Dear ImGui?
|
||||||
|
|
||||||
|
Yes. People have written game editors, data browsers, debuggers, profilers and all sort of non-trivial tools with the library. In my experience the simplicity of the API is very empowering. Your UI runs close to your live data. Make the tools always-on and everybody in the team will be inclined to create new tools (as opposed to more "offline" UI toolkits where only a fraction of your team effectively creates tools). The list of sponsors below is also an indicator that serious game teams have been using the library.
|
||||||
|
|
||||||
|
Dear ImGui is very programmer centric and the immediate-mode GUI paradigm might require you to readjust some habits before you can realize its full potential. Dear ImGui is about making things that are simple, efficient and powerful.
|
||||||
|
|
||||||
|
Dear ImGui is built to be efficient and scalable toward the needs for AAA-quality applications running all day. The IMGUI paradigm offers different opportunities for optimization that the more typical RMGUI paradigm.
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q: Can you reskin the look of Dear ImGui?
|
||||||
|
|
||||||
|
Somehow. You can alter the look of the interface to some degree: changing colors, sizes, padding, rounding, fonts. However, as Dear ImGui is designed and optimized to create debug tools, the amount of skinning you can apply is limited. There is only so much you can stray away from the default look and feel of the interface. Dear ImGui is NOT designed to create user interface for games, although with ingenious use of the low-level API you can do it.
|
||||||
|
|
||||||
|
A reasonably skinned application may look like (screenshot from [#2529](https://github.com/ocornut/imgui/issues/2529#issuecomment-524281119))
|
||||||
|

|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q: Why using C++ (as opposed to C)?
|
||||||
|
|
||||||
|
Dear ImGui takes advantage of a few C++ languages features for convenience but nothing anywhere Boost insanity/quagmire. Dear ImGui does NOT require C++11 so it can be used with most old C++ compilers. Dear ImGui doesn't use any C++ header file. Language-wise, function overloading and default parameters are used to make the API easier to use and code more terse. Doing so I believe the API is sitting on a sweet spot and giving up on those features would make the API more cumbersome. Other features such as namespace, constructors and templates (in the case of the ImVector<> class) are also relied on as a convenience.
|
||||||
|
|
||||||
|
There is an auto-generated [c-api for Dear ImGui (cimgui)](https://github.com/cimgui/cimgui) by Sonoro1234 and Stephan Dilly. It is designed for creating binding to other languages. If possible, I would suggest using your target language functionalities to try replicating the function overloading and default parameters used in C++ else the API may be harder to use. Also see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings) for various third-party bindings.
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Q&A: Community
|
||||||
|
|
||||||
|
### Q: How can I help?
|
||||||
|
- Businesses: please reach out to `contact AT dearimgui.org` if you work in a place using Dear ImGui! We can discuss ways for your company to fund development via invoiced technical support, maintenance or sponsoring contacts. This is among the most useful thing you can do for Dear ImGui. With increased funding we can hire more people working on this project.
|
||||||
|
- Individuals: you can support continued maintenance and development via PayPal donations. See [README](https://github.com/ocornut/imgui/blob/master/docs/README.md).
|
||||||
|
- If you are experienced with Dear ImGui and C++, look at the [GitHub Issues](https://github.com/ocornut/imgui/issues), look at the [Wiki](https://github.com/ocornut/imgui/wiki), read [docs/TODO.txt](https://github.com/ocornut/imgui/blob/master/docs/TODO.txt) and see how you want to help and can help!
|
||||||
|
- Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
|
||||||
|
You may post screenshot or links in the [gallery threads](https://github.com/ocornut/imgui/issues/2847). Visuals are ideal as they inspire other programmers. Disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions.
|
||||||
|
- If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues or sometimes incomplete PR.
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
dear imgui, v1.71
|
dear imgui
|
||||||
(Font Readme)
|
FONTS DOCUMENTATION
|
||||||
|
|
||||||
---------------------------------------
|
Also read https://www.dearimgui.org/faq for more fonts related infos.
|
||||||
|
|
||||||
The code in imgui.cpp embeds a copy of 'ProggyClean.ttf' (by Tristan Grimmer),
|
The code in imgui.cpp embeds a copy of 'ProggyClean.ttf' (by Tristan Grimmer),
|
||||||
a 13 pixels high, pixel-perfect font used by default.
|
a 13 pixels high, pixel-perfect font used by default.
|
||||||
@ -10,11 +10,8 @@ We embed it font in source code so you can use Dear ImGui without any file syste
|
|||||||
You may also load external .TTF/.OTF files.
|
You may also load external .TTF/.OTF files.
|
||||||
The files in this folder are suggested fonts, provided as a convenience.
|
The files in this folder are suggested fonts, provided as a convenience.
|
||||||
|
|
||||||
Fonts are rasterized in a single texture at the time of calling either of io.Fonts->GetTexDataAsAlpha8()/GetTexDataAsRGBA32()/Build().
|
Please read the FAQ: https://www.dearimgui.org/faq
|
||||||
Also read dear imgui FAQ in imgui.cpp!
|
Please use the Discord server: http://discord.dearimgui.org and not the Github issue tracker for basic font loading questions.
|
||||||
|
|
||||||
If you have other loading/merging/adding fonts, you can post on the Dear ImGui "Getting Started" forum:
|
|
||||||
https://discourse.dearimgui.org/c/getting-started
|
|
||||||
|
|
||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
@ -22,13 +19,13 @@ If you have other loading/merging/adding fonts, you can post on the Dear ImGui "
|
|||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
- Readme First / FAQ
|
- Readme First / FAQ
|
||||||
- Using Icons
|
|
||||||
- Fonts Loading Instructions
|
- Fonts Loading Instructions
|
||||||
- FreeType rasterizer, Small font sizes
|
- Using Icons
|
||||||
|
- Using FreeType rasterizer
|
||||||
- Building Custom Glyph Ranges
|
- Building Custom Glyph Ranges
|
||||||
- Using custom colorful icons
|
- Using custom colorful icons
|
||||||
- Embedding Fonts in Source Code
|
- Embedding Fonts in Source Code
|
||||||
- Credits/Licences for fonts included in this folder
|
- Credits/Licences for fonts included in repository
|
||||||
- Fonts Links
|
- Fonts Links
|
||||||
|
|
||||||
|
|
||||||
@ -38,53 +35,13 @@ If you have other loading/merging/adding fonts, you can post on the Dear ImGui "
|
|||||||
|
|
||||||
- You can use the style editor ImGui::ShowStyleEditor() in the "Fonts" section to browse your fonts
|
- You can use the style editor ImGui::ShowStyleEditor() in the "Fonts" section to browse your fonts
|
||||||
and understand what's going on if you have an issue.
|
and understand what's going on if you have an issue.
|
||||||
- Make sure your font ranges data are persistent (available during the call to GetTexDataAsAlpha8()/GetTexDataAsRGBA32()/Build().
|
- Fonts are rasterized in a single texture at the time of calling either of io.Fonts->GetTexDataAsAlpha8()/GetTexDataAsRGBA32()/Build().
|
||||||
|
- Make sure your font ranges data are persistent and available at the time the font atlas is being built.
|
||||||
- Use C++11 u8"my text" syntax to encode literal strings as UTF-8. e.g.:
|
- Use C++11 u8"my text" syntax to encode literal strings as UTF-8. e.g.:
|
||||||
u8"hello"
|
u8"hello"
|
||||||
u8"こんにちは" // this will be encoded as UTF-8
|
u8"こんにちは" // this will be encoded as UTF-8
|
||||||
- If you want to include a backslash \ character in your string literal, you need to double them e.g. "folder\\filename".
|
- If you want to include a backslash \ character in your string literal, you need to double them e.g. "folder\\filename".
|
||||||
- Please use the Discourse forum (https://discourse.dearimgui.org) and not the Github issue tracker for basic font loading questions.
|
Read FAQ for details.
|
||||||
|
|
||||||
|
|
||||||
---------------------------------------
|
|
||||||
USING ICONS
|
|
||||||
---------------------------------------
|
|
||||||
|
|
||||||
Using an icon font (such as FontAwesome: http://fontawesome.io or OpenFontIcons. https://github.com/traverseda/OpenFontIcons)
|
|
||||||
is an easy and practical way to use icons in your Dear ImGui application.
|
|
||||||
A common pattern is to merge the icon font within your main font, so you can embed icons directly from your strings without
|
|
||||||
having to change fonts back and forth.
|
|
||||||
|
|
||||||
To refer to the icon UTF-8 codepoints from your C++ code, you may use those headers files created by Juliette Foucaut:
|
|
||||||
https://github.com/juliettef/IconFontCppHeaders
|
|
||||||
|
|
||||||
The C++11 version of those files uses the u8"" utf-8 encoding syntax + \u
|
|
||||||
#define ICON_FA_SEARCH u8"\uf002"
|
|
||||||
The pre-C++11 version has the values directly encoded as utf-8:
|
|
||||||
#define ICON_FA_SEARCH "\xEF\x80\x82"
|
|
||||||
|
|
||||||
Example Setup:
|
|
||||||
|
|
||||||
// Merge icons into default tool font
|
|
||||||
#include "IconsFontAwesome.h"
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
io.Fonts->AddFontDefault();
|
|
||||||
|
|
||||||
ImFontConfig config;
|
|
||||||
config.MergeMode = true;
|
|
||||||
config.GlyphMinAdvanceX = 13.0f; // Use if you want to make the icon monospaced
|
|
||||||
static const ImWchar icon_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
|
|
||||||
io.Fonts->AddFontFromFileTTF("fonts/fontawesome-webfont.ttf", 13.0f, &config, icon_ranges);
|
|
||||||
|
|
||||||
Example Usage:
|
|
||||||
|
|
||||||
// Usage, e.g.
|
|
||||||
ImGui::Text("%s among %d items", ICON_FA_SEARCH, count);
|
|
||||||
ImGui::Button(ICON_FA_SEARCH " Search");
|
|
||||||
// C string _literals_ can be concatenated at compilation time, e.g. "hello" " world"
|
|
||||||
// ICON_FA_SEARCH is defined as a string literal so this is the same as "A" "B" becoming "AB"
|
|
||||||
|
|
||||||
See Links below for other icons fonts and related tools.
|
|
||||||
|
|
||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
@ -98,6 +55,11 @@ Load default font:
|
|||||||
|
|
||||||
Load .TTF/.OTF file with:
|
Load .TTF/.OTF file with:
|
||||||
|
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
|
||||||
|
|
||||||
|
Load multiple fonts:
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImFont* font1 = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
|
ImFont* font1 = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
|
||||||
ImFont* font2 = io.Fonts->AddFontFromFileTTF("anotherfont.otf", size_pixels);
|
ImFont* font2 = io.Fonts->AddFontFromFileTTF("anotherfont.otf", size_pixels);
|
||||||
@ -116,23 +78,6 @@ For advanced options create a ImFontConfig structure and pass it to the AddFont
|
|||||||
config.GlyphExtraSpacing.x = 1.0f;
|
config.GlyphExtraSpacing.x = 1.0f;
|
||||||
ImFont* font = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, &config);
|
ImFont* font = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, &config);
|
||||||
|
|
||||||
Read about oversampling here:
|
|
||||||
https://github.com/nothings/stb/blob/master/tests/oversample
|
|
||||||
|
|
||||||
If you have very large number of glyphs or multiple fonts, the texture may become too big for your graphics API.
|
|
||||||
The typical result of failing to upload a texture is if every glyphs appears as white rectangles.
|
|
||||||
In particular, using a large range such as GetGlyphRangesChineseSimplifiedCommon() is not recommended unless you
|
|
||||||
set OversampleH/OversampleV to 1 and use a small font size.
|
|
||||||
Mind the fact that some graphics drivers have texture size limitation.
|
|
||||||
If you are building a PC application, mind the fact that your users may use hardware with lower limitations than yours.
|
|
||||||
Some solutions:
|
|
||||||
|
|
||||||
- 1) Reduce glyphs ranges by calculating them from source localization data.
|
|
||||||
You can use ImFontGlyphRangesBuilder for this purpose, this will be the biggest win!
|
|
||||||
- 2) You may reduce oversampling, e.g. config.OversampleH = config.OversampleV = 1, this will largely reduce your texture size.
|
|
||||||
- 3) Set io.Fonts.TexDesiredWidth to specify a texture width to minimize texture height (see comment in ImFontAtlas::Build function).
|
|
||||||
- 4) Set io.Fonts.Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight; to disable rounding the texture height to the next power of two.
|
|
||||||
|
|
||||||
Combine two fonts into one:
|
Combine two fonts into one:
|
||||||
|
|
||||||
// Load a first font
|
// Load a first font
|
||||||
@ -148,6 +93,25 @@ Combine two fonts into one:
|
|||||||
io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 18.0f, &config, icons_ranges);
|
io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 18.0f, &config, icons_ranges);
|
||||||
io.Fonts->Build();
|
io.Fonts->Build();
|
||||||
|
|
||||||
|
Font atlas is too large?
|
||||||
|
|
||||||
|
- If you have very large number of glyphs or multiple fonts, the texture may become too big for your graphics API.
|
||||||
|
- The typical result of failing to upload a texture is if every glyphs appears as white rectangles.
|
||||||
|
- In particular, using a large range such as GetGlyphRangesChineseSimplifiedCommon() is not recommended
|
||||||
|
unless you set OversampleH/OversampleV to 1 and use a small font size.
|
||||||
|
- Mind the fact that some graphics drivers have texture size limitation.
|
||||||
|
- If you are building a PC application, mind the fact that users may run on hardware with lower specs than yours.
|
||||||
|
|
||||||
|
Some solutions:
|
||||||
|
|
||||||
|
- 1) Reduce glyphs ranges by calculating them from source localization data.
|
||||||
|
You can use ImFontGlyphRangesBuilder for this purpose, this will be the biggest win!
|
||||||
|
- 2) You may reduce oversampling, e.g. config.OversampleH = config.OversampleV = 1, this will largely reduce your texture size.
|
||||||
|
- 3) Set io.Fonts.TexDesiredWidth to specify a texture width to minimize texture height (see comment in ImFontAtlas::Build function).
|
||||||
|
- 4) Set io.Fonts.Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight; to disable rounding the texture height to the next power of two.
|
||||||
|
- Read about oversampling here: https://github.com/nothings/stb/blob/master/tests/oversample
|
||||||
|
|
||||||
|
|
||||||
Add a fourth parameter to bake specific font ranges only:
|
Add a fourth parameter to bake specific font ranges only:
|
||||||
|
|
||||||
// Basic Latin, Extended Latin
|
// Basic Latin, Extended Latin
|
||||||
@ -166,6 +130,49 @@ Offset font vertically by altering the io.Font->DisplayOffset value:
|
|||||||
font->DisplayOffset.y = 1; // Render 1 pixel down
|
font->DisplayOffset.y = 1; // Render 1 pixel down
|
||||||
|
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
|
USING ICONS
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
|
Using an icon font (such as FontAwesome: http://fontawesome.io or OpenFontIcons. https://github.com/traverseda/OpenFontIcons)
|
||||||
|
is an easy and practical way to use icons in your Dear ImGui application.
|
||||||
|
A common pattern is to merge the icon font within your main font, so you can embed icons directly from your strings without
|
||||||
|
having to change fonts back and forth.
|
||||||
|
|
||||||
|
To refer to the icon UTF-8 codepoints from your C++ code, you may use those headers files created by Juliette Foucaut:
|
||||||
|
|
||||||
|
https://github.com/juliettef/IconFontCppHeaders
|
||||||
|
|
||||||
|
Those files contains a bunch of named #define which you can use to refer to specific icons of the font, e.g.:
|
||||||
|
|
||||||
|
#define ICON_FA_MUSIC "\xef\x80\x81"
|
||||||
|
#define ICON_FA_SEARCH "\xef\x80\x82"
|
||||||
|
|
||||||
|
Example Setup:
|
||||||
|
|
||||||
|
// Merge icons into default tool font
|
||||||
|
#include "IconsFontAwesome.h"
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.Fonts->AddFontDefault();
|
||||||
|
|
||||||
|
ImFontConfig config;
|
||||||
|
config.MergeMode = true;
|
||||||
|
config.GlyphMinAdvanceX = 13.0f; // Use if you want to make the icon monospaced
|
||||||
|
static const ImWchar icon_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
|
||||||
|
io.Fonts->AddFontFromFileTTF("fonts/fontawesome-webfont.ttf", 13.0f, &config, icon_ranges);
|
||||||
|
|
||||||
|
Example Usage:
|
||||||
|
|
||||||
|
// Usage, e.g.
|
||||||
|
ImGui::Text("%s among %d items", ICON_FA_SEARCH, count);
|
||||||
|
ImGui::Button(ICON_FA_SEARCH " Search");
|
||||||
|
|
||||||
|
Important to understand: C string _literals_ can be concatenated at compilation time, e.g. "hello" " world"
|
||||||
|
ICON_FA_SEARCH is defined as a string literal so this is the same as "A" "B" becoming "AB"
|
||||||
|
|
||||||
|
See Links below for other icons fonts and related tools.
|
||||||
|
|
||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
FREETYPE RASTERIZER, SMALL FONT SIZES
|
FREETYPE RASTERIZER, SMALL FONT SIZES
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
@ -212,9 +219,11 @@ texture, and blit/copy any graphics data of your choice into those rectangles.
|
|||||||
|
|
||||||
Pseudo-code:
|
Pseudo-code:
|
||||||
|
|
||||||
// Add font, then register one custom 13x13 rectangle mapped to glyph 'a' of this font
|
// Add font, then register two custom 13x13 rectangles mapped to glyph 'a' and 'b' of this font
|
||||||
ImFont* font = io.Fonts->AddFontDefault();
|
ImFont* font = io.Fonts->AddFontDefault();
|
||||||
int rect_id = io.Fonts->AddCustomRectFontGlyph(font, 'a', 13, 13, 13+1);
|
int rect_ids[2];
|
||||||
|
rect_ids[0] = io.Fonts->AddCustomRectFontGlyph(font, 'a', 13, 13, 13+1);
|
||||||
|
rect_ids[1] = io.Fonts->AddCustomRectFontGlyph(font, 'b', 13, 13, 13+1);
|
||||||
|
|
||||||
// Build atlas
|
// Build atlas
|
||||||
io.Fonts->Build();
|
io.Fonts->Build();
|
||||||
@ -224,14 +233,18 @@ Pseudo-code:
|
|||||||
int tex_width, tex_height;
|
int tex_width, tex_height;
|
||||||
io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_width, &tex_height);
|
io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_width, &tex_height);
|
||||||
|
|
||||||
// Fill the custom rectangle with red pixels (in reality you would draw/copy your bitmap data here)
|
for (int rect_n = 0; rect_n < IM_ARRAYSIZE(rect_ids); rect_n++)
|
||||||
if (const ImFontAtlas::CustomRect* rect = io.Fonts->GetCustomRectByIndex(rect_id))
|
|
||||||
{
|
{
|
||||||
for (int y = 0; y < rect->Height; y++)
|
int rect_id = rects_ids[rect_n];
|
||||||
|
if (const ImFontAtlas::CustomRect* rect = io.Fonts->GetCustomRectByIndex(rect_id))
|
||||||
{
|
{
|
||||||
ImU32* p = (ImU32*)tex_pixels + (rect->Y + y) * tex_width + (rect->X);
|
// Fill the custom rectangle with red pixels (in reality you would draw/copy your bitmap data here!)
|
||||||
for (int x = rect->Width; x > 0; x--)
|
for (int y = 0; y < rect->Height; y++)
|
||||||
*p++ = IM_COL32(255, 0, 0, 255);
|
{
|
||||||
|
ImU32* p = (ImU32*)tex_pixels + (rect->Y + y) * tex_width + (rect->X);
|
||||||
|
for (int x = rect->Width; x > 0; x--)
|
||||||
|
*p++ = IM_COL32(255, 0, 0, 255);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,9 +266,11 @@ or:
|
|||||||
|
|
||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
CREDITS/LICENSES FOR FONTS INCLUDED IN THIS FOLDER
|
CREDITS/LICENSES FOR FONTS INCLUDED IN REPOSITORY
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
|
Some fonts are available in the misc/fonts/ folder:
|
||||||
|
|
||||||
Roboto-Medium.ttf
|
Roboto-Medium.ttf
|
||||||
|
|
||||||
Apache License 2.0
|
Apache License 2.0
|
||||||
@ -328,15 +343,17 @@ REGULAR FONTS
|
|||||||
(Japanese) M+ fonts by Coji Morishita are free
|
(Japanese) M+ fonts by Coji Morishita are free
|
||||||
http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/index-en.html
|
http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/index-en.html
|
||||||
|
|
||||||
MONOSPACE FONTS
|
MONOSPACE FONTS (PIXEL PERFECT)
|
||||||
|
|
||||||
(Pixel Perfect) Proggy Fonts, by Tristan Grimmer
|
Proggy Fonts, by Tristan Grimmer
|
||||||
http://www.proggyfonts.net or http://upperbounds.net
|
http://www.proggyfonts.net or http://upperbounds.net
|
||||||
|
|
||||||
(Pixel Perfect) Sweet16, Sweet16 Mono, by Martin Sedlak (Latin + Supplemental + Extended A)
|
Sweet16, Sweet16 Mono, by Martin Sedlak (Latin + Supplemental + Extended A)
|
||||||
https://github.com/kmar/Sweet16Font
|
https://github.com/kmar/Sweet16Font
|
||||||
Also include .inl file to use directly in dear imgui.
|
Also include .inl file to use directly in dear imgui.
|
||||||
|
|
||||||
|
MONOSPACE FONTS (REGULAR)
|
||||||
|
|
||||||
Google Noto Mono Fonts
|
Google Noto Mono Fonts
|
||||||
https://www.google.com/get/noto/
|
https://www.google.com/get/noto/
|
||||||
|
|
286
docs/README.md
286
docs/README.md
@ -1,57 +1,49 @@
|
|||||||
dear imgui
|
dear imgui
|
||||||
=====
|
=====
|
||||||
[](https://travis-ci.org/ocornut/imgui)
|
[](https://github.com/ocornut/imgui/actions?workflow=build)
|
||||||
[](https://scan.coverity.com/projects/4720)
|
|
||||||
|
|
||||||
_(This library is free as in freedom, but needs your support to sustain its development. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using dear imgui, please consider reaching out for invoiced financial support. If you are an individual using dear imgui, please consider donating via Patreon or PayPal.)_
|
<sub>(This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using dear imgui, please consider reaching out.)</sub>
|
||||||
|
|
||||||
Individuals/hobbyists: support continued maintenance and development via the monthly Patreon:
|
Businesses: support continued development via invoiced technical support, maintenance, sponsoring contracts:
|
||||||
<br> [](http://www.patreon.com/imgui)
|
<br> _E-mail: contact @ dearimgui dot org_
|
||||||
|
|
||||||
Individuals/hobbyists: support continued maintenance and development via PayPal:
|
Individuals: support continued maintenance and development via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S) donations.
|
||||||
<br> [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S)
|
|
||||||
|
|
||||||
Businesses: support continued maintenance and development via support contracts or sponsoring:
|
----
|
||||||
<br> _E-mail: omarcornut at gmail dot com_
|
|
||||||
|
|
||||||
Dear ImGui is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
|
Dear ImGui is a **bloat-free graphical user interface library for C++**. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
|
||||||
|
|
||||||
Dear ImGui is designed to enable fast iterations and to empower programmers to create content creation tools and visualization / debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and lacks certain features normally found in more high-level libraries.
|
Dear ImGui is designed to **enable fast iterations** and to **empower programmers** to create **content creation tools and visualization / debug tools** (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and lacks certain features normally found in more high-level libraries.
|
||||||
|
|
||||||
Dear ImGui is particularly suited to integration in games engine (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard.
|
Dear ImGui is particularly suited to integration in games engine (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard.
|
||||||
|
|
||||||
See [Software using dear imgui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui), [Quotes](https://github.com/ocornut/imgui/wiki/Quotes) and [Gallery](https://github.com/ocornut/imgui/issues/2529) pages to get an idea of its use cases.
|
| [Usage](#usage) - [How it works](#how-it-works) - [Demo](#demo) - [Integration](#integration) |
|
||||||
|
:----------------------------------------------------------: |
|
||||||
Dear ImGui is self-contained within a few files that you can easily copy and compile into your application/engine:
|
| [Upcoming changes](#upcoming-changes) - [Gallery](#gallery) - [Support, FAQ](#support-frequently-asked-questions-faq) - [How to help](#how-to-help) - [Sponsors](#sponsors) - [Credits](#credits) - [License](#license) |
|
||||||
- imgui.cpp
|
| [Wiki](https://github.com/ocornut/imgui/wiki) - [Language & frameworks bindings](https://github.com/ocornut/imgui/wiki/Bindings) - [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) - [User quotes](https://github.com/ocornut/imgui/wiki/Quotes) |
|
||||||
- imgui.h
|
|
||||||
- imgui_demo.cpp
|
|
||||||
- imgui_draw.cpp
|
|
||||||
- imgui_widgets.cpp
|
|
||||||
- imgui_internal.h
|
|
||||||
- imconfig.h (empty by default, user-editable)
|
|
||||||
- imstb_rectpack.h
|
|
||||||
- imstb_textedit.h
|
|
||||||
- imstb_truetype.h
|
|
||||||
|
|
||||||
No specific build process is required. You can add the .cpp files to your project or #include them from an existing file.
|
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
Your code passes mouse/keyboard/gamepad inputs and settings to Dear ImGui (see example applications for more details). After Dear ImGui is setup, you can use it from \_anywhere\_ in your program loop:
|
**The core of Dear ImGui is self-contained within a few platform-agnostic files** which you can easily compile in your application/engine. They are all the files in the root folder of the repository (imgui.cpp, imgui.h, imgui_demo.cpp, imgui_draw.cpp etc.).
|
||||||
|
|
||||||
|
**No specific build process is required**. You can add the .cpp files to your existing project.
|
||||||
|
|
||||||
|
You will need a backend to integrate Dear ImGui in your app. The backend passes mouse/keyboard/gamepad inputs and variety of settings to Dear ImGui, and is in charge of rendering the resulting vertices.
|
||||||
|
|
||||||
|
**Backends for a variety of graphics api and rendering platforms** are provided in the [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder, along with example applications. See the [Integration](#integration) section of this document for details. You may also create your own backend. Anywhere where you can render textured triangles, you can render Dear ImGui.
|
||||||
|
|
||||||
|
After Dear ImGui is setup in your application, you can use it from \_anywhere\_ in your program loop:
|
||||||
|
|
||||||
Code:
|
Code:
|
||||||
```cpp
|
```cp
|
||||||
ImGui::Text("Hello, world %d", 123);
|
ImGui::Text("Hello, world %d", 123);
|
||||||
if (ImGui::Button("Save"))
|
if (ImGui::Button("Save"))
|
||||||
{
|
MySaveFunction();
|
||||||
// do stuff
|
|
||||||
}
|
|
||||||
ImGui::InputText("string", buf, IM_ARRAYSIZE(buf));
|
ImGui::InputText("string", buf, IM_ARRAYSIZE(buf));
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
||||||
```
|
```
|
||||||
Result:
|
Result:
|
||||||
<br>
|
<br> 
|
||||||
<br>_(settings: Dark style (left), Light style (right) / Font: Roboto-Medium, 16px / Rounding: 5)_
|
<br>_(settings: Dark style (left), Light style (right) / Font: Roboto-Medium, 16px / Rounding: 5)_
|
||||||
|
|
||||||
Code:
|
Code:
|
||||||
@ -88,97 +80,58 @@ ImGui::End();
|
|||||||
Result:
|
Result:
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
Dear ImGui allows you **create elaborate tools** as well as very short-lived ones. On the extreme side of short-livedness: using the Edit&Continue (hot code reload) feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! Dear ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, an entire game making editor/framework, etc.
|
||||||
|
|
||||||
### How it works
|
### How it works
|
||||||
|
|
||||||
Check out the References section if you want to understand the core principles behind the IMGUI paradigm. An IMGUI tries to minimize superfluous state duplication, state synchronization and state retention from the user's point of view. It is less error prone (less code and less bugs) than traditional retained-mode interfaces, and lends itself to create dynamic user interfaces.
|
Check out the Wiki's [About the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#About-the-IMGUI-paradigm) section if you want to understand the core principles behind the IMGUI paradigm. An IMGUI tries to minimize superfluous state duplication, state synchronization and state retention from the user's point of view. It is less error prone (less code and less bugs) than traditional retained-mode interfaces, and lends itself to create dynamic user interfaces.
|
||||||
|
|
||||||
Dear ImGui outputs vertex buffers and command lists that you can easily render in your application. The number of draw calls and state changes required to render them is fairly small. Because Dear ImGui doesn't know or touch graphics state directly, you can call its functions anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate dear imgui with your existing codebase.
|
Dear ImGui outputs vertex buffers and command lists that you can easily render in your application. The number of draw calls and state changes required to render them is fairly small. Because Dear ImGui doesn't know or touch graphics state directly, you can call its functions anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate dear imgui with your existing codebase.
|
||||||
|
|
||||||
_A common misunderstanding is to mistake immediate mode gui for immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes as the gui functions are called. This is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are decently optimal and you can render them later, in your app or even remotely._
|
_A common misunderstanding is to mistake immediate mode gui for immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes as the gui functions are called. This is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are decently optimal and you can render them later, in your app or even remotely._
|
||||||
|
|
||||||
Dear ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue (hot code reload) feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! Dear ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, an entire game making editor/framework, etc.
|
### Demo
|
||||||
|
|
||||||
Demo Binaries
|
Calling the `ImGui::ShowDemoWindow()` function will create a demo window showcasing variety of features and examples. The code is always available for reference in `imgui_demo.cpp`.
|
||||||
-------------
|
|
||||||
|

|
||||||
|
|
||||||
You should be able to build the examples from sources (tested on Windows/Mac/Linux). If you don't, let me know! If you want to have a quick look at some Dear ImGui features, you can download Windows binaries of the demo app here:
|
You should be able to build the examples from sources (tested on Windows/Mac/Linux). If you don't, let me know! If you want to have a quick look at some Dear ImGui features, you can download Windows binaries of the demo app here:
|
||||||
- [imgui-demo-binaries-20190219.zip](http://www.dearimgui.org/binaries/imgui-demo-binaries-20190219.zip) (Windows binaries, Dear ImGui 1.68 built 2019/02/19, master branch, 5 executables)
|
- [imgui-demo-binaries-20190715.zip](http://www.dearimgui.org/binaries/imgui-demo-binaries-20190715.zip) (Windows binaries, 1.72 WIP, built 2019/07/15, master branch, 5 executables)
|
||||||
|
|
||||||
The demo applications are unfortunately not yet DPI aware so expect some blurriness on a 4K screen. For DPI awareness in your application, you can load/reload your font at different scale, and scale your Style with `style.ScaleAllSizes()`.
|
The demo applications are not DPI aware so expect some blurriness on a 4K screen. For DPI awareness in your application, you can load/reload your font at different scale, and scale your style with `style.ScaleAllSizes()`.
|
||||||
|
|
||||||
Bindings
|
### Integration
|
||||||
--------
|
|
||||||
|
|
||||||
Integrating Dear ImGui within your custom engine is a matter of 1) wiring mouse/keyboard/gamepad inputs 2) uploading one texture to your GPU/render engine 3) providing a render function that can bind textures and render textured triangles. The [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder is populated with applications doing just that. If you are an experienced programmer at ease with those concepts, it should take you about an hour to integrate Dear ImGui in your custom engine. Make sure to spend time reading the FAQ, the comments and other documentation!
|
On most platforms and when using C++, **you should be able to use a combination of the [imgui_impl_xxxx](https://github.com/ocornut/imgui/tree/master/examples) files without modification** (e.g. `imgui_impl_win32.cpp` + `imgui_impl_dx11.cpp`). If your engine supports multiple platforms, consider using more of the imgui_impl_xxxx files instead of rewriting them: this will be less work for you and you can get Dear ImGui running immediately. You can _later_ decide to rewrite a custom binding using your custom engine functions if you wish so.
|
||||||
|
|
||||||
_NB: those third-party bindings may be more or less maintained, more or less close to the original API (as people who create language bindings sometimes haven't used the C++ API themselves.. for the good reason that they aren't C++ users). Dear ImGui was designed with C++ in mind and some of the subtleties may be lost in translation with other languages. If your language supports it, I would suggest replicating the function overloading and default parameters used in the original, else the API may be harder to use. In doubt, please check the original C++ version first!_
|
Integrating Dear ImGui within your custom engine is a matter of 1) wiring mouse/keyboard/gamepad inputs 2) uploading one texture to your GPU/render engine 3) providing a render function that can bind textures and render textured triangles. The [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder is populated with applications doing just that. If you are an experienced programmer at ease with those concepts, it should take you less than two hours to integrate Dear ImGui in your custom engine. **Make sure to spend time reading the [FAQ](https://www.dearimgui.org/faq), comments, and some of the examples/ application!**
|
||||||
|
|
||||||
Languages: (third-party bindings)
|
Officially maintained bindings (in repository):
|
||||||
- C: [cimgui](https://github.com/cimgui/cimgui) (2018: now auto-generated! you can use its json output to generate bindings for other languages)
|
- Renderers: DirectX9, DirectX10, DirectX11, DirectX12, OpenGL (legacy), OpenGL3/ES/ES2 (modern), Vulkan, Metal.
|
||||||
- C#/.Net: [ImGui.NET](https://github.com/mellinoe/ImGui.NET)
|
- Platforms: GLFW, SDL2, Win32, Glut, OSX.
|
||||||
- ChaiScript: [imgui-chaiscript](https://github.com/JuJuBoSc/imgui-chaiscript)
|
- Frameworks: Emscripten, Allegro5, Marmalade.
|
||||||
- D: [DerelictImgui](https://github.com/Extrawurst/DerelictImgui)
|
|
||||||
- Go: [imgui-go](https://github.com/inkyblackness/imgui-go) or [go-imgui](https://github.com/Armored-Dragon/go-imgui)
|
|
||||||
- Haxe/hxcpp: [linc_imgui](https://github.com/Aidan63/linc_imgui)
|
|
||||||
- Java: [jimgui](https://github.com/ice1000/jimgui)
|
|
||||||
- JavaScript: [imgui-js](https://github.com/flyover/imgui-js)
|
|
||||||
- Julia: [CImGui.jl](https://github.com/Gnimuc/CImGui.jl)
|
|
||||||
- Lua: [LuaJIT-ImGui](https://github.com/sonoro1234/LuaJIT-ImGui), [imgui_lua_bindings](https://github.com/patrickriordan/imgui_lua_bindings) or [lua-ffi-bindings](https://github.com/thenumbernine/lua-ffi-bindings)
|
|
||||||
- Odin: [odin-dear_imgui](https://github.com/ThisDrunkDane/odin-dear_imgui)
|
|
||||||
- Pascal: [imgui-pas](https://github.com/dpethes/imgui-pas)
|
|
||||||
- PureBasic: [pb-cimgui](https://github.com/hippyau/pb-cimgui)
|
|
||||||
- Python: [pyimgui](https://github.com/swistakm/pyimgui) or [bimpy](https://github.com/podgorskiy/bimpy)
|
|
||||||
- Ruby: [ruby-imgui](https://github.com/vaiorabbit/ruby-imgui)
|
|
||||||
- Rust: [imgui-rs](https://github.com/Gekkio/imgui-rs) or [imgui-rust](https://github.com/nsf/imgui-rust)
|
|
||||||
- Swift [swift-imgui](https://github.com/mnmly/Swift-imgui)
|
|
||||||
|
|
||||||
Frameworks:
|
Third-party bindings (see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings/) page):
|
||||||
- Renderers: DirectX 9/10/11/12, Metal, OpenGL2, OpenGL3+/ES2/ES3, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
|
- Languages: C, C#/.Net, ChaiScript, D, Go, Haskell, Haxe/hxcpp, Java, JavaScript, Julia, Kotlin, Lua, Odin, Pascal, PureBasic, Python, Ruby, Rust, Swift...
|
||||||
- Platform: GLFW, SDL, Win32, OSX, GLUT: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
|
- Frameworks: AGS/Adventure Game Studio, Amethyst, bsf, Cinder, Cocos2d-x, Diligent Engine, Flexium, GML/Game Maker Studio2, GTK3+OpenGL3, Irrlicht Engine, LÖVE+LUA, Magnum, NanoRT, Nim Game Lib, Ogre, openFrameworks, OSG/OpenSceneGraph, Orx, px_render, Qt/QtDirect3D, SFML, Sokol, Unreal Engine 4, vtk, Win32 GDI.
|
||||||
- Framework: Allegro 5, Emscripten, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples)
|
- Note that C bindings ([cimgui](https://github.com/cimgui/cimgui)) are auto-generated, you can use its json/lua output to generate bindings for other languages.
|
||||||
- Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421)
|
|
||||||
- Cinder: [Cinder-ImGui](https://github.com/simongeilfus/Cinder-ImGui)
|
|
||||||
- Cocos2d-x: [imguix](https://github.com/c0i/imguix), [#551](https://github.com/ocornut/imgui/issues/551)
|
|
||||||
- Flexium: [FlexGUI](https://github.com/DXsmiley/FlexGUI)
|
|
||||||
- GML/GameMakerStudio2: [ImGuiGML](https://marketplace.yoyogames.com/assets/6221/imguigml)
|
|
||||||
- Irrlicht: [IrrIMGUI](https://github.com/ZahlGraf/IrrIMGUI)
|
|
||||||
- Ogre: [ogreimgui](https://bitbucket.org/LMCrashy/ogreimgui/src)
|
|
||||||
- OpenFrameworks: [ofxImGui](https://github.com/jvcleave/ofxImGui)
|
|
||||||
- OpenSceneGraph/OSG: [gist](https://gist.github.com/fulezi/d2442ca7626bf270226014501357042c)
|
|
||||||
- ORX: [ImGuiOrx](https://github.com/thegwydd/ImGuiOrx), [#1843](https://github.com/ocornut/imgui/pull/1843)
|
|
||||||
- px_render: [px_render_imgui.h](https://github.com/pplux/px/blob/master/px_render_imgui.h), [#1935](https://github.com/ocornut/imgui/pull/1935)
|
|
||||||
- LÖVE+Lua: [love-imgui](https://github.com/slages/love-imgui)
|
|
||||||
- Magnum: [ImGuiIntegration](https://doc.magnum.graphics/magnum/namespaceMagnum_1_1ImGuiIntegration.html) ([example](https://doc.magnum.graphics/magnum/examples-imgui.html))
|
|
||||||
- NanoRT: [syoyo/imgui](https://github.com/syoyo/imgui/tree/nanort)
|
|
||||||
- Qt: [imgui-qt3d](https://github.com/alpqr/imgui-qt3d) / [QOpenGLWindow (qtimgui)](https://github.com/ocornut/imgui/issues/1910) / [QtDirect3D](https://github.com/giladreich/QtDirect3D) / [qt6](https://github.com/alpqr/qvk6/tree/imgui/examples/rhi/imguidemo)
|
|
||||||
- SFML: [imgui-sfml](https://github.com/eliasdaler/imgui-sfml)
|
|
||||||
- Software renderer: [imgui_software_renderer](https://github.com/emilk/imgui_software_renderer)
|
|
||||||
- Unreal Engine 4: [segross/UnrealImGui](https://github.com/segross/UnrealImGui) or [sronsse/UnrealEngine_ImGui](https://github.com/sronsse/UnrealEngine_ImGui)
|
|
||||||
|
|
||||||
For other bindings: see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings/). Also see [Wiki](https://github.com/ocornut/imgui/wiki) for more links and ideas.
|
Also see [Wiki](https://github.com/ocornut/imgui/wiki) for more links and ideas.
|
||||||
|
|
||||||
Roadmap
|
### Upcoming Changes
|
||||||
-------
|
|
||||||
Some of the goals for 2019 are:
|
Some of the goals for 2020 are:
|
||||||
- Finish work on docking, tabs. (see [#2109](https://github.com/ocornut/imgui/issues/2109), in public `docking` branch looking for feedback)
|
- Finish work on docking, tabs. (see [#2109](https://github.com/ocornut/imgui/issues/2109), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch looking for feedback)
|
||||||
- Finish work on multiple viewports / multiple OS windows. (see [#1542](https://github.com/ocornut/imgui/issues/1542), in public `docking` branch looking for feedback)
|
- Finish work on multiple viewports / multiple OS windows. (see [#1542](https://github.com/ocornut/imgui/issues/1542), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch looking for feedback)
|
||||||
- Finish work on gamepad/keyboard controls. (see [#787](https://github.com/ocornut/imgui/issues/787))
|
- Finish work on gamepad/keyboard controls. (see [#787](https://github.com/ocornut/imgui/issues/787))
|
||||||
|
- Finish work on new Tables API (to replace Columns). (see [#2957](https://github.com/ocornut/imgui/issues/2957))
|
||||||
- Add an automation and testing system, both to test the library and end-user apps. (see [#435](https://github.com/ocornut/imgui/issues/435))
|
- Add an automation and testing system, both to test the library and end-user apps. (see [#435](https://github.com/ocornut/imgui/issues/435))
|
||||||
- Make Columns better. (they are currently pretty terrible!)
|
- Make the examples look better, improve styles, improve font support, make the examples hi-DPI and multi-DPI aware.
|
||||||
- Make the examples look better, improve styles, improve font support, make the examples hi-DPI aware.
|
|
||||||
|
|
||||||
Gallery
|
### Gallery
|
||||||
-------
|
|
||||||
User screenshots:
|
For more user-submitted screenshots of projects using Dear ImGui, check out the [Gallery Threads](https://github.com/ocornut/imgui/issues/2847)!
|
||||||
<br>[Gallery Part 1](https://github.com/ocornut/imgui/issues/123) (Feb 2015 to Feb 2016)
|
|
||||||
<br>[Gallery Part 2](https://github.com/ocornut/imgui/issues/539) (Feb 2016 to Aug 2016)
|
|
||||||
<br>[Gallery Part 3](https://github.com/ocornut/imgui/issues/772) (Aug 2016 to Jan 2017)
|
|
||||||
<br>[Gallery Part 4](https://github.com/ocornut/imgui/issues/973) (Jan 2017 to Aug 2017)
|
|
||||||
<br>[Gallery Part 5](https://github.com/ocornut/imgui/issues/1269) (Aug 2017 to Feb 2018)
|
|
||||||
<br>[Gallery Part 6](https://github.com/ocornut/imgui/issues/1607) (Feb 2018 to June 2018)
|
|
||||||
<br>[Gallery Part 7](https://github.com/ocornut/imgui/issues/1902) (June 2018 to January 2019)
|
|
||||||
<br>[Gallery Part 8](https://github.com/ocornut/imgui/issues/2265) (January 2019 to May 2019)
|
|
||||||
<br>[Gallery Part 9](https://github.com/ocornut/imgui/issues/2529) (May 2019 onward)
|
|
||||||
|
|
||||||
Custom engine
|
Custom engine
|
||||||
[](https://cloud.githubusercontent.com/assets/8225057/20628927/33e14cac-b329-11e6-80f6-9524e93b048a.png)
|
[](https://cloud.githubusercontent.com/assets/8225057/20628927/33e14cac-b329-11e6-80f6-9524e93b048a.png)
|
||||||
@ -186,47 +139,22 @@ Custom engine
|
|||||||
Custom engine
|
Custom engine
|
||||||
[](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v160/editor_white.png)
|
[](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v160/editor_white.png)
|
||||||
|
|
||||||
Demo window
|
|
||||||

|
|
||||||
|
|
||||||
[Tracy Profiler](https://bitbucket.org/wolfpld/tracy)
|
[Tracy Profiler](https://bitbucket.org/wolfpld/tracy)
|
||||||

|

|
||||||
|
|
||||||
References
|
### Support, Frequently Asked Questions (FAQ)
|
||||||
----------
|
|
||||||
|
|
||||||
The Immediate Mode GUI paradigm may at first appear unusual to some users. This is mainly because "Retained Mode" GUIs have been so widespread and predominant. The following links can give you a better understanding about how Immediate Mode GUIs works.
|
Most common questions will be answered by the [Frequently Asked Questions (FAQ)](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md) page.
|
||||||
- [Johannes 'johno' Norneby's article](http://www.johno.se/book/imgui.html).
|
|
||||||
- [A presentation by Rickard Gustafsson and Johannes Algelind](http://www.cse.chalmers.se/edu/year/2011/course/TDA361/Advanced%20Computer%20Graphics/IMGUI.pdf).
|
|
||||||
- [Jari Komppa's tutorial on building an IMGUI library](http://iki.fi/sol/imgui/).
|
|
||||||
- [Casey Muratori's original video that popularized the concept](https://mollyrocket.com/861).
|
|
||||||
- [Nicolas Guillemot's CppCon'16 flash-talk about Dear ImGui](https://www.youtube.com/watch?v=LSRJ1jZq90k).
|
|
||||||
- [Thierry Excoffier's Zero Memory Widget](http://perso.univ-lyon1.fr/thierry.excoffier/ZMW/).
|
|
||||||
|
|
||||||
See the [Wiki](https://github.com/ocornut/imgui/wiki) for more references and [Bindings](https://github.com/ocornut/imgui/wiki/Bindings) for third-party bindings to different languages and frameworks.
|
See: [Wiki](https://github.com/ocornut/imgui/wiki) for many links, references, articles.
|
||||||
|
|
||||||
Support
|
See: [Articles about the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#Articles-about-the-IMGUI-paradigm) to read/learn about the Immediate Mode GUI paradigm.
|
||||||
-------
|
|
||||||
|
|
||||||
If you are new to Dear ImGui and have issues with: compiling, linking, adding fonts, wiring inputs, running or displaying Dear ImGui: please post on the Discourse forums: https://discourse.dearimgui.org.
|
If you are new to Dear ImGui and have issues with: compiling, linking, adding fonts, wiring inputs, running or displaying Dear ImGui: you can use [Discord server](http://discord.dearimgui.org).
|
||||||
|
|
||||||
Otherwise for any other questions, bug reports, requests, feedback, you may post on https://github.com/ocornut/imgui/issues. Please read and fill the New Issue template carefully.
|
Otherwise, for any other questions, bug reports, requests, feedback, you may post on https://github.com/ocornut/imgui/issues. Please read and fill the New Issue template carefully.
|
||||||
|
|
||||||
Private support is available for paying customers.
|
Paid private support is available for business customers (E-mail: _contact @ dearimgui dot org_).
|
||||||
|
|
||||||
Frequently Asked Question (FAQ)
|
|
||||||
-------------------------------
|
|
||||||
|
|
||||||
**Where is the documentation?**
|
|
||||||
|
|
||||||
This library is poorly documented at the moment and expects of the user to be acquainted with C/C++.
|
|
||||||
- Run the examples/ applications and explore them.
|
|
||||||
- See demo code in imgui_demo.cpp and particularly the ImGui::ShowDemoWindow() function.
|
|
||||||
- The demo covers most features of Dear ImGui, so you can read the code and see its output.
|
|
||||||
- See documentation and comments at the top of imgui.cpp + effectively imgui.h.
|
|
||||||
- Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the examples/ folder to explain how to integrate Dear ImGui with your own engine/application.
|
|
||||||
- Your programming IDE is your friend, find the type or function declaration to find comments associated to it.
|
|
||||||
- We obviously needs better documentation! Consider contributing or becoming a [Patron](http://www.patreon.com/imgui) to promote this effort.
|
|
||||||
|
|
||||||
**Which version should I get?**
|
**Which version should I get?**
|
||||||
|
|
||||||
@ -236,97 +164,63 @@ You may also peak at the [Multi-Viewport](https://github.com/ocornut/imgui/issue
|
|||||||
|
|
||||||
**Who uses Dear ImGui?**
|
**Who uses Dear ImGui?**
|
||||||
|
|
||||||
See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes) and [Software using dear imgui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) Wiki pages for a list of games/software which are publicly known to use dear imgui. Please add yours if you can!
|
See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes) and [Software using dear imgui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) Wiki pages for a list of games/software which are publicly known to use dear imgui. Please add yours if you can! Also see the [Gallery Threads](https://github.com/ocornut/imgui/issues/2847)!
|
||||||
|
|
||||||
**Why the odd dual naming, "Dear ImGui" vs "ImGui"?**
|
How to help
|
||||||
|
-----------
|
||||||
The library started its life as "ImGui" due to the fact that I didn't give it a proper name when I released 1.0 and had no particular expectation that it would take off. However, the term IMGUI (immediate-mode graphical user interface) was coined before and is being used in variety of other situations (e.g. Unity uses it own implementation of the IMGUI paradigm). To reduce this ambiguity without affecting existing codebases, I have decided on an alternate, longer name "Dear ImGui" that people can use to refer to this specific library. Please try to refer to this library as "Dear ImGui".
|
|
||||||
|
|
||||||
**How can I tell whether to dispatch mouse/keyboard to Dear ImGui or to my application?**
|
|
||||||
<br>**How can I display an image? What is ImTextureID, how does it works?**
|
|
||||||
<br>**Why are multiple widgets reacting when I interact with a single one? How can I have multiple widgets with the same label or with an empty label? A primer on labels and the ID Stack...**
|
|
||||||
<br>**How can I use my own math types instead of ImVec2/ImVec4?**
|
|
||||||
<br>**How can I load a different font than the default?**
|
|
||||||
<br>**How can I easily use icons in my application?**
|
|
||||||
<br>**How can I load multiple fonts?**
|
|
||||||
<br>**How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?** ([example](https://github.com/ocornut/imgui/wiki/Loading-Font-Example))
|
|
||||||
<br>**How can I interact with standard C++ types (such as std::string and std::vector)?**
|
|
||||||
<br>**How can I use the drawing facilities without a Dear ImGui window? (using ImDrawList API)**
|
|
||||||
<br>**How can I use this without a mouse, without a keyboard or without a screen? (gamepad, input share, remote display)**
|
|
||||||
<br>**I integrated Dear ImGui in my engine and the text or lines are blurry..**
|
|
||||||
<br>**I integrated Dear ImGui in my engine and some elements are disappearing when I move windows around..**
|
|
||||||
<br>**How can I help?**
|
|
||||||
|
|
||||||
See the FAQ in [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) for answers.
|
|
||||||
|
|
||||||
**Can you create elaborate/serious tools with Dear ImGui?**
|
|
||||||
|
|
||||||
Yes. People have written game editors, data browsers, debuggers, profilers and all sort of non-trivial tools with the library. In my experience the simplicity of the API is very empowering. Your UI runs close to your live data. Make the tools always-on and everybody in the team will be inclined to create new tools (as opposed to more "offline" UI toolkits where only a fraction of your team effectively creates tools). The list of sponsors below is also an indicator that serious game teams have been using the library.
|
|
||||||
|
|
||||||
Dear ImGui is very programmer centric and the immediate-mode GUI paradigm might requires you to readjust some habits before you can realize its full potential. Dear ImGui is about making things that are simple, efficient and powerful.
|
|
||||||
|
|
||||||
**Can you reskin the look of Dear ImGui?**
|
|
||||||
|
|
||||||
You can alter the look of the interface to some degree: changing colors, sizes, padding, rounding, fonts. However, as Dear ImGui is designed and optimized to create debug tools, the amount of skinning you can apply is limited. There is only so much you can stray away from the default look and feel of the interface. Below is a screenshot from [LumixEngine](https://github.com/nem0/LumixEngine) with custom colors + a docking/tabs extension (both of which you can find in the Issues section and will eventually be merged):
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
**Why using C++ (as opposed to C)?**
|
|
||||||
|
|
||||||
Dear ImGui takes advantage of a few C++ languages features for convenience but nothing anywhere Boost-insanity/quagmire. Dear ImGui does NOT require C++11 so it can be used with most old C++ compilers. Dear ImGui doesn't use any C++ header file. Language-wise, function overloading and default parameters are used to make the API easier to use and code more terse. Doing so I believe the API is sitting on a sweet spot and giving up on those features would make the API more cumbersome. Other features such as namespace, constructors and templates (in the case of the ImVector<> class) are also relied on as a convenience.
|
|
||||||
|
|
||||||
There is an auto-generated [c-api for Dear ImGui (cimgui)](https://github.com/cimgui/cimgui) by Sonoro1234 and Stephan Dilly. It is designed for creating binding to other languages. If possible, I would suggest using your target language functionalities to try replicating the function overloading and default parameters used in C++ else the API may be harder to use. Also see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings) for various third-party bindings.
|
|
||||||
|
|
||||||
Support dear imgui
|
|
||||||
------------------
|
|
||||||
|
|
||||||
**How can I help?**
|
**How can I help?**
|
||||||
|
|
||||||
- You may participate in the [Discourse forums](https://discourse.dearimgui.org) and the GitHub [issues tracker](https://github.com/ocornut/imgui/issues).
|
- You may participate in the [Discord server](http://discord.dearimgui.org), [GitHub forum/issues](https://github.com/ocornut/imgui/issues).
|
||||||
- You may help with development and submit pull requests! Please understand that by submitting a PR you are also submitting a request for the maintainer to review your code and then take over its maintenance forever. PR should be crafted both in the interest in the end-users and also to ease the maintainer into understanding and accepting it.
|
- You may help with development and submit pull requests! Please understand that by submitting a PR you are also submitting a request for the maintainer to review your code and then take over its maintenance forever. PR should be crafted both in the interest in the end-users and also to ease the maintainer into understanding and accepting it.
|
||||||
- See [Help wanted](https://github.com/ocornut/imgui/wiki/Help-Wanted) on the [Wiki](https://github.com/ocornut/imgui/wiki/) for some more ideas.
|
- See [Help wanted](https://github.com/ocornut/imgui/wiki/Help-Wanted) on the [Wiki](https://github.com/ocornut/imgui/wiki/) for some more ideas.
|
||||||
- Have your company financially support this project.
|
- Have your company financially support this project.
|
||||||
|
|
||||||
**How can I help financing further development of Dear ImGui?**
|
**How can I help financing further development of Dear ImGui?**
|
||||||
|
|
||||||
Your contributions are keeping this project alive. The library is free as in freedom, but continued maintenance and development are a full-time endeavor. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using dear imgui, please consider reaching out for financial support. If you are an individual using dear imgui, please consider donating via Patreon or PayPal. Thank you!
|
Your contributions are keeping this project alive. The library is available under a free and permissive license, but continued maintenance and development are a full-time endeavor and I would like to grow the team. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using dear imgui, please consider reaching out for invoiced technical support and maintenance contracts. Thank you!
|
||||||
|
|
||||||
Individuals/hobbyists: support continued maintenance and development via the monthly Patreon:
|
Businesses: support continued development via invoiced technical support, maintenance, sponsoring contracts:
|
||||||
<br> [](http://www.patreon.com/imgui)
|
<br> _E-mail: contact @ dearimgui dot org_
|
||||||
|
|
||||||
Individuals/hobbyists: support continued maintenance and development via PayPal:
|
Individuals: support continued maintenance and development via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S) donations.
|
||||||
<br> [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S)
|
|
||||||
|
|
||||||
Businesses: support continued maintenance and development via support contracts or sponsoring:
|
### Sponsors
|
||||||
<br> _E-mail: omarcornut at gmail dot com_
|
|
||||||
|
|
||||||
Ongoing dear imgui development is financially supported by users and private sponsors, recently:
|
Ongoing Dear ImGui development is financially supported by users and private sponsors, recently:
|
||||||
|
|
||||||
**Platinum-chocolate sponsors**
|
*Platinum-chocolate sponsors*
|
||||||
- **Blizzard Entertainment**.
|
- Blizzard Entertainment
|
||||||
|
- Google
|
||||||
|
- Ubisoft
|
||||||
|
- Nvidia
|
||||||
|
|
||||||
**Double-chocolate sponsors**
|
*Double-chocolate sponsors*
|
||||||
- Media Molecule, Mobigame, Aras Pranckevičius, Greggman, DotEmu, Nadeo, Supercell, Runner, Aiden Koss, Kylotonn.
|
- Media Molecule, Mobigame, Aras Pranckevičius, Greggman, DotEmu, Nadeo, Supercell, Aiden Koss, Kylotonn.
|
||||||
|
|
||||||
**Salty caramel supporters**
|
*Salty caramel supporters*
|
||||||
- Remedy Entertainment, Recognition Robotics, ikrima, Geoffrey Evans, Mercury Labs, Singularity Demo Group, Lionel Landwerlin, Ron Gilbert, Brandon Townsend, Nikhil Deshpande, Cort Stratton, drudru, Harfang 3D, Jeff Roberts, Rainway inc, Ondra Voves, Mesh Consultants, Unit 2 Games, Neil Bickford.
|
- Remedy Entertainment, Next Level Games, Recognition Robotics, ikrima, Geoffrey Evans, Mercury Labs, Singularity Demo Group, Lionel Landwerlin, Ron Gilbert, Brandon Townsend, G3DVu, Cort Stratton, drudru, Harfang 3D, Jeff Roberts, Rainway inc, Ondra Voves, Mesh Consultants, Unit 2 Games, Neil Bickford, Bill Six, Graham Manders.
|
||||||
|
|
||||||
**Caramel supporters**
|
*Caramel supporters*
|
||||||
- Jerome Lanquetot, Daniel Collin, Ctrl Alt Ninja, Neil Henning, Neil Blakey-Milner, Aleksei, NeiloGD, Eric, Game Atelier, Vincent Hamm, Colin Riley, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, Josh Faust, Martin Donlon, Codecat, Doug McNabb, Emmanuel Julien, Guillaume Chereau, Jeffrey Slutter, Jeremiah Deckard, r-lyeh, Nekith, Joshua Fisher, Malte Hoffmann, Mustafa Karaalioglu, Merlyn Morgan-Graham, Per Vognsen, Fabian Giesen, Jan Staubach, Matt Hargett, John Shearer, Jesse Chounard, kingcoopa, Jonas Bernemann, Johan Andersson, Michael Labbe, Tomasz Golebiowski, Louis Schnellbach, Jimmy Andrews, Bojan Endrovski, Robin Berg Pettersen, Rachel Crawford, Andrew Johnson, Sean Hunter, Jordan Mellow, Nefarius Software Solutions, Laura Wieme, Robert Nix, Mick Honey, Steven Kah Hien Wong, Bartosz Bielecki, Oscar Penas, A M, Liam Moynihan, Artometa, Mark Lee, Dimitri Diakopoulos, Pete Goodwin, Johnathan Roatch, nyu lea, Oswald Hurlem, Semyon Smelyanskiy, Le Bach, Jeong MyeongSoo, Chris Matthews, Astrofra.
|
- Jerome Lanquetot, Daniel Collin, Ctrl Alt Ninja, Neil Henning, Neil Blakey-Milner, Aleksei, NeiloGD, Eric, Game Atelier, Vincent Hamm, Morten Skaaning, Colin Riley, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, Josh Faust, Martin Donlon, Codecat, Doug McNabb, Emmanuel Julien, Guillaume Chereau, Jeffrey Slutter, Jeremiah Deckard, r-lyeh, Nekith, Joshua Fisher, Malte Hoffmann, Mustafa Karaalioglu, Merlyn Morgan-Graham, Per Vognsen, Fabian Giesen, Jan Staubach, Matt Hargett, John Shearer, Jesse Chounard, kingcoopa, Jonas Bernemann, Johan Andersson, Michael Labbe, Tomasz Golebiowski, Louis Schnellbach, Jimmy Andrews, Bojan Endrovski, Robin Berg Pettersen, Rachel Crawford, Andrew Johnson, Sean Hunter, Jordan Mellow, Nefarius Software Solutions, Laura Wieme, Robert Nix, Mick Honey, Steven Kah Hien Wong, Bartosz Bielecki, Oscar Penas, A M, Liam Moynihan, Artometa, Mark Lee, Dimitri Diakopoulos, Pete Goodwin, Johnathan Roatch, nyu lea, Oswald Hurlem, Semyon Smelyanskiy, Le Bach, Jeong MyeongSoo, Chris Matthews, Astrofra, Frederik De Bleser, Anticrisis, Matt Reyer.
|
||||||
|
|
||||||
And all other past and present supporters; THANK YOU!
|
And all other past and present supporters; THANK YOU!
|
||||||
(Please contact me if you would like to be added or removed from this list)
|
(Please contact me if you would like to be added or removed from this list)
|
||||||
|
|
||||||
|
Dear ImGui is using software and services kindly provided free of charge for open source projects:
|
||||||
|
- [PVS-Studio](https://www.viva64.com/en/b/0570/) for static analysis.
|
||||||
|
- [GitHub actions](https://github.com/features/actions) for continuous integration systems.
|
||||||
|
|
||||||
Credits
|
Credits
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Developed by [Omar Cornut](http://www.miracleworld.net) and every direct or indirect contributors to the GitHub. The early version of this library was developed with the support of [Media Molecule](http://www.mediamolecule.com) and first used internally on the game [Tearaway](http://tearaway.mediamolecule.com).
|
Developed by [Omar Cornut](http://www.miracleworld.net) and every direct or indirect contributors to the GitHub. The early version of this library was developed with the support of [Media Molecule](http://www.mediamolecule.com) and first used internally on the game [Tearaway](http://tearaway.mediamolecule.com) (Vita).
|
||||||
|
|
||||||
I first discovered the IMGUI paradigm at [Q-Games](http://www.q-games.com) where Atman Binstock had dropped his own simple implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating and improving it.
|
I first discovered the IMGUI paradigm at [Q-Games](http://www.q-games.com) where Atman Binstock had dropped his own simple implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating and improving it.
|
||||||
|
|
||||||
Embeds [ProggyClean.ttf](http://upperbounds.net) font by Tristan Grimmer (MIT license).
|
Embeds [ProggyClean.ttf](http://upperbounds.net) font by Tristan Grimmer (MIT license).
|
||||||
|
|
||||||
Embeds [stb_textedit.h, stb_truetype.h, stb_rectpack.h](https://github.com/nothings/stb/) by Sean Barrett (public domain).
|
Embeds [stb_textedit.h, stb_truetype.h, stb_rect_pack.h](https://github.com/nothings/stb/) by Sean Barrett (public domain).
|
||||||
|
|
||||||
Inspiration, feedback, and testing for early versions: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. And everybody posting feedback, questions and patches on the GitHub.
|
Inspiration, feedback, and testing for early versions: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. And everybody posting feedback, questions and patches on the GitHub.
|
||||||
|
|
||||||
|
103
docs/TODO.txt
103
docs/TODO.txt
@ -8,6 +8,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- doc/test: add a proper documentation+regression testing system (#435)
|
- doc/test: add a proper documentation+regression testing system (#435)
|
||||||
- doc/test: checklist app to verify binding/integration of imgui (test inputs, rendering, callback, etc.).
|
- doc/test: checklist app to verify binding/integration of imgui (test inputs, rendering, callback, etc.).
|
||||||
- doc/tips: tips of the day: website? applet in imgui_club?
|
- doc/tips: tips of the day: website? applet in imgui_club?
|
||||||
|
- doc/wiki: work on the wiki https://github.com/ocornut/imgui/wiki
|
||||||
|
|
||||||
- window: preserve/restore relative focus ordering (persistent or not) (#2304) -> also see docking reference to same #.
|
- window: preserve/restore relative focus ordering (persistent or not) (#2304) -> also see docking reference to same #.
|
||||||
- window: calling SetNextWindowSize() every frame with <= 0 doesn't do anything, may be useful to allow (particularly when used for a single axis). (#690)
|
- window: calling SetNextWindowSize() every frame with <= 0 doesn't do anything, may be useful to allow (particularly when used for a single axis). (#690)
|
||||||
@ -27,17 +28,22 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- window: GetWindowSize() returns (0,0) when not calculated? (#1045)
|
- window: GetWindowSize() returns (0,0) when not calculated? (#1045)
|
||||||
- window: investigate better auto-positioning for new windows.
|
- window: investigate better auto-positioning for new windows.
|
||||||
- window: top most window flag? (#2574)
|
- window: top most window flag? (#2574)
|
||||||
|
- window: the size_on_first_use path of Begin() can probably be removed
|
||||||
|
- window/size: manually triggered auto-fit (double-click on grip) shouldn't resize window down to viewport size?
|
||||||
- window/opt: freeze window flag: if not focused/hovered, return false, render with previous ImDrawList. and/or reduce refresh rate. -> this may require enforcing that it is illegal to submit contents if Begin returns false.
|
- window/opt: freeze window flag: if not focused/hovered, return false, render with previous ImDrawList. and/or reduce refresh rate. -> this may require enforcing that it is illegal to submit contents if Begin returns false.
|
||||||
- window/child: the first draw command of a child window could be moved into the current draw command of the parent window (unless child+tooltip?).
|
- window/child: the first draw command of a child window could be moved into the current draw command of the parent window (unless child+tooltip?).
|
||||||
- window/child: border could be emitted in parent as well.
|
- window/child: border could be emitted in parent as well.
|
||||||
|
- window/child: allow SetNextWindowContentSize() to work on child windows.
|
||||||
- window/clipping: some form of clipping when DisplaySize (or corresponding viewport) is zero.
|
- window/clipping: some form of clipping when DisplaySize (or corresponding viewport) is zero.
|
||||||
- window/tab: add a way to signify that a window or docked window requires attention (e.g. blinking title bar).
|
- window/tab: add a way to signify that a window or docked window requires attention (e.g. blinking title bar).
|
||||||
|
! scrolling: exposing horizontal scrolling with Shift+Wheel even when scrollbar is disabled expose lots of issues (#2424, #1463)
|
||||||
- scrolling: while holding down a scrollbar, try to keep the same contents visible (at least while not moving mouse)
|
- scrolling: while holding down a scrollbar, try to keep the same contents visible (at least while not moving mouse)
|
||||||
- scrolling: allow immediately effective change of scroll after Begin() if we haven't appended items yet.
|
- scrolling: allow immediately effective change of scroll after Begin() if we haven't appended items yet.
|
||||||
|
- scrolling: forward mouse wheel scrolling to parent window when at the edge of scrolling limits? (useful for listbox,tables?)
|
||||||
- scrolling/clipping: separator on the initial position of a window is not visible (cursorpos.y <= clippos.y). (2017-08-20: can't repro)
|
- scrolling/clipping: separator on the initial position of a window is not visible (cursorpos.y <= clippos.y). (2017-08-20: can't repro)
|
||||||
- scrolling/style: shadows on scrollable areas to denote that there is more contents
|
- scrolling/style: shadows on scrollable areas to denote that there is more contents
|
||||||
|
|
||||||
- drawdata: make it easy to clone (or swap?) a ImDrawData so user can easily save that data if they use threaded rendering.
|
- drawdata: make it easy to clone (or swap?) a full ImDrawData so user can easily save that data if they use threaded rendering. (e.g. #2646)
|
||||||
! drawlist: add calctextsize func to facilitate consistent code from user pov (currently need to use ImGui or ImFont alternatives!)
|
! drawlist: add calctextsize func to facilitate consistent code from user pov (currently need to use ImGui or ImFont alternatives!)
|
||||||
- drawlist: end-user probably can't call Clear() directly because we expect a texture to be pushed in the stack.
|
- drawlist: end-user probably can't call Clear() directly because we expect a texture to be pushed in the stack.
|
||||||
- drawlist: maintaining bounding box per command would allow to merge draw command when clipping isn't relied on (typical non-scrolling window or non-overflowing column would merge with previous command).
|
- drawlist: maintaining bounding box per command would allow to merge draw command when clipping isn't relied on (typical non-scrolling window or non-overflowing column would merge with previous command).
|
||||||
@ -56,16 +62,15 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- main: find a way to preserve relative orders of multiple reappearing windows (so an app toggling between "modes" e.g. fullscreen vs all tools) won't lose relative ordering.
|
- main: find a way to preserve relative orders of multiple reappearing windows (so an app toggling between "modes" e.g. fullscreen vs all tools) won't lose relative ordering.
|
||||||
- main: IsItemHovered() make it more consistent for various type of widgets, widgets with multiple components, etc. also effectively IsHovered() region sometimes differs from hot region, e.g tree nodes
|
- main: IsItemHovered() make it more consistent for various type of widgets, widgets with multiple components, etc. also effectively IsHovered() region sometimes differs from hot region, e.g tree nodes
|
||||||
- main: IsItemHovered() info stored in a stack? so that 'if TreeNode() { Text; TreePop; } if IsHovered' return the hover state of the TreeNode?
|
- main: IsItemHovered() info stored in a stack? so that 'if TreeNode() { Text; TreePop; } if IsHovered' return the hover state of the TreeNode?
|
||||||
- main: rename the main "Debug" window to avoid ID collision with user who may want to use "Debug" with specific flags.
|
|
||||||
|
|
||||||
- widgets: display mode: widget-label, label-widget (aligned on column or using fixed size), label-newline-tab-widget etc. (#395)
|
- widgets: display mode: widget-label, label-widget (aligned on column or using fixed size), label-newline-tab-widget etc. (#395)
|
||||||
- widgets: clean up widgets internal toward exposing everything and stabilizing imgui_internals.h.
|
- widgets: clean up widgets internal toward exposing everything and stabilizing imgui_internals.h.
|
||||||
- widgets: add visuals for Disabled/ReadOnly mode and expose publicly (#211)
|
- widgets: add visuals for Disabled/ReadOnly mode and expose publicly (#211)
|
||||||
- widgets: add always-allow-overlap mode. This should perhaps be the default.
|
- widgets: add always-allow-overlap mode. This should perhaps be the default? one problem is that highlight after mouse-wheel scrolling gets deferred, makes scrolling more flickery.
|
||||||
- widgets: start exposing PushItemFlag() and ImGuiItemFlags
|
- widgets: start exposing PushItemFlag() and ImGuiItemFlags
|
||||||
- widgets: alignment options in style (e.g. center Selectable, Right-Align within Button, etc.) #1260
|
- widgets: alignment options in style (e.g. center Selectable, Right-Align within Button, etc.) #1260
|
||||||
- widgets: activate by identifier (trigger button, focus given id)
|
- widgets: activate by identifier (trigger button, focus given id)
|
||||||
- widgets: a way to represent "mixed" values, so e.g. all values replaced with **, including check-boxes, colors, etc. with support for multi-components widgets (e.g. SliderFloat3, make only "Y" mixed)
|
- widgets: a way to represent "mixed" values, so e.g. all values replaced with *, including check-boxes, colors, etc. with support for multi-components widgets (e.g. SliderFloat3, make only "Y" mixed) (#2644)
|
||||||
- widgets: selectable: generic BeginSelectable()/EndSelectable() mechanism.
|
- widgets: selectable: generic BeginSelectable()/EndSelectable() mechanism.
|
||||||
- widgets: selectable: a way to visualize partial/mixed selection (e.g. parent tree node has children with mixed selection)
|
- widgets: selectable: a way to visualize partial/mixed selection (e.g. parent tree node has children with mixed selection)
|
||||||
- widgets: checkbox: checkbox with custom glyph inside frame.
|
- widgets: checkbox: checkbox with custom glyph inside frame.
|
||||||
@ -75,6 +80,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- input text: clean up the mess caused by converting UTF-8 <> wchar. the code is rather inefficient right now and super fragile.
|
- input text: clean up the mess caused by converting UTF-8 <> wchar. the code is rather inefficient right now and super fragile.
|
||||||
- input text: reorganize event handling, allow CharFilter to modify buffers, allow multiple events? (#541)
|
- input text: reorganize event handling, allow CharFilter to modify buffers, allow multiple events? (#541)
|
||||||
- input text: expose CursorPos in char filter event (#816)
|
- input text: expose CursorPos in char filter event (#816)
|
||||||
|
- input text: try usage idiom of using InputText with data only exposed through get/set accessors, without extraneous copy/alloc. (#3009)
|
||||||
- input text: access public fields via a non-callback API e.g. InputTextGetState("xxx") that may return NULL if not active.
|
- input text: access public fields via a non-callback API e.g. InputTextGetState("xxx") that may return NULL if not active.
|
||||||
- input text: flag to disable live update of the user buffer (also applies to float/int text input) (#701)
|
- input text: flag to disable live update of the user buffer (also applies to float/int text input) (#701)
|
||||||
- input text: hover tooltip could show unclamped text
|
- input text: hover tooltip could show unclamped text
|
||||||
@ -87,9 +93,11 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- input text: decorrelate layout from inputs - e.g. what's the easiest way to implement a nice IP/Mac address input editor?
|
- input text: decorrelate layout from inputs - e.g. what's the easiest way to implement a nice IP/Mac address input editor?
|
||||||
- input text: global callback system so user can plug in an expression evaluator easily. (#1691)
|
- input text: global callback system so user can plug in an expression evaluator easily. (#1691)
|
||||||
- input text: force scroll to end or scroll to a given line/contents (so user can implement a log or a search feature)
|
- input text: force scroll to end or scroll to a given line/contents (so user can implement a log or a search feature)
|
||||||
|
- input text: a way to preview completion (e.g. disabled text completing from the cursor)
|
||||||
- input text: a side bar that could e.g. preview where errors are. probably left to the user to draw but we'd need to give them the info there.
|
- input text: a side bar that could e.g. preview where errors are. probably left to the user to draw but we'd need to give them the info there.
|
||||||
- input text: a way for the user to provide syntax coloring.
|
- input text: a way for the user to provide syntax coloring.
|
||||||
- input text: Shift+TAB with ImGuiInputTextFlags_AllowTabInput could eat preceding blanks, up to tab_count.
|
- input text: Shift+TAB with ImGuiInputTextFlags_AllowTabInput could eat preceding blanks, up to tab_count.
|
||||||
|
- input text: facilitate patterns like if (InputText(..., obj.get_string_ref()) { obj.set_string(...); } relying on internally held buffer.
|
||||||
- input text multi-line: don't directly call AddText() which does an unnecessary vertex reserve for character count prior to clipping. and/or more line-based clipping to AddText(). and/or reorganize TextUnformatted/RenderText for more efficiency for large text (e.g TextUnformatted could clip and log separately, etc).
|
- input text multi-line: don't directly call AddText() which does an unnecessary vertex reserve for character count prior to clipping. and/or more line-based clipping to AddText(). and/or reorganize TextUnformatted/RenderText for more efficiency for large text (e.g TextUnformatted could clip and log separately, etc).
|
||||||
- input text multi-line: support for cut/paste without selection (cut/paste the current line)
|
- input text multi-line: support for cut/paste without selection (cut/paste the current line)
|
||||||
- input text multi-line: line numbers? status bar? (follow up on #200)
|
- input text multi-line: line numbers? status bar? (follow up on #200)
|
||||||
@ -108,6 +116,9 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- layout: more generic alignment state (left/right/centered) for single items?
|
- layout: more generic alignment state (left/right/centered) for single items?
|
||||||
- layout: clean up the InputFloatN/SliderFloatN/ColorEdit4 layout code. item width should include frame padding.
|
- layout: clean up the InputFloatN/SliderFloatN/ColorEdit4 layout code. item width should include frame padding.
|
||||||
- layout: vertical alignment of mixed height items (e.g. buttons) within a same line (#1284)
|
- layout: vertical alignment of mixed height items (e.g. buttons) within a same line (#1284)
|
||||||
|
- layout: null layout mode were items are not rendered but user can query GetItemRectMin()/Max/Size.
|
||||||
|
- layout: (R&D) local multi-pass layout mode.
|
||||||
|
- layout: (R&D) bind authored layout data (created by an off-line tool), items fetch their pos/size at submission, self-optimize data structures to stable linear access.
|
||||||
|
|
||||||
- group: BeginGroup() needs a border option. (~#1496)
|
- group: BeginGroup() needs a border option. (~#1496)
|
||||||
- group: IsHovered() after EndGroup() covers whole aabb rather than the intersection of individual items. Is that desirable?
|
- group: IsHovered() after EndGroup() covers whole aabb rather than the intersection of individual items. Is that desirable?
|
||||||
@ -120,6 +131,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- columns: option to alternate background colors on odd/even scanlines.
|
- columns: option to alternate background colors on odd/even scanlines.
|
||||||
- columns: allow columns to recurse.
|
- columns: allow columns to recurse.
|
||||||
- columns: allow a same columns set to be interrupted by e.g. CollapsingHeader and resume with columns in sync when moving them.
|
- columns: allow a same columns set to be interrupted by e.g. CollapsingHeader and resume with columns in sync when moving them.
|
||||||
|
- columns: sizing is lossy when columns width is very small (default width may turn negative etc.)
|
||||||
- columns: separator function or parameter that works within the column (currently Separator() bypass all columns) (#125)
|
- columns: separator function or parameter that works within the column (currently Separator() bypass all columns) (#125)
|
||||||
- columns: flag to add horizontal separator above/below?
|
- columns: flag to add horizontal separator above/below?
|
||||||
- columns/layout: setup minimum line height (equivalent of automatically calling AlignFirstTextHeightToWidgets)
|
- columns/layout: setup minimum line height (equivalent of automatically calling AlignFirstTextHeightToWidgets)
|
||||||
@ -150,11 +162,12 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
|
|
||||||
- tabs: make EndTabBar fail if users doesn't respect BeginTabBar return value, for consistency/future-proofing.
|
- tabs: make EndTabBar fail if users doesn't respect BeginTabBar return value, for consistency/future-proofing.
|
||||||
- tabs: persistent order/focus in BeginTabBar() api (#261, #351)
|
- tabs: persistent order/focus in BeginTabBar() api (#261, #351)
|
||||||
|
- tabs: TabItem could honor SetNextItemWidth()?
|
||||||
|
|
||||||
- button: provide a button that looks framed. (?)
|
|
||||||
- image/image button: misalignment on padded/bordered button?
|
- image/image button: misalignment on padded/bordered button?
|
||||||
- image/image button: parameters are confusing, image() has tint_col,border_col whereas imagebutton() has bg_col/tint_col. Even thou they are different parameters ordering could be more consistent. can we fix that?
|
- image/image button: parameters are confusing, image() has tint_col,border_col whereas imagebutton() has bg_col/tint_col. Even thou they are different parameters ordering could be more consistent. can we fix that?
|
||||||
- image button: not taking an explicit id can be problematic. (#2464, #1390)
|
- image button: not taking an explicit id can be problematic. (#2464, #1390)
|
||||||
|
- button: provide a button that looks framed. (?)
|
||||||
- slider/drag: ctrl+click when format doesn't include a % character.. disable? display underlying value in default format? (see TempInputTextScalar)
|
- slider/drag: ctrl+click when format doesn't include a % character.. disable? display underlying value in default format? (see TempInputTextScalar)
|
||||||
- slider: allow using the [-]/[+] buttons used by InputFloat()/InputInt()
|
- slider: allow using the [-]/[+] buttons used by InputFloat()/InputInt()
|
||||||
- slider: initial absolute click is imprecise. change to relative movement slider (same as scrollbar). (#1946)
|
- slider: initial absolute click is imprecise. change to relative movement slider (same as scrollbar). (#1946)
|
||||||
@ -191,10 +204,12 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- popups: clicking outside (to close popup) and holding shouldn't drag window below.
|
- popups: clicking outside (to close popup) and holding shouldn't drag window below.
|
||||||
- popups: add variant using global identifier similar to Begin/End (#402)
|
- popups: add variant using global identifier similar to Begin/End (#402)
|
||||||
- popups: border options. richer api like BeginChild() perhaps? (#197)
|
- popups: border options. richer api like BeginChild() perhaps? (#197)
|
||||||
|
|
||||||
- tooltip: drag and drop with tooltip near monitor edges lose/changes its last direction instead of locking one. The drag and drop tooltip should always follow without changing direction.
|
- tooltip: drag and drop with tooltip near monitor edges lose/changes its last direction instead of locking one. The drag and drop tooltip should always follow without changing direction.
|
||||||
- tooltip: tooltip that doesn't fit in entire screen seems to lose their "last preferred direction" and may teleport when moving mouse.
|
- tooltip: tooltip that doesn't fit in entire screen seems to lose their "last preferred direction" and may teleport when moving mouse.
|
||||||
- tooltip: allow to set the width of a tooltip to allow TextWrapped() etc. while keeping the height automatic.
|
- tooltip: allow to set the width of a tooltip to allow TextWrapped() etc. while keeping the height automatic.
|
||||||
- tooltip: tooltips with delay timers? or general timer policy? (instantaneous vs timed): IsItemHovered() with timer + implicit aabb-id for items with no ID. (#1485)
|
- tooltip: tooltips with delay timers? or general timer policy? (instantaneous vs timed): IsItemHovered() with timer + implicit aabb-id for items with no ID. (#1485)
|
||||||
|
- tooltip: drag tooltip hovering over source widget with IsItemHovered/SetTooltip flickers.
|
||||||
|
|
||||||
- menus: calling BeginMenu() twice with a same name doesn't append as Begin() does for regular windows (#1207)
|
- menus: calling BeginMenu() twice with a same name doesn't append as Begin() does for regular windows (#1207)
|
||||||
- menus: menu bars inside modal windows are acting weird.
|
- menus: menu bars inside modal windows are acting weird.
|
||||||
@ -204,27 +219,18 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- shortcuts: programmatically access shortcuts "Focus("&Save"))
|
- shortcuts: programmatically access shortcuts "Focus("&Save"))
|
||||||
- menus: menu-bar: main menu-bar could affect clamping of windows position (~ akin to modifying DisplayMin)
|
- menus: menu-bar: main menu-bar could affect clamping of windows position (~ akin to modifying DisplayMin)
|
||||||
- menus: hovering from menu to menu on a menu-bar has 1 frame without any menu, which is a little annoying. ideally either 0 either longer.
|
- menus: hovering from menu to menu on a menu-bar has 1 frame without any menu, which is a little annoying. ideally either 0 either longer.
|
||||||
|
- menus: could merge draw call in most cases (how about storing an optional aabb in ImDrawCmd to move the burden of merging in a single spot).
|
||||||
|
|
||||||
- text: selectable text (for copy) as a generic feature (ItemFlags?)
|
|
||||||
- text: proper alignment options in imgui_internal.h
|
|
||||||
- text wrapped: figure out better way to use TextWrapped() in an always auto-resize context (tooltip, etc.) (#249)
|
|
||||||
- text: it's currently impossible to have a window title with "##". perhaps an official workaround would be nice. \ style inhibitor? non-visible ascii code to insert between #?
|
|
||||||
- text: provided a framed text helper, e.g. https://pastebin.com/1Laxy8bT
|
|
||||||
- text: refactor TextUnformatted (or underlying function) to more explicitly request if we need width measurement or not
|
|
||||||
- text link/url button: underlined. should api expose an ID or use text contents as ID? which colors enum to use?
|
|
||||||
|
|
||||||
- tree node / optimization: avoid formatting when clipped.
|
|
||||||
- tree node: tree-node/header right-most side doesn't take account of horizontal scrolling.
|
|
||||||
- tree node: add treenode/treepush int variants? not there because (void*) cast from int warns on some platforms/settings?
|
- tree node: add treenode/treepush int variants? not there because (void*) cast from int warns on some platforms/settings?
|
||||||
- tree node: try to apply scrolling at time of TreePop() if node was just opened and end of node is past scrolling limits?
|
- tree node: try to apply scrolling at time of TreePop() if node was just opened and end of node is past scrolling limits?
|
||||||
- tree node / selectable render mismatch which is visible if you use them both next to each other (e.g. cf. property viewer)
|
- tree node / selectable render mismatch which is visible if you use them both next to each other (e.g. cf. property viewer)
|
||||||
- tree node: tweak color scheme to distinguish headers from selected tree node (#581)
|
- tree node: tweak color scheme to distinguish headers from selected tree node (#581)
|
||||||
- tree node: leaf/non-leaf highlight mismatch.
|
- tree node: leaf/non-leaf highlight mismatch.
|
||||||
- tree node: _NoIndentOnOpen flag? would require to store a per-depth bit mask to store info for pop (or whatever is cheaper)
|
- tree node/opt: could avoid formatting when clipped (flag assuming we don't care about width/height, assume single line height?)
|
||||||
|
|
||||||
- settings: write more decent code to allow saving/loading new fields: columns, selected tree nodes?
|
- settings: write more decent code to allow saving/loading new fields: columns, selected tree nodes?
|
||||||
- settings: api for per-tool simple persistent data (bool,int,float,columns sizes,etc.) in .ini file (#437)
|
- settings: api for per-tool simple persistent data (bool,int,float,columns sizes,etc.) in .ini file (#437)
|
||||||
- stb: add defines to disable stb implementations
|
- settings/persistence: helpers to make TreeNodeBehavior persist (even during dev!) - may need to store some semantic and/or data type in ImGuiStoragePair
|
||||||
|
|
||||||
- style: better default styles. (#707)
|
- style: better default styles. (#707)
|
||||||
- style: add a highlighted text color (for headers, etc.)
|
- style: add a highlighted text color (for headers, etc.)
|
||||||
@ -249,27 +255,39 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- filters: handle wild-cards (with implicit leading/trailing *), reg-exprs
|
- filters: handle wild-cards (with implicit leading/trailing *), reg-exprs
|
||||||
- filters: fuzzy matches (may use code at blog.forrestthewoods.com/4cffeed33fdb)
|
- filters: fuzzy matches (may use code at blog.forrestthewoods.com/4cffeed33fdb)
|
||||||
|
|
||||||
- drag and drop: drag tooltip hovering over source widget with IsItemHovered/SetTooltip flickers.
|
|
||||||
- drag and drop: fix/support/options for overlapping drag sources.
|
- drag and drop: fix/support/options for overlapping drag sources.
|
||||||
- drag and drop: releasing a drop shows the "..." tooltip for one frame - since e13e598 (#1725)
|
- drag and drop: releasing a drop shows the "..." tooltip for one frame - since e13e598 (#1725)
|
||||||
- drag and drop: drag source on a group object (would need e.g. an invisible button covering group in EndGroup) https://twitter.com/paniq/status/1121446364909535233
|
- drag and drop: drag source on a group object (would need e.g. an invisible button covering group in EndGroup) https://twitter.com/paniq/status/1121446364909535233
|
||||||
- drag and drop: have some way to know when a drag begin from BeginDragDropSource() pov.
|
- drag and drop: have some way to know when a drag begin from BeginDragDropSource() pov. (see 2018/01/11 post in #143)
|
||||||
- drag and drop: allow preview tooltip to be submitted from a different place than the drag source. (#1725)
|
- drag and drop: allow preview tooltip to be submitted from a different place than the drag source. (#1725)
|
||||||
- drag and drop: allow using with other mouse buttons (where activeid won't be set). (#1637)
|
- drag and drop: allow using with other mouse buttons (where activeid won't be set). (#1637)
|
||||||
- drag and drop: make it easier and provide a demo to have tooltip both are source and target site, with a more detailed one on target site (tooltip ordering problem)
|
- drag and drop: make it easier and provide a demo to have tooltip both are source and target site, with a more detailed one on target site (tooltip ordering problem)
|
||||||
- drag and drop: demo with reordering nodes (in a list, or a tree node). (#143)
|
- drag and drop: demo with reordering nodes (in a list, or a tree node). (#143)
|
||||||
- drag and drop: test integrating with os drag and drop (make it easy to do a naive WM_DROPFILE integration)
|
- drag and drop: test integrating with os drag and drop (make it easy to do a naive WM_DROPFILE integration)
|
||||||
- drag and drop: allow for multiple payload types. (#143)
|
- drag and drop: allow for multiple payload types. (#143)
|
||||||
- drag and drop: make payload optional? (#143)
|
- drag and drop: make payload optional? payload promise? (see 2018/01/11 post in #143)
|
||||||
- drag and drop: (#143) "both an in-process pointer and a promise to generate a serialized version, for whether the drag ends inside or outside the same process"
|
- drag and drop: (#143) "both an in-process pointer and a promise to generate a serialized version, for whether the drag ends inside or outside the same process"
|
||||||
- drag and drop: feedback when hovering a region blocked by modal (mouse cursor "NO"?)
|
- drag and drop: feedback when hovering a region blocked by modal (mouse cursor "NO"?)
|
||||||
- node/graph editor (#306)
|
|
||||||
|
- node/graph editors (#306) (also see https://github.com/ocornut/imgui/wiki#node-editors)
|
||||||
- pie menus patterns (#434)
|
- pie menus patterns (#434)
|
||||||
- markup: simple markup language for color change? (#902)
|
- markup: simple markup language for color change? (#902)
|
||||||
|
|
||||||
|
- text: selectable text (for copy) as a generic feature (ItemFlags?)
|
||||||
|
- text: proper alignment options in imgui_internal.h
|
||||||
|
- text: it's currently impossible to have a window title with "##". perhaps an official workaround would be nice. \ style inhibitor? non-visible ascii code to insert between #?
|
||||||
|
- text: provided a framed text helper, e.g. https://pastebin.com/1Laxy8bT
|
||||||
|
- text: refactor TextUnformatted (or underlying function) to more explicitly request if we need width measurement or not
|
||||||
|
- text link/url button: underlined. should api expose an ID or use text contents as ID? which colors enum to use?
|
||||||
|
- text/wrapped: should be a more first-class citizen, e.g. wrapped text within a Selectable with known width.
|
||||||
|
- text/wrapped: custom separator for text wrapping. (#3002)
|
||||||
|
- text/wrapped: figure out better way to use TextWrapped() in an always auto-resize context (tooltip, etc.) (#249)
|
||||||
|
|
||||||
|
- font: arbitrary line spacing. (#2945)
|
||||||
- font: MergeMode: flags to select overwriting or not (this is now very easy with refactored ImFontAtlasBuildWithStbTruetype)
|
- font: MergeMode: flags to select overwriting or not (this is now very easy with refactored ImFontAtlasBuildWithStbTruetype)
|
||||||
- font: free the Alpha buffer if user only requested RGBA.
|
- font: free the Alpha buffer if user only requested RGBA.
|
||||||
!- font: better CalcTextSizeA() API, at least for simple use cases. current one is horrible (perhaps have simple vs extended versions).
|
!- font: better CalcTextSizeA() API, at least for simple use cases. current one is horrible (perhaps have simple vs extended versions).
|
||||||
|
- font: for the purpose of RenderTextEllipsis(), it might be useful that CalcTextSizeA() can ignore the trailing padding?
|
||||||
- font: a CalcTextHeight() helper could run faster than CalcTextSize().y
|
- font: a CalcTextHeight() helper could run faster than CalcTextSize().y
|
||||||
- font: enforce monospace through ImFontConfig (for icons?) + create dual ImFont output from same input, reusing rasterized data but with different glyphs/AdvanceX
|
- font: enforce monospace through ImFontConfig (for icons?) + create dual ImFont output from same input, reusing rasterized data but with different glyphs/AdvanceX
|
||||||
- font: finish CustomRectRegister() to allow mapping Unicode codepoint to custom texture data
|
- font: finish CustomRectRegister() to allow mapping Unicode codepoint to custom texture data
|
||||||
@ -290,35 +308,39 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- font: add support for kerning, probably optional. A) perhaps default to (32..128)^2 matrix ~ 9K entries = 36KB, then hash for non-ascii?. B) or sparse lookup into per-char list?
|
- font: add support for kerning, probably optional. A) perhaps default to (32..128)^2 matrix ~ 9K entries = 36KB, then hash for non-ascii?. B) or sparse lookup into per-char list?
|
||||||
- font: add a simpler CalcTextSizeA() api? current one ok but not welcome if user needs to call it directly (without going through ImGui::CalcTextSize)
|
- font: add a simpler CalcTextSizeA() api? current one ok but not welcome if user needs to call it directly (without going through ImGui::CalcTextSize)
|
||||||
- font: fix AddRemapChar() to work before atlas has been built.
|
- font: fix AddRemapChar() to work before atlas has been built.
|
||||||
- font: what would it take to support codepoint higher than 0xFFFF? (smileys, etc.) (#2538, #2541)
|
- font: support for unicode codepoints higher than 0xFFFF? (pr #2815)
|
||||||
- font: (api breaking) remove "TTF" from symbol names. also because it now supports OTF.
|
- font: (api breaking) remove "TTF" from symbol names. also because it now supports OTF.
|
||||||
- font/opt: Considering storing standalone AdvanceX table as 16-bit fixed point integer?
|
- font/opt: Considering storing standalone AdvanceX table as 16-bit fixed point integer?
|
||||||
- font/opt: Glyph currently 40 bytes (2+9*4). Consider storing UV as 16 bits integer? (->32 bytes). X0/Y0/X1/Y1 as 16 fixed-point integers? Or X0/Y0 as float and X1/Y1 as fixed8_8?
|
- font/opt: Glyph currently 40 bytes (2+9*4). Consider storing UV as 16 bits integer? (->32 bytes). X0/Y0/X1/Y1 as 16 fixed-point integers? Or X0/Y0 as float and X1/Y1 as fixed8_8?
|
||||||
|
|
||||||
|
- nav: some features such as PageUp/Down/Home/End should probably work without ImGuiConfigFlags_NavEnableKeyboard? (where do we draw the line?)
|
||||||
|
! nav: never clear NavId on some setup (e.g. gamepad centric)
|
||||||
|
- nav: code to focus child-window on restoring NavId appears to have issue: e.g. when focus change is implicit because of window closure.
|
||||||
|
- nav: configuration flag to disable global shortcuts (currently only CTRL-Tab) ?
|
||||||
|
- nav: Home/End behavior when navigable item is not fully visible at the edge of scrolling? should be backtrack to keep item into view?
|
||||||
- nav: NavScrollToBringItemIntoView() with item bigger than view should focus top-right? Repro: using Nav in "About Window"
|
- nav: NavScrollToBringItemIntoView() with item bigger than view should focus top-right? Repro: using Nav in "About Window"
|
||||||
- nav: wrap around logic to allow e.g. grid based layout (pressing NavRight on the right-most element would go to the next row, etc.). see internal's NavMoveRequestTryWrapping().
|
- nav: wrap around logic to allow e.g. grid based layout (pressing NavRight on the right-most element would go to the next row, etc.). see internal's NavMoveRequestTryWrapping().
|
||||||
- nav: patterns to make it possible for arrows key to update selection
|
- nav: patterns to make it possible for arrows key to update selection
|
||||||
- nav: restore/find nearest navid when current one disappear (e.g. pressed a button that disappear, or perhaps auto restoring when current button change name)
|
- nav: restore/find nearest NavId when current one disappear (e.g. pressed a button that disappear, or perhaps auto restoring when current button change name)
|
||||||
- nav: SetItemDefaultFocus() level of priority, so widget like Selectable when inside a popup could claim a low-priority default focus on the first selected iem
|
- nav: SetItemDefaultFocus() level of priority, so widget like Selectable when inside a popup could claim a low-priority default focus on the first selected iem
|
||||||
- nav: allow input system to be be more tolerant of io.DeltaTime=0.0f
|
|
||||||
- nav: ESC within a menu of a child window seems to exit the child window.
|
|
||||||
- nav: NavFlattened: ESC on a flattened child should select something.
|
- nav: NavFlattened: ESC on a flattened child should select something.
|
||||||
- nav: NavFlattened: broken: in typical usage scenario, the items of a fully clipped child are currently not considered to enter into a NavFlattened child.
|
- nav: NavFlattened: broken: in typical usage scenario, the items of a fully clipped child are currently not considered to enter into a NavFlattened child.
|
||||||
- nav: NavFlattened: init request doesn't select items that are part of a NavFlattened child
|
- nav: NavFlattened: init request doesn't select items that are part of a NavFlattened child
|
||||||
- nav: NavFlattened: cannot access menu-bar of a flattened child window with Alt/menu key (not a very common use case..).
|
- nav: NavFlattened: cannot access menu-bar of a flattened child window with Alt/menu key (not a very common use case..).
|
||||||
- nav: Left within a tree node block as a fallback (ImGuiTreeNodeFlags_NavLeftJumpsBackHere by default?)
|
- nav/treenode: Left within a tree node block as a fallback (ImGuiTreeNodeFlags_NavLeftJumpsBackHere by default?)
|
||||||
- nav/menus: pressing left-right on a vertically clipped menu bar tends to jump to the collapse/close buttons.
|
- nav/menus: pressing left-right on a vertically clipped menu bar tends to jump to the collapse/close buttons.
|
||||||
- nav/menus: allow pressing Menu to leave a sub-menu.
|
- nav/menus: allow pressing Menu to leave a sub-menu.
|
||||||
- nav/menus: a way to access the main menu bar with Alt? (currently needs CTRL+TAB)
|
- nav/menus: a way to access the main menu bar with Alt? (currently needs CTRL+TAB) or last focused window menu bar?
|
||||||
- nav/menus: when using the main menu bar, even though we restore focus after, the underlying window loses its title bar highlight during menu manipulation. could we prevent it?
|
- nav/menus: when using the main menu bar, even though we restore focus after, the underlying window loses its title bar highlight during menu manipulation. could we prevent it?
|
||||||
- nav/menus: main menu bar currently cannot restore a NULL focus. Could save NavWindow at the time of being focused, similarly to what popup do?
|
- nav/menus: main menu bar currently cannot restore a NULL focus. Could save NavWindow at the time of being focused, similarly to what popup do?
|
||||||
|
- nav/menus: Alt,Up could open the first menu (e.g. "File") currently it tends to nav into the window/collapse menu. Do do that we would need custom transition?
|
||||||
|
- nav/windowing: configure fade-in/fade-out delay on Ctrl+Tab?
|
||||||
|
- nav/windowing: when CTRL-Tab/windowing is active, the HoveredWindow detection doesn't take account of the window display re-ordering.
|
||||||
- nav: simulate right-click or context activation? (SHIFT+F10)
|
- nav: simulate right-click or context activation? (SHIFT+F10)
|
||||||
- nav: tabs should go through most/all widgets (in submission order?).
|
- nav: tabs should go through most/all widgets (in submission order?).
|
||||||
- nav: when CTRL-Tab/windowing is active, the HoveredWindow detection doesn't take account of the window display re-ordering.
|
|
||||||
- nav: esc/enter default behavior for popups, e.g. be able to mark an "ok" or "cancel" button that would get triggered by those keys.
|
- nav: esc/enter default behavior for popups, e.g. be able to mark an "ok" or "cancel" button that would get triggered by those keys.
|
||||||
- nav: when activating a button that changes label (without a static ID) or disappear, can we somehow automatically recover into a nearest highlight item?
|
- nav: when activating a button that changes label (without a static ID) or disappear, can we somehow automatically recover into a nearest highlight item?
|
||||||
- nav: there's currently no way to completely clear focus with the keyboard. depending on patterns used by the application to dispatch inputs, it may be desirable.
|
- nav: there's currently no way to completely clear focus with the keyboard. depending on patterns used by the application to dispatch inputs, it may be desirable.
|
||||||
- nav: configuration flag to disable global shortcuts (currently only CTRL-tab) ?
|
|
||||||
- focus: preserve ActiveId/focus stack state, e.g. when opening a menu and close it, previously selected InputText() focus gets restored (#622)
|
- focus: preserve ActiveId/focus stack state, e.g. when opening a menu and close it, previously selected InputText() focus gets restored (#622)
|
||||||
- focus: SetKeyboardFocusHere() on with >= 0 offset could be done on same frame (else latch and modulate on beginning of next frame)
|
- focus: SetKeyboardFocusHere() on with >= 0 offset could be done on same frame (else latch and modulate on beginning of next frame)
|
||||||
- focus: unable to use SetKeyboardFocusHere() on clipped widgets. (#787)
|
- focus: unable to use SetKeyboardFocusHere() on clipped widgets. (#787)
|
||||||
@ -328,12 +350,12 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- inputs: support track pad style scrolling & slider edit.
|
- inputs: support track pad style scrolling & slider edit.
|
||||||
- inputs/io: backspace and arrows in the context of a text input could use system repeat rate.
|
- inputs/io: backspace and arrows in the context of a text input could use system repeat rate.
|
||||||
- inputs/io: clarify/standardize/expose repeat rate and repeat delays (#1808)
|
- inputs/io: clarify/standardize/expose repeat rate and repeat delays (#1808)
|
||||||
- inputs: add mouse cursor for unavailable/no? IDC_NO/SDL_SYSTEM_CURSOR_NO.
|
|
||||||
- inputs/scrolling: support for smooth scrolling (#2462, #2569)
|
- inputs/scrolling: support for smooth scrolling (#2462, #2569)
|
||||||
|
|
||||||
- misc: idle: expose "woken up" boolean (set by inputs) and/or animation time (for cursor blink) for back-end to be able stop refreshing easily.
|
- misc: idle: expose "woken up" boolean (set by inputs) and/or animation time (for cursor blink) for back-end to be able stop refreshing easily.
|
||||||
- misc: idle: if cursor blink if the _only_ visible animation, core imgui could rewrite vertex alpha to avoid CPU pass on ImGui:: calls.
|
- misc: idle: if cursor blink if the _only_ visible animation, core imgui could rewrite vertex alpha to avoid CPU pass on ImGui:: calls.
|
||||||
- misc: idle: if cursor blink if the _only_ visible animation, could even expose a dirty rectangle that optionally can be leverage by some app to render in a smaller viewport, getting rid of much pixel shading cost.
|
- misc: idle: if cursor blink if the _only_ visible animation, could even expose a dirty rectangle that optionally can be leverage by some app to render in a smaller viewport, getting rid of much pixel shading cost.
|
||||||
|
- misc: no way to run a root-most GetID() with ImGui:: api since there's always a Debug window in the stack. (mentioned in #2960)
|
||||||
- misc: make the ImGuiCond values linear (non-power-of-two). internal storage for ImGuiWindow can use integers to combine into flags (Why?)
|
- misc: make the ImGuiCond values linear (non-power-of-two). internal storage for ImGuiWindow can use integers to combine into flags (Why?)
|
||||||
- misc: provide a way to compile out the entire implementation while providing a dummy API (e.g. #define IMGUI_DUMMY_IMPL)
|
- misc: provide a way to compile out the entire implementation while providing a dummy API (e.g. #define IMGUI_DUMMY_IMPL)
|
||||||
- misc: PushItemFlag(): add a flag to disable keyboard capture when used with mouse? (#1682)
|
- misc: PushItemFlag(): add a flag to disable keyboard capture when used with mouse? (#1682)
|
||||||
@ -341,9 +363,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- misc: possible compile-time support for string view/range instead of char* would e.g. facilitate usage with Rust (#683)
|
- misc: possible compile-time support for string view/range instead of char* would e.g. facilitate usage with Rust (#683)
|
||||||
- misc: possible compile-time support for wchar_t instead of char*?
|
- misc: possible compile-time support for wchar_t instead of char*?
|
||||||
|
|
||||||
- backend: bgfx? https://gist.github.com/RichardGale/6e2b74bc42b3005e08397236e4be0fd0
|
|
||||||
- emscriptem: with refactored examples, we could provide a direct imgui_impl_emscripten platform layer (see eg. https://github.com/floooh/sokol-samples/blob/master/html5/imgui-emsc.cc#L42)
|
|
||||||
|
|
||||||
- remote: make a system like RemoteImGui first-class citizen/project (#75)
|
- remote: make a system like RemoteImGui first-class citizen/project (#75)
|
||||||
|
|
||||||
- demo: find a way to demonstrate textures in the examples application, as it such a common issue for new users.
|
- demo: find a way to demonstrate textures in the examples application, as it such a common issue for new users.
|
||||||
@ -351,14 +370,20 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- demo: add vertical separator demo
|
- demo: add vertical separator demo
|
||||||
- demo: add virtual scrolling example?
|
- demo: add virtual scrolling example?
|
||||||
- demo: demonstrate Plot offset
|
- demo: demonstrate Plot offset
|
||||||
|
- demo: window size constraint: square demo is broken when resizing from edges (#1975), would need to rework the callback system to solve this
|
||||||
|
|
||||||
- examples: window minimize, maximize (#583)
|
- examples: window minimize, maximize (#583)
|
||||||
- examples: provide a zero frame-rate/idle example.
|
- examples: provide a zero frame-rate/idle example.
|
||||||
- examples: apple: example_apple should be using modern GL3.
|
- backends: apple: example_apple should be using modern GL3.
|
||||||
- examples: glfw: could go idle when minimized? if (glfwGetWindowAttrib(window, GLFW_ICONIFIED)) { glfwWaitEvents(); continue; } // issue: DeltaTime will be super high on resume, perhaps provide a way to let impl know (#440)
|
- backends: glfw: could go idle when minimized? if (glfwGetWindowAttrib(window, GLFW_ICONIFIED)) { glfwWaitEvents(); continue; } // issue: DeltaTime will be super high on resume, perhaps provide a way to let impl know (#440)
|
||||||
- examples: opengl: rename imgui_impl_opengl2 to impl_opengl_legacy and imgui_impl_opengl3 to imgui_impl_opengl? (#1900)
|
- backends: opengl: rename imgui_impl_opengl2 to impl_opengl_legacy and imgui_impl_opengl3 to imgui_impl_opengl? (#1900)
|
||||||
- examples: opengl: could use a single vertex buffer and glBufferSubData for uploads?
|
- backends: opengl: could use a single vertex buffer and glBufferSubData for uploads?
|
||||||
- examples: opengl: explicitly disable GL_STENCIL_TEST in bindings.
|
- backends: opengl: explicitly disable GL_STENCIL_TEST in bindings.
|
||||||
- examples: vulkan: viewport: support for synchronized swapping of multiple swap chains.
|
- backends: opengl: consider gl_lite loader https://github.com/ApoorvaJ/Papaya/blob/3808e39b0f45d4ca4972621c847586e4060c042a/src/libs/gl_lite.h
|
||||||
|
- backends: vulkan: viewport: support for synchronized swapping of multiple swap chains.
|
||||||
|
- backends: bgfx: https://gist.github.com/RichardGale/6e2b74bc42b3005e08397236e4be0fd0
|
||||||
|
- backends: mscriptem: with refactored examples, we could provide a direct imgui_impl_emscripten platform layer (see eg. https://github.com/floooh/sokol-samples/blob/master/html5/imgui-emsc.cc#L42)
|
||||||
|
|
||||||
- optimization: replace vsnprintf with stb_printf? or enable the defines/infrastructure to allow it (#1038)
|
- optimization: replace vsnprintf with stb_printf? or enable the defines/infrastructure to allow it (#1038)
|
||||||
- optimization: add clipping for multi-component widgets (SliderFloatX, ColorEditX, etc.). one problem is that nav branch can't easily clip parent group when there is a move request.
|
- optimization: add clipping for multi-component widgets (SliderFloatX, ColorEditX, etc.). one problem is that nav branch can't easily clip parent group when there is a move request.
|
||||||
- optimization: add a flag to disable most of rendering, for the case where the user expect to skip it (#335)
|
- optimization: add a flag to disable most of rendering, for the case where the user expect to skip it (#335)
|
||||||
|
4
examples/.gitignore
vendored
4
examples/.gitignore
vendored
@ -40,3 +40,7 @@ example_sdl_opengl3/example_sdl_opengl3
|
|||||||
|
|
||||||
## Dear ImGui Ini files
|
## Dear ImGui Ini files
|
||||||
imgui.ini
|
imgui.ini
|
||||||
|
|
||||||
|
## JetBrains IDEs
|
||||||
|
.idea
|
||||||
|
cmake-build-*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
dear imgui, v1.71
|
dear imgui, v1.75
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
examples/README.txt
|
examples/README.txt
|
||||||
(This is the README file for the examples/ folder. See docs/ for more documentation)
|
(This is the README file for the examples/ folder. See docs/ for more documentation)
|
||||||
@ -35,6 +35,8 @@ You can find binaries of some of those example applications at:
|
|||||||
MISC COMMENTS AND SUGGESTIONS
|
MISC COMMENTS AND SUGGESTIONS
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
|
- Read FAQ at http://dearimgui.org/faq
|
||||||
|
|
||||||
- Please read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
|
- Please read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
|
||||||
Please read the comments and instruction at the top of each file.
|
Please read the comments and instruction at the top of each file.
|
||||||
|
|
||||||
@ -62,10 +64,10 @@ You can find binaries of some of those example applications at:
|
|||||||
Most the example bindings are split in 2 parts:
|
Most the example bindings are split in 2 parts:
|
||||||
|
|
||||||
- The "Platform" bindings, in charge of: mouse/keyboard/gamepad inputs, cursor shape, timing, windowing.
|
- The "Platform" bindings, in charge of: mouse/keyboard/gamepad inputs, cursor shape, timing, windowing.
|
||||||
Examples: Windows (imgui_impl_win32.cpp), GLFW (imgui_impl_glfw.cpp), SDL2 (imgui_impl_sdl.cpp)
|
Examples: Windows (imgui_impl_win32.cpp), GLFW (imgui_impl_glfw.cpp), SDL2 (imgui_impl_sdl.cpp), etc.
|
||||||
|
|
||||||
- The "Renderer" bindings, in charge of: creating the main font texture, rendering imgui draw data.
|
- The "Renderer" bindings, in charge of: creating the main font texture, rendering imgui draw data.
|
||||||
Examples: DirectX11 (imgui_impl_dx11.cpp), GL3 (imgui_impl_opengl3.cpp), Vulkan (imgui_impl_vulkan.cpp)
|
Examples: DirectX11 (imgui_impl_dx11.cpp), GL3 (imgui_impl_opengl3.cpp), Vulkan (imgui_impl_vulkan.cpp), etc.
|
||||||
|
|
||||||
- The example _applications_ usually combine 1 platform + 1 renderer binding to create a working program.
|
- The example _applications_ usually combine 1 platform + 1 renderer binding to create a working program.
|
||||||
Examples: the example_win32_directx11/ application combines imgui_impl_win32.cpp + imgui_impl_dx11.cpp.
|
Examples: the example_win32_directx11/ application combines imgui_impl_win32.cpp + imgui_impl_dx11.cpp.
|
||||||
@ -104,7 +106,7 @@ List of Platforms Bindings in this repository:
|
|||||||
imgui_impl_osx.mm ; macOS native API (not as feature complete as glfw/sdl back-ends)
|
imgui_impl_osx.mm ; macOS native API (not as feature complete as glfw/sdl back-ends)
|
||||||
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
|
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
|
||||||
imgui_impl_win32.cpp ; Win32 native API (Windows)
|
imgui_impl_win32.cpp ; Win32 native API (Windows)
|
||||||
imgui_impl_glut.cpp ; GLUT/FreeGLUT (absolutely not recommended in 2019)
|
imgui_impl_glut.cpp ; GLUT/FreeGLUT (absolutely not recommended in 2020!)
|
||||||
|
|
||||||
List of Renderer Bindings in this repository:
|
List of Renderer Bindings in this repository:
|
||||||
|
|
||||||
@ -122,16 +124,28 @@ List of high-level Frameworks Bindings in this repository: (combine Platform + R
|
|||||||
imgui_impl_allegro5.cpp
|
imgui_impl_allegro5.cpp
|
||||||
imgui_impl_marmalade.cpp
|
imgui_impl_marmalade.cpp
|
||||||
|
|
||||||
Note that Dear ImGui works with Emscripten.
|
Note that Dear ImGui works with Emscripten. The examples_emscripten/ app uses imgui_impl_sdl.cpp and
|
||||||
The examples_emscripten/ app uses sdl.cpp + opengl3.cpp but other combinations are possible.
|
imgui_impl_opengl3.cpp, but other combinations are possible.
|
||||||
|
|
||||||
Third-party framework, graphics API and languages bindings are listed at:
|
Third-party framework, graphics API and languages bindings are listed at:
|
||||||
|
|
||||||
https://github.com/ocornut/imgui/wiki/Bindings
|
https://github.com/ocornut/imgui/wiki/Bindings
|
||||||
|
|
||||||
Languages: C, C#, ChaiScript, D, Go, Haxe, Java, Lua, Odin, Pascal, PureBasic, Python, Rust, Swift...
|
Including backends for:
|
||||||
Frameworks: Cinder, Cocoa (OSX), Cocos2d-x, SFML, GML/GameMaker Studio, Irrlicht, Ogre, OpenSceneGraph,
|
|
||||||
openFrameworks, LOVE, NanoRT, Nim Game Lib, Qt3d, SFML, Unreal Engine 4...
|
AGS/Adventure Game Studio, Amethyst, bsf, Cinder, Cocos2d-x, Diligent Engine, Flexium,
|
||||||
Miscellaneous: Software Renderer, RemoteImgui, etc.
|
GML/Game Maker Studio2, GTK3+OpenGL3, Irrlicht Engine, LÖVE+LUA, Magnum, NanoRT, Nim Game Lib,
|
||||||
|
Ogre, openFrameworks, OSG/OpenSceneGraph, Orx, px_render, Qt/QtDirect3D, SFML, Sokol,
|
||||||
|
Unreal Engine 4, vtk, Win32 GDI, etc.
|
||||||
|
|
||||||
|
Not sure which to use?
|
||||||
|
Recommended platform/frameworks:
|
||||||
|
|
||||||
|
GLFW https://github.com/glfw/glfw Use imgui_impl_glfw.cpp
|
||||||
|
SDL2 https://www.libsdl.org Use imgui_impl_sdl.cpp
|
||||||
|
Sokol https://github.com/floooh/sokol Use util/sokol_imgui.h in Sokol repository.
|
||||||
|
|
||||||
|
Those will allow you to create portable applications and will solve and abstract away many issues.
|
||||||
|
|
||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
@ -182,7 +196,7 @@ example_glfw_opengl2/
|
|||||||
GLFW + OpenGL2 example (legacy, fixed pipeline).
|
GLFW + OpenGL2 example (legacy, fixed pipeline).
|
||||||
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp
|
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp
|
||||||
**DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
**DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
**Prefer using OPENGL3 code (with gl3w/glew/glad, you can replace the OpenGL function loader)**
|
**Prefer using OPENGL3 code (with gl3w/glew/glad/glbindings, you can replace the OpenGL function loader)**
|
||||||
This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter.
|
This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter.
|
||||||
If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
|
If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
|
||||||
make things more complicated, will require your code to reset many OpenGL attributes to their initial
|
make things more complicated, will require your code to reset many OpenGL attributes to their initial
|
||||||
@ -201,6 +215,7 @@ example_glfw_vulkan/
|
|||||||
GLFW (Win32, Mac, Linux) + Vulkan example.
|
GLFW (Win32, Mac, Linux) + Vulkan example.
|
||||||
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp
|
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp
|
||||||
This is quite long and tedious, because: Vulkan.
|
This is quite long and tedious, because: Vulkan.
|
||||||
|
For this example, the main.cpp file exceptionally use helpers function from imgui_impl_vulkan.h/cpp.
|
||||||
|
|
||||||
example_glut_opengl2/
|
example_glut_opengl2/
|
||||||
GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
|
GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2.
|
||||||
@ -217,11 +232,16 @@ example_null
|
|||||||
This is used to quickly test compilation of core imgui files in as many setups as possible.
|
This is used to quickly test compilation of core imgui files in as many setups as possible.
|
||||||
Because this application doesn't create a window nor a graphic context, there's no graphics output.
|
Because this application doesn't create a window nor a graphic context, there's no graphics output.
|
||||||
|
|
||||||
|
example_sdl_directx11/
|
||||||
|
SDL2 + DirectX11 example, Windows only.
|
||||||
|
= main.cpp + imgui_impl_sdl.cpp + imgui_impl_dx11.cpp
|
||||||
|
This to demonstrate usage of DirectX with SDL.
|
||||||
|
|
||||||
example_sdl_opengl2/
|
example_sdl_opengl2/
|
||||||
SDL2 (Win32, Mac, Linux etc.) + OpenGL example (legacy, fixed pipeline).
|
SDL2 (Win32, Mac, Linux etc.) + OpenGL example (legacy, fixed pipeline).
|
||||||
= main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl2.cpp
|
= main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl2.cpp
|
||||||
**DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
**DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
**Prefer using OPENGL3 code (with gl3w/glew/glad, you can replace the OpenGL function loader)**
|
**Prefer using OPENGL3 code (with gl3w/glew/glad/glbindings, you can replace the OpenGL function loader)**
|
||||||
This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter.
|
This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter.
|
||||||
If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
|
If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
|
||||||
make things more complicated, will require your code to reset many OpenGL attributes to their initial
|
make things more complicated, will require your code to reset many OpenGL attributes to their initial
|
||||||
@ -240,6 +260,7 @@ example_sdl_vulkan/
|
|||||||
SDL2 (Win32, Mac, Linux, etc.) + Vulkan example.
|
SDL2 (Win32, Mac, Linux, etc.) + Vulkan example.
|
||||||
= main.cpp + imgui_impl_sdl.cpp + imgui_impl_vulkan.cpp
|
= main.cpp + imgui_impl_sdl.cpp + imgui_impl_vulkan.cpp
|
||||||
This is quite long and tedious, because: Vulkan.
|
This is quite long and tedious, because: Vulkan.
|
||||||
|
For this example, the main.cpp file exceptionally use helpers function from imgui_impl_vulkan.h/cpp.
|
||||||
|
|
||||||
example_win32_directx9/
|
example_win32_directx9/
|
||||||
DirectX9 example, Windows only.
|
DirectX9 example, Windows only.
|
||||||
|
@ -9,12 +9,14 @@ Note that the back-end supports _BOTH_ 16-bit and 32-bit indices, but 32-bit ind
|
|||||||
|
|
||||||
# How to Build
|
# How to Build
|
||||||
|
|
||||||
### On Ubuntu 14.04+
|
### On Ubuntu 14.04+ and macOS
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
g++ -DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" -I .. -I ../.. main.cpp ../imgui_impl_allegro5.cpp ../../imgui*.cpp -lallegro -lallegro_primitives -o allegro5_example
|
g++ -DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" -I .. -I ../.. main.cpp ../imgui_impl_allegro5.cpp ../../imgui*.cpp -lallegro -lallegro_main -lallegro_primitives -o allegro5_example
|
||||||
```
|
```
|
||||||
|
|
||||||
|
On macOS, install Allegro with homebrew: `brew install allegro`.
|
||||||
|
|
||||||
### On Windows with Visual Studio's CLI
|
### On Windows with Visual Studio's CLI
|
||||||
|
|
||||||
You may install Allegro using vcpkg:
|
You may install Allegro using vcpkg:
|
||||||
|
@ -40,7 +40,7 @@ int main(int, char**)
|
|||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Read 'misc/fonts/README.txt' for more instructions and details.
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
|
@ -133,12 +133,6 @@
|
|||||||
return (YES);
|
return (YES);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flip coordinate system upside down on Y
|
|
||||||
-(BOOL)isFlipped
|
|
||||||
{
|
|
||||||
return (YES);
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)dealloc
|
-(void)dealloc
|
||||||
{
|
{
|
||||||
animationTimer = nil;
|
animationTimer = nil;
|
||||||
@ -150,6 +144,8 @@
|
|||||||
-(void)flagsChanged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
|
-(void)flagsChanged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
|
||||||
-(void)mouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
|
-(void)mouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
|
||||||
-(void)mouseUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
|
-(void)mouseUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
|
||||||
|
-(void)mouseMoved:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
|
||||||
|
-(void)mouseDragged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
|
||||||
-(void)scrollWheel:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
|
-(void)scrollWheel:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); }
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@ -179,6 +175,7 @@
|
|||||||
|
|
||||||
_window = [[NSWindow alloc] initWithContentRect:viewRect styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskResizable|NSWindowStyleMaskClosable backing:NSBackingStoreBuffered defer:YES];
|
_window = [[NSWindow alloc] initWithContentRect:viewRect styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskResizable|NSWindowStyleMaskClosable backing:NSBackingStoreBuffered defer:YES];
|
||||||
[_window setTitle:@"Dear ImGui OSX+OpenGL2 Example"];
|
[_window setTitle:@"Dear ImGui OSX+OpenGL2 Example"];
|
||||||
|
[_window setAcceptsMouseMovedEvents:YES];
|
||||||
[_window setOpaque:YES];
|
[_window setOpaque:YES];
|
||||||
[_window makeKeyAndOrderFront:NSApp];
|
[_window makeKeyAndOrderFront:NSApp];
|
||||||
|
|
||||||
@ -256,7 +253,7 @@
|
|||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Read 'misc/fonts/README.txt' for more instructions and details.
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#
|
#
|
||||||
# Makefile to use with emscripten
|
# Makefile to use with emscripten
|
||||||
# See https://emscripten.org/docs/getting_started/downloads.html
|
# See https://emscripten.org/docs/getting_started/downloads.html
|
||||||
# for installation instructions. This Makefile assumes you have
|
# for installation instructions.
|
||||||
# loaded emscripten's environment.
|
#
|
||||||
|
# This Makefile assumes you have loaded emscripten's environment.
|
||||||
|
# (On Windows, you may need to execute emsdk_env.bat or encmdprompt.bat ahead)
|
||||||
#
|
#
|
||||||
# Running `make` will produce three files:
|
# Running `make` will produce three files:
|
||||||
# - example_emscripten.html
|
# - example_emscripten.html
|
||||||
@ -13,7 +15,6 @@
|
|||||||
|
|
||||||
CC = emcc
|
CC = emcc
|
||||||
CXX = em++
|
CXX = em++
|
||||||
|
|
||||||
EXE = example_emscripten.html
|
EXE = example_emscripten.html
|
||||||
SOURCES = main.cpp
|
SOURCES = main.cpp
|
||||||
SOURCES += ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp
|
SOURCES += ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp
|
||||||
@ -21,18 +22,41 @@ SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui
|
|||||||
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
|
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
|
|
||||||
EMS = -s USE_SDL=2 -s WASM=1
|
##---------------------------------------------------------------------
|
||||||
EMS += -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_TRAP_MODE=clamp
|
## EMSCRIPTEN OPTIONS
|
||||||
|
##---------------------------------------------------------------------
|
||||||
|
|
||||||
|
EMS += -s USE_SDL=2 -s WASM=1
|
||||||
|
EMS += -s ALLOW_MEMORY_GROWTH=1
|
||||||
EMS += -s DISABLE_EXCEPTION_CATCHING=1 -s NO_EXIT_RUNTIME=0
|
EMS += -s DISABLE_EXCEPTION_CATCHING=1 -s NO_EXIT_RUNTIME=0
|
||||||
EMS += -s ASSERTIONS=1 -s NO_FILESYSTEM=1
|
EMS += -s ASSERTIONS=1
|
||||||
|
|
||||||
|
# Uncomment next line to fix possible rendering bugs with Emscripten version older then 1.39.0 (https://github.com/ocornut/imgui/issues/2877)
|
||||||
|
#EMS += -s BINARYEN_TRAP_MODE=clamp
|
||||||
#EMS += -s SAFE_HEAP=1 ## Adds overhead
|
#EMS += -s SAFE_HEAP=1 ## Adds overhead
|
||||||
|
|
||||||
CPPFLAGS = -I../ -I../../
|
# Emscripten allows preloading a file or folder to be accessible at runtime.
|
||||||
|
# The Makefile for this example project suggests embedding the misc/fonts/ folder into our application, it will then be accessible as "/fonts"
|
||||||
|
# See documentation for more details: https://emscripten.org/docs/porting/files/packaging_files.html
|
||||||
|
# (Default value is 0. Set to 1 to enable file-system and include the misc/fonts/ folder as part of the build.)
|
||||||
|
USE_FILE_SYSTEM ?= 0
|
||||||
|
ifeq ($(USE_FILE_SYSTEM), 0)
|
||||||
|
EMS += -s NO_FILESYSTEM=1 -DIMGUI_DISABLE_FILE_FUNCTIONS
|
||||||
|
endif
|
||||||
|
ifeq ($(USE_FILE_SYSTEM), 1)
|
||||||
|
LDFLAGS += --no-heap-copy --preload-file ../../misc/fonts@/fonts
|
||||||
|
endif
|
||||||
|
|
||||||
|
##---------------------------------------------------------------------
|
||||||
|
## FINAL BUILD FLAGS
|
||||||
|
##---------------------------------------------------------------------
|
||||||
|
|
||||||
|
CPPFLAGS += -I../ -I../../
|
||||||
#CPPFLAGS += -g
|
#CPPFLAGS += -g
|
||||||
CPPFLAGS += -Wall -Wformat -Os
|
CPPFLAGS += -Wall -Wformat -Os
|
||||||
CPPFLAGS += $(EMS)
|
CPPFLAGS += $(EMS)
|
||||||
LIBS = $(EMS)
|
LIBS += $(EMS)
|
||||||
LDFLAGS = --shell-file shell_minimal.html
|
LDFLAGS += --shell-file shell_minimal.html
|
||||||
|
|
||||||
##---------------------------------------------------------------------
|
##---------------------------------------------------------------------
|
||||||
## BUILD RULES
|
## BUILD RULES
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
|
|
||||||
- You need to install Emscripten from https://emscripten.org/docs/getting_started/downloads.html, and have the environment variables set, as described in https://emscripten.org/docs/getting_started/downloads.html#installation-instructions
|
- You need to install Emscripten from https://emscripten.org/docs/getting_started/downloads.html, and have the environment variables set, as described in https://emscripten.org/docs/getting_started/downloads.html#installation-instructions
|
||||||
|
|
||||||
```
|
- Depending on your configuration, in Windows you may need to run `emsdk/emsdk_env.bat` in your console to access the Emscripten command-line tools.
|
||||||
em++ -I.. -I../.. main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp ../../imgui*.cpp -s USE_SDL=2 -s USE_WEBGL2=1 -s WASM=1 -s FULL_ES3=1 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_TRAP_MODE=clamp --shell-file shell_minimal.html -o example-emscripten.html
|
|
||||||
```
|
- Then build using `make` while in the `example_emscripten/` directory.
|
||||||
|
|
||||||
|
- Note that Emscripten 1.39.0 (October 2019) obsoleted the `BINARYEN_TRAP_MODE=clamp` compilation flag which was required with version older than 1.39.0 to avoid rendering artefacts. See [#2877](https://github.com/ocornut/imgui/issues/2877) for details. If you use an older version, uncomment this line in the Makefile:
|
||||||
|
|
||||||
|
`#EMS += -s BINARYEN_TRAP_MODE=clamp`
|
||||||
|
@ -81,15 +81,18 @@ int main(int, char**)
|
|||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Read 'misc/fonts/README.txt' for more instructions and details.
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
|
// - Emscripten allows preloading a file or folder to be accessible at runtime. See Makefile for details.
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
#ifndef IMGUI_DISABLE_FILE_FUNCTIONS
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
|
io.Fonts->AddFontFromFileTTF("fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
|
//io.Fonts->AddFontFromFileTTF("fonts/DroidSans.ttf", 16.0f);
|
||||||
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
//io.Fonts->AddFontFromFileTTF("fonts/ProggyTiny.ttf", 10.0f);
|
||||||
|
//ImFont* font = io.Fonts->AddFontFromFileTTF("fonts/ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
||||||
//IM_ASSERT(font != NULL);
|
//IM_ASSERT(font != NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
// This function call won't return, and will engage in an infinite loop, processing events from the browser, and dispatching them.
|
// This function call won't return, and will engage in an infinite loop, processing events from the browser, and dispatching them.
|
||||||
emscripten_set_main_loop_arg(main_loop, NULL, 0, true);
|
emscripten_set_main_loop_arg(main_loop, NULL, 0, true);
|
||||||
|
@ -38,7 +38,7 @@ int main(int, char**)
|
|||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Read 'misc/fonts/README.txt' for more instructions and details.
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
@ -74,6 +74,7 @@ int main(int, char**)
|
|||||||
|
|
||||||
MTLRenderPassDescriptor *renderPassDescriptor = [MTLRenderPassDescriptor new];
|
MTLRenderPassDescriptor *renderPassDescriptor = [MTLRenderPassDescriptor new];
|
||||||
|
|
||||||
|
// Our state
|
||||||
bool show_demo_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
float clear_color[4] = {0.45f, 0.55f, 0.60f, 1.00f};
|
float clear_color[4] = {0.45f, 0.55f, 0.60f, 1.00f};
|
||||||
@ -81,77 +82,80 @@ int main(int, char**)
|
|||||||
// Main loop
|
// Main loop
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
// Poll and handle events (inputs, window resize, etc.)
|
@autoreleasepool
|
||||||
// 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.
|
|
||||||
glfwPollEvents();
|
|
||||||
|
|
||||||
int width, height;
|
|
||||||
glfwGetFramebufferSize(window, &width, &height);
|
|
||||||
layer.drawableSize = CGSizeMake(width, height);
|
|
||||||
id<CAMetalDrawable> drawable = [layer nextDrawable];
|
|
||||||
|
|
||||||
id<MTLCommandBuffer> commandBuffer = [commandQueue commandBuffer];
|
|
||||||
renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color[0], clear_color[1], clear_color[2], clear_color[3]);
|
|
||||||
renderPassDescriptor.colorAttachments[0].texture = drawable.texture;
|
|
||||||
renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear;
|
|
||||||
renderPassDescriptor.colorAttachments[0].storeAction = MTLStoreActionStore;
|
|
||||||
id <MTLRenderCommandEncoder> renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];
|
|
||||||
[renderEncoder pushDebugGroup:@"ImGui demo"];
|
|
||||||
|
|
||||||
// Start the Dear ImGui frame
|
|
||||||
ImGui_ImplMetal_NewFrame(renderPassDescriptor);
|
|
||||||
ImGui_ImplGlfw_NewFrame();
|
|
||||||
ImGui::NewFrame();
|
|
||||||
|
|
||||||
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
|
||||||
if (show_demo_window)
|
|
||||||
ImGui::ShowDemoWindow(&show_demo_window);
|
|
||||||
|
|
||||||
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
|
|
||||||
{
|
{
|
||||||
static float f = 0.0f;
|
// Poll and handle events (inputs, window resize, etc.)
|
||||||
static int counter = 0;
|
// 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.
|
||||||
|
glfwPollEvents();
|
||||||
|
|
||||||
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
|
int width, height;
|
||||||
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
|
layer.drawableSize = CGSizeMake(width, height);
|
||||||
|
id<CAMetalDrawable> drawable = [layer nextDrawable];
|
||||||
|
|
||||||
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
|
id<MTLCommandBuffer> commandBuffer = [commandQueue commandBuffer];
|
||||||
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
|
renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color[0], clear_color[1], clear_color[2], clear_color[3]);
|
||||||
ImGui::Checkbox("Another Window", &show_another_window);
|
renderPassDescriptor.colorAttachments[0].texture = drawable.texture;
|
||||||
|
renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear;
|
||||||
|
renderPassDescriptor.colorAttachments[0].storeAction = MTLStoreActionStore;
|
||||||
|
id <MTLRenderCommandEncoder> renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];
|
||||||
|
[renderEncoder pushDebugGroup:@"ImGui demo"];
|
||||||
|
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
// Start the Dear ImGui frame
|
||||||
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
ImGui_ImplMetal_NewFrame(renderPassDescriptor);
|
||||||
|
ImGui_ImplGlfw_NewFrame();
|
||||||
|
ImGui::NewFrame();
|
||||||
|
|
||||||
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
||||||
counter++;
|
if (show_demo_window)
|
||||||
ImGui::SameLine();
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
ImGui::Text("counter = %d", counter);
|
|
||||||
|
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
|
||||||
ImGui::End();
|
{
|
||||||
|
static float f = 0.0f;
|
||||||
|
static int counter = 0;
|
||||||
|
|
||||||
|
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
|
||||||
|
|
||||||
|
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
|
||||||
|
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
|
||||||
|
ImGui::Checkbox("Another Window", &show_another_window);
|
||||||
|
|
||||||
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
||||||
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
||||||
|
|
||||||
|
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||||
|
counter++;
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Text("counter = %d", counter);
|
||||||
|
|
||||||
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Show another simple window.
|
||||||
|
if (show_another_window)
|
||||||
|
{
|
||||||
|
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
|
||||||
|
ImGui::Text("Hello from another window!");
|
||||||
|
if (ImGui::Button("Close Me"))
|
||||||
|
show_another_window = false;
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rendering
|
||||||
|
ImGui::Render();
|
||||||
|
ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder);
|
||||||
|
|
||||||
|
[renderEncoder popDebugGroup];
|
||||||
|
[renderEncoder endEncoding];
|
||||||
|
|
||||||
|
[commandBuffer presentDrawable:drawable];
|
||||||
|
[commandBuffer commit];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Show another simple window.
|
|
||||||
if (show_another_window)
|
|
||||||
{
|
|
||||||
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
|
|
||||||
ImGui::Text("Hello from another window!");
|
|
||||||
if (ImGui::Button("Close Me"))
|
|
||||||
show_another_window = false;
|
|
||||||
ImGui::End();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rendering
|
|
||||||
ImGui::Render();
|
|
||||||
ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder);
|
|
||||||
|
|
||||||
[renderEncoder popDebugGroup];
|
|
||||||
[renderEncoder endEncoding];
|
|
||||||
|
|
||||||
[commandBuffer presentDrawable:drawable];
|
|
||||||
[commandBuffer commit];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
|
@ -52,7 +52,7 @@ ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
|
|||||||
ECHO_MESSAGE = "MinGW"
|
ECHO_MESSAGE = "MinGW"
|
||||||
LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32
|
LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32
|
||||||
|
|
||||||
CXXFLAGS += -I../libs/gl3w `pkg-config --cflags glfw3`
|
CXXFLAGS += `pkg-config --cflags glfw3`
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ int main(int, char**)
|
|||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Read 'misc/fonts/README.txt' for more instructions and details.
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
@ -69,6 +69,7 @@ int main(int, char**)
|
|||||||
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
||||||
//IM_ASSERT(font != NULL);
|
//IM_ASSERT(font != NULL);
|
||||||
|
|
||||||
|
// Our state
|
||||||
bool show_demo_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
@ -31,16 +31,19 @@ LIBS =
|
|||||||
|
|
||||||
## Using OpenGL loader: gl3w [default]
|
## Using OpenGL loader: gl3w [default]
|
||||||
SOURCES += ../libs/gl3w/GL/gl3w.c
|
SOURCES += ../libs/gl3w/GL/gl3w.c
|
||||||
CXXFLAGS += -I../libs/gl3w
|
CXXFLAGS += -I../libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W
|
||||||
|
|
||||||
## Using OpenGL loader: glew
|
## Using OpenGL loader: glew
|
||||||
## (This assumes a system-wide installation)
|
## (This assumes a system-wide installation)
|
||||||
# CXXFLAGS = -lGLEW -DIMGUI_IMPL_OPENGL_LOADER_GLEW
|
# CXXFLAGS += -lGLEW -DIMGUI_IMPL_OPENGL_LOADER_GLEW
|
||||||
|
|
||||||
## Using OpenGL loader: glad
|
## Using OpenGL loader: glad
|
||||||
## (You'll also need to change the rule at line ~77 of this Makefile to compile/link glad.c/.o)
|
|
||||||
# SOURCES += ../libs/glad/src/glad.c
|
# SOURCES += ../libs/glad/src/glad.c
|
||||||
# CXXFLAGS = -I../libs/glad/include -DIMGUI_IMPL_OPENGL_LOADER_GLAD
|
# CXXFLAGS += -I../libs/glad/include -DIMGUI_IMPL_OPENGL_LOADER_GLAD
|
||||||
|
|
||||||
|
## Using OpenGL loader: glbinding
|
||||||
|
## (This assumes a system-wide installation)
|
||||||
|
# CXXFLAGS += -lglbinding -DIMGUI_IMPL_OPENGL_LOADER_GLBINDING
|
||||||
|
|
||||||
##---------------------------------------------------------------------
|
##---------------------------------------------------------------------
|
||||||
## BUILD FLAGS PER PLATFORM
|
## BUILD FLAGS PER PLATFORM
|
||||||
@ -87,7 +90,9 @@ endif
|
|||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
%.o:../libs/gl3w/GL/%.c
|
%.o:../libs/gl3w/GL/%.c
|
||||||
# %.o:../libs/glad/src/%.c
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
%.o:../libs/glad/src/%.c
|
||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
all: $(EXE)
|
all: $(EXE)
|
||||||
|
@ -7,15 +7,21 @@
|
|||||||
#include "imgui_impl_opengl3.h"
|
#include "imgui_impl_opengl3.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
// About OpenGL function loaders: modern OpenGL doesn't have a standard header file and requires individual function pointers to be loaded manually.
|
// About Desktop OpenGL function loaders:
|
||||||
// Helper libraries are often used for this purpose! Here we are supporting a few common ones: gl3w, glew, glad.
|
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
|
||||||
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
|
// 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)
|
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
|
||||||
#include <GL/gl3w.h> // Initialize with gl3wInit()
|
#include <GL/gl3w.h> // Initialize with gl3wInit()
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
|
||||||
#include <GL/glew.h> // Initialize with glewInit()
|
#include <GL/glew.h> // Initialize with glewInit()
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||||
#include <glad/glad.h> // Initialize with gladLoadGL()
|
#include <glad/glad.h> // Initialize with gladLoadGL()
|
||||||
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING)
|
||||||
|
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
||||||
|
#include <glbinding/glbinding.h> // Initialize with glbinding::initialize()
|
||||||
|
#include <glbinding/gl/gl.h>
|
||||||
|
using namespace gl;
|
||||||
#else
|
#else
|
||||||
#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
|
#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
|
||||||
#endif
|
#endif
|
||||||
@ -73,6 +79,9 @@ int main(int, char**)
|
|||||||
bool err = glewInit() != GLEW_OK;
|
bool err = glewInit() != GLEW_OK;
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||||
bool err = gladLoadGL() == 0;
|
bool err = gladLoadGL() == 0;
|
||||||
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING)
|
||||||
|
bool err = false;
|
||||||
|
glbinding::initialize([](const char* name) { return (glbinding::ProcAddress)glfwGetProcAddress(name); });
|
||||||
#else
|
#else
|
||||||
bool err = false; // If you use IMGUI_IMPL_OPENGL_LOADER_CUSTOM, your loader is likely to requires some form of initialization.
|
bool err = false; // If you use IMGUI_IMPL_OPENGL_LOADER_CUSTOM, your loader is likely to requires some form of initialization.
|
||||||
#endif
|
#endif
|
||||||
@ -102,7 +111,7 @@ int main(int, char**)
|
|||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Read 'misc/fonts/README.txt' for more instructions and details.
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
@ -112,6 +121,7 @@ int main(int, char**)
|
|||||||
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
||||||
//IM_ASSERT(font != NULL);
|
//IM_ASSERT(font != NULL);
|
||||||
|
|
||||||
|
// Our state
|
||||||
bool show_demo_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
@ -400,7 +400,7 @@ int main(int, char**)
|
|||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Read 'misc/fonts/README.txt' for more instructions and details.
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
@ -440,6 +440,7 @@ int main(int, char**)
|
|||||||
ImGui_ImplVulkan_DestroyFontUploadObjects();
|
ImGui_ImplVulkan_DestroyFontUploadObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Our state
|
||||||
bool show_demo_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
@ -41,7 +41,13 @@ endif
|
|||||||
|
|
||||||
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
|
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
|
||||||
ECHO_MESSAGE = "MinGW"
|
ECHO_MESSAGE = "MinGW"
|
||||||
LIBS += -lgdi32 -lopengl32 -limm32 -lglut
|
LIBS += -lgdi32 -lopengl32 -limm32
|
||||||
|
ifeq ($(shell pkg-config freeglut --exists 2> /dev/null && echo yes || echo no),yes)
|
||||||
|
CXXFLAGS += $(shell pkg-config freeglut --cflags)
|
||||||
|
LIBS += $(shell pkg-config freeglut --libs)
|
||||||
|
else
|
||||||
|
LIBS += -lglut
|
||||||
|
endif
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
|
||||||
// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
|
// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
|
||||||
// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
|
// !!! If someone or something is teaching you GLUT in 2020, you are being abused. Please show some resistance. !!!
|
||||||
// !!! Nowadays, prefer using GLFW or SDL instead!
|
// !!! Nowadays, prefer using GLFW or SDL instead!
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "../imgui_impl_glut.h"
|
#include "imgui_impl_glut.h"
|
||||||
#include "../imgui_impl_opengl2.h"
|
#include "imgui_impl_opengl2.h"
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <GLUT/glut.h>
|
#include <GLUT/glut.h>
|
||||||
#else
|
#else
|
||||||
@ -18,6 +18,7 @@
|
|||||||
#pragma warning (disable: 4505) // unreferenced local function has been removed
|
#pragma warning (disable: 4505) // unreferenced local function has been removed
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Our state
|
||||||
static bool show_demo_window = true;
|
static bool show_demo_window = true;
|
||||||
static bool show_another_window = false;
|
static bool show_another_window = false;
|
||||||
static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
@ -105,6 +106,7 @@ int main(int argc, char** argv)
|
|||||||
glutDisplayFunc(glut_display_func);
|
glutDisplayFunc(glut_display_func);
|
||||||
|
|
||||||
// Setup Dear ImGui context
|
// Setup Dear ImGui context
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
@ -123,7 +125,7 @@ int main(int argc, char** argv)
|
|||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Read 'misc/fonts/README.txt' for more instructions and details.
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
|
@ -34,7 +34,7 @@ int main(int, char**)
|
|||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Read 'misc/fonts/README.txt' for more instructions and details.
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
@ -44,6 +44,7 @@ int main(int, char**)
|
|||||||
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
||||||
//IM_ASSERT(font != NULL);
|
//IM_ASSERT(font != NULL);
|
||||||
|
|
||||||
|
// Our state
|
||||||
bool show_demo_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
@ -4,31 +4,46 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
EXE = example_null
|
EXE = example_null
|
||||||
|
EXTRA_WARNINGS ?= 0
|
||||||
SOURCES = main.cpp
|
SOURCES = main.cpp
|
||||||
SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
|
SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
|
||||||
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
|
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
|
|
||||||
CXXFLAGS = -I../ -I../../
|
CXXFLAGS += -I../ -I../../
|
||||||
CXXFLAGS += -g -Wall -Wformat
|
CXXFLAGS += -g -Wall -Wformat
|
||||||
LIBS =
|
LIBS =
|
||||||
|
|
||||||
|
# We use the EXTRA_WARNINGS flag on our CI setup to eagerly catch zealous warnings
|
||||||
|
ifeq ($(EXTRA_WARNINGS), 1)
|
||||||
|
CXXFLAGS += -Wno-zero-as-null-pointer-constant -Wno-double-promotion -Wno-variadic-macros
|
||||||
|
endif
|
||||||
|
|
||||||
##---------------------------------------------------------------------
|
##---------------------------------------------------------------------
|
||||||
## BUILD FLAGS PER PLATFORM
|
## BUILD FLAGS PER PLATFORM
|
||||||
##---------------------------------------------------------------------
|
##---------------------------------------------------------------------
|
||||||
|
|
||||||
ifeq ($(UNAME_S), Linux) #LINUX
|
ifeq ($(UNAME_S), Linux) #LINUX
|
||||||
ECHO_MESSAGE = "Linux"
|
ECHO_MESSAGE = "Linux"
|
||||||
|
ifneq ($(EXTRA_WARNINGS), 0)
|
||||||
|
CXXFLAGS += -Wextra -pedantic
|
||||||
|
endif
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(UNAME_S), Darwin) #APPLE
|
ifeq ($(UNAME_S), Darwin) #APPLE
|
||||||
ECHO_MESSAGE = "Mac OS X"
|
ECHO_MESSAGE = "Mac OS X"
|
||||||
|
ifneq ($(EXTRA_WARNINGS), 0)
|
||||||
|
CXXFLAGS += -Weverything -Wno-reserved-id-macro -Wno-c++98-compat-pedantic -Wno-padded -Wno-c++11-long-long
|
||||||
|
endif
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
|
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
|
||||||
ECHO_MESSAGE = "MinGW"
|
ECHO_MESSAGE = "MinGW"
|
||||||
|
ifneq ($(EXTRA_WARNINGS), 0)
|
||||||
|
CXXFLAGS += -Wextra -pedantic
|
||||||
|
endif
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -45,10 +60,6 @@ endif
|
|||||||
%.o:../../%.cpp
|
%.o:../../%.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
%.o:../libs/gl3w/GL/%.c
|
|
||||||
# %.o:../libs/glad/src/%.c
|
|
||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
|
||||||
|
|
||||||
all: $(EXE)
|
all: $(EXE)
|
||||||
@echo Build complete for $(ECHO_MESSAGE)
|
@echo Build complete for $(ECHO_MESSAGE)
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
|
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
|
||||||
mkdir Debug
|
mkdir Debug
|
||||||
cl /nologo /Zi /MD /I ..\.. *.cpp ..\..\*.cpp /FeDebug/example_null.exe /FoDebug/ /link gdi32.lib shell32.lib
|
cl /nologo /Zi /MD /I ..\.. %* *.cpp ..\..\*.cpp /FeDebug/example_null.exe /FoDebug/ /link gdi32.lib shell32.lib
|
||||||
|
8
examples/example_sdl_directx11/build_win32.bat
Normal file
8
examples/example_sdl_directx11/build_win32.bat
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
|
||||||
|
set OUT_DIR=Debug
|
||||||
|
set OUT_EXE=example_sdl_directx11
|
||||||
|
set INCLUDES=/I.. /I..\.. /I%SDL2_DIR%\include /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include"
|
||||||
|
set SOURCES=main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_dx11.cpp ..\..\imgui*.cpp
|
||||||
|
set LIBS=/libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib
|
||||||
|
mkdir %OUT_DIR%
|
||||||
|
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
|
181
examples/example_sdl_directx11/example_sdl_directx11.vcxproj
Normal file
181
examples/example_sdl_directx11/example_sdl_directx11.vcxproj
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{9E1987E3-1F19-45CA-B9C9-D31E791836D8}</ProjectGuid>
|
||||||
|
<RootNamespace>example_sdl_directx11</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||||
|
<ProjectName>example_sdl_directx11</ProjectName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||||
|
<IncludePath>$(IncludePath)</IncludePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalLibraryDirectories>%SDL2_DIR%\lib\x86;$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<AdditionalDependencies>SDL2.lib;SDL2main.lib;d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<IgnoreSpecificDefaultLibraries>msvcrt.lib</IgnoreSpecificDefaultLibraries>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalLibraryDirectories>%SDL2_DIR%\lib\x64;$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<AdditionalDependencies>SDL2.lib;SDL2main.lib;d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<IgnoreSpecificDefaultLibraries>msvcrt.lib</IgnoreSpecificDefaultLibraries>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<AdditionalIncludeDirectories>..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalLibraryDirectories>%SDL2_DIR%\lib\x86;$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<AdditionalDependencies>SDL2.lib;SDL2main.lib;d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<IgnoreSpecificDefaultLibraries>
|
||||||
|
</IgnoreSpecificDefaultLibraries>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<AdditionalIncludeDirectories>..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalLibraryDirectories>%SDL2_DIR%\lib\x64;$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<AdditionalDependencies>SDL2.lib;SDL2main.lib;d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<IgnoreSpecificDefaultLibraries>
|
||||||
|
</IgnoreSpecificDefaultLibraries>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\imgui.cpp" />
|
||||||
|
<ClCompile Include="..\..\imgui_demo.cpp" />
|
||||||
|
<ClCompile Include="..\..\imgui_draw.cpp" />
|
||||||
|
<ClCompile Include="..\..\imgui_widgets.cpp" />
|
||||||
|
<ClCompile Include="..\imgui_impl_dx11.cpp" />
|
||||||
|
<ClCompile Include="..\imgui_impl_sdl.cpp" />
|
||||||
|
<ClCompile Include="main.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\imconfig.h" />
|
||||||
|
<ClInclude Include="..\..\imgui.h" />
|
||||||
|
<ClInclude Include="..\..\imgui_internal.h" />
|
||||||
|
<ClInclude Include="..\imgui_impl_dx11.h" />
|
||||||
|
<ClInclude Include="..\imgui_impl_sdl.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="..\..\misc\natvis\imgui.natvis" />
|
||||||
|
<None Include="..\README.txt" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="imgui">
|
||||||
|
<UniqueIdentifier>{0587d7a3-f2ce-4d56-b84f-a0005d3bfce6}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="sources">
|
||||||
|
<UniqueIdentifier>{08e36723-ce4f-4cff-9662-c40801cf1acf}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\imconfig.h">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\imgui.h">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\imgui_internal.h">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\imgui_impl_dx11.h">
|
||||||
|
<Filter>sources</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\imgui_impl_sdl.h">
|
||||||
|
<Filter>sources</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\imgui.cpp">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="main.cpp">
|
||||||
|
<Filter>sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\imgui_demo.cpp">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\imgui_draw.cpp">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\imgui_impl_dx11.cpp">
|
||||||
|
<Filter>sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\imgui_widgets.cpp">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\imgui_impl_sdl.cpp">
|
||||||
|
<Filter>sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="..\README.txt" />
|
||||||
|
<None Include="..\..\misc\natvis\imgui.natvis">
|
||||||
|
<Filter>sources</Filter>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
221
examples/example_sdl_directx11/main.cpp
Normal file
221
examples/example_sdl_directx11/main.cpp
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
// dear imgui: standalone example application for SDL2 + DirectX 11
|
||||||
|
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "imgui_impl_sdl.h"
|
||||||
|
#include "imgui_impl_dx11.h"
|
||||||
|
#include <d3d11.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <SDL.h>
|
||||||
|
#include <SDL_syswm.h>
|
||||||
|
|
||||||
|
// Data
|
||||||
|
static ID3D11Device* g_pd3dDevice = NULL;
|
||||||
|
static ID3D11DeviceContext* g_pd3dDeviceContext = NULL;
|
||||||
|
static IDXGISwapChain* g_pSwapChain = NULL;
|
||||||
|
static ID3D11RenderTargetView* g_mainRenderTargetView = NULL;
|
||||||
|
|
||||||
|
// Forward declarations of helper functions
|
||||||
|
bool CreateDeviceD3D(HWND hWnd);
|
||||||
|
void CleanupDeviceD3D();
|
||||||
|
void CreateRenderTarget();
|
||||||
|
void CleanupRenderTarget();
|
||||||
|
|
||||||
|
// Main code
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
// Setup SDL
|
||||||
|
// (Some versions of SDL before <2.0.10 appears to have performance/stalling issues on a minority of Windows systems,
|
||||||
|
// depending on whether SDL_INIT_GAMECONTROLLER is enabled or disabled.. updating to latest version of SDL is recommended!)
|
||||||
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0)
|
||||||
|
{
|
||||||
|
printf("Error: %s\n", SDL_GetError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup window
|
||||||
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+DirectX11 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
|
||||||
|
SDL_SysWMinfo wmInfo;
|
||||||
|
SDL_VERSION(&wmInfo.version);
|
||||||
|
SDL_GetWindowWMInfo(window, &wmInfo);
|
||||||
|
HWND hwnd = (HWND)wmInfo.info.win.window;
|
||||||
|
|
||||||
|
// Initialize Direct3D
|
||||||
|
if (!CreateDeviceD3D(hwnd))
|
||||||
|
{
|
||||||
|
CleanupDeviceD3D();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup Dear ImGui context
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
|
ImGui::CreateContext();
|
||||||
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
|
||||||
|
// Setup Dear ImGui style
|
||||||
|
ImGui::StyleColorsDark();
|
||||||
|
//ImGui::StyleColorsClassic();
|
||||||
|
|
||||||
|
// Setup Platform/Renderer bindings
|
||||||
|
ImGui_ImplSDL2_InitForD3D(window);
|
||||||
|
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
|
||||||
|
|
||||||
|
// Load Fonts
|
||||||
|
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
|
//io.Fonts->AddFontDefault();
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
|
||||||
|
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
||||||
|
//IM_ASSERT(font != NULL);
|
||||||
|
|
||||||
|
// Our state
|
||||||
|
bool show_demo_window = true;
|
||||||
|
bool show_another_window = false;
|
||||||
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
|
||||||
|
// Main loop
|
||||||
|
bool done = false;
|
||||||
|
while (!done)
|
||||||
|
{
|
||||||
|
// Poll and handle events (inputs, window resize, etc.)
|
||||||
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||||
|
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||||
|
// - 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.
|
||||||
|
SDL_Event event;
|
||||||
|
while (SDL_PollEvent(&event))
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ProcessEvent(&event);
|
||||||
|
if (event.type == SDL_QUIT)
|
||||||
|
done = true;
|
||||||
|
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window))
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start the Dear ImGui frame
|
||||||
|
ImGui_ImplDX11_NewFrame();
|
||||||
|
ImGui_ImplSDL2_NewFrame(window);
|
||||||
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
||||||
|
if (show_demo_window)
|
||||||
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
|
|
||||||
|
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
|
||||||
|
{
|
||||||
|
static float f = 0.0f;
|
||||||
|
static int counter = 0;
|
||||||
|
|
||||||
|
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
|
||||||
|
|
||||||
|
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
|
||||||
|
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
|
||||||
|
ImGui::Checkbox("Another Window", &show_another_window);
|
||||||
|
|
||||||
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
||||||
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
||||||
|
|
||||||
|
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||||
|
counter++;
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Text("counter = %d", counter);
|
||||||
|
|
||||||
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Show another simple window.
|
||||||
|
if (show_another_window)
|
||||||
|
{
|
||||||
|
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
|
||||||
|
ImGui::Text("Hello from another window!");
|
||||||
|
if (ImGui::Button("Close Me"))
|
||||||
|
show_another_window = false;
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rendering
|
||||||
|
ImGui::Render();
|
||||||
|
g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL);
|
||||||
|
g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, (float*)&clear_color);
|
||||||
|
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
g_pSwapChain->Present(1, 0); // Present with vsync
|
||||||
|
//g_pSwapChain->Present(0, 0); // Present without vsync
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
ImGui_ImplDX11_Shutdown();
|
||||||
|
ImGui_ImplSDL2_Shutdown();
|
||||||
|
ImGui::DestroyContext();
|
||||||
|
|
||||||
|
CleanupDeviceD3D();
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
SDL_Quit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper functions
|
||||||
|
|
||||||
|
bool CreateDeviceD3D(HWND hWnd)
|
||||||
|
{
|
||||||
|
// Setup swap chain
|
||||||
|
DXGI_SWAP_CHAIN_DESC sd;
|
||||||
|
ZeroMemory(&sd, sizeof(sd));
|
||||||
|
sd.BufferCount = 2;
|
||||||
|
sd.BufferDesc.Width = 0;
|
||||||
|
sd.BufferDesc.Height = 0;
|
||||||
|
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
sd.BufferDesc.RefreshRate.Numerator = 60;
|
||||||
|
sd.BufferDesc.RefreshRate.Denominator = 1;
|
||||||
|
sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
|
||||||
|
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||||
|
sd.OutputWindow = hWnd;
|
||||||
|
sd.SampleDesc.Count = 1;
|
||||||
|
sd.SampleDesc.Quality = 0;
|
||||||
|
sd.Windowed = TRUE;
|
||||||
|
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||||
|
|
||||||
|
UINT createDeviceFlags = 0;
|
||||||
|
//createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||||
|
D3D_FEATURE_LEVEL featureLevel;
|
||||||
|
const D3D_FEATURE_LEVEL featureLevelArray[2] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_0, };
|
||||||
|
if (D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext) != S_OK)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CreateRenderTarget();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CleanupDeviceD3D()
|
||||||
|
{
|
||||||
|
CleanupRenderTarget();
|
||||||
|
if (g_pSwapChain) { g_pSwapChain->Release(); g_pSwapChain = NULL; }
|
||||||
|
if (g_pd3dDeviceContext) { g_pd3dDeviceContext->Release(); g_pd3dDeviceContext = NULL; }
|
||||||
|
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateRenderTarget()
|
||||||
|
{
|
||||||
|
ID3D11Texture2D* pBackBuffer;
|
||||||
|
g_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
||||||
|
g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &g_mainRenderTargetView);
|
||||||
|
pBackBuffer->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CleanupRenderTarget()
|
||||||
|
{
|
||||||
|
if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = NULL; }
|
||||||
|
}
|
@ -13,9 +13,12 @@
|
|||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_opengl.h>
|
#include <SDL_opengl.h>
|
||||||
|
|
||||||
|
// Main code
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
// Setup SDL
|
// Setup SDL
|
||||||
|
// (Some versions of SDL before <2.0.10 appears to have performance/stalling issues on a minority of Windows systems,
|
||||||
|
// depending on whether SDL_INIT_GAMECONTROLLER is enabled or disabled.. updating to latest version of SDL is recommended!)
|
||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0)
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0)
|
||||||
{
|
{
|
||||||
printf("Error: %s\n", SDL_GetError());
|
printf("Error: %s\n", SDL_GetError());
|
||||||
@ -54,7 +57,7 @@ int main(int, char**)
|
|||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Read 'misc/fonts/README.txt' for more instructions and details.
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
@ -64,6 +67,7 @@ int main(int, char**)
|
|||||||
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
||||||
//IM_ASSERT(font != NULL);
|
//IM_ASSERT(font != NULL);
|
||||||
|
|
||||||
|
// Our state
|
||||||
bool show_demo_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
@ -31,16 +31,19 @@ LIBS =
|
|||||||
|
|
||||||
## Using OpenGL loader: gl3w [default]
|
## Using OpenGL loader: gl3w [default]
|
||||||
SOURCES += ../libs/gl3w/GL/gl3w.c
|
SOURCES += ../libs/gl3w/GL/gl3w.c
|
||||||
CXXFLAGS += -I../libs/gl3w
|
CXXFLAGS += -I../libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W
|
||||||
|
|
||||||
## Using OpenGL loader: glew
|
## Using OpenGL loader: glew
|
||||||
## (This assumes a system-wide installation)
|
## (This assumes a system-wide installation)
|
||||||
# CXXFLAGS = -lGLEW -DIMGUI_IMPL_OPENGL_LOADER_GLEW
|
# CXXFLAGS += -lGLEW -DIMGUI_IMPL_OPENGL_LOADER_GLEW
|
||||||
|
|
||||||
## Using OpenGL loader: glad
|
## Using OpenGL loader: glad
|
||||||
## (You'll also need to change the rule at line ~77 of this Makefile to compile/link glad.c/.o)
|
|
||||||
# SOURCES += ../libs/glad/src/glad.c
|
# SOURCES += ../libs/glad/src/glad.c
|
||||||
# CXXFLAGS = -I../libs/glad/include -DIMGUI_IMPL_OPENGL_LOADER_GLAD
|
# CXXFLAGS += -I../libs/glad/include -DIMGUI_IMPL_OPENGL_LOADER_GLAD
|
||||||
|
|
||||||
|
## Using OpenGL loader: glbinding
|
||||||
|
## (This assumes a system-wide installation)
|
||||||
|
# CXXFLAGS += -lglbinding -DIMGUI_IMPL_OPENGL_LOADER_GLBINDING
|
||||||
|
|
||||||
##---------------------------------------------------------------------
|
##---------------------------------------------------------------------
|
||||||
## BUILD FLAGS PER PLATFORM
|
## BUILD FLAGS PER PLATFORM
|
||||||
@ -50,7 +53,7 @@ ifeq ($(UNAME_S), Linux) #LINUX
|
|||||||
ECHO_MESSAGE = "Linux"
|
ECHO_MESSAGE = "Linux"
|
||||||
LIBS += -lGL -ldl `sdl2-config --libs`
|
LIBS += -lGL -ldl `sdl2-config --libs`
|
||||||
|
|
||||||
CXXFLAGS += -I../libs/gl3w `sdl2-config --cflags`
|
CXXFLAGS += `sdl2-config --cflags`
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -59,7 +62,7 @@ ifeq ($(UNAME_S), Darwin) #APPLE
|
|||||||
LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs`
|
LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs`
|
||||||
LIBS += -L/usr/local/lib -L/opt/local/lib
|
LIBS += -L/usr/local/lib -L/opt/local/lib
|
||||||
|
|
||||||
CXXFLAGS += -I../libs/gl3w `sdl2-config --cflags`
|
CXXFLAGS += `sdl2-config --cflags`
|
||||||
CXXFLAGS += -I/usr/local/include -I/opt/local/include
|
CXXFLAGS += -I/usr/local/include -I/opt/local/include
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
endif
|
endif
|
||||||
@ -68,7 +71,7 @@ ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
|
|||||||
ECHO_MESSAGE = "MinGW"
|
ECHO_MESSAGE = "MinGW"
|
||||||
LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
|
LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
|
||||||
|
|
||||||
CXXFLAGS += -I../libs/gl3w `pkg-config --cflags sdl2`
|
CXXFLAGS += `pkg-config --cflags sdl2`
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -88,6 +91,9 @@ endif
|
|||||||
%.o:../libs/gl3w/GL/%.c
|
%.o:../libs/gl3w/GL/%.c
|
||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
%.o:../libs/glad/src/%.c
|
||||||
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
all: $(EXE)
|
all: $(EXE)
|
||||||
@echo Build complete for $(ECHO_MESSAGE)
|
@echo Build complete for $(ECHO_MESSAGE)
|
||||||
|
|
||||||
|
@ -9,22 +9,30 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
// About OpenGL function loaders: modern OpenGL doesn't have a standard header file and requires individual function pointers to be loaded manually.
|
// About Desktop OpenGL function loaders:
|
||||||
// Helper libraries are often used for this purpose! Here we are supporting a few common ones: gl3w, glew, glad.
|
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
|
||||||
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
|
// 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)
|
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
|
||||||
#include <GL/gl3w.h> // Initialize with gl3wInit()
|
#include <GL/gl3w.h> // Initialize with gl3wInit()
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
|
||||||
#include <GL/glew.h> // Initialize with glewInit()
|
#include <GL/glew.h> // Initialize with glewInit()
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||||
#include <glad/glad.h> // Initialize with gladLoadGL()
|
#include <glad/glad.h> // Initialize with gladLoadGL()
|
||||||
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING)
|
||||||
|
#include <glbinding/glbinding.h> // Initialize with glbinding::initialize()
|
||||||
|
#include <glbinding/gl/gl.h>
|
||||||
|
using namespace gl;
|
||||||
#else
|
#else
|
||||||
#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
|
#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Main code
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
// Setup SDL
|
// Setup SDL
|
||||||
|
// (Some versions of SDL before <2.0.10 appears to have performance/stalling issues on a minority of Windows systems,
|
||||||
|
// depending on whether SDL_INIT_GAMECONTROLLER is enabled or disabled.. updating to latest version of SDL is recommended!)
|
||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0)
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0)
|
||||||
{
|
{
|
||||||
printf("Error: %s\n", SDL_GetError());
|
printf("Error: %s\n", SDL_GetError());
|
||||||
@ -65,6 +73,9 @@ int main(int, char**)
|
|||||||
bool err = glewInit() != GLEW_OK;
|
bool err = glewInit() != GLEW_OK;
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||||
bool err = gladLoadGL() == 0;
|
bool err = gladLoadGL() == 0;
|
||||||
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING)
|
||||||
|
bool err = false;
|
||||||
|
glbinding::initialize([](const char* name) { return (glbinding::ProcAddress)SDL_GL_GetProcAddress(name); });
|
||||||
#else
|
#else
|
||||||
bool err = false; // If you use IMGUI_IMPL_OPENGL_LOADER_CUSTOM, your loader is likely to requires some form of initialization.
|
bool err = false; // If you use IMGUI_IMPL_OPENGL_LOADER_CUSTOM, your loader is likely to requires some form of initialization.
|
||||||
#endif
|
#endif
|
||||||
@ -94,7 +105,7 @@ int main(int, char**)
|
|||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Read 'misc/fonts/README.txt' for more instructions and details.
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
@ -104,6 +115,7 @@ int main(int, char**)
|
|||||||
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
||||||
//IM_ASSERT(font != NULL);
|
//IM_ASSERT(font != NULL);
|
||||||
|
|
||||||
|
// Our state
|
||||||
bool show_demo_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
@ -322,7 +322,7 @@ int main(int, char**)
|
|||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0)
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0)
|
||||||
{
|
{
|
||||||
printf("Error: %s\n", SDL_GetError());
|
printf("Error: %s\n", SDL_GetError());
|
||||||
return 1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup window
|
// Setup window
|
||||||
@ -353,6 +353,7 @@ int main(int, char**)
|
|||||||
SetupVulkanWindow(wd, surface, w, h);
|
SetupVulkanWindow(wd, surface, w, h);
|
||||||
|
|
||||||
// Setup Dear ImGui context
|
// Setup Dear ImGui context
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
@ -383,7 +384,7 @@ int main(int, char**)
|
|||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Read 'misc/fonts/README.txt' for more instructions and details.
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
@ -423,6 +424,7 @@ int main(int, char**)
|
|||||||
ImGui_ImplVulkan_DestroyFontUploadObjects();
|
ImGui_ImplVulkan_DestroyFontUploadObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Our state
|
||||||
bool show_demo_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
@ -121,7 +121,7 @@
|
|||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>d3d10.lib;d3dcompiler.lib;dxgi.lib;imm32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>d3d10.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalLibraryDirectories>$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
</Link>
|
</Link>
|
||||||
@ -139,7 +139,7 @@
|
|||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>d3d10.lib;d3dcompiler.lib;dxgi.lib;imm32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>d3d10.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalLibraryDirectories>$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -62,7 +62,7 @@ int main(int, char**)
|
|||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Read 'misc/fonts/README.txt' for more instructions and details.
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
|
@ -120,7 +120,7 @@
|
|||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>d3d11.lib;d3dcompiler.lib;dxgi.lib;imm32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalLibraryDirectories>$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
</Link>
|
</Link>
|
||||||
@ -138,7 +138,7 @@
|
|||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>d3d11.lib;d3dcompiler.lib;dxgi.lib;imm32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalLibraryDirectories>$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -62,7 +62,7 @@ int main(int, char**)
|
|||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Read 'misc/fonts/README.txt' for more instructions and details.
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
@ -146,6 +146,7 @@ int main(int, char**)
|
|||||||
//g_pSwapChain->Present(0, 0); // Present without vsync
|
//g_pSwapChain->Present(0, 0); // Present without vsync
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
ImGui_ImplDX11_Shutdown();
|
ImGui_ImplDX11_Shutdown();
|
||||||
ImGui_ImplWin32_Shutdown();
|
ImGui_ImplWin32_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
|
@ -9,7 +9,12 @@
|
|||||||
#include <dxgi1_4.h>
|
#include <dxgi1_4.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
|
||||||
#define DX12_ENABLE_DEBUG_LAYER 0
|
//#define DX12_ENABLE_DEBUG_LAYER
|
||||||
|
|
||||||
|
#ifdef DX12_ENABLE_DEBUG_LAYER
|
||||||
|
#include <dxgidebug.h>
|
||||||
|
#pragma comment(lib, "dxguid.lib")
|
||||||
|
#endif
|
||||||
|
|
||||||
struct FrameContext
|
struct FrameContext
|
||||||
{
|
{
|
||||||
@ -80,7 +85,7 @@ int main(int, char**)
|
|||||||
// Setup Platform/Renderer bindings
|
// Setup Platform/Renderer bindings
|
||||||
ImGui_ImplWin32_Init(hwnd);
|
ImGui_ImplWin32_Init(hwnd);
|
||||||
ImGui_ImplDX12_Init(g_pd3dDevice, NUM_FRAMES_IN_FLIGHT,
|
ImGui_ImplDX12_Init(g_pd3dDevice, NUM_FRAMES_IN_FLIGHT,
|
||||||
DXGI_FORMAT_R8G8B8A8_UNORM,
|
DXGI_FORMAT_R8G8B8A8_UNORM, g_pd3dSrvDescHeap,
|
||||||
g_pd3dSrvDescHeap->GetCPUDescriptorHandleForHeapStart(),
|
g_pd3dSrvDescHeap->GetCPUDescriptorHandleForHeapStart(),
|
||||||
g_pd3dSrvDescHeap->GetGPUDescriptorHandleForHeapStart());
|
g_pd3dSrvDescHeap->GetGPUDescriptorHandleForHeapStart());
|
||||||
|
|
||||||
@ -89,7 +94,7 @@ int main(int, char**)
|
|||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Read 'misc/fonts/README.txt' for more instructions and details.
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
@ -233,15 +238,14 @@ bool CreateDeviceD3D(HWND hWnd)
|
|||||||
sd.Stereo = FALSE;
|
sd.Stereo = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DX12_ENABLE_DEBUG_LAYER)
|
#ifdef DX12_ENABLE_DEBUG_LAYER
|
||||||
|
ID3D12Debug* pdx12Debug = NULL;
|
||||||
|
if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&pdx12Debug))))
|
||||||
{
|
{
|
||||||
ID3D12Debug* dx12Debug = NULL;
|
pdx12Debug->EnableDebugLayer();
|
||||||
if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&dx12Debug))))
|
pdx12Debug->Release();
|
||||||
{
|
|
||||||
dx12Debug->EnableDebugLayer();
|
|
||||||
dx12Debug->Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0;
|
D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0;
|
||||||
if (D3D12CreateDevice(NULL, featureLevel, IID_PPV_ARGS(&g_pd3dDevice)) != S_OK)
|
if (D3D12CreateDevice(NULL, featureLevel, IID_PPV_ARGS(&g_pd3dDevice)) != S_OK)
|
||||||
@ -329,6 +333,15 @@ void CleanupDeviceD3D()
|
|||||||
if (g_fence) { g_fence->Release(); g_fence = NULL; }
|
if (g_fence) { g_fence->Release(); g_fence = NULL; }
|
||||||
if (g_fenceEvent) { CloseHandle(g_fenceEvent); g_fenceEvent = NULL; }
|
if (g_fenceEvent) { CloseHandle(g_fenceEvent); g_fenceEvent = NULL; }
|
||||||
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
|
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
|
||||||
|
|
||||||
|
#ifdef DX12_ENABLE_DEBUG_LAYER
|
||||||
|
IDXGIDebug1* pDebug = NULL;
|
||||||
|
if (SUCCEEDED(DXGIGetDebugInterface1(0, IID_PPV_ARGS(&pDebug))))
|
||||||
|
{
|
||||||
|
pDebug->ReportLiveObjects(DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_SUMMARY);
|
||||||
|
pDebug->Release();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateRenderTarget()
|
void CreateRenderTarget()
|
||||||
|
@ -60,7 +60,7 @@ int main(int, char**)
|
|||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Read 'misc/fonts/README.txt' for more instructions and details.
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.)
|
// (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Platform: Clipboard support (from Allegro 5.1.12)
|
// [X] Platform: Clipboard support (from Allegro 5.1.12)
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// Issues:
|
// Issues:
|
||||||
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
|
||||||
|
// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter.
|
||||||
// 2019-05-11: Inputs: Don't filter character value from ALLEGRO_EVENT_KEY_CHAR before calling AddInputCharacter().
|
// 2019-05-11: Inputs: Don't filter character value from ALLEGRO_EVENT_KEY_CHAR before calling AddInputCharacter().
|
||||||
// 2019-04-30: Renderer: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
// 2019-04-30: Renderer: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||||
// 2018-11-30: Platform: Added touchscreen support.
|
// 2018-11-30: Platform: Added touchscreen support.
|
||||||
@ -24,7 +26,7 @@
|
|||||||
// 2018-06-13: Renderer: Backup/restore transform and clipping rectangle.
|
// 2018-06-13: Renderer: Backup/restore transform and clipping rectangle.
|
||||||
// 2018-06-11: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoMouseCursorChange flag.
|
// 2018-06-11: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoMouseCursorChange flag.
|
||||||
// 2018-04-18: Misc: Renamed file from imgui_impl_a5.cpp to imgui_impl_allegro5.cpp.
|
// 2018-04-18: Misc: Renamed file from imgui_impl_a5.cpp to imgui_impl_allegro5.cpp.
|
||||||
// 2018-04-18: Misc: Added support for 32-bits vertex indices to avoid conversion at runtime. Added imconfig_allegro5.h to enforce 32-bit indices when included from imgui.h.
|
// 2018-04-18: Misc: Added support for 32-bit vertex indices to avoid conversion at runtime. Added imconfig_allegro5.h to enforce 32-bit indices when included from imgui.h.
|
||||||
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplAllegro5_RenderDrawData() in the .h file so you can call it yourself.
|
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplAllegro5_RenderDrawData() in the .h file so you can call it yourself.
|
||||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
// 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-06: Inputs: Added mapping for ImGuiKey_Space.
|
||||||
@ -107,7 +109,7 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data)
|
|||||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||||
|
|
||||||
// Allegro's implementation of al_draw_indexed_prim() for DX9 is completely broken. Unindex our buffers ourselves.
|
// Allegro's implementation of al_draw_indexed_prim() for DX9 is completely broken. Unindex our buffers ourselves.
|
||||||
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 float as well..
|
// FIXME-OPT: Unfortunately Allegro doesn't support 32-bit packed colors so we have to convert them to 4 float as well..
|
||||||
static ImVector<ImDrawVertAllegro> vertices;
|
static ImVector<ImDrawVertAllegro> vertices;
|
||||||
vertices.resize(cmd_list->IdxBuffer.Size);
|
vertices.resize(cmd_list->IdxBuffer.Size);
|
||||||
for (int i = 0; i < cmd_list->IdxBuffer.Size; i++)
|
for (int i = 0; i < cmd_list->IdxBuffer.Size; i++)
|
||||||
@ -256,7 +258,7 @@ bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
|
|||||||
io.BackendPlatformName = io.BackendRendererName = "imgui_impl_allegro5";
|
io.BackendPlatformName = io.BackendRendererName = "imgui_impl_allegro5";
|
||||||
|
|
||||||
// Create custom vertex declaration.
|
// Create custom vertex declaration.
|
||||||
// Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats.
|
// Unfortunately Allegro doesn't support 32-bit packed colors so we have to convert them to 4 floats.
|
||||||
// We still use a custom declaration to use 'ALLEGRO_PRIM_TEX_COORD' instead of 'ALLEGRO_PRIM_TEX_COORD_PIXEL' else we can't do a reliable conversion.
|
// We still use a custom declaration to use 'ALLEGRO_PRIM_TEX_COORD' instead of 'ALLEGRO_PRIM_TEX_COORD_PIXEL' else we can't do a reliable conversion.
|
||||||
ALLEGRO_VERTEX_ELEMENT elems[] =
|
ALLEGRO_VERTEX_ELEMENT elems[] =
|
||||||
{
|
{
|
||||||
@ -282,6 +284,7 @@ bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
|
|||||||
io.KeyMap[ImGuiKey_Space] = ALLEGRO_KEY_SPACE;
|
io.KeyMap[ImGuiKey_Space] = ALLEGRO_KEY_SPACE;
|
||||||
io.KeyMap[ImGuiKey_Enter] = ALLEGRO_KEY_ENTER;
|
io.KeyMap[ImGuiKey_Enter] = ALLEGRO_KEY_ENTER;
|
||||||
io.KeyMap[ImGuiKey_Escape] = ALLEGRO_KEY_ESCAPE;
|
io.KeyMap[ImGuiKey_Escape] = ALLEGRO_KEY_ESCAPE;
|
||||||
|
io.KeyMap[ImGuiKey_KeyPadEnter] = ALLEGRO_KEY_PAD_ENTER;
|
||||||
io.KeyMap[ImGuiKey_A] = ALLEGRO_KEY_A;
|
io.KeyMap[ImGuiKey_A] = ALLEGRO_KEY_A;
|
||||||
io.KeyMap[ImGuiKey_C] = ALLEGRO_KEY_C;
|
io.KeyMap[ImGuiKey_C] = ALLEGRO_KEY_C;
|
||||||
io.KeyMap[ImGuiKey_V] = ALLEGRO_KEY_V;
|
io.KeyMap[ImGuiKey_V] = ALLEGRO_KEY_V;
|
||||||
@ -388,6 +391,7 @@ static void ImGui_ImplAllegro5_UpdateMouseCursor()
|
|||||||
case ImGuiMouseCursor_ResizeEW: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_E; break;
|
case ImGuiMouseCursor_ResizeEW: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_E; break;
|
||||||
case ImGuiMouseCursor_ResizeNESW: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NE; break;
|
case ImGuiMouseCursor_ResizeNESW: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NE; break;
|
||||||
case ImGuiMouseCursor_ResizeNWSE: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NW; break;
|
case ImGuiMouseCursor_ResizeNWSE: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NW; break;
|
||||||
|
case ImGuiMouseCursor_NotAllowed: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_UNAVAILABLE; break;
|
||||||
}
|
}
|
||||||
al_set_system_mouse_cursor(g_Display, cursor_id);
|
al_set_system_mouse_cursor(g_Display, cursor_id);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.)
|
// (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Platform: Clipboard support (from Allegro 5.1.12)
|
// [X] Platform: Clipboard support (from Allegro 5.1.12)
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// Issues:
|
// Issues:
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// This needs to be used along with a Platform Binding (e.g. Win32)
|
// This needs to be used along with a Platform Binding (e.g. Win32)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bits indices.
|
// [X] Renderer: 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.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2019-07-21: DirectX10: Backup, clear and restore Geometry Shader is any is bound when calling ImGui_ImplDX10_RenderDrawData().
|
||||||
// 2019-05-29: DirectX10: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
// 2019-05-29: DirectX10: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
||||||
// 2019-04-30: DirectX10: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
// 2019-04-30: DirectX10: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||||
// 2018-12-03: Misc: Added #pragma comment statement to automatically link with d3dcompiler.lib when using D3DCompile().
|
// 2018-12-03: Misc: Added #pragma comment statement to automatically link with d3dcompiler.lib when using D3DCompile().
|
||||||
@ -81,6 +82,7 @@ static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device*
|
|||||||
ctx->VSSetConstantBuffers(0, 1, &g_pVertexConstantBuffer);
|
ctx->VSSetConstantBuffers(0, 1, &g_pVertexConstantBuffer);
|
||||||
ctx->PSSetShader(g_pPixelShader);
|
ctx->PSSetShader(g_pPixelShader);
|
||||||
ctx->PSSetSamplers(0, 1, &g_pFontSampler);
|
ctx->PSSetSamplers(0, 1, &g_pFontSampler);
|
||||||
|
ctx->GSSetShader(NULL);
|
||||||
|
|
||||||
// Setup render state
|
// Setup render state
|
||||||
const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
|
const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
|
||||||
@ -183,6 +185,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ID3D10SamplerState* PSSampler;
|
ID3D10SamplerState* PSSampler;
|
||||||
ID3D10PixelShader* PS;
|
ID3D10PixelShader* PS;
|
||||||
ID3D10VertexShader* VS;
|
ID3D10VertexShader* VS;
|
||||||
|
ID3D10GeometryShader* GS;
|
||||||
D3D10_PRIMITIVE_TOPOLOGY PrimitiveTopology;
|
D3D10_PRIMITIVE_TOPOLOGY PrimitiveTopology;
|
||||||
ID3D10Buffer* IndexBuffer, *VertexBuffer, *VSConstantBuffer;
|
ID3D10Buffer* IndexBuffer, *VertexBuffer, *VSConstantBuffer;
|
||||||
UINT IndexBufferOffset, VertexBufferStride, VertexBufferOffset;
|
UINT IndexBufferOffset, VertexBufferStride, VertexBufferOffset;
|
||||||
@ -201,6 +204,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ctx->PSGetShader(&old.PS);
|
ctx->PSGetShader(&old.PS);
|
||||||
ctx->VSGetShader(&old.VS);
|
ctx->VSGetShader(&old.VS);
|
||||||
ctx->VSGetConstantBuffers(0, 1, &old.VSConstantBuffer);
|
ctx->VSGetConstantBuffers(0, 1, &old.VSConstantBuffer);
|
||||||
|
ctx->GSGetShader(&old.GS);
|
||||||
ctx->IAGetPrimitiveTopology(&old.PrimitiveTopology);
|
ctx->IAGetPrimitiveTopology(&old.PrimitiveTopology);
|
||||||
ctx->IAGetIndexBuffer(&old.IndexBuffer, &old.IndexBufferFormat, &old.IndexBufferOffset);
|
ctx->IAGetIndexBuffer(&old.IndexBuffer, &old.IndexBufferFormat, &old.IndexBufferOffset);
|
||||||
ctx->IAGetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset);
|
ctx->IAGetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset);
|
||||||
@ -255,6 +259,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ctx->PSSetSamplers(0, 1, &old.PSSampler); if (old.PSSampler) old.PSSampler->Release();
|
ctx->PSSetSamplers(0, 1, &old.PSSampler); if (old.PSSampler) old.PSSampler->Release();
|
||||||
ctx->PSSetShader(old.PS); if (old.PS) old.PS->Release();
|
ctx->PSSetShader(old.PS); if (old.PS) old.PS->Release();
|
||||||
ctx->VSSetShader(old.VS); if (old.VS) old.VS->Release();
|
ctx->VSSetShader(old.VS); if (old.VS) old.VS->Release();
|
||||||
|
ctx->GSSetShader(old.GS); if (old.GS) old.GS->Release();
|
||||||
ctx->VSSetConstantBuffers(0, 1, &old.VSConstantBuffer); if (old.VSConstantBuffer) old.VSConstantBuffer->Release();
|
ctx->VSSetConstantBuffers(0, 1, &old.VSConstantBuffer); if (old.VSConstantBuffer) old.VSConstantBuffer->Release();
|
||||||
ctx->IASetPrimitiveTopology(old.PrimitiveTopology);
|
ctx->IASetPrimitiveTopology(old.PrimitiveTopology);
|
||||||
ctx->IASetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset); if (old.IndexBuffer) old.IndexBuffer->Release();
|
ctx->IASetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset); if (old.IndexBuffer) old.IndexBuffer->Release();
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// This needs to be used along with a Platform Binding (e.g. Win32)
|
// This needs to be used along with a Platform Binding (e.g. Win32)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bits indices.
|
// [X] Renderer: 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.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// This needs to be used along with a Platform Binding (e.g. Win32)
|
// This needs to be used along with a Platform Binding (e.g. Win32)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bits indices.
|
// [X] Renderer: 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.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp
|
||||||
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2019-08-01: DirectX11: Fixed code querying the Geometry Shader state (would generally error with Debug layer enabled).
|
||||||
|
// 2019-07-21: DirectX11: Backup, clear and restore Geometry Shader is any is bound when calling ImGui_ImplDX10_RenderDrawData. Clearing Hull/Domain/Compute shaders without backup/restore.
|
||||||
// 2019-05-29: DirectX11: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
// 2019-05-29: DirectX11: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
||||||
// 2019-04-30: DirectX11: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
// 2019-04-30: DirectX11: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||||
// 2018-12-03: Misc: Added #pragma comment statement to automatically link with d3dcompiler.lib when using D3DCompile().
|
// 2018-12-03: Misc: Added #pragma comment statement to automatically link with d3dcompiler.lib when using D3DCompile().
|
||||||
@ -81,6 +83,10 @@ static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceC
|
|||||||
ctx->VSSetConstantBuffers(0, 1, &g_pVertexConstantBuffer);
|
ctx->VSSetConstantBuffers(0, 1, &g_pVertexConstantBuffer);
|
||||||
ctx->PSSetShader(g_pPixelShader, NULL, 0);
|
ctx->PSSetShader(g_pPixelShader, NULL, 0);
|
||||||
ctx->PSSetSamplers(0, 1, &g_pFontSampler);
|
ctx->PSSetSamplers(0, 1, &g_pFontSampler);
|
||||||
|
ctx->GSSetShader(NULL, NULL, 0);
|
||||||
|
ctx->HSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
||||||
|
ctx->DSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
||||||
|
ctx->CSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
||||||
|
|
||||||
// Setup blend state
|
// Setup blend state
|
||||||
const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
|
const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
|
||||||
@ -185,8 +191,9 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ID3D11SamplerState* PSSampler;
|
ID3D11SamplerState* PSSampler;
|
||||||
ID3D11PixelShader* PS;
|
ID3D11PixelShader* PS;
|
||||||
ID3D11VertexShader* VS;
|
ID3D11VertexShader* VS;
|
||||||
UINT PSInstancesCount, VSInstancesCount;
|
ID3D11GeometryShader* GS;
|
||||||
ID3D11ClassInstance* PSInstances[256], *VSInstances[256]; // 256 is max according to PSSetShader documentation
|
UINT PSInstancesCount, VSInstancesCount, GSInstancesCount;
|
||||||
|
ID3D11ClassInstance *PSInstances[256], *VSInstances[256], *GSInstances[256]; // 256 is max according to PSSetShader documentation
|
||||||
D3D11_PRIMITIVE_TOPOLOGY PrimitiveTopology;
|
D3D11_PRIMITIVE_TOPOLOGY PrimitiveTopology;
|
||||||
ID3D11Buffer* IndexBuffer, *VertexBuffer, *VSConstantBuffer;
|
ID3D11Buffer* IndexBuffer, *VertexBuffer, *VSConstantBuffer;
|
||||||
UINT IndexBufferOffset, VertexBufferStride, VertexBufferOffset;
|
UINT IndexBufferOffset, VertexBufferStride, VertexBufferOffset;
|
||||||
@ -202,10 +209,12 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ctx->OMGetDepthStencilState(&old.DepthStencilState, &old.StencilRef);
|
ctx->OMGetDepthStencilState(&old.DepthStencilState, &old.StencilRef);
|
||||||
ctx->PSGetShaderResources(0, 1, &old.PSShaderResource);
|
ctx->PSGetShaderResources(0, 1, &old.PSShaderResource);
|
||||||
ctx->PSGetSamplers(0, 1, &old.PSSampler);
|
ctx->PSGetSamplers(0, 1, &old.PSSampler);
|
||||||
old.PSInstancesCount = old.VSInstancesCount = 256;
|
old.PSInstancesCount = old.VSInstancesCount = old.GSInstancesCount = 256;
|
||||||
ctx->PSGetShader(&old.PS, old.PSInstances, &old.PSInstancesCount);
|
ctx->PSGetShader(&old.PS, old.PSInstances, &old.PSInstancesCount);
|
||||||
ctx->VSGetShader(&old.VS, old.VSInstances, &old.VSInstancesCount);
|
ctx->VSGetShader(&old.VS, old.VSInstances, &old.VSInstancesCount);
|
||||||
ctx->VSGetConstantBuffers(0, 1, &old.VSConstantBuffer);
|
ctx->VSGetConstantBuffers(0, 1, &old.VSConstantBuffer);
|
||||||
|
ctx->GSGetShader(&old.GS, old.GSInstances, &old.GSInstancesCount);
|
||||||
|
|
||||||
ctx->IAGetPrimitiveTopology(&old.PrimitiveTopology);
|
ctx->IAGetPrimitiveTopology(&old.PrimitiveTopology);
|
||||||
ctx->IAGetIndexBuffer(&old.IndexBuffer, &old.IndexBufferFormat, &old.IndexBufferOffset);
|
ctx->IAGetIndexBuffer(&old.IndexBuffer, &old.IndexBufferFormat, &old.IndexBufferOffset);
|
||||||
ctx->IAGetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset);
|
ctx->IAGetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset);
|
||||||
@ -262,6 +271,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
for (UINT i = 0; i < old.PSInstancesCount; i++) if (old.PSInstances[i]) old.PSInstances[i]->Release();
|
for (UINT i = 0; i < old.PSInstancesCount; i++) if (old.PSInstances[i]) old.PSInstances[i]->Release();
|
||||||
ctx->VSSetShader(old.VS, old.VSInstances, old.VSInstancesCount); if (old.VS) old.VS->Release();
|
ctx->VSSetShader(old.VS, old.VSInstances, old.VSInstancesCount); if (old.VS) old.VS->Release();
|
||||||
ctx->VSSetConstantBuffers(0, 1, &old.VSConstantBuffer); if (old.VSConstantBuffer) old.VSConstantBuffer->Release();
|
ctx->VSSetConstantBuffers(0, 1, &old.VSConstantBuffer); if (old.VSConstantBuffer) old.VSConstantBuffer->Release();
|
||||||
|
ctx->GSSetShader(old.GS, old.GSInstances, old.GSInstancesCount); if (old.GS) old.GS->Release();
|
||||||
for (UINT i = 0; i < old.VSInstancesCount; i++) if (old.VSInstances[i]) old.VSInstances[i]->Release();
|
for (UINT i = 0; i < old.VSInstancesCount; i++) if (old.VSInstances[i]) old.VSInstances[i]->Release();
|
||||||
ctx->IASetPrimitiveTopology(old.PrimitiveTopology);
|
ctx->IASetPrimitiveTopology(old.PrimitiveTopology);
|
||||||
ctx->IASetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset); if (old.IndexBuffer) old.IndexBuffer->Release();
|
ctx->IASetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset); if (old.IndexBuffer) old.IndexBuffer->Release();
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// This needs to be used along with a Platform Binding (e.g. Win32)
|
// This needs to be used along with a Platform Binding (e.g. Win32)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bits indices.
|
// [X] Renderer: 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.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// This needs to be used along with a Platform Binding (e.g. Win32)
|
// This needs to be used along with a Platform Binding (e.g. Win32)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bits indices.
|
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||||
// Issues:
|
// Issues:
|
||||||
// [ ] 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*)). See github.com/ocornut/imgui/pull/301
|
// [ ] 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*)). See github.com/ocornut/imgui/pull/301
|
||||||
|
|
||||||
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2019-10-18: DirectX12: *BREAKING CHANGE* Added extra ID3D12DescriptorHeap parameter to ImGui_ImplDX12_Init() function.
|
||||||
// 2019-05-29: DirectX12: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
// 2019-05-29: DirectX12: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
||||||
// 2019-04-30: DirectX12: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
// 2019-04-30: DirectX12: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||||
// 2019-03-29: Misc: Various minor tidying up.
|
// 2019-03-29: Misc: Various minor tidying up.
|
||||||
@ -56,6 +57,14 @@ static FrameResources* g_pFrameResources = NULL;
|
|||||||
static UINT g_numFramesInFlight = 0;
|
static UINT g_numFramesInFlight = 0;
|
||||||
static UINT g_frameIndex = UINT_MAX;
|
static UINT g_frameIndex = UINT_MAX;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
static void SafeRelease(T*& res)
|
||||||
|
{
|
||||||
|
if (res)
|
||||||
|
res->Release();
|
||||||
|
res = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
struct VERTEX_CONSTANT_BUFFER
|
struct VERTEX_CONSTANT_BUFFER
|
||||||
{
|
{
|
||||||
float mvp[4][4];
|
float mvp[4][4];
|
||||||
@ -132,7 +141,7 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
|
|||||||
// Create and grow vertex/index buffers if needed
|
// Create and grow vertex/index buffers if needed
|
||||||
if (fr->VertexBuffer == NULL || fr->VertexBufferSize < draw_data->TotalVtxCount)
|
if (fr->VertexBuffer == NULL || fr->VertexBufferSize < draw_data->TotalVtxCount)
|
||||||
{
|
{
|
||||||
if (fr->VertexBuffer != NULL) { fr->VertexBuffer->Release(); fr->VertexBuffer = NULL; }
|
SafeRelease(fr->VertexBuffer);
|
||||||
fr->VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
fr->VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
||||||
D3D12_HEAP_PROPERTIES props;
|
D3D12_HEAP_PROPERTIES props;
|
||||||
memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES));
|
memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES));
|
||||||
@ -155,7 +164,7 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
|
|||||||
}
|
}
|
||||||
if (fr->IndexBuffer == NULL || fr->IndexBufferSize < draw_data->TotalIdxCount)
|
if (fr->IndexBuffer == NULL || fr->IndexBufferSize < draw_data->TotalIdxCount)
|
||||||
{
|
{
|
||||||
if (fr->IndexBuffer != NULL) { fr->IndexBuffer->Release(); fr->IndexBuffer = NULL; }
|
SafeRelease(fr->IndexBuffer);
|
||||||
fr->IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
fr->IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||||
D3D12_HEAP_PROPERTIES props;
|
D3D12_HEAP_PROPERTIES props;
|
||||||
memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES));
|
memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES));
|
||||||
@ -375,8 +384,7 @@ static void ImGui_ImplDX12_CreateFontsTexture()
|
|||||||
srvDesc.Texture2D.MostDetailedMip = 0;
|
srvDesc.Texture2D.MostDetailedMip = 0;
|
||||||
srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
|
srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
|
||||||
g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, g_hFontSrvCpuDescHandle);
|
g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, g_hFontSrvCpuDescHandle);
|
||||||
if (g_pFontTextureResource != NULL)
|
SafeRelease(g_pFontTextureResource);
|
||||||
g_pFontTextureResource->Release();
|
|
||||||
g_pFontTextureResource = pTexture;
|
g_pFontTextureResource = pTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,9 +510,9 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
|
|||||||
|
|
||||||
// Create the input layout
|
// Create the input layout
|
||||||
static D3D12_INPUT_ELEMENT_DESC local_layout[] = {
|
static D3D12_INPUT_ELEMENT_DESC local_layout[] = {
|
||||||
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, IM_OFFSETOF(ImDrawVert, pos), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, pos), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
||||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, IM_OFFSETOF(ImDrawVert, uv), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
||||||
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, IM_OFFSETOF(ImDrawVert, col), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
||||||
};
|
};
|
||||||
psoDesc.InputLayout = { local_layout, 3 };
|
psoDesc.InputLayout = { local_layout, 3 };
|
||||||
}
|
}
|
||||||
@ -588,21 +596,24 @@ void ImGui_ImplDX12_InvalidateDeviceObjects()
|
|||||||
if (!g_pd3dDevice)
|
if (!g_pd3dDevice)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
SafeRelease(g_pVertexShaderBlob);
|
||||||
|
SafeRelease(g_pPixelShaderBlob);
|
||||||
|
SafeRelease(g_pRootSignature);
|
||||||
|
SafeRelease(g_pPipelineState);
|
||||||
|
SafeRelease(g_pFontTextureResource);
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
if (g_pVertexShaderBlob) { g_pVertexShaderBlob->Release(); g_pVertexShaderBlob = NULL; }
|
io.Fonts->TexID = NULL; // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
||||||
if (g_pPixelShaderBlob) { g_pPixelShaderBlob->Release(); g_pPixelShaderBlob = NULL; }
|
|
||||||
if (g_pRootSignature) { g_pRootSignature->Release(); g_pRootSignature = NULL; }
|
|
||||||
if (g_pPipelineState) { g_pPipelineState->Release(); g_pPipelineState = NULL; }
|
|
||||||
if (g_pFontTextureResource) { g_pFontTextureResource->Release(); g_pFontTextureResource = NULL; io.Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
|
||||||
for (UINT i = 0; i < g_numFramesInFlight; i++)
|
for (UINT i = 0; i < g_numFramesInFlight; i++)
|
||||||
{
|
{
|
||||||
FrameResources* fr = &g_pFrameResources[i];
|
FrameResources* fr = &g_pFrameResources[i];
|
||||||
if (fr->IndexBuffer) { fr->IndexBuffer->Release(); fr->IndexBuffer = NULL; }
|
SafeRelease(fr->IndexBuffer);
|
||||||
if (fr->VertexBuffer) { fr->VertexBuffer->Release(); fr->VertexBuffer = NULL; }
|
SafeRelease(fr->VertexBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format,
|
bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap,
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle)
|
D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle)
|
||||||
{
|
{
|
||||||
// Setup back-end capabilities flags
|
// Setup back-end capabilities flags
|
||||||
@ -617,6 +628,7 @@ bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FO
|
|||||||
g_pFrameResources = new FrameResources[num_frames_in_flight];
|
g_pFrameResources = new FrameResources[num_frames_in_flight];
|
||||||
g_numFramesInFlight = num_frames_in_flight;
|
g_numFramesInFlight = num_frames_in_flight;
|
||||||
g_frameIndex = UINT_MAX;
|
g_frameIndex = UINT_MAX;
|
||||||
|
IM_UNUSED(cbv_srv_heap); // Unused in master branch (will be used by multi-viewports)
|
||||||
|
|
||||||
// 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)
|
||||||
for (int i = 0; i < num_frames_in_flight; i++)
|
for (int i = 0; i < num_frames_in_flight; i++)
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// This needs to be used along with a Platform Binding (e.g. Win32)
|
// This needs to be used along with a Platform Binding (e.g. Win32)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bits indices.
|
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||||
// Issues:
|
// Issues:
|
||||||
// [ ] 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*)). See github.com/ocornut/imgui/pull/301
|
// [ ] 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*)). See github.com/ocornut/imgui/pull/301
|
||||||
|
|
||||||
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
enum DXGI_FORMAT;
|
enum DXGI_FORMAT;
|
||||||
struct ID3D12Device;
|
struct ID3D12Device;
|
||||||
|
struct ID3D12DescriptorHeap;
|
||||||
struct ID3D12GraphicsCommandList;
|
struct ID3D12GraphicsCommandList;
|
||||||
struct D3D12_CPU_DESCRIPTOR_HANDLE;
|
struct D3D12_CPU_DESCRIPTOR_HANDLE;
|
||||||
struct D3D12_GPU_DESCRIPTOR_HANDLE;
|
struct D3D12_GPU_DESCRIPTOR_HANDLE;
|
||||||
@ -23,7 +24,7 @@ struct D3D12_GPU_DESCRIPTOR_HANDLE;
|
|||||||
// Before calling the render function, caller must prepare cmd_list by resetting it and setting the appropriate
|
// Before calling the render function, caller must prepare cmd_list by resetting it and setting the appropriate
|
||||||
// render target and descriptor heap that contains font_srv_cpu_desc_handle/font_srv_gpu_desc_handle.
|
// render target and descriptor heap that contains font_srv_cpu_desc_handle/font_srv_gpu_desc_handle.
|
||||||
// font_srv_cpu_desc_handle and font_srv_gpu_desc_handle are handles to a single SRV descriptor to use for the internal font texture.
|
// font_srv_cpu_desc_handle and font_srv_gpu_desc_handle are handles to a single SRV descriptor to use for the internal font texture.
|
||||||
IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format,
|
IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap,
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle);
|
D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle);
|
||||||
IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame();
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// This needs to be used along with a Platform Binding (e.g. Win32)
|
// This needs to be used along with a Platform Binding (e.g. Win32)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bits indices.
|
// [X] Renderer: 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.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// This needs to be used along with a Platform Binding (e.g. Win32)
|
// This needs to be used along with a Platform Binding (e.g. Win32)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bits indices.
|
// [X] Renderer: 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.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Clipboard support.
|
// [X] Platform: Clipboard support.
|
||||||
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: 3 cursors types are missing from GLFW.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
|
||||||
// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE).
|
// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE).
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
@ -15,6 +15,10 @@
|
|||||||
|
|
||||||
// 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)
|
||||||
|
// 2020-01-17: Inputs: Disable error callback while assigning mouse cursors because some X11 setup don't have them and it generates errors.
|
||||||
|
// 2019-12-05: Inputs: Added support for new mouse cursors added in GLFW 3.4+ (resizing cursors, not allowed cursor).
|
||||||
|
// 2019-10-18: Misc: Previously installed user callbacks are now restored on shutdown.
|
||||||
|
// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter.
|
||||||
// 2019-05-11: Inputs: Don't filter value from character callback before calling AddInputCharacter().
|
// 2019-05-11: Inputs: Don't filter value from character callback before calling AddInputCharacter().
|
||||||
// 2019-03-12: Misc: Preserve DisplayFramebufferScale when main window is minimized.
|
// 2019-03-12: Misc: Preserve DisplayFramebufferScale when main window is minimized.
|
||||||
// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
|
// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
|
||||||
@ -48,6 +52,11 @@
|
|||||||
#define GLFW_HAS_WINDOW_ALPHA (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwSetWindowOpacity
|
#define GLFW_HAS_WINDOW_ALPHA (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwSetWindowOpacity
|
||||||
#define GLFW_HAS_PER_MONITOR_DPI (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwGetMonitorContentScale
|
#define GLFW_HAS_PER_MONITOR_DPI (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwGetMonitorContentScale
|
||||||
#define GLFW_HAS_VULKAN (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ glfwCreateWindowSurface
|
#define GLFW_HAS_VULKAN (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ glfwCreateWindowSurface
|
||||||
|
#ifdef GLFW_RESIZE_NESW_CURSOR // let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released?
|
||||||
|
#define GLFW_HAS_NEW_CURSORS (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3400) // 3.4+ GLFW_RESIZE_ALL_CURSOR, GLFW_RESIZE_NESW_CURSOR, GLFW_RESIZE_NWSE_CURSOR, GLFW_NOT_ALLOWED_CURSOR
|
||||||
|
#else
|
||||||
|
#define GLFW_HAS_NEW_CURSORS (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
enum GlfwClientApi
|
enum GlfwClientApi
|
||||||
@ -60,7 +69,8 @@ static GLFWwindow* g_Window = NULL; // Main window
|
|||||||
static GlfwClientApi g_ClientApi = GlfwClientApi_Unknown;
|
static GlfwClientApi g_ClientApi = GlfwClientApi_Unknown;
|
||||||
static double g_Time = 0.0;
|
static double g_Time = 0.0;
|
||||||
static bool g_MouseJustPressed[5] = { false, false, false, false, false };
|
static bool g_MouseJustPressed[5] = { false, false, false, false, false };
|
||||||
static GLFWcursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = { 0 };
|
static GLFWcursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
|
||||||
|
static bool g_InstalledCallbacks = false;
|
||||||
|
|
||||||
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
|
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
|
||||||
static GLFWmousebuttonfun g_PrevUserCallbackMousebutton = NULL;
|
static GLFWmousebuttonfun g_PrevUserCallbackMousebutton = NULL;
|
||||||
@ -112,7 +122,11 @@ void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int a
|
|||||||
io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
|
io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
|
||||||
io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
|
io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
|
||||||
io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
|
io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
|
||||||
|
#ifdef _WIN32
|
||||||
|
io.KeySuper = false;
|
||||||
|
#else
|
||||||
io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
|
io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c)
|
void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c)
|
||||||
@ -151,6 +165,7 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE;
|
io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE;
|
||||||
io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
|
io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
|
||||||
io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
|
io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
|
||||||
|
io.KeyMap[ImGuiKey_KeyPadEnter] = GLFW_KEY_KP_ENTER;
|
||||||
io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
|
io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
|
||||||
io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
|
io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
|
||||||
io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
|
io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
|
||||||
@ -165,14 +180,28 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
io.ImeWindowHandle = (void*)glfwGetWin32Window(g_Window);
|
io.ImeWindowHandle = (void*)glfwGetWin32Window(g_Window);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Create mouse cursors
|
||||||
|
// (By design, on X11 cursors are user configurable and some cursors may be missing. When a cursor doesn't exist,
|
||||||
|
// GLFW will emit an error which will often be printed by the app, so we temporarily disable error reporting.
|
||||||
|
// Missing cursors will return NULL and our _UpdateMouseCursor() function will use the Arrow cursor instead.)
|
||||||
|
GLFWerrorfun prev_error_callback = glfwSetErrorCallback(NULL);
|
||||||
g_MouseCursors[ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
|
g_MouseCursors[ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
|
||||||
g_MouseCursors[ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR);
|
g_MouseCursors[ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR);
|
||||||
g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); // FIXME: GLFW doesn't have this.
|
|
||||||
g_MouseCursors[ImGuiMouseCursor_ResizeNS] = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR);
|
g_MouseCursors[ImGuiMouseCursor_ResizeNS] = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR);
|
||||||
g_MouseCursors[ImGuiMouseCursor_ResizeEW] = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR);
|
g_MouseCursors[ImGuiMouseCursor_ResizeEW] = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR);
|
||||||
g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); // FIXME: GLFW doesn't have this.
|
|
||||||
g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); // FIXME: GLFW doesn't have this.
|
|
||||||
g_MouseCursors[ImGuiMouseCursor_Hand] = glfwCreateStandardCursor(GLFW_HAND_CURSOR);
|
g_MouseCursors[ImGuiMouseCursor_Hand] = glfwCreateStandardCursor(GLFW_HAND_CURSOR);
|
||||||
|
#if GLFW_HAS_NEW_CURSORS
|
||||||
|
g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_RESIZE_ALL_CURSOR);
|
||||||
|
g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_RESIZE_NESW_CURSOR);
|
||||||
|
g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_RESIZE_NWSE_CURSOR);
|
||||||
|
g_MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_NOT_ALLOWED_CURSOR);
|
||||||
|
#else
|
||||||
|
g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
|
||||||
|
g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
|
||||||
|
g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
|
||||||
|
g_MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
|
||||||
|
#endif
|
||||||
|
glfwSetErrorCallback(prev_error_callback);
|
||||||
|
|
||||||
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
|
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
|
||||||
g_PrevUserCallbackMousebutton = NULL;
|
g_PrevUserCallbackMousebutton = NULL;
|
||||||
@ -181,6 +210,7 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
g_PrevUserCallbackChar = NULL;
|
g_PrevUserCallbackChar = NULL;
|
||||||
if (install_callbacks)
|
if (install_callbacks)
|
||||||
{
|
{
|
||||||
|
g_InstalledCallbacks = true;
|
||||||
g_PrevUserCallbackMousebutton = glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
|
g_PrevUserCallbackMousebutton = glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
|
||||||
g_PrevUserCallbackScroll = glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
|
g_PrevUserCallbackScroll = glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
|
||||||
g_PrevUserCallbackKey = glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
|
g_PrevUserCallbackKey = glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
|
||||||
@ -203,6 +233,15 @@ bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks)
|
|||||||
|
|
||||||
void ImGui_ImplGlfw_Shutdown()
|
void ImGui_ImplGlfw_Shutdown()
|
||||||
{
|
{
|
||||||
|
if (g_InstalledCallbacks)
|
||||||
|
{
|
||||||
|
glfwSetMouseButtonCallback(g_Window, g_PrevUserCallbackMousebutton);
|
||||||
|
glfwSetScrollCallback(g_Window, g_PrevUserCallbackScroll);
|
||||||
|
glfwSetKeyCallback(g_Window, g_PrevUserCallbackKey);
|
||||||
|
glfwSetCharCallback(g_Window, g_PrevUserCallbackChar);
|
||||||
|
g_InstalledCallbacks = false;
|
||||||
|
}
|
||||||
|
|
||||||
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
||||||
{
|
{
|
||||||
glfwDestroyCursor(g_MouseCursors[cursor_n]);
|
glfwDestroyCursor(g_MouseCursors[cursor_n]);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// This needs to be used along with a Renderer (e.g. OpenGL2)
|
// This needs to be used along with a Renderer (e.g. OpenGL2)
|
||||||
|
|
||||||
// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
|
// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
|
||||||
// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
|
// !!! If someone or something is teaching you GLUT in 2020, you are being abused. Please show some resistance. !!!
|
||||||
// !!! Nowadays, prefer using GLFW or SDL instead!
|
// !!! Nowadays, prefer using GLFW or SDL instead!
|
||||||
|
|
||||||
// Issues:
|
// Issues:
|
||||||
@ -39,7 +39,12 @@ static int g_Time = 0; // Current time, in milliseconds
|
|||||||
bool ImGui_ImplGLUT_Init()
|
bool ImGui_ImplGLUT_Init()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
#ifdef FREEGLUT
|
||||||
|
io.BackendPlatformName ="imgui_impl_glut (freeglut)";
|
||||||
|
#else
|
||||||
io.BackendPlatformName ="imgui_impl_glut";
|
io.BackendPlatformName ="imgui_impl_glut";
|
||||||
|
#endif
|
||||||
|
|
||||||
g_Time = 0;
|
g_Time = 0;
|
||||||
|
|
||||||
@ -59,6 +64,7 @@ bool ImGui_ImplGLUT_Init()
|
|||||||
io.KeyMap[ImGuiKey_Space] = ' ';
|
io.KeyMap[ImGuiKey_Space] = ' ';
|
||||||
io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
|
io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M
|
||||||
io.KeyMap[ImGuiKey_Escape] = 27;
|
io.KeyMap[ImGuiKey_Escape] = 27;
|
||||||
|
io.KeyMap[ImGuiKey_KeyPadEnter] = 13; // == CTRL+M
|
||||||
io.KeyMap[ImGuiKey_A] = 'A';
|
io.KeyMap[ImGuiKey_A] = 'A';
|
||||||
io.KeyMap[ImGuiKey_C] = 'C';
|
io.KeyMap[ImGuiKey_C] = 'C';
|
||||||
io.KeyMap[ImGuiKey_V] = 'V';
|
io.KeyMap[ImGuiKey_V] = 'V';
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// This needs to be used along with a Renderer (e.g. OpenGL2)
|
// This needs to be used along with a Renderer (e.g. OpenGL2)
|
||||||
|
|
||||||
// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
|
// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
|
||||||
// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
|
// !!! If someone or something is teaching you GLUT in 2020, you are being abused. Please show some resistance. !!!
|
||||||
// !!! Nowadays, prefer using GLFW or SDL instead!
|
// !!! Nowadays, prefer using GLFW or SDL instead!
|
||||||
|
|
||||||
// Issues:
|
// Issues:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of Dear ImGui)
|
// Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of Dear ImGui)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// Missing features:
|
// Missing features:
|
||||||
// [ ] Renderer: Clipping rectangles are not honored.
|
// [ ] Renderer: Clipping rectangles are not honored.
|
||||||
|
|
||||||
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter.
|
||||||
// 2019-05-11: Inputs: Don't filter value from character callback before calling AddInputCharacter().
|
// 2019-05-11: Inputs: Don't filter value from character callback before calling AddInputCharacter().
|
||||||
// 2018-11-30: Misc: Setting up io.BackendPlatformName/io.BackendRendererName so they can be displayed in the About Window.
|
// 2018-11-30: Misc: Setting up io.BackendPlatformName/io.BackendRendererName so they can be displayed in the About Window.
|
||||||
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_Marmalade_RenderDrawData() in the .h file so you can call it yourself.
|
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_Marmalade_RenderDrawData() in the .h file so you can call it yourself.
|
||||||
@ -235,6 +236,7 @@ bool ImGui_Marmalade_Init(bool install_callbacks)
|
|||||||
io.KeyMap[ImGuiKey_Space] = s3eKeySpace;
|
io.KeyMap[ImGuiKey_Space] = s3eKeySpace;
|
||||||
io.KeyMap[ImGuiKey_Enter] = s3eKeyEnter;
|
io.KeyMap[ImGuiKey_Enter] = s3eKeyEnter;
|
||||||
io.KeyMap[ImGuiKey_Escape] = s3eKeyEsc;
|
io.KeyMap[ImGuiKey_Escape] = s3eKeyEsc;
|
||||||
|
io.KeyMap[ImGuiKey_KeyPadEnter] = s3eKeyNumPadEnter;
|
||||||
io.KeyMap[ImGuiKey_A] = s3eKeyA;
|
io.KeyMap[ImGuiKey_A] = s3eKeyA;
|
||||||
io.KeyMap[ImGuiKey_C] = s3eKeyC;
|
io.KeyMap[ImGuiKey_C] = s3eKeyC;
|
||||||
io.KeyMap[ImGuiKey_V] = s3eKeyV;
|
io.KeyMap[ImGuiKey_V] = s3eKeyV;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of Dear ImGui)
|
// Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of Dear ImGui)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// This needs to be used along with a Platform Binding (e.g. OSX)
|
// This needs to be used along with a Platform Binding (e.g. OSX)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bits indices.
|
// [X] Renderer: 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.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// This needs to be used along with a Platform Binding (e.g. OSX)
|
// This needs to be used along with a Platform Binding (e.g. OSX)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bits indices.
|
// [X] Renderer: 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.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
@ -18,13 +18,14 @@
|
|||||||
|
|
||||||
// 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)
|
||||||
|
// 2020-01-23: OpenGL: Explicitly backup, setup and restore GL_TEXTURE_ENV to increase compatibility with legacy OpenGL applications.
|
||||||
// 2019-04-30: OpenGL: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
// 2019-04-30: OpenGL: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||||
// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
|
// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
|
||||||
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
||||||
// 2018-08-03: OpenGL: Disabling/restoring GL_LIGHTING and GL_COLOR_MATERIAL to increase compatibility with legacy OpenGL applications.
|
// 2018-08-03: OpenGL: Disabling/restoring GL_LIGHTING and GL_COLOR_MATERIAL to increase compatibility with legacy OpenGL applications.
|
||||||
// 2018-06-08: Misc: Extracted imgui_impl_opengl2.cpp/.h away from the old combined GLFW/SDL+OpenGL2 examples.
|
// 2018-06-08: Misc: Extracted imgui_impl_opengl2.cpp/.h away from the old combined GLFW/SDL+OpenGL2 examples.
|
||||||
// 2018-06-08: OpenGL: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
|
// 2018-06-08: OpenGL: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
|
||||||
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplGlfwGL2_RenderDrawData() in the .h file so you can call it yourself.
|
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplOpenGL2_RenderDrawData() in the .h file so you can call it yourself.
|
||||||
// 2017-09-01: OpenGL: Save and restore current polygon mode.
|
// 2017-09-01: OpenGL: Save and restore current polygon mode.
|
||||||
// 2016-09-10: OpenGL: Uploading font texture as RGBA32 to increase compatibility with users shaders (not ideal).
|
// 2016-09-10: OpenGL: Uploading font texture as RGBA32 to increase compatibility with users shaders (not ideal).
|
||||||
// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
|
// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
|
||||||
@ -89,6 +90,7 @@ static void ImGui_ImplOpenGL2_SetupRenderState(ImDrawData* draw_data, int fb_wid
|
|||||||
glEnableClientState(GL_COLOR_ARRAY);
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
|
||||||
// If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!),
|
// If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!),
|
||||||
// you may need to backup/reset/restore current shader using the lines below. DO NOT MODIFY THIS FILE! Add the code in your calling function:
|
// you may need to backup/reset/restore current shader using the lines below. DO NOT MODIFY THIS FILE! Add the code in your calling function:
|
||||||
@ -126,6 +128,7 @@ void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data)
|
|||||||
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
|
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
|
||||||
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
|
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
|
||||||
GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
|
GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
|
||||||
|
GLint last_tex_env_mode; glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &last_tex_env_mode);
|
||||||
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
|
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
|
||||||
|
|
||||||
// Setup desired GL state
|
// Setup desired GL state
|
||||||
@ -193,6 +196,7 @@ void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data)
|
|||||||
glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]); glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]);
|
glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]); glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]);
|
||||||
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
|
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]);
|
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, last_tex_env_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplOpenGL2_CreateFontsTexture()
|
bool ImGui_ImplOpenGL2_CreateFontsTexture()
|
||||||
@ -201,7 +205,7 @@ bool ImGui_ImplOpenGL2_CreateFontsTexture()
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
unsigned char* pixels;
|
unsigned char* pixels;
|
||||||
int width, height;
|
int width, height;
|
||||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (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.
|
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
|
// Upload texture to graphics system
|
||||||
GLint last_texture;
|
GLint last_texture;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
|
// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
|
||||||
// - Desktop GL: 3.x 4.x
|
// - Desktop GL: 2.x 3.x 4.x
|
||||||
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
|
// - 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..)
|
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [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-bits indices.
|
// [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.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
@ -13,6 +13,10 @@
|
|||||||
|
|
||||||
// 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)
|
||||||
|
// 2020-01-07: OpenGL: Added support for glbindings 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-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-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-29: OpenGL: Not calling glBindBuffer more than necessary in the render loop.
|
||||||
@ -75,19 +79,34 @@
|
|||||||
#include "TargetConditionals.h"
|
#include "TargetConditionals.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Auto-detect GL version
|
// Auto-enable GLES on matching platforms
|
||||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3)
|
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3)
|
||||||
#if (defined(__APPLE__) && TARGET_OS_IOS) || (defined(__ANDROID__))
|
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
|
||||||
#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
|
#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
|
||||||
|
#undef IMGUI_IMPL_OPENGL_LOADER_GL3W
|
||||||
|
#undef IMGUI_IMPL_OPENGL_LOADER_GLEW
|
||||||
|
#undef IMGUI_IMPL_OPENGL_LOADER_GLAD
|
||||||
|
#undef IMGUI_IMPL_OPENGL_LOADER_GLBINDING
|
||||||
|
#undef IMGUI_IMPL_OPENGL_LOADER_CUSTOM
|
||||||
#elif defined(__EMSCRIPTEN__)
|
#elif defined(__EMSCRIPTEN__)
|
||||||
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
|
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
|
||||||
|
#undef IMGUI_IMPL_OPENGL_LOADER_GL3W
|
||||||
|
#undef IMGUI_IMPL_OPENGL_LOADER_GLEW
|
||||||
|
#undef IMGUI_IMPL_OPENGL_LOADER_GLAD
|
||||||
|
#undef IMGUI_IMPL_OPENGL_LOADER_GLBINDING
|
||||||
|
#undef IMGUI_IMPL_OPENGL_LOADER_CUSTOM
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// GL includes
|
||||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||||
#include <GLES2/gl2.h>
|
#include <GLES2/gl2.h>
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
||||||
#include <GLES3/gl3.h> // Use GL ES 3
|
#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
|
#else
|
||||||
// About Desktop OpenGL function loaders:
|
// About Desktop OpenGL function loaders:
|
||||||
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
|
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
|
||||||
@ -99,20 +118,25 @@
|
|||||||
#include <GL/glew.h> // Needs to be initialized with glewInit() in user's code
|
#include <GL/glew.h> // Needs to be initialized with glewInit() in user's code
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||||
#include <glad/glad.h> // Needs to be initialized with gladLoadGL() in user's code
|
#include <glad/glad.h> // Needs to be initialized with gladLoadGL() in user's code
|
||||||
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING)
|
||||||
|
#include <glbinding/gl/gl.h> // Initialize with glbinding::initialize()
|
||||||
|
#include <glbinding/glbinding.h>
|
||||||
|
using namespace gl;
|
||||||
#else
|
#else
|
||||||
#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
|
#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Desktop GL has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
|
// 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)
|
#if defined(IMGUI_IMPL_OPENGL_ES2) || defined(IMGUI_IMPL_OPENGL_ES3) || !defined(GL_VERSION_3_2)
|
||||||
#define IMGUI_IMPL_OPENGL_HAS_DRAW_WITH_BASE_VERTEX 0
|
#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET 0
|
||||||
#else
|
#else
|
||||||
#define IMGUI_IMPL_OPENGL_HAS_DRAW_WITH_BASE_VERTEX 1
|
#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// OpenGL Data
|
// OpenGL Data
|
||||||
static char g_GlslVersionString[32] = "";
|
static GLuint g_GlVersion = 0; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries.
|
||||||
|
static char g_GlslVersionString[32] = ""; // Specified by user or detected based on compile time GL settings.
|
||||||
static GLuint g_FontTexture = 0;
|
static GLuint g_FontTexture = 0;
|
||||||
static GLuint g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
|
static GLuint g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
|
||||||
static int g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; // Uniforms location
|
static int g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; // Uniforms location
|
||||||
@ -122,14 +146,26 @@ static unsigned int g_VboHandle = 0, g_ElementsHandle = 0;
|
|||||||
// Functions
|
// Functions
|
||||||
bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
||||||
{
|
{
|
||||||
|
// Query for GL version
|
||||||
|
#if !defined(IMGUI_IMPL_OPENGL_ES2)
|
||||||
|
GLint major, minor;
|
||||||
|
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
||||||
|
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
||||||
|
g_GlVersion = major * 1000 + minor;
|
||||||
|
#else
|
||||||
|
g_GlVersion = 2000; // GLES 2
|
||||||
|
#endif
|
||||||
|
|
||||||
// Setup back-end capabilities flags
|
// Setup back-end capabilities flags
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.BackendRendererName = "imgui_impl_opengl3";
|
io.BackendRendererName = "imgui_impl_opengl3";
|
||||||
#if IMGUI_IMPL_OPENGL_HAS_DRAW_WITH_BASE_VERTEX
|
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
if (g_GlVersion >= 3200)
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
#endif
|
#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.
|
// 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 defined(IMGUI_IMPL_OPENGL_ES2)
|
||||||
if (glsl_version == NULL)
|
if (glsl_version == NULL)
|
||||||
glsl_version = "#version 100";
|
glsl_version = "#version 100";
|
||||||
@ -144,6 +180,25 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
strcpy(g_GlslVersionString, glsl_version);
|
strcpy(g_GlslVersionString, glsl_version);
|
||||||
strcat(g_GlslVersionString, "\n");
|
strcat(g_GlslVersionString, "\n");
|
||||||
|
|
||||||
|
// Dummy 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_GLBINDING)
|
||||||
|
gl_loader = "glbinding";
|
||||||
|
#else // IMGUI_IMPL_OPENGL_LOADER_CUSTOM
|
||||||
|
gl_loader = "Custom";
|
||||||
|
#endif
|
||||||
|
|
||||||
// Make a dummy GL call (we don't actually need the result)
|
// Make a dummy 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.
|
// 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.
|
// Desktop OpenGL 3/4 need a function loader. See the IMGUI_IMPL_OPENGL_LOADER_xxx explanation above.
|
||||||
@ -160,7 +215,7 @@ void ImGui_ImplOpenGL3_Shutdown()
|
|||||||
|
|
||||||
void ImGui_ImplOpenGL3_NewFrame()
|
void ImGui_ImplOpenGL3_NewFrame()
|
||||||
{
|
{
|
||||||
if (!g_FontTexture)
|
if (!g_ShaderHandle)
|
||||||
ImGui_ImplOpenGL3_CreateDeviceObjects();
|
ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,11 +367,12 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
|
|
||||||
// Bind texture, Draw
|
// Bind texture, Draw
|
||||||
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
||||||
#if IMGUI_IMPL_OPENGL_HAS_DRAW_WITH_BASE_VERTEX
|
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||||
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);
|
if (g_GlVersion >= 3200)
|
||||||
#else
|
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);
|
||||||
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)));
|
else
|
||||||
#endif
|
#endif
|
||||||
|
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -357,7 +413,7 @@ bool ImGui_ImplOpenGL3_CreateFontsTexture()
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
unsigned char* pixels;
|
unsigned char* pixels;
|
||||||
int width, height;
|
int width, height;
|
||||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (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.
|
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
|
// Upload texture to graphics system
|
||||||
GLint last_texture;
|
GLint last_texture;
|
||||||
@ -609,20 +665,13 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects()
|
|||||||
|
|
||||||
void ImGui_ImplOpenGL3_DestroyDeviceObjects()
|
void ImGui_ImplOpenGL3_DestroyDeviceObjects()
|
||||||
{
|
{
|
||||||
if (g_VboHandle) glDeleteBuffers(1, &g_VboHandle);
|
if (g_VboHandle) { glDeleteBuffers(1, &g_VboHandle); g_VboHandle = 0; }
|
||||||
if (g_ElementsHandle) glDeleteBuffers(1, &g_ElementsHandle);
|
if (g_ElementsHandle) { glDeleteBuffers(1, &g_ElementsHandle); g_ElementsHandle = 0; }
|
||||||
g_VboHandle = 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_ShaderHandle && g_VertHandle) glDetachShader(g_ShaderHandle, g_VertHandle);
|
if (g_VertHandle) { glDeleteShader(g_VertHandle); g_VertHandle = 0; }
|
||||||
if (g_VertHandle) glDeleteShader(g_VertHandle);
|
if (g_FragHandle) { glDeleteShader(g_FragHandle); g_FragHandle = 0; }
|
||||||
g_VertHandle = 0;
|
if (g_ShaderHandle) { glDeleteProgram(g_ShaderHandle); g_ShaderHandle = 0; }
|
||||||
|
|
||||||
if (g_ShaderHandle && g_FragHandle) glDetachShader(g_ShaderHandle, g_FragHandle);
|
|
||||||
if (g_FragHandle) glDeleteShader(g_FragHandle);
|
|
||||||
g_FragHandle = 0;
|
|
||||||
|
|
||||||
if (g_ShaderHandle) glDeleteProgram(g_ShaderHandle);
|
|
||||||
g_ShaderHandle = 0;
|
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_DestroyFontsTexture();
|
ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
|
// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
|
||||||
// - Desktop GL: 3.x 4.x
|
// - Desktop GL: 2.x 3.x 4.x
|
||||||
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
|
// - 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..)
|
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [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-bits indices.
|
// [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.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
@ -23,25 +23,45 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// Specific OpenGL versions
|
// Backend API
|
||||||
//#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten
|
|
||||||
//#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android
|
|
||||||
|
|
||||||
// Set default OpenGL3 loader to be gl3w
|
|
||||||
#if !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \
|
|
||||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \
|
|
||||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \
|
|
||||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
|
|
||||||
#define IMGUI_IMPL_OPENGL_LOADER_GL3W
|
|
||||||
#endif
|
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL);
|
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_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
|
||||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
|
IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
|
||||||
|
|
||||||
// Called by Init/NewFrame/Shutdown
|
// (Optional) Called by Init/NewFrame/Shutdown
|
||||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture();
|
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture();
|
||||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture();
|
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
||||||
|
|
||||||
|
// Specific OpenGL versions
|
||||||
|
//#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten
|
||||||
|
//#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android
|
||||||
|
|
||||||
|
// Desktop OpenGL: attempt to detect default 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 '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
|
||||||
|
#if !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \
|
||||||
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \
|
||||||
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \
|
||||||
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING) \
|
||||||
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
|
||||||
|
#if 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(<GL/gl3w.h>)
|
||||||
|
#define IMGUI_IMPL_OPENGL_LOADER_GL3W
|
||||||
|
#elif __has_include(<glbinding/gl/gl.h>)
|
||||||
|
#define IMGUI_IMPL_OPENGL_LOADER_GLBINDING
|
||||||
|
#else
|
||||||
|
#error "Cannot detect OpenGL loader!"
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define IMGUI_IMPL_OPENGL_LOADER_GL3W // Default to GL3W
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -13,5 +13,5 @@
|
|||||||
|
|
||||||
IMGUI_API bool ImGui_ImplOSX_Init();
|
IMGUI_API bool ImGui_ImplOSX_Init();
|
||||||
IMGUI_API void ImGui_ImplOSX_Shutdown();
|
IMGUI_API void ImGui_ImplOSX_Shutdown();
|
||||||
IMGUI_API void ImGui_ImplOSX_NewFrame(NSView *_Nonnull view);
|
IMGUI_API void ImGui_ImplOSX_NewFrame(NSView *_Nullable view);
|
||||||
IMGUI_API bool ImGui_ImplOSX_HandleEvent(NSEvent *_Nonnull event, NSView *_Nullable view);
|
IMGUI_API bool ImGui_ImplOSX_HandleEvent(NSEvent *_Nonnull event, NSView *_Nullable view);
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
|
||||||
|
// 2019-10-11: Inputs: Fix using Backspace key.
|
||||||
|
// 2019-07-21: Re-added clipboard handlers as they are not enabled by default in core imgui.cpp (reverted 2019-05-18 change).
|
||||||
// 2019-05-28: Inputs: Added mouse cursor shape and visibility support.
|
// 2019-05-28: Inputs: Added mouse cursor shape and visibility support.
|
||||||
// 2019-05-18: Misc: Removed clipboard handlers as they are now supported by core imgui.cpp.
|
// 2019-05-18: Misc: Removed clipboard handlers as they are now supported by core imgui.cpp.
|
||||||
// 2019-05-11: Inputs: Don't filter character values before calling AddInputCharacter() apart from 0xF700..0xFFFF range.
|
// 2019-05-11: Inputs: Don't filter character values before calling AddInputCharacter() apart from 0xF700..0xFFFF range.
|
||||||
@ -22,7 +25,7 @@
|
|||||||
|
|
||||||
// Data
|
// Data
|
||||||
static CFAbsoluteTime g_Time = 0.0;
|
static CFAbsoluteTime g_Time = 0.0;
|
||||||
static NSCursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = { 0 };
|
static NSCursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
|
||||||
static bool g_MouseCursorHidden = false;
|
static bool g_MouseCursorHidden = false;
|
||||||
|
|
||||||
// Undocumented methods for creating cursors.
|
// Undocumented methods for creating cursors.
|
||||||
@ -39,35 +42,36 @@ bool ImGui_ImplOSX_Init()
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
// Setup back-end capabilities flags
|
// Setup back-end capabilities flags
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
//io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
//io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||||
//io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
|
//io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
|
||||||
//io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can set io.MouseHoveredViewport correctly (optional, not easy)
|
//io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can set io.MouseHoveredViewport correctly (optional, not easy)
|
||||||
io.BackendPlatformName = "imgui_impl_osx";
|
io.BackendPlatformName = "imgui_impl_osx";
|
||||||
|
|
||||||
// Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
|
// Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeyDown[] array.
|
||||||
const int offset_for_function_keys = 256 - 0xF700;
|
const int offset_for_function_keys = 256 - 0xF700;
|
||||||
io.KeyMap[ImGuiKey_Tab] = '\t';
|
io.KeyMap[ImGuiKey_Tab] = '\t';
|
||||||
io.KeyMap[ImGuiKey_LeftArrow] = NSLeftArrowFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_LeftArrow] = NSLeftArrowFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_RightArrow] = NSRightArrowFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_RightArrow] = NSRightArrowFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_UpArrow] = NSUpArrowFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_UpArrow] = NSUpArrowFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_DownArrow] = NSDownArrowFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_DownArrow] = NSDownArrowFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_PageUp] = NSPageUpFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_PageUp] = NSPageUpFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_PageDown] = NSPageDownFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_PageDown] = NSPageDownFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_Home] = NSHomeFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_Home] = NSHomeFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_End] = NSEndFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_End] = NSEndFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_Insert] = NSInsertFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_Insert] = NSInsertFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_Delete] = NSDeleteFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_Delete] = NSDeleteFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_Backspace] = 127;
|
io.KeyMap[ImGuiKey_Backspace] = 127;
|
||||||
io.KeyMap[ImGuiKey_Space] = 32;
|
io.KeyMap[ImGuiKey_Space] = 32;
|
||||||
io.KeyMap[ImGuiKey_Enter] = 13;
|
io.KeyMap[ImGuiKey_Enter] = 13;
|
||||||
io.KeyMap[ImGuiKey_Escape] = 27;
|
io.KeyMap[ImGuiKey_Escape] = 27;
|
||||||
io.KeyMap[ImGuiKey_A] = 'A';
|
io.KeyMap[ImGuiKey_KeyPadEnter] = 13;
|
||||||
io.KeyMap[ImGuiKey_C] = 'C';
|
io.KeyMap[ImGuiKey_A] = 'A';
|
||||||
io.KeyMap[ImGuiKey_V] = 'V';
|
io.KeyMap[ImGuiKey_C] = 'C';
|
||||||
io.KeyMap[ImGuiKey_X] = 'X';
|
io.KeyMap[ImGuiKey_V] = 'V';
|
||||||
io.KeyMap[ImGuiKey_Y] = 'Y';
|
io.KeyMap[ImGuiKey_X] = 'X';
|
||||||
io.KeyMap[ImGuiKey_Z] = 'Z';
|
io.KeyMap[ImGuiKey_Y] = 'Y';
|
||||||
|
io.KeyMap[ImGuiKey_Z] = 'Z';
|
||||||
|
|
||||||
// Load cursors. Some of them are undocumented.
|
// Load cursors. Some of them are undocumented.
|
||||||
g_MouseCursorHidden = false;
|
g_MouseCursorHidden = false;
|
||||||
@ -75,13 +79,40 @@ bool ImGui_ImplOSX_Init()
|
|||||||
g_MouseCursors[ImGuiMouseCursor_TextInput] = [NSCursor IBeamCursor];
|
g_MouseCursors[ImGuiMouseCursor_TextInput] = [NSCursor IBeamCursor];
|
||||||
g_MouseCursors[ImGuiMouseCursor_ResizeAll] = [NSCursor closedHandCursor];
|
g_MouseCursors[ImGuiMouseCursor_ResizeAll] = [NSCursor closedHandCursor];
|
||||||
g_MouseCursors[ImGuiMouseCursor_Hand] = [NSCursor pointingHandCursor];
|
g_MouseCursors[ImGuiMouseCursor_Hand] = [NSCursor pointingHandCursor];
|
||||||
|
g_MouseCursors[ImGuiMouseCursor_NotAllowed] = [NSCursor operationNotAllowedCursor];
|
||||||
g_MouseCursors[ImGuiMouseCursor_ResizeNS] = [NSCursor respondsToSelector:@selector(_windowResizeNorthSouthCursor)] ? [NSCursor _windowResizeNorthSouthCursor] : [NSCursor resizeUpDownCursor];
|
g_MouseCursors[ImGuiMouseCursor_ResizeNS] = [NSCursor respondsToSelector:@selector(_windowResizeNorthSouthCursor)] ? [NSCursor _windowResizeNorthSouthCursor] : [NSCursor resizeUpDownCursor];
|
||||||
g_MouseCursors[ImGuiMouseCursor_ResizeEW] = [NSCursor respondsToSelector:@selector(_windowResizeEastWestCursor)] ? [NSCursor _windowResizeEastWestCursor] : [NSCursor resizeLeftRightCursor];
|
g_MouseCursors[ImGuiMouseCursor_ResizeEW] = [NSCursor respondsToSelector:@selector(_windowResizeEastWestCursor)] ? [NSCursor _windowResizeEastWestCursor] : [NSCursor resizeLeftRightCursor];
|
||||||
g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = [NSCursor respondsToSelector:@selector(_windowResizeNorthEastSouthWestCursor)] ? [NSCursor _windowResizeNorthEastSouthWestCursor] : [NSCursor closedHandCursor];
|
g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = [NSCursor respondsToSelector:@selector(_windowResizeNorthEastSouthWestCursor)] ? [NSCursor _windowResizeNorthEastSouthWestCursor] : [NSCursor closedHandCursor];
|
||||||
g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = [NSCursor respondsToSelector:@selector(_windowResizeNorthWestSouthEastCursor)] ? [NSCursor _windowResizeNorthWestSouthEastCursor] : [NSCursor closedHandCursor];
|
g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = [NSCursor respondsToSelector:@selector(_windowResizeNorthWestSouthEastCursor)] ? [NSCursor _windowResizeNorthWestSouthEastCursor] : [NSCursor closedHandCursor];
|
||||||
|
|
||||||
// We don't set the io.SetClipboardTextFn/io.GetClipboardTextFn handlers,
|
// Note that imgui.cpp also include default OSX clipboard handlers which can be enabled
|
||||||
// because imgui.cpp has a default for them that works with OSX.
|
// by adding '#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS' in imconfig.h and adding '-framework ApplicationServices' to your linker command-line.
|
||||||
|
// Since we are already in ObjC land here, it is easy for us to add a clipboard handler using the NSPasteboard api.
|
||||||
|
io.SetClipboardTextFn = [](void*, const char* str) -> void
|
||||||
|
{
|
||||||
|
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
|
||||||
|
[pasteboard declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil];
|
||||||
|
[pasteboard setString:[NSString stringWithUTF8String:str] forType:NSPasteboardTypeString];
|
||||||
|
};
|
||||||
|
|
||||||
|
io.GetClipboardTextFn = [](void*) -> const char*
|
||||||
|
{
|
||||||
|
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
|
||||||
|
NSString* available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:NSPasteboardTypeString]];
|
||||||
|
if (![available isEqualToString:NSPasteboardTypeString])
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
NSString* string = [pasteboard stringForType:NSPasteboardTypeString];
|
||||||
|
if (string == nil)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
const char* string_c = (const char*)[string UTF8String];
|
||||||
|
size_t string_len = strlen(string_c);
|
||||||
|
static ImVector<char> s_clipboard;
|
||||||
|
s_clipboard.resize((int)string_len + 1);
|
||||||
|
strcpy(s_clipboard.Data, string_c);
|
||||||
|
return s_clipboard.Data;
|
||||||
|
};
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -122,9 +153,12 @@ void ImGui_ImplOSX_NewFrame(NSView* view)
|
|||||||
{
|
{
|
||||||
// Setup display size
|
// Setup display size
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
const float dpi = [view.window backingScaleFactor];
|
if (view)
|
||||||
io.DisplaySize = ImVec2((float)view.bounds.size.width, (float)view.bounds.size.height);
|
{
|
||||||
io.DisplayFramebufferScale = ImVec2(dpi, dpi);
|
const float dpi = [view.window backingScaleFactor];
|
||||||
|
io.DisplaySize = ImVec2((float)view.bounds.size.width, (float)view.bounds.size.height);
|
||||||
|
io.DisplayFramebufferScale = ImVec2(dpi, dpi);
|
||||||
|
}
|
||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
if (g_Time == 0.0)
|
if (g_Time == 0.0)
|
||||||
@ -201,7 +235,7 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
#endif // MAC_OS_X_VERSION_MAX_ALLOWED
|
||||||
{
|
{
|
||||||
wheel_dx = [event deltaX];
|
wheel_dx = [event deltaX];
|
||||||
wheel_dy = [event deltaY];
|
wheel_dy = [event deltaY];
|
||||||
@ -222,7 +256,7 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
|||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
int c = [str characterAtIndex:i];
|
int c = [str characterAtIndex:i];
|
||||||
if (!io.KeyCtrl && !(c >= 0xF700 && c <= 0xFFFF))
|
if (!io.KeyCtrl && !(c >= 0xF700 && c <= 0xFFFF) && c != 127)
|
||||||
io.AddInputCharacter((unsigned int)c);
|
io.AddInputCharacter((unsigned int)c);
|
||||||
|
|
||||||
// We must reset in case we're pressing a sequence of special keys while keeping the command pressed
|
// We must reset in case we're pressing a sequence of special keys while keeping the command pressed
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2019-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-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.
|
// 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-12-21: Inputs: Workaround for Android/iOS which don't seem to handle focus related calls.
|
||||||
@ -56,8 +59,9 @@
|
|||||||
static SDL_Window* g_Window = NULL;
|
static SDL_Window* g_Window = NULL;
|
||||||
static Uint64 g_Time = 0;
|
static Uint64 g_Time = 0;
|
||||||
static bool g_MousePressed[3] = { false, false, false };
|
static bool g_MousePressed[3] = { false, false, false };
|
||||||
static SDL_Cursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = { 0 };
|
static SDL_Cursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
|
||||||
static char* g_ClipboardTextData = NULL;
|
static char* g_ClipboardTextData = NULL;
|
||||||
|
static bool g_MouseCanUseGlobalState = true;
|
||||||
|
|
||||||
static const char* ImGui_ImplSDL2_GetClipboardText(void*)
|
static const char* ImGui_ImplSDL2_GetClipboardText(void*)
|
||||||
{
|
{
|
||||||
@ -111,7 +115,11 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
|||||||
io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
|
io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
|
||||||
io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
|
io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
|
||||||
io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);
|
io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);
|
||||||
|
#ifdef _WIN32
|
||||||
|
io.KeySuper = false;
|
||||||
|
#else
|
||||||
io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0);
|
io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,6 +152,7 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window)
|
|||||||
io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
|
io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
|
||||||
io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
|
io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
|
||||||
io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
|
io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
|
||||||
|
io.KeyMap[ImGuiKey_KeyPadEnter] = SDL_SCANCODE_RETURN2;
|
||||||
io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
|
io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
|
||||||
io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
|
io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
|
||||||
io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
|
io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
|
||||||
@ -155,6 +164,7 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window)
|
|||||||
io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
|
io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
|
||||||
io.ClipboardUserData = NULL;
|
io.ClipboardUserData = NULL;
|
||||||
|
|
||||||
|
// Load mouse cursors
|
||||||
g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
|
g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
|
||||||
g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
|
g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
|
||||||
g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
|
g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
|
||||||
@ -163,6 +173,10 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window)
|
|||||||
g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
|
g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
|
||||||
g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
|
g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
|
||||||
g_MouseCursors[ImGuiMouseCursor_Hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
|
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
|
#ifdef _WIN32
|
||||||
SDL_SysWMinfo wmInfo;
|
SDL_SysWMinfo wmInfo;
|
||||||
@ -190,6 +204,14 @@ bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
|
|||||||
return ImGui_ImplSDL2_Init(window);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDL2_Shutdown()
|
void ImGui_ImplSDL2_Shutdown()
|
||||||
{
|
{
|
||||||
g_Window = NULL;
|
g_Window = NULL;
|
||||||
@ -226,13 +248,17 @@ static void ImGui_ImplSDL2_UpdateMousePosAndButtons()
|
|||||||
SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
||||||
if (g_Window == focused_window)
|
if (g_Window == focused_window)
|
||||||
{
|
{
|
||||||
// SDL_GetMouseState() gives mouse position seemingly based on the last window entered/focused(?)
|
if (g_MouseCanUseGlobalState)
|
||||||
// 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.
|
{
|
||||||
int wx, wy;
|
// SDL_GetMouseState() gives mouse position seemingly based on the last window entered/focused(?)
|
||||||
SDL_GetWindowPosition(focused_window, &wx, &wy);
|
// 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.
|
||||||
SDL_GetGlobalMouseState(&mx, &my);
|
// Won't use this workaround when on Wayland, as there is no global mouse position.
|
||||||
mx -= wx;
|
int wx, wy;
|
||||||
my -= wy;
|
SDL_GetWindowPosition(focused_window, &wx, &wy);
|
||||||
|
SDL_GetGlobalMouseState(&mx, &my);
|
||||||
|
mx -= wx;
|
||||||
|
my -= wy;
|
||||||
|
}
|
||||||
io.MousePos = ImVec2((float)mx, (float)my);
|
io.MousePos = ImVec2((float)mx, (float)my);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ 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_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window);
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame(SDL_Window* window);
|
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame(SDL_Window* window);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bits indices.
|
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||||
// Missing features:
|
// Missing features:
|
||||||
// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this binding! See https://github.com/ocornut/imgui/pull/914
|
// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this binding! See https://github.com/ocornut/imgui/pull/914
|
||||||
|
|
||||||
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2019-08-01: Vulkan: Added support for specifying multisample count. Set ImGui_ImplVulkan_InitInfo::MSAASamples to one of the VkSampleCountFlagBits values to use, default is non-multisampled as before.
|
||||||
// 2019-05-29: Vulkan: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
// 2019-05-29: Vulkan: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
||||||
// 2019-04-30: Vulkan: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
// 2019-04-30: Vulkan: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||||
// 2019-04-04: *BREAKING CHANGE*: Vulkan: Added ImageCount/MinImageCount fields in ImGui_ImplVulkan_InitInfo, required for initialization (was previously a hard #define IMGUI_VK_QUEUED_FRAMES 2). Added ImGui_ImplVulkan_SetMinImageCount().
|
// 2019-04-04: *BREAKING CHANGE*: Vulkan: Added ImageCount/MinImageCount fields in ImGui_ImplVulkan_InitInfo, required for initialization (was previously a hard #define IMGUI_VK_QUEUED_FRAMES 2). Added ImGui_ImplVulkan_SetMinImageCount().
|
||||||
@ -721,7 +722,10 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
|||||||
|
|
||||||
VkPipelineMultisampleStateCreateInfo ms_info = {};
|
VkPipelineMultisampleStateCreateInfo ms_info = {};
|
||||||
ms_info.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
ms_info.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
||||||
ms_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
|
if (v->MSAASamples != 0)
|
||||||
|
ms_info.rasterizationSamples = v->MSAASamples;
|
||||||
|
else
|
||||||
|
ms_info.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
|
|
||||||
VkPipelineColorBlendAttachmentState color_attachment[1] = {};
|
VkPipelineColorBlendAttachmentState color_attachment[1] = {};
|
||||||
color_attachment[0].blendEnable = VK_TRUE;
|
color_attachment[0].blendEnable = VK_TRUE;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bits indices.
|
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||||
// Missing features:
|
// Missing features:
|
||||||
// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this binding! See https://github.com/ocornut/imgui/pull/914
|
// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this binding! See https://github.com/ocornut/imgui/pull/914
|
||||||
|
|
||||||
@ -37,6 +37,7 @@ struct ImGui_ImplVulkan_InitInfo
|
|||||||
VkDescriptorPool DescriptorPool;
|
VkDescriptorPool DescriptorPool;
|
||||||
uint32_t MinImageCount; // >= 2
|
uint32_t MinImageCount; // >= 2
|
||||||
uint32_t ImageCount; // >= MinImageCount
|
uint32_t ImageCount; // >= MinImageCount
|
||||||
|
VkSampleCountFlagBits MSAASamples; // >= VK_SAMPLE_COUNT_1_BIT
|
||||||
const VkAllocationCallbacks* Allocator;
|
const VkAllocationCallbacks* Allocator;
|
||||||
void (*CheckVkResultFn)(VkResult err);
|
void (*CheckVkResultFn)(VkResult err);
|
||||||
};
|
};
|
||||||
|
@ -13,11 +13,23 @@
|
|||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#endif
|
#endif
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <XInput.h>
|
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
|
||||||
|
// Using XInput library for gamepad (with recent Windows SDK this may leads to executables which won't run on Windows 7)
|
||||||
|
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
|
#include <XInput.h>
|
||||||
|
#else
|
||||||
|
#define IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT
|
||||||
|
#endif
|
||||||
|
#if defined(_MSC_VER) && !defined(IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT)
|
||||||
|
#pragma comment(lib, "xinput")
|
||||||
|
//#pragma comment(lib, "Xinput9_1_0")
|
||||||
|
#endif
|
||||||
|
|
||||||
// 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)
|
||||||
|
// 2020-01-14: Inputs: Added support for #define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD/IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT.
|
||||||
|
// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
|
||||||
// 2019-05-11: Inputs: Don't filter value from WM_CHAR before calling AddInputCharacter().
|
// 2019-05-11: Inputs: Don't filter value from WM_CHAR before calling AddInputCharacter().
|
||||||
// 2019-01-17: Misc: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created in a different thread or parent.
|
// 2019-01-17: Misc: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created in a different thread or parent.
|
||||||
// 2019-01-17: Inputs: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages.
|
// 2019-01-17: Inputs: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages.
|
||||||
@ -39,7 +51,7 @@
|
|||||||
// 2016-11-12: Inputs: Only call Win32 ::SetCursor(NULL) when io.MouseDrawCursor is set.
|
// 2016-11-12: Inputs: Only call Win32 ::SetCursor(NULL) when io.MouseDrawCursor is set.
|
||||||
|
|
||||||
// Win32 Data
|
// Win32 Data
|
||||||
static HWND g_hWnd = 0;
|
static HWND g_hWnd = NULL;
|
||||||
static INT64 g_Time = 0;
|
static INT64 g_Time = 0;
|
||||||
static INT64 g_TicksPerSecond = 0;
|
static INT64 g_TicksPerSecond = 0;
|
||||||
static ImGuiMouseCursor g_LastMouseCursor = ImGuiMouseCursor_COUNT;
|
static ImGuiMouseCursor g_LastMouseCursor = ImGuiMouseCursor_COUNT;
|
||||||
@ -78,6 +90,7 @@ bool ImGui_ImplWin32_Init(void* hwnd)
|
|||||||
io.KeyMap[ImGuiKey_Space] = VK_SPACE;
|
io.KeyMap[ImGuiKey_Space] = VK_SPACE;
|
||||||
io.KeyMap[ImGuiKey_Enter] = VK_RETURN;
|
io.KeyMap[ImGuiKey_Enter] = VK_RETURN;
|
||||||
io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE;
|
io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE;
|
||||||
|
io.KeyMap[ImGuiKey_KeyPadEnter] = VK_RETURN;
|
||||||
io.KeyMap[ImGuiKey_A] = 'A';
|
io.KeyMap[ImGuiKey_A] = 'A';
|
||||||
io.KeyMap[ImGuiKey_C] = 'C';
|
io.KeyMap[ImGuiKey_C] = 'C';
|
||||||
io.KeyMap[ImGuiKey_V] = 'V';
|
io.KeyMap[ImGuiKey_V] = 'V';
|
||||||
@ -119,6 +132,7 @@ static bool ImGui_ImplWin32_UpdateMouseCursor()
|
|||||||
case ImGuiMouseCursor_ResizeNESW: win32_cursor = IDC_SIZENESW; break;
|
case ImGuiMouseCursor_ResizeNESW: win32_cursor = IDC_SIZENESW; break;
|
||||||
case ImGuiMouseCursor_ResizeNWSE: win32_cursor = IDC_SIZENWSE; break;
|
case ImGuiMouseCursor_ResizeNWSE: win32_cursor = IDC_SIZENWSE; break;
|
||||||
case ImGuiMouseCursor_Hand: win32_cursor = IDC_HAND; break;
|
case ImGuiMouseCursor_Hand: win32_cursor = IDC_HAND; break;
|
||||||
|
case ImGuiMouseCursor_NotAllowed: win32_cursor = IDC_NO; break;
|
||||||
}
|
}
|
||||||
::SetCursor(::LoadCursor(NULL, win32_cursor));
|
::SetCursor(::LoadCursor(NULL, win32_cursor));
|
||||||
}
|
}
|
||||||
@ -146,13 +160,10 @@ static void ImGui_ImplWin32_UpdateMousePos()
|
|||||||
io.MousePos = ImVec2((float)pos.x, (float)pos.y);
|
io.MousePos = ImVec2((float)pos.x, (float)pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma comment(lib, "xinput")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Gamepad navigation mapping
|
// Gamepad navigation mapping
|
||||||
static void ImGui_ImplWin32_UpdateGamepads()
|
static void ImGui_ImplWin32_UpdateGamepads()
|
||||||
{
|
{
|
||||||
|
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
memset(io.NavInputs, 0, sizeof(io.NavInputs));
|
memset(io.NavInputs, 0, sizeof(io.NavInputs));
|
||||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
||||||
@ -195,6 +206,7 @@ static void ImGui_ImplWin32_UpdateGamepads()
|
|||||||
#undef MAP_BUTTON
|
#undef MAP_BUTTON
|
||||||
#undef MAP_ANALOG
|
#undef MAP_ANALOG
|
||||||
}
|
}
|
||||||
|
#endif // #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplWin32_NewFrame()
|
void ImGui_ImplWin32_NewFrame()
|
||||||
|
@ -13,9 +13,13 @@ IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd);
|
|||||||
IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame();
|
||||||
|
|
||||||
|
// Configuration: Disable gamepad support or linking with xinput.lib
|
||||||
|
//#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
|
//#define IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT
|
||||||
|
|
||||||
// Handler for Win32 messages, update mouse/keyboard data.
|
// Handler for Win32 messages, update mouse/keyboard data.
|
||||||
// You may or not need this for your implementation, but it can serve as reference for handling inputs.
|
// You may or not need this for your implementation, but it can serve as reference for handling inputs.
|
||||||
// Intentionally commented out to avoid dragging dependencies on <windows.h> types. You can COPY this line into your .cpp code instead.
|
// Intentionally commented out to avoid dragging dependencies on <windows.h> types. You can COPY this line into your .cpp code instead.
|
||||||
/*
|
#if 0
|
||||||
IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
*/
|
#endif
|
||||||
|
41
imconfig.h
41
imconfig.h
@ -14,6 +14,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
//---- Define assertion handler. Defaults to calling assert().
|
//---- 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) MyAssert(_EXPR)
|
||||||
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
|
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
|
||||||
|
|
||||||
@ -22,20 +23,23 @@
|
|||||||
//#define IMGUI_API __declspec( dllexport )
|
//#define IMGUI_API __declspec( dllexport )
|
||||||
//#define IMGUI_API __declspec( dllimport )
|
//#define IMGUI_API __declspec( dllimport )
|
||||||
|
|
||||||
//---- Don't define obsolete functions/enums names. 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 avoid using soon-to-be obsolete function/names.
|
||||||
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
|
||||||
//---- Don't implement demo windows functionality (ShowDemoWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty)
|
//---- 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 the comments in imgui_demo.cpp.
|
// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
|
||||||
//#define IMGUI_DISABLE_DEMO_WINDOWS
|
//#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.
|
||||||
|
|
||||||
//---- Don't implement some functions to reduce linkage requirements.
|
//---- 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_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_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_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
|
||||||
//#define IMGUI_DISABLE_OSX_FUNCTIONS // [OSX] Won't use and link with any OSX function (clipboard).
|
//#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_FORMAT_STRING_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself if you don't want to link with vsnprintf.
|
//#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_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 wrapper so you can implement them yourself. Declare your prototypes in imconfig.h.
|
//#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_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_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
|
||||||
|
|
||||||
//---- Include imgui_user.h at the end of imgui.h as a convenience
|
//---- Include imgui_user.h at the end of imgui.h as a convenience
|
||||||
@ -51,6 +55,10 @@
|
|||||||
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
|
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
|
||||||
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
|
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
|
||||||
|
|
||||||
|
//---- 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
|
||||||
|
|
||||||
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
|
//---- 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.
|
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
|
||||||
/*
|
/*
|
||||||
@ -63,9 +71,9 @@
|
|||||||
operator MyVec4() const { return MyVec4(x,y,z,w); }
|
operator MyVec4() const { return MyVec4(x,y,z,w); }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//---- Using 32-bits vertex indices (default is 16-bits) is one way to allow large meshes with more than 64K vertices.
|
//---- 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-bits indices).
|
// Your renderer back-end will need to support it (most example renderer back-ends support both 16/32-bit indices).
|
||||||
// Another way to allow large meshes while keeping 16-bits indices is to handle ImDrawCmd::VtxOffset in your renderer.
|
// 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.
|
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
|
||||||
//#define ImDrawIdx unsigned int
|
//#define ImDrawIdx unsigned int
|
||||||
|
|
||||||
@ -75,6 +83,19 @@
|
|||||||
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
|
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
|
||||||
//#define ImDrawCallback MyImDrawCallback
|
//#define ImDrawCallback MyImDrawCallback
|
||||||
|
|
||||||
|
//---- Debug Tools: Macro to break in Debugger
|
||||||
|
// (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, here or in your own headers files.
|
||||||
/*
|
/*
|
||||||
namespace ImGui
|
namespace ImGui
|
||||||
|
697
imgui_demo.cpp
697
imgui_demo.cpp
File diff suppressed because it is too large
Load Diff
371
imgui_draw.cpp
371
imgui_draw.cpp
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.71
|
// dear imgui, v1.75
|
||||||
// (drawing and font code)
|
// (drawing and font code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -27,6 +27,8 @@ Index of this file:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
#endif
|
#endif
|
||||||
@ -72,13 +74,12 @@ 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.
|
||||||
#endif
|
#endif
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
|
#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
|
||||||
#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
|
#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
|
||||||
#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
|
#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
|
||||||
#pragma GCC diagnostic ignored "-Wstack-protector" // warning: stack protector not protecting local variables: variable length buffer
|
#pragma GCC diagnostic ignored "-Wstack-protector" // warning: stack protector not protecting local variables: variable length buffer
|
||||||
#if __GNUC__ >= 8
|
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
|
||||||
#pragma GCC diagnostic ignored "-Wclass-memaccess" // warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@ -261,7 +262,7 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst)
|
|||||||
colors[ImGuiCol_Header] = ImVec4(0.40f, 0.40f, 0.90f, 0.45f);
|
colors[ImGuiCol_Header] = ImVec4(0.40f, 0.40f, 0.90f, 0.45f);
|
||||||
colors[ImGuiCol_HeaderHovered] = ImVec4(0.45f, 0.45f, 0.90f, 0.80f);
|
colors[ImGuiCol_HeaderHovered] = ImVec4(0.45f, 0.45f, 0.90f, 0.80f);
|
||||||
colors[ImGuiCol_HeaderActive] = ImVec4(0.53f, 0.53f, 0.87f, 0.80f);
|
colors[ImGuiCol_HeaderActive] = ImVec4(0.53f, 0.53f, 0.87f, 0.80f);
|
||||||
colors[ImGuiCol_Separator] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
|
colors[ImGuiCol_Separator] = ImVec4(0.50f, 0.50f, 0.50f, 0.60f);
|
||||||
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.60f, 0.60f, 0.70f, 1.00f);
|
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.60f, 0.60f, 0.70f, 1.00f);
|
||||||
colors[ImGuiCol_SeparatorActive] = ImVec4(0.70f, 0.70f, 0.90f, 1.00f);
|
colors[ImGuiCol_SeparatorActive] = ImVec4(0.70f, 0.70f, 0.90f, 1.00f);
|
||||||
colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.16f);
|
colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.16f);
|
||||||
@ -317,7 +318,7 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst)
|
|||||||
colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f);
|
colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f);
|
||||||
colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
|
colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
|
||||||
colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
||||||
colors[ImGuiCol_Separator] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
|
colors[ImGuiCol_Separator] = ImVec4(0.39f, 0.39f, 0.39f, 0.62f);
|
||||||
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.14f, 0.44f, 0.80f, 0.78f);
|
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.14f, 0.44f, 0.80f, 0.78f);
|
||||||
colors[ImGuiCol_SeparatorActive] = ImVec4(0.14f, 0.44f, 0.80f, 1.00f);
|
colors[ImGuiCol_SeparatorActive] = ImVec4(0.14f, 0.44f, 0.80f, 1.00f);
|
||||||
colors[ImGuiCol_ResizeGrip] = ImVec4(0.80f, 0.80f, 0.80f, 0.56f);
|
colors[ImGuiCol_ResizeGrip] = ImVec4(0.80f, 0.80f, 0.80f, 0.56f);
|
||||||
@ -349,15 +350,30 @@ ImDrawListSharedData::ImDrawListSharedData()
|
|||||||
Font = NULL;
|
Font = NULL;
|
||||||
FontSize = 0.0f;
|
FontSize = 0.0f;
|
||||||
CurveTessellationTol = 0.0f;
|
CurveTessellationTol = 0.0f;
|
||||||
|
CircleSegmentMaxError = 0.0f;
|
||||||
ClipRectFullscreen = ImVec4(-8192.0f, -8192.0f, +8192.0f, +8192.0f);
|
ClipRectFullscreen = ImVec4(-8192.0f, -8192.0f, +8192.0f, +8192.0f);
|
||||||
InitialFlags = ImDrawListFlags_None;
|
InitialFlags = ImDrawListFlags_None;
|
||||||
|
|
||||||
// Const data
|
// Lookup tables
|
||||||
for (int i = 0; i < IM_ARRAYSIZE(CircleVtx12); i++)
|
for (int i = 0; i < IM_ARRAYSIZE(CircleVtx12); i++)
|
||||||
{
|
{
|
||||||
const float a = ((float)i * 2 * IM_PI) / (float)IM_ARRAYSIZE(CircleVtx12);
|
const float a = ((float)i * 2 * IM_PI) / (float)IM_ARRAYSIZE(CircleVtx12);
|
||||||
CircleVtx12[i] = ImVec2(ImCos(a), ImSin(a));
|
CircleVtx12[i] = ImVec2(ImCos(a), ImSin(a));
|
||||||
}
|
}
|
||||||
|
memset(CircleSegmentCounts, 0, sizeof(CircleSegmentCounts)); // This will be set by SetCircleSegmentMaxError()
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImDrawListSharedData::SetCircleSegmentMaxError(float max_error)
|
||||||
|
{
|
||||||
|
if (CircleSegmentMaxError == max_error)
|
||||||
|
return;
|
||||||
|
CircleSegmentMaxError = max_error;
|
||||||
|
for (int i = 0; i < IM_ARRAYSIZE(CircleSegmentCounts); i++)
|
||||||
|
{
|
||||||
|
const float radius = i + 1.0f;
|
||||||
|
const int segment_count = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, CircleSegmentMaxError);
|
||||||
|
CircleSegmentCounts[i] = (ImU8)ImMin(segment_count, 255);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::Clear()
|
void ImDrawList::Clear()
|
||||||
@ -365,7 +381,7 @@ void ImDrawList::Clear()
|
|||||||
CmdBuffer.resize(0);
|
CmdBuffer.resize(0);
|
||||||
IdxBuffer.resize(0);
|
IdxBuffer.resize(0);
|
||||||
VtxBuffer.resize(0);
|
VtxBuffer.resize(0);
|
||||||
Flags = _Data->InitialFlags;
|
Flags = _Data ? _Data->InitialFlags : ImDrawListFlags_None;
|
||||||
_VtxCurrentOffset = 0;
|
_VtxCurrentOffset = 0;
|
||||||
_VtxCurrentIdx = 0;
|
_VtxCurrentIdx = 0;
|
||||||
_VtxWritePtr = NULL;
|
_VtxWritePtr = NULL;
|
||||||
@ -392,7 +408,7 @@ void ImDrawList::ClearFreeMemory()
|
|||||||
|
|
||||||
ImDrawList* ImDrawList::CloneOutput() const
|
ImDrawList* ImDrawList::CloneOutput() const
|
||||||
{
|
{
|
||||||
ImDrawList* dst = IM_NEW(ImDrawList(NULL));
|
ImDrawList* dst = IM_NEW(ImDrawList(_Data));
|
||||||
dst->CmdBuffer = CmdBuffer;
|
dst->CmdBuffer = CmdBuffer;
|
||||||
dst->IdxBuffer = IdxBuffer;
|
dst->IdxBuffer = IdxBuffer;
|
||||||
dst->VtxBuffer = VtxBuffer;
|
dst->VtxBuffer = VtxBuffer;
|
||||||
@ -517,10 +533,13 @@ void ImDrawList::PopTextureID()
|
|||||||
UpdateTextureID();
|
UpdateTextureID();
|
||||||
}
|
}
|
||||||
|
|
||||||
// NB: this can be called with negative count for removing primitives (as long as the result does not underflow)
|
// Reserve space for a number of vertices and indices.
|
||||||
|
// You must finish filling your reserved data before calling PrimReserve() again, as it may reallocate or
|
||||||
|
// submit the intermediate results. PrimUnreserve() can be used to release unused allocations.
|
||||||
void ImDrawList::PrimReserve(int idx_count, int vtx_count)
|
void ImDrawList::PrimReserve(int idx_count, int vtx_count)
|
||||||
{
|
{
|
||||||
// Large mesh support (when enabled)
|
// Large mesh support (when enabled)
|
||||||
|
IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
|
||||||
if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset))
|
if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset))
|
||||||
{
|
{
|
||||||
_VtxCurrentOffset = VtxBuffer.Size;
|
_VtxCurrentOffset = VtxBuffer.Size;
|
||||||
@ -528,7 +547,7 @@ void ImDrawList::PrimReserve(int idx_count, int vtx_count)
|
|||||||
AddDrawCmd();
|
AddDrawCmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size-1];
|
ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
draw_cmd.ElemCount += idx_count;
|
draw_cmd.ElemCount += idx_count;
|
||||||
|
|
||||||
int vtx_buffer_old_size = VtxBuffer.Size;
|
int vtx_buffer_old_size = VtxBuffer.Size;
|
||||||
@ -540,6 +559,17 @@ void ImDrawList::PrimReserve(int idx_count, int vtx_count)
|
|||||||
_IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size;
|
_IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Release the a number of reserved vertices/indices from the end of the last reservation made with PrimReserve().
|
||||||
|
void ImDrawList::PrimUnreserve(int idx_count, int vtx_count)
|
||||||
|
{
|
||||||
|
IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
|
||||||
|
|
||||||
|
ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
|
draw_cmd.ElemCount -= idx_count;
|
||||||
|
VtxBuffer.shrink(VtxBuffer.Size - vtx_count);
|
||||||
|
IdxBuffer.shrink(IdxBuffer.Size - idx_count);
|
||||||
|
}
|
||||||
|
|
||||||
// Fully unrolled with inline call to keep our debug builds decently fast.
|
// Fully unrolled with inline call to keep our debug builds decently fast.
|
||||||
void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, ImU32 col)
|
void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, ImU32 col)
|
||||||
{
|
{
|
||||||
@ -861,26 +891,26 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::PathArcToFast(const ImVec2& centre, float radius, int a_min_of_12, int a_max_of_12)
|
void ImDrawList::PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12)
|
||||||
{
|
{
|
||||||
if (radius == 0.0f || a_min_of_12 > a_max_of_12)
|
if (radius == 0.0f || a_min_of_12 > a_max_of_12)
|
||||||
{
|
{
|
||||||
_Path.push_back(centre);
|
_Path.push_back(center);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_Path.reserve(_Path.Size + (a_max_of_12 - a_min_of_12 + 1));
|
_Path.reserve(_Path.Size + (a_max_of_12 - a_min_of_12 + 1));
|
||||||
for (int a = a_min_of_12; a <= a_max_of_12; a++)
|
for (int a = a_min_of_12; a <= a_max_of_12; a++)
|
||||||
{
|
{
|
||||||
const ImVec2& c = _Data->CircleVtx12[a % IM_ARRAYSIZE(_Data->CircleVtx12)];
|
const ImVec2& c = _Data->CircleVtx12[a % IM_ARRAYSIZE(_Data->CircleVtx12)];
|
||||||
_Path.push_back(ImVec2(centre.x + c.x * radius, centre.y + c.y * radius));
|
_Path.push_back(ImVec2(center.x + c.x * radius, center.y + c.y * radius));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments)
|
void ImDrawList::PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments)
|
||||||
{
|
{
|
||||||
if (radius == 0.0f)
|
if (radius == 0.0f)
|
||||||
{
|
{
|
||||||
_Path.push_back(centre);
|
_Path.push_back(center);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -890,10 +920,21 @@ void ImDrawList::PathArcTo(const ImVec2& centre, float radius, float a_min, floa
|
|||||||
for (int i = 0; i <= num_segments; i++)
|
for (int i = 0; i <= num_segments; i++)
|
||||||
{
|
{
|
||||||
const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min);
|
const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min);
|
||||||
_Path.push_back(ImVec2(centre.x + ImCos(a) * radius, centre.y + ImSin(a) * radius));
|
_Path.push_back(ImVec2(center.x + ImCos(a) * radius, center.y + ImSin(a) * radius));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImVec2 ImBezierCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, float t)
|
||||||
|
{
|
||||||
|
float u = 1.0f - t;
|
||||||
|
float w1 = u*u*u;
|
||||||
|
float w2 = 3*u*u*t;
|
||||||
|
float w3 = 3*u*t*t;
|
||||||
|
float w4 = t*t*t;
|
||||||
|
return ImVec2(w1*p1.x + w2*p2.x + w3*p3.x + w4*p4.x, w1*p1.y + w2*p2.y + w3*p3.y + w4*p4.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Closely mimics BezierClosestPointCasteljauStep() in imgui.cpp
|
||||||
static void PathBezierToCasteljau(ImVector<ImVec2>* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level)
|
static void PathBezierToCasteljau(ImVector<ImVec2>* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level)
|
||||||
{
|
{
|
||||||
float dx = x4 - x1;
|
float dx = x4 - x1;
|
||||||
@ -914,7 +955,6 @@ static void PathBezierToCasteljau(ImVector<ImVec2>* path, float x1, float y1, fl
|
|||||||
float x123 = (x12+x23)*0.5f, y123 = (y12+y23)*0.5f;
|
float x123 = (x12+x23)*0.5f, y123 = (y12+y23)*0.5f;
|
||||||
float x234 = (x23+x34)*0.5f, y234 = (y23+y34)*0.5f;
|
float x234 = (x23+x34)*0.5f, y234 = (y23+y34)*0.5f;
|
||||||
float x1234 = (x123+x234)*0.5f, y1234 = (y123+y234)*0.5f;
|
float x1234 = (x123+x234)*0.5f, y1234 = (y123+y234)*0.5f;
|
||||||
|
|
||||||
PathBezierToCasteljau(path, x1,y1, x12,y12, x123,y123, x1234,y1234, tess_tol, level+1);
|
PathBezierToCasteljau(path, x1,y1, x12,y12, x123,y123, x1234,y1234, tess_tol, level+1);
|
||||||
PathBezierToCasteljau(path, x1234,y1234, x234,y234, x34,y34, x4,y4, tess_tol, level+1);
|
PathBezierToCasteljau(path, x1234,y1234, x234,y234, x34,y34, x4,y4, tess_tol, level+1);
|
||||||
}
|
}
|
||||||
@ -925,26 +965,17 @@ void ImDrawList::PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImV
|
|||||||
ImVec2 p1 = _Path.back();
|
ImVec2 p1 = _Path.back();
|
||||||
if (num_segments == 0)
|
if (num_segments == 0)
|
||||||
{
|
{
|
||||||
// Auto-tessellated
|
PathBezierToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, _Data->CurveTessellationTol, 0); // Auto-tessellated
|
||||||
PathBezierToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, _Data->CurveTessellationTol, 0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float t_step = 1.0f / (float)num_segments;
|
float t_step = 1.0f / (float)num_segments;
|
||||||
for (int i_step = 1; i_step <= num_segments; i_step++)
|
for (int i_step = 1; i_step <= num_segments; i_step++)
|
||||||
{
|
_Path.push_back(ImBezierCalc(p1, p2, p3, p4, t_step * i_step));
|
||||||
float t = t_step * i_step;
|
|
||||||
float u = 1.0f - t;
|
|
||||||
float w1 = u*u*u;
|
|
||||||
float w2 = 3*u*u*t;
|
|
||||||
float w3 = 3*u*t*t;
|
|
||||||
float w4 = t*t*t;
|
|
||||||
_Path.push_back(ImVec2(w1*p1.x + w2*p2.x + w3*p3.x + w4*p4.x, w1*p1.y + w2*p2.y + w3*p3.y + w4*p4.y));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, int rounding_corners)
|
void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, ImDrawCornerFlags rounding_corners)
|
||||||
{
|
{
|
||||||
rounding = ImMin(rounding, ImFabs(b.x - a.x) * ( ((rounding_corners & ImDrawCornerFlags_Top) == ImDrawCornerFlags_Top) || ((rounding_corners & ImDrawCornerFlags_Bot) == ImDrawCornerFlags_Bot) ? 0.5f : 1.0f ) - 1.0f);
|
rounding = ImMin(rounding, ImFabs(b.x - a.x) * ( ((rounding_corners & ImDrawCornerFlags_Top) == ImDrawCornerFlags_Top) || ((rounding_corners & ImDrawCornerFlags_Bot) == ImDrawCornerFlags_Bot) ? 0.5f : 1.0f ) - 1.0f);
|
||||||
rounding = ImMin(rounding, ImFabs(b.y - a.y) * ( ((rounding_corners & ImDrawCornerFlags_Left) == ImDrawCornerFlags_Left) || ((rounding_corners & ImDrawCornerFlags_Right) == ImDrawCornerFlags_Right) ? 0.5f : 1.0f ) - 1.0f);
|
rounding = ImMin(rounding, ImFabs(b.y - a.y) * ( ((rounding_corners & ImDrawCornerFlags_Left) == ImDrawCornerFlags_Left) || ((rounding_corners & ImDrawCornerFlags_Right) == ImDrawCornerFlags_Right) ? 0.5f : 1.0f ) - 1.0f);
|
||||||
@ -969,44 +1000,46 @@ void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness)
|
void ImDrawList::AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
PathLineTo(a + ImVec2(0.5f,0.5f));
|
PathLineTo(p1 + ImVec2(0.5f, 0.5f));
|
||||||
PathLineTo(b + ImVec2(0.5f,0.5f));
|
PathLineTo(p2 + ImVec2(0.5f, 0.5f));
|
||||||
PathStroke(col, false, thickness);
|
PathStroke(col, false, thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
// a: upper-left, b: lower-right. we don't render 1 px sized rectangles properly.
|
// p_min = upper-left, p_max = lower-right
|
||||||
void ImDrawList::AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, int rounding_corners_flags, float thickness)
|
// Note we don't render 1 pixels sized rectangles properly.
|
||||||
|
void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners, float thickness)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
if (Flags & ImDrawListFlags_AntiAliasedLines)
|
if (Flags & ImDrawListFlags_AntiAliasedLines)
|
||||||
PathRect(a + ImVec2(0.5f,0.5f), b - ImVec2(0.50f,0.50f), rounding, rounding_corners_flags);
|
PathRect(p_min + ImVec2(0.50f,0.50f), p_max - ImVec2(0.50f,0.50f), rounding, rounding_corners);
|
||||||
else
|
else
|
||||||
PathRect(a + ImVec2(0.5f,0.5f), b - ImVec2(0.49f,0.49f), rounding, rounding_corners_flags); // Better looking lower-right corner and rounded non-AA shapes.
|
PathRect(p_min + ImVec2(0.50f,0.50f), p_max - ImVec2(0.49f,0.49f), rounding, rounding_corners); // Better looking lower-right corner and rounded non-AA shapes.
|
||||||
PathStroke(col, true, thickness);
|
PathStroke(col, true, thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, int rounding_corners_flags)
|
void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
if (rounding > 0.0f)
|
if (rounding > 0.0f)
|
||||||
{
|
{
|
||||||
PathRect(a, b, rounding, rounding_corners_flags);
|
PathRect(p_min, p_max, rounding, rounding_corners);
|
||||||
PathFillConvex(col);
|
PathFillConvex(col);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PrimReserve(6, 4);
|
PrimReserve(6, 4);
|
||||||
PrimRect(a, b, col);
|
PrimRect(p_min, p_max, col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddRectFilledMultiColor(const ImVec2& a, const ImVec2& c, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left)
|
// p_min = upper-left, p_max = lower-right
|
||||||
|
void ImDrawList::AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left)
|
||||||
{
|
{
|
||||||
if (((col_upr_left | col_upr_right | col_bot_right | col_bot_left) & IM_COL32_A_MASK) == 0)
|
if (((col_upr_left | col_upr_right | col_bot_right | col_bot_left) & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
@ -1015,87 +1048,150 @@ void ImDrawList::AddRectFilledMultiColor(const ImVec2& a, const ImVec2& c, ImU32
|
|||||||
PrimReserve(6, 4);
|
PrimReserve(6, 4);
|
||||||
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+1)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2));
|
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+1)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2));
|
||||||
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+3));
|
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+3));
|
||||||
PrimWriteVtx(a, uv, col_upr_left);
|
PrimWriteVtx(p_min, uv, col_upr_left);
|
||||||
PrimWriteVtx(ImVec2(c.x, a.y), uv, col_upr_right);
|
PrimWriteVtx(ImVec2(p_max.x, p_min.y), uv, col_upr_right);
|
||||||
PrimWriteVtx(c, uv, col_bot_right);
|
PrimWriteVtx(p_max, uv, col_bot_right);
|
||||||
PrimWriteVtx(ImVec2(a.x, c.y), uv, col_bot_left);
|
PrimWriteVtx(ImVec2(p_min.x, p_max.y), uv, col_bot_left);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddQuad(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col, float thickness)
|
void ImDrawList::AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PathLineTo(a);
|
PathLineTo(p1);
|
||||||
PathLineTo(b);
|
PathLineTo(p2);
|
||||||
PathLineTo(c);
|
PathLineTo(p3);
|
||||||
PathLineTo(d);
|
PathLineTo(p4);
|
||||||
PathStroke(col, true, thickness);
|
PathStroke(col, true, thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddQuadFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col)
|
void ImDrawList::AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PathLineTo(a);
|
PathLineTo(p1);
|
||||||
PathLineTo(b);
|
PathLineTo(p2);
|
||||||
PathLineTo(c);
|
PathLineTo(p3);
|
||||||
PathLineTo(d);
|
PathLineTo(p4);
|
||||||
PathFillConvex(col);
|
PathFillConvex(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddTriangle(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col, float thickness)
|
void ImDrawList::AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PathLineTo(a);
|
PathLineTo(p1);
|
||||||
PathLineTo(b);
|
PathLineTo(p2);
|
||||||
PathLineTo(c);
|
PathLineTo(p3);
|
||||||
PathStroke(col, true, thickness);
|
PathStroke(col, true, thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col)
|
void ImDrawList::AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PathLineTo(a);
|
PathLineTo(p1);
|
||||||
PathLineTo(b);
|
PathLineTo(p2);
|
||||||
PathLineTo(c);
|
PathLineTo(p3);
|
||||||
PathFillConvex(col);
|
PathFillConvex(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments, float thickness)
|
void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness)
|
||||||
|
{
|
||||||
|
if ((col & IM_COL32_A_MASK) == 0 || radius <= 0.0f)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Obtain segment count
|
||||||
|
if (num_segments <= 0)
|
||||||
|
{
|
||||||
|
// Automatic segment count
|
||||||
|
const int radius_idx = (int)radius - 1;
|
||||||
|
if (radius_idx < IM_ARRAYSIZE(_Data->CircleSegmentCounts))
|
||||||
|
num_segments = _Data->CircleSegmentCounts[radius_idx]; // Use cached value
|
||||||
|
else
|
||||||
|
num_segments = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, _Data->CircleSegmentMaxError);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Explicit segment count (still clamp to avoid drawing insanely tessellated shapes)
|
||||||
|
num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
||||||
|
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
|
||||||
|
if (num_segments == 12)
|
||||||
|
PathArcToFast(center, radius - 0.5f, 0, 12);
|
||||||
|
else
|
||||||
|
PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1);
|
||||||
|
PathStroke(col, true, thickness);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments)
|
||||||
|
{
|
||||||
|
if ((col & IM_COL32_A_MASK) == 0 || radius <= 0.0f)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Obtain segment count
|
||||||
|
if (num_segments <= 0)
|
||||||
|
{
|
||||||
|
// Automatic segment count
|
||||||
|
const int radius_idx = (int)radius - 1;
|
||||||
|
if (radius_idx < IM_ARRAYSIZE(_Data->CircleSegmentCounts))
|
||||||
|
num_segments = _Data->CircleSegmentCounts[radius_idx]; // Use cached value
|
||||||
|
else
|
||||||
|
num_segments = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, _Data->CircleSegmentMaxError);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Explicit segment count (still clamp to avoid drawing insanely tessellated shapes)
|
||||||
|
num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
||||||
|
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
|
||||||
|
if (num_segments == 12)
|
||||||
|
PathArcToFast(center, radius, 0, 12);
|
||||||
|
else
|
||||||
|
PathArcTo(center, radius, 0.0f, a_max, num_segments - 1);
|
||||||
|
PathFillConvex(col);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Guaranteed to honor 'num_segments'
|
||||||
|
void ImDrawList::AddNgon(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2)
|
if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
||||||
const float a_max = IM_PI*2.0f * ((float)num_segments - 1.0f) / (float)num_segments;
|
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
|
||||||
PathArcTo(centre, radius-0.5f, 0.0f, a_max, num_segments - 1);
|
PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1);
|
||||||
PathStroke(col, true, thickness);
|
PathStroke(col, true, thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments)
|
// Guaranteed to honor 'num_segments'
|
||||||
|
void ImDrawList::AddNgonFilled(const ImVec2& center, float radius, ImU32 col, int num_segments)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2)
|
if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
||||||
const float a_max = IM_PI*2.0f * ((float)num_segments - 1.0f) / (float)num_segments;
|
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
|
||||||
PathArcTo(centre, radius, 0.0f, a_max, num_segments - 1);
|
PathArcTo(center, radius, 0.0f, a_max, num_segments - 1);
|
||||||
PathFillConvex(col);
|
PathFillConvex(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments)
|
// Cubic Bezier takes 4 controls points
|
||||||
|
void ImDrawList::AddBezierCurve(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PathLineTo(pos0);
|
PathLineTo(p1);
|
||||||
PathBezierCurveTo(cp0, cp1, pos1, num_segments);
|
PathBezierCurveTo(p2, p3, p4, num_segments);
|
||||||
PathStroke(col, false, thickness);
|
PathStroke(col, false, thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1133,7 +1229,7 @@ void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, c
|
|||||||
AddText(NULL, 0.0f, pos, col, text_begin, text_end);
|
AddText(NULL, 0.0f, pos, col, text_begin, text_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col)
|
void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
@ -1143,13 +1239,13 @@ void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& a, const Im
|
|||||||
PushTextureID(user_texture_id);
|
PushTextureID(user_texture_id);
|
||||||
|
|
||||||
PrimReserve(6, 4);
|
PrimReserve(6, 4);
|
||||||
PrimRectUV(a, b, uv_a, uv_b, col);
|
PrimRectUV(p_min, p_max, uv_min, uv_max, col);
|
||||||
|
|
||||||
if (push_texture_id)
|
if (push_texture_id)
|
||||||
PopTextureID();
|
PopTextureID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col)
|
void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1, const ImVec2& uv2, const ImVec2& uv3, const ImVec2& uv4, ImU32 col)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
@ -1159,20 +1255,20 @@ void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& a, cons
|
|||||||
PushTextureID(user_texture_id);
|
PushTextureID(user_texture_id);
|
||||||
|
|
||||||
PrimReserve(6, 4);
|
PrimReserve(6, 4);
|
||||||
PrimQuadUV(a, b, c, d, uv_a, uv_b, uv_c, uv_d, col);
|
PrimQuadUV(p1, p2, p3, p4, uv1, uv2, uv3, uv4, col);
|
||||||
|
|
||||||
if (push_texture_id)
|
if (push_texture_id)
|
||||||
PopTextureID();
|
PopTextureID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col, float rounding, int rounding_corners)
|
void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (rounding <= 0.0f || (rounding_corners & ImDrawCornerFlags_All) == 0)
|
if (rounding <= 0.0f || (rounding_corners & ImDrawCornerFlags_All) == 0)
|
||||||
{
|
{
|
||||||
AddImage(user_texture_id, a, b, uv_a, uv_b, col);
|
AddImage(user_texture_id, p_min, p_max, uv_min, uv_max, col);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1181,10 +1277,10 @@ void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& a, c
|
|||||||
PushTextureID(user_texture_id);
|
PushTextureID(user_texture_id);
|
||||||
|
|
||||||
int vert_start_idx = VtxBuffer.Size;
|
int vert_start_idx = VtxBuffer.Size;
|
||||||
PathRect(a, b, rounding, rounding_corners);
|
PathRect(p_min, p_max, rounding, rounding_corners);
|
||||||
PathFillConvex(col);
|
PathFillConvex(col);
|
||||||
int vert_end_idx = VtxBuffer.Size;
|
int vert_end_idx = VtxBuffer.Size;
|
||||||
ImGui::ShadeVertsLinearUV(this, vert_start_idx, vert_end_idx, a, b, uv_a, uv_b, true);
|
ImGui::ShadeVertsLinearUV(this, vert_start_idx, vert_end_idx, p_min, p_max, uv_min, uv_max, true);
|
||||||
|
|
||||||
if (push_texture_id)
|
if (push_texture_id)
|
||||||
PopTextureID();
|
PopTextureID();
|
||||||
@ -1213,7 +1309,7 @@ void ImDrawListSplitter::ClearFreeMemory()
|
|||||||
|
|
||||||
void ImDrawListSplitter::Split(ImDrawList* draw_list, int channels_count)
|
void ImDrawListSplitter::Split(ImDrawList* draw_list, int channels_count)
|
||||||
{
|
{
|
||||||
IM_ASSERT(_Current == 0 && _Count <= 1);
|
IM_ASSERT(_Current == 0 && _Count <= 1 && "Nested channel splitting is not supported. Please use separate instances of ImDrawListSplitter.");
|
||||||
int old_channels_count = _Channels.Size;
|
int old_channels_count = _Channels.Size;
|
||||||
if (old_channels_count < channels_count)
|
if (old_channels_count < channels_count)
|
||||||
_Channels.resize(channels_count);
|
_Channels.resize(channels_count);
|
||||||
@ -1262,7 +1358,7 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list)
|
|||||||
// Calculate our final buffer sizes. Also fix the incorrect IdxOffset values in each command.
|
// Calculate our final buffer sizes. Also fix the incorrect IdxOffset values in each command.
|
||||||
int new_cmd_buffer_count = 0;
|
int new_cmd_buffer_count = 0;
|
||||||
int new_idx_buffer_count = 0;
|
int new_idx_buffer_count = 0;
|
||||||
ImDrawCmd* last_cmd = (_Count > 0 && _Channels[0]._CmdBuffer.Size > 0) ? &_Channels[0]._CmdBuffer.back() : NULL;
|
ImDrawCmd* last_cmd = (_Count > 0 && draw_list->CmdBuffer.Size > 0) ? &draw_list->CmdBuffer.back() : NULL;
|
||||||
int idx_offset = last_cmd ? last_cmd->IdxOffset + last_cmd->ElemCount : 0;
|
int idx_offset = last_cmd ? last_cmd->IdxOffset + last_cmd->ElemCount : 0;
|
||||||
for (int i = 1; i < _Count; i++)
|
for (int i = 1; i < _Count; i++)
|
||||||
{
|
{
|
||||||
@ -1274,7 +1370,7 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list)
|
|||||||
// Merge previous channel last draw command with current channel first draw command if matching.
|
// Merge previous channel last draw command with current channel first draw command if matching.
|
||||||
last_cmd->ElemCount += ch._CmdBuffer[0].ElemCount;
|
last_cmd->ElemCount += ch._CmdBuffer[0].ElemCount;
|
||||||
idx_offset += ch._CmdBuffer[0].ElemCount;
|
idx_offset += ch._CmdBuffer[0].ElemCount;
|
||||||
ch._CmdBuffer.erase(ch._CmdBuffer.Data);
|
ch._CmdBuffer.erase(ch._CmdBuffer.Data); // FIXME-OPT: Improve for multiple merges.
|
||||||
}
|
}
|
||||||
if (ch._CmdBuffer.Size > 0)
|
if (ch._CmdBuffer.Size > 0)
|
||||||
last_cmd = &ch._CmdBuffer.back();
|
last_cmd = &ch._CmdBuffer.back();
|
||||||
@ -1300,12 +1396,13 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list)
|
|||||||
}
|
}
|
||||||
draw_list->_IdxWritePtr = idx_write;
|
draw_list->_IdxWritePtr = idx_write;
|
||||||
draw_list->UpdateClipRect(); // We call this instead of AddDrawCmd(), so that empty channels won't produce an extra draw call.
|
draw_list->UpdateClipRect(); // We call this instead of AddDrawCmd(), so that empty channels won't produce an extra draw call.
|
||||||
|
draw_list->UpdateTextureID();
|
||||||
_Count = 1;
|
_Count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx)
|
void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx)
|
||||||
{
|
{
|
||||||
IM_ASSERT(idx < _Count);
|
IM_ASSERT(idx >= 0 && idx < _Count);
|
||||||
if (_Current == idx)
|
if (_Current == idx)
|
||||||
return;
|
return;
|
||||||
// Overwrite ImVector (12/16 bytes), four times. This is merely a silly optimization instead of doing .swap()
|
// Overwrite ImVector (12/16 bytes), four times. This is merely a silly optimization instead of doing .swap()
|
||||||
@ -1425,6 +1522,7 @@ ImFontConfig::ImFontConfig()
|
|||||||
MergeMode = false;
|
MergeMode = false;
|
||||||
RasterizerFlags = 0x00;
|
RasterizerFlags = 0x00;
|
||||||
RasterizerMultiply = 1.0f;
|
RasterizerMultiply = 1.0f;
|
||||||
|
EllipsisChar = (ImWchar)-1;
|
||||||
memset(Name, 0, sizeof(Name));
|
memset(Name, 0, sizeof(Name));
|
||||||
DstFont = NULL;
|
DstFont = NULL;
|
||||||
}
|
}
|
||||||
@ -1617,6 +1715,9 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg)
|
|||||||
memcpy(new_font_cfg.FontData, font_cfg->FontData, (size_t)new_font_cfg.FontDataSize);
|
memcpy(new_font_cfg.FontData, font_cfg->FontData, (size_t)new_font_cfg.FontDataSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (new_font_cfg.DstFont->EllipsisChar == (ImWchar)-1)
|
||||||
|
new_font_cfg.DstFont->EllipsisChar = font_cfg->EllipsisChar;
|
||||||
|
|
||||||
// Invalidate texture
|
// Invalidate texture
|
||||||
ClearTexData();
|
ClearTexData();
|
||||||
return new_font_cfg.DstFont;
|
return new_font_cfg.DstFont;
|
||||||
@ -1651,6 +1752,7 @@ ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
|
|||||||
font_cfg.SizePixels = 13.0f * 1.0f;
|
font_cfg.SizePixels = 13.0f * 1.0f;
|
||||||
if (font_cfg.Name[0] == '\0')
|
if (font_cfg.Name[0] == '\0')
|
||||||
ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "ProggyClean.ttf, %dpx", (int)font_cfg.SizePixels);
|
ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "ProggyClean.ttf, %dpx", (int)font_cfg.SizePixels);
|
||||||
|
font_cfg.EllipsisChar = (ImWchar)0x0085;
|
||||||
|
|
||||||
const char* ttf_compressed_base85 = GetDefaultCompressedFontDataTTFBase85();
|
const char* ttf_compressed_base85 = GetDefaultCompressedFontDataTTFBase85();
|
||||||
const ImWchar* glyph_ranges = font_cfg.GlyphRanges != NULL ? font_cfg.GlyphRanges : GetGlyphRangesDefault();
|
const ImWchar* glyph_ranges = font_cfg.GlyphRanges != NULL ? font_cfg.GlyphRanges : GetGlyphRangesDefault();
|
||||||
@ -1666,7 +1768,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
|
|||||||
void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0);
|
void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0);
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
IM_ASSERT(0); // Could not load file.
|
IM_ASSERT_USER_ERROR(0, "Could not load font file!");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
||||||
@ -1718,10 +1820,11 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed
|
|||||||
|
|
||||||
int ImFontAtlas::AddCustomRectRegular(unsigned int id, int width, int height)
|
int ImFontAtlas::AddCustomRectRegular(unsigned int id, int width, int height)
|
||||||
{
|
{
|
||||||
IM_ASSERT(id >= 0x10000);
|
// Breaking change on 2019/11/21 (1.74): ImFontAtlas::AddCustomRectRegular() now requires an ID >= 0x110000 (instead of >= 0x10000)
|
||||||
|
IM_ASSERT(id >= 0x110000);
|
||||||
IM_ASSERT(width > 0 && width <= 0xFFFF);
|
IM_ASSERT(width > 0 && width <= 0xFFFF);
|
||||||
IM_ASSERT(height > 0 && height <= 0xFFFF);
|
IM_ASSERT(height > 0 && height <= 0xFFFF);
|
||||||
CustomRect r;
|
ImFontAtlasCustomRect r;
|
||||||
r.ID = id;
|
r.ID = id;
|
||||||
r.Width = (unsigned short)width;
|
r.Width = (unsigned short)width;
|
||||||
r.Height = (unsigned short)height;
|
r.Height = (unsigned short)height;
|
||||||
@ -1734,7 +1837,7 @@ int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int
|
|||||||
IM_ASSERT(font != NULL);
|
IM_ASSERT(font != NULL);
|
||||||
IM_ASSERT(width > 0 && width <= 0xFFFF);
|
IM_ASSERT(width > 0 && width <= 0xFFFF);
|
||||||
IM_ASSERT(height > 0 && height <= 0xFFFF);
|
IM_ASSERT(height > 0 && height <= 0xFFFF);
|
||||||
CustomRect r;
|
ImFontAtlasCustomRect r;
|
||||||
r.ID = id;
|
r.ID = id;
|
||||||
r.Width = (unsigned short)width;
|
r.Width = (unsigned short)width;
|
||||||
r.Height = (unsigned short)height;
|
r.Height = (unsigned short)height;
|
||||||
@ -1745,7 +1848,7 @@ int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int
|
|||||||
return CustomRects.Size - 1; // Return index
|
return CustomRects.Size - 1; // Return index
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImFontAtlas::CalcCustomRectUV(const CustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max)
|
void ImFontAtlas::CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max) const
|
||||||
{
|
{
|
||||||
IM_ASSERT(TexWidth > 0 && TexHeight > 0); // Font atlas needs to be built before we can calculate UV coordinates
|
IM_ASSERT(TexWidth > 0 && TexHeight > 0); // Font atlas needs to be built before we can calculate UV coordinates
|
||||||
IM_ASSERT(rect->IsPacked()); // Make sure the rectangle has been packed
|
IM_ASSERT(rect->IsPacked()); // Make sure the rectangle has been packed
|
||||||
@ -1761,7 +1864,7 @@ bool ImFontAtlas::GetMouseCursorTexData(ImGuiMouseCursor cursor_type, ImVec2* ou
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
IM_ASSERT(CustomRectIds[0] != -1);
|
IM_ASSERT(CustomRectIds[0] != -1);
|
||||||
ImFontAtlas::CustomRect& r = CustomRects[CustomRectIds[0]];
|
ImFontAtlasCustomRect& r = CustomRects[CustomRectIds[0]];
|
||||||
IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID);
|
IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID);
|
||||||
ImVec2 pos = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][0] + ImVec2((float)r.X, (float)r.Y);
|
ImVec2 pos = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][0] + ImVec2((float)r.X, (float)r.Y);
|
||||||
ImVec2 size = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][1];
|
ImVec2 size = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][1];
|
||||||
@ -1898,7 +2001,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|||||||
dst_tmp.GlyphsSet.Resize(dst_tmp.GlyphsHighest + 1);
|
dst_tmp.GlyphsSet.Resize(dst_tmp.GlyphsHighest + 1);
|
||||||
|
|
||||||
for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2)
|
for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2)
|
||||||
for (int codepoint = src_range[0]; codepoint <= src_range[1]; codepoint++)
|
for (unsigned int codepoint = src_range[0]; codepoint <= src_range[1]; codepoint++)
|
||||||
{
|
{
|
||||||
if (dst_tmp.GlyphsSet.GetBit(codepoint)) // Don't overwrite existing glyphs. We could make this an option for MergeMode (e.g. MergeOverwrite==true)
|
if (dst_tmp.GlyphsSet.GetBit(codepoint)) // Don't overwrite existing glyphs. We could make this an option for MergeMode (e.g. MergeOverwrite==true)
|
||||||
continue;
|
continue;
|
||||||
@ -2062,7 +2165,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|||||||
const float descent = ImFloor(unscaled_descent * font_scale + ((unscaled_descent > 0.0f) ? +1 : -1));
|
const float descent = ImFloor(unscaled_descent * font_scale + ((unscaled_descent > 0.0f) ? +1 : -1));
|
||||||
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 + (float)(int)(dst_font->Ascent + 0.5f);
|
const float font_off_y = cfg.GlyphOffset.y + IM_ROUND(dst_font->Ascent);
|
||||||
|
|
||||||
for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++)
|
for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++)
|
||||||
{
|
{
|
||||||
@ -2073,7 +2176,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|||||||
const float char_advance_x_mod = ImClamp(char_advance_x_org, cfg.GlyphMinAdvanceX, cfg.GlyphMaxAdvanceX);
|
const float char_advance_x_mod = ImClamp(char_advance_x_org, cfg.GlyphMinAdvanceX, cfg.GlyphMaxAdvanceX);
|
||||||
float char_off_x = font_off_x;
|
float char_off_x = font_off_x;
|
||||||
if (char_advance_x_org != char_advance_x_mod)
|
if (char_advance_x_org != char_advance_x_mod)
|
||||||
char_off_x += cfg.PixelSnapH ? (float)(int)((char_advance_x_mod - char_advance_x_org) * 0.5f) : (char_advance_x_mod - char_advance_x_org) * 0.5f;
|
char_off_x += cfg.PixelSnapH ? ImFloor((char_advance_x_mod - char_advance_x_org) * 0.5f) : (char_advance_x_mod - char_advance_x_org) * 0.5f;
|
||||||
|
|
||||||
// Register glyph
|
// Register glyph
|
||||||
stbtt_aligned_quad q;
|
stbtt_aligned_quad q;
|
||||||
@ -2120,7 +2223,7 @@ void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opa
|
|||||||
stbrp_context* pack_context = (stbrp_context*)stbrp_context_opaque;
|
stbrp_context* pack_context = (stbrp_context*)stbrp_context_opaque;
|
||||||
IM_ASSERT(pack_context != NULL);
|
IM_ASSERT(pack_context != NULL);
|
||||||
|
|
||||||
ImVector<ImFontAtlas::CustomRect>& user_rects = atlas->CustomRects;
|
ImVector<ImFontAtlasCustomRect>& user_rects = atlas->CustomRects;
|
||||||
IM_ASSERT(user_rects.Size >= 1); // We expect at least the default custom rects to be registered, else something went wrong.
|
IM_ASSERT(user_rects.Size >= 1); // We expect at least the default custom rects to be registered, else something went wrong.
|
||||||
|
|
||||||
ImVector<stbrp_rect> pack_rects;
|
ImVector<stbrp_rect> pack_rects;
|
||||||
@ -2146,7 +2249,7 @@ static void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas)
|
|||||||
{
|
{
|
||||||
IM_ASSERT(atlas->CustomRectIds[0] >= 0);
|
IM_ASSERT(atlas->CustomRectIds[0] >= 0);
|
||||||
IM_ASSERT(atlas->TexPixelsAlpha8 != NULL);
|
IM_ASSERT(atlas->TexPixelsAlpha8 != NULL);
|
||||||
ImFontAtlas::CustomRect& r = atlas->CustomRects[atlas->CustomRectIds[0]];
|
ImFontAtlasCustomRect& r = atlas->CustomRects[atlas->CustomRectIds[0]];
|
||||||
IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID);
|
IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID);
|
||||||
IM_ASSERT(r.IsPacked());
|
IM_ASSERT(r.IsPacked());
|
||||||
|
|
||||||
@ -2181,8 +2284,8 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
|
|||||||
// Register custom rectangle glyphs
|
// Register custom rectangle glyphs
|
||||||
for (int i = 0; i < atlas->CustomRects.Size; i++)
|
for (int i = 0; i < atlas->CustomRects.Size; i++)
|
||||||
{
|
{
|
||||||
const ImFontAtlas::CustomRect& r = atlas->CustomRects[i];
|
const ImFontAtlasCustomRect& r = atlas->CustomRects[i];
|
||||||
if (r.Font == NULL || r.ID > 0x10000)
|
if (r.Font == NULL || r.ID >= 0x110000)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
IM_ASSERT(r.Font->ContainerAtlas == atlas);
|
IM_ASSERT(r.Font->ContainerAtlas == atlas);
|
||||||
@ -2195,6 +2298,23 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
|
|||||||
for (int i = 0; i < atlas->Fonts.Size; i++)
|
for (int i = 0; i < atlas->Fonts.Size; i++)
|
||||||
if (atlas->Fonts[i]->DirtyLookupTables)
|
if (atlas->Fonts[i]->DirtyLookupTables)
|
||||||
atlas->Fonts[i]->BuildLookupTable();
|
atlas->Fonts[i]->BuildLookupTable();
|
||||||
|
|
||||||
|
// Ellipsis character is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis).
|
||||||
|
// However some old fonts may contain ellipsis at U+0085. Here we auto-detect most suitable ellipsis character.
|
||||||
|
// FIXME: Also note that 0x2026 is currently seldomly included in our font ranges. Because of this we are more likely to use three individual dots.
|
||||||
|
for (int i = 0; i < atlas->Fonts.size(); i++)
|
||||||
|
{
|
||||||
|
ImFont* font = atlas->Fonts[i];
|
||||||
|
if (font->EllipsisChar != (ImWchar)-1)
|
||||||
|
continue;
|
||||||
|
const ImWchar ellipsis_variants[] = { (ImWchar)0x2026, (ImWchar)0x0085 };
|
||||||
|
for (int j = 0; j < IM_ARRAYSIZE(ellipsis_variants); j++)
|
||||||
|
if (font->FindGlyphNoFallback(ellipsis_variants[j]) != NULL) // Verify glyph exists
|
||||||
|
{
|
||||||
|
font->EllipsisChar = ellipsis_variants[j];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve list of range (2 int per range, values are inclusive)
|
// Retrieve list of range (2 int per range, values are inclusive)
|
||||||
@ -2429,7 +2549,7 @@ void ImFontGlyphRangesBuilder::AddText(const char* text, const char* text_end)
|
|||||||
text += c_len;
|
text += c_len;
|
||||||
if (c_len == 0)
|
if (c_len == 0)
|
||||||
break;
|
break;
|
||||||
if (c < 0x10000)
|
if (c <= IM_UNICODE_CODEPOINT_MAX)
|
||||||
AddChar((ImWchar)c);
|
AddChar((ImWchar)c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2443,12 +2563,12 @@ void ImFontGlyphRangesBuilder::AddRanges(const ImWchar* ranges)
|
|||||||
|
|
||||||
void ImFontGlyphRangesBuilder::BuildRanges(ImVector<ImWchar>* out_ranges)
|
void ImFontGlyphRangesBuilder::BuildRanges(ImVector<ImWchar>* out_ranges)
|
||||||
{
|
{
|
||||||
int max_codepoint = 0x10000;
|
const int max_codepoint = IM_UNICODE_CODEPOINT_MAX;
|
||||||
for (int n = 0; n < max_codepoint; n++)
|
for (int n = 0; n <= max_codepoint; n++)
|
||||||
if (GetBit(n))
|
if (GetBit(n))
|
||||||
{
|
{
|
||||||
out_ranges->push_back((ImWchar)n);
|
out_ranges->push_back((ImWchar)n);
|
||||||
while (n < max_codepoint - 1 && GetBit(n + 1))
|
while (n < max_codepoint && GetBit(n + 1))
|
||||||
n++;
|
n++;
|
||||||
out_ranges->push_back((ImWchar)n);
|
out_ranges->push_back((ImWchar)n);
|
||||||
}
|
}
|
||||||
@ -2464,6 +2584,7 @@ ImFont::ImFont()
|
|||||||
FontSize = 0.0f;
|
FontSize = 0.0f;
|
||||||
FallbackAdvanceX = 0.0f;
|
FallbackAdvanceX = 0.0f;
|
||||||
FallbackChar = (ImWchar)'?';
|
FallbackChar = (ImWchar)'?';
|
||||||
|
EllipsisChar = (ImWchar)-1;
|
||||||
DisplayOffset = ImVec2(0.0f, 0.0f);
|
DisplayOffset = ImVec2(0.0f, 0.0f);
|
||||||
FallbackGlyph = NULL;
|
FallbackGlyph = NULL;
|
||||||
ContainerAtlas = NULL;
|
ContainerAtlas = NULL;
|
||||||
@ -2566,7 +2687,7 @@ void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1,
|
|||||||
glyph.AdvanceX = advance_x + ConfigData->GlyphExtraSpacing.x; // Bake spacing into AdvanceX
|
glyph.AdvanceX = advance_x + ConfigData->GlyphExtraSpacing.x; // Bake spacing into AdvanceX
|
||||||
|
|
||||||
if (ConfigData->PixelSnapH)
|
if (ConfigData->PixelSnapH)
|
||||||
glyph.AdvanceX = (float)(int)(glyph.AdvanceX + 0.5f);
|
glyph.AdvanceX = IM_ROUND(glyph.AdvanceX);
|
||||||
|
|
||||||
// Compute rough surface usage metrics (+1 to account for average padding, +0.99 to round)
|
// Compute rough surface usage metrics (+1 to account for average padding, +0.99 to round)
|
||||||
DirtyLookupTables = true;
|
DirtyLookupTables = true;
|
||||||
@ -2576,7 +2697,7 @@ void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1,
|
|||||||
void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
|
void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
|
||||||
{
|
{
|
||||||
IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function.
|
IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function.
|
||||||
int index_size = IndexLookup.Size;
|
unsigned int index_size = (unsigned int)IndexLookup.Size;
|
||||||
|
|
||||||
if (dst < index_size && IndexLookup.Data[dst] == (ImWchar)-1 && !overwrite_dst) // 'dst' already exists
|
if (dst < index_size && IndexLookup.Data[dst] == (ImWchar)-1 && !overwrite_dst) // 'dst' already exists
|
||||||
return;
|
return;
|
||||||
@ -2693,7 +2814,7 @@ const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We ignore blank width at the end of the line (they can be skipped)
|
// We ignore blank width at the end of the line (they can be skipped)
|
||||||
if (line_width + word_width >= wrap_width)
|
if (line_width + word_width > wrap_width)
|
||||||
{
|
{
|
||||||
// Words that cannot possibly fit within an entire line will be cut anywhere.
|
// Words that cannot possibly fit within an entire line will be cut anywhere.
|
||||||
if (word_width < wrap_width)
|
if (word_width < wrap_width)
|
||||||
@ -2808,8 +2929,8 @@ void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
|||||||
if (const ImFontGlyph* glyph = FindGlyph(c))
|
if (const ImFontGlyph* glyph = FindGlyph(c))
|
||||||
{
|
{
|
||||||
float scale = (size >= 0.0f) ? (size / FontSize) : 1.0f;
|
float scale = (size >= 0.0f) ? (size / FontSize) : 1.0f;
|
||||||
pos.x = (float)(int)pos.x + DisplayOffset.x;
|
pos.x = IM_FLOOR(pos.x + DisplayOffset.x);
|
||||||
pos.y = (float)(int)pos.y + DisplayOffset.y;
|
pos.y = IM_FLOOR(pos.y + DisplayOffset.y);
|
||||||
draw_list->PrimReserve(6, 4);
|
draw_list->PrimReserve(6, 4);
|
||||||
draw_list->PrimRectUV(ImVec2(pos.x + glyph->X0 * scale, pos.y + glyph->Y0 * scale), ImVec2(pos.x + glyph->X1 * scale, pos.y + glyph->Y1 * scale), ImVec2(glyph->U0, glyph->V0), ImVec2(glyph->U1, glyph->V1), col);
|
draw_list->PrimRectUV(ImVec2(pos.x + glyph->X0 * scale, pos.y + glyph->Y0 * scale), ImVec2(pos.x + glyph->X1 * scale, pos.y + glyph->Y1 * scale), ImVec2(glyph->U0, glyph->V0), ImVec2(glyph->U1, glyph->V1), col);
|
||||||
}
|
}
|
||||||
@ -2821,8 +2942,8 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
|||||||
text_end = text_begin + strlen(text_begin); // ImGui:: functions generally already provides a valid text_end, so this is merely to handle direct calls.
|
text_end = text_begin + strlen(text_begin); // ImGui:: functions generally already provides a valid text_end, so this is merely to handle direct calls.
|
||||||
|
|
||||||
// Align to be pixel perfect
|
// Align to be pixel perfect
|
||||||
pos.x = (float)(int)pos.x + DisplayOffset.x;
|
pos.x = IM_FLOOR(pos.x + DisplayOffset.x);
|
||||||
pos.y = (float)(int)pos.y + DisplayOffset.y;
|
pos.y = IM_FLOOR(pos.y + DisplayOffset.y);
|
||||||
float x = pos.x;
|
float x = pos.x;
|
||||||
float y = pos.y;
|
float y = pos.y;
|
||||||
if (y > clip_rect.w)
|
if (y > clip_rect.w)
|
||||||
@ -2995,9 +3116,9 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
|||||||
x += char_width;
|
x += char_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give back unused vertices
|
// Give back unused vertices (clipped ones, blanks) ~ this is essentially a PrimUnreserve() action.
|
||||||
draw_list->VtxBuffer.resize((int)(vtx_write - draw_list->VtxBuffer.Data));
|
draw_list->VtxBuffer.Size = (int)(vtx_write - draw_list->VtxBuffer.Data); // Same as calling shrink()
|
||||||
draw_list->IdxBuffer.resize((int)(idx_write - draw_list->IdxBuffer.Data));
|
draw_list->IdxBuffer.Size = (int)(idx_write - draw_list->IdxBuffer.Data);
|
||||||
draw_list->CmdBuffer[draw_list->CmdBuffer.Size-1].ElemCount -= (idx_expected_size - draw_list->IdxBuffer.Size);
|
draw_list->CmdBuffer[draw_list->CmdBuffer.Size-1].ElemCount -= (idx_expected_size - draw_list->IdxBuffer.Size);
|
||||||
draw_list->_VtxWritePtr = vtx_write;
|
draw_list->_VtxWritePtr = vtx_write;
|
||||||
draw_list->_IdxWritePtr = idx_write;
|
draw_list->_IdxWritePtr = idx_write;
|
||||||
@ -3011,19 +3132,14 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
|||||||
// - RenderMouseCursor()
|
// - RenderMouseCursor()
|
||||||
// - RenderArrowPointingAt()
|
// - RenderArrowPointingAt()
|
||||||
// - RenderRectFilledRangeH()
|
// - RenderRectFilledRangeH()
|
||||||
// - RenderPixelEllipsis()
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor)
|
void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow)
|
||||||
{
|
{
|
||||||
if (mouse_cursor == ImGuiMouseCursor_None)
|
if (mouse_cursor == ImGuiMouseCursor_None)
|
||||||
return;
|
return;
|
||||||
IM_ASSERT(mouse_cursor > ImGuiMouseCursor_None && mouse_cursor < ImGuiMouseCursor_COUNT);
|
IM_ASSERT(mouse_cursor > ImGuiMouseCursor_None && mouse_cursor < ImGuiMouseCursor_COUNT);
|
||||||
|
|
||||||
const ImU32 col_shadow = IM_COL32(0, 0, 0, 48);
|
|
||||||
const ImU32 col_border = IM_COL32(0, 0, 0, 255); // Black
|
|
||||||
const ImU32 col_fill = IM_COL32(255, 255, 255, 255); // White
|
|
||||||
|
|
||||||
ImFontAtlas* font_atlas = draw_list->_Data->Font->ContainerAtlas;
|
ImFontAtlas* font_atlas = draw_list->_Data->Font->ContainerAtlas;
|
||||||
ImVec2 offset, size, uv[4];
|
ImVec2 offset, size, uv[4];
|
||||||
if (font_atlas->GetMouseCursorTexData(mouse_cursor, &offset, &size, &uv[0], &uv[2]))
|
if (font_atlas->GetMouseCursorTexData(mouse_cursor, &offset, &size, &uv[0], &uv[2]))
|
||||||
@ -3121,18 +3237,6 @@ void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, Im
|
|||||||
draw_list->PathFillConvex(col);
|
draw_list->PathFillConvex(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Rendering an ellipsis "..." is a surprisingly tricky problem for us... we cannot rely on font glyph having it,
|
|
||||||
// and regular dot are typically too wide. If we render a dot/shape ourselves it comes with the risk that it wouldn't match
|
|
||||||
// the boldness or positioning of what the font uses...
|
|
||||||
void ImGui::RenderPixelEllipsis(ImDrawList* draw_list, ImVec2 pos, ImU32 col, int count)
|
|
||||||
{
|
|
||||||
ImFont* font = draw_list->_Data->Font;
|
|
||||||
const float font_scale = draw_list->_Data->FontSize / font->FontSize;
|
|
||||||
pos.y += (float)(int)(font->DisplayOffset.y + font->Ascent * font_scale + 0.5f - 1.0f);
|
|
||||||
for (int dot_n = 0; dot_n < count; dot_n++)
|
|
||||||
draw_list->AddRectFilled(ImVec2(pos.x + dot_n * 2.0f, pos.y), ImVec2(pos.x + dot_n * 2.0f + 1.0f, pos.y + 1.0f), col);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Decompression code
|
// [SECTION] Decompression code
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -3193,9 +3297,9 @@ static unsigned int stb_adler32(unsigned int adler32, unsigned char *buffer, uns
|
|||||||
{
|
{
|
||||||
const unsigned long ADLER_MOD = 65521;
|
const unsigned long ADLER_MOD = 65521;
|
||||||
unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16;
|
unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16;
|
||||||
unsigned long blocklen, i;
|
unsigned long blocklen = buflen % 5552;
|
||||||
|
|
||||||
blocklen = buflen % 5552;
|
unsigned long i;
|
||||||
while (buflen) {
|
while (buflen) {
|
||||||
for (i=0; i + 7 < blocklen; i += 8) {
|
for (i=0; i + 7 < blocklen; i += 8) {
|
||||||
s1 += buffer[0], s2 += s1;
|
s1 += buffer[0], s2 += s1;
|
||||||
@ -3222,10 +3326,9 @@ static unsigned int stb_adler32(unsigned int adler32, unsigned char *buffer, uns
|
|||||||
|
|
||||||
static unsigned int stb_decompress(unsigned char *output, const unsigned char *i, unsigned int /*length*/)
|
static unsigned int stb_decompress(unsigned char *output, const unsigned char *i, unsigned int /*length*/)
|
||||||
{
|
{
|
||||||
unsigned int olen;
|
|
||||||
if (stb__in4(0) != 0x57bC0000) return 0;
|
if (stb__in4(0) != 0x57bC0000) return 0;
|
||||||
if (stb__in4(4) != 0) return 0; // error! stream is > 4GB
|
if (stb__in4(4) != 0) return 0; // error! stream is > 4GB
|
||||||
olen = stb_decompress_length(i);
|
const unsigned int olen = stb_decompress_length(i);
|
||||||
stb__barrier_in_b = i;
|
stb__barrier_in_b = i;
|
||||||
stb__barrier_out_e = output + olen;
|
stb__barrier_out_e = output + olen;
|
||||||
stb__barrier_out_b = output;
|
stb__barrier_out_b = output;
|
||||||
@ -3357,3 +3460,5 @@ static const char* GetDefaultCompressedFontDataTTFBase85()
|
|||||||
{
|
{
|
||||||
return proggy_clean_ttf_compressed_data_base85;
|
return proggy_clean_ttf_compressed_data_base85;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
779
imgui_internal.h
779
imgui_internal.h
File diff suppressed because it is too large
Load Diff
1452
imgui_widgets.cpp
1452
imgui_widgets.cpp
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,10 @@
|
|||||||
// [DEAR IMGUI]
|
// [DEAR IMGUI]
|
||||||
// This is a slightly modified version of stb_rect_pack.h 0.99.
|
// This is a slightly modified version of stb_rect_pack.h 1.00.
|
||||||
// Those changes would need to be pushed into nothings/stb:
|
// Those changes would need to be pushed into nothings/stb:
|
||||||
// - Added STBRP__CDECL
|
// - Added STBRP__CDECL
|
||||||
// Grep for [DEAR IMGUI] to find the changes.
|
// Grep for [DEAR IMGUI] to find the changes.
|
||||||
|
|
||||||
// stb_rect_pack.h - v0.99 - public domain - rectangle packing
|
// stb_rect_pack.h - v1.00 - public domain - rectangle packing
|
||||||
// Sean Barrett 2014
|
// Sean Barrett 2014
|
||||||
//
|
//
|
||||||
// Useful for e.g. packing rectangular textures into an atlas.
|
// Useful for e.g. packing rectangular textures into an atlas.
|
||||||
@ -37,9 +37,11 @@
|
|||||||
//
|
//
|
||||||
// Bugfixes / warning fixes
|
// Bugfixes / warning fixes
|
||||||
// Jeremy Jaussaud
|
// Jeremy Jaussaud
|
||||||
|
// Fabian Giesen
|
||||||
//
|
//
|
||||||
// Version history:
|
// Version history:
|
||||||
//
|
//
|
||||||
|
// 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles
|
||||||
// 0.99 (2019-02-07) warning fixes
|
// 0.99 (2019-02-07) warning fixes
|
||||||
// 0.11 (2017-03-03) return packing success/fail result
|
// 0.11 (2017-03-03) return packing success/fail result
|
||||||
// 0.10 (2016-10-25) remove cast-away-const to avoid warnings
|
// 0.10 (2016-10-25) remove cast-away-const to avoid warnings
|
||||||
@ -357,6 +359,13 @@ static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int widt
|
|||||||
width -= width % c->align;
|
width -= width % c->align;
|
||||||
STBRP_ASSERT(width % c->align == 0);
|
STBRP_ASSERT(width % c->align == 0);
|
||||||
|
|
||||||
|
// if it can't possibly fit, bail immediately
|
||||||
|
if (width > c->width || height > c->height) {
|
||||||
|
fr.prev_link = NULL;
|
||||||
|
fr.x = fr.y = 0;
|
||||||
|
return fr;
|
||||||
|
}
|
||||||
|
|
||||||
node = c->active_head;
|
node = c->active_head;
|
||||||
prev = &c->active_head;
|
prev = &c->active_head;
|
||||||
while (node->x + width <= c->width) {
|
while (node->x + width <= c->width) {
|
||||||
@ -420,7 +429,7 @@ static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int widt
|
|||||||
}
|
}
|
||||||
STBRP_ASSERT(node->next->x > xpos && node->x <= xpos);
|
STBRP_ASSERT(node->next->x > xpos && node->x <= xpos);
|
||||||
y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste);
|
y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste);
|
||||||
if (y + height < c->height) {
|
if (y + height <= c->height) {
|
||||||
if (y <= best_y) {
|
if (y <= best_y) {
|
||||||
if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
|
if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
|
||||||
best_x = xpos;
|
best_x = xpos;
|
||||||
|
@ -16,3 +16,9 @@ misc/natvis/
|
|||||||
Natvis file to describe dear imgui types in the Visual Studio debugger.
|
Natvis file to describe dear imgui types in the Visual Studio debugger.
|
||||||
With this, types like ImVector<> will be displayed nicely in the debugger.
|
With this, types like ImVector<> will be displayed nicely in the debugger.
|
||||||
You can include this file a Visual Studio project file, or install it in Visual Studio folder.
|
You can include this file a Visual Studio project file, or install it in Visual Studio folder.
|
||||||
|
|
||||||
|
misc/single_file/
|
||||||
|
Single-file header stub.
|
||||||
|
We use this to validate compiling all *.cpp files in a same compilation unit.
|
||||||
|
Users of that technique (also called "Unity builds") can generally provide this themselves,
|
||||||
|
so we don't really recommend you use this in your projects.
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
// ImGui - binary_to_compressed_c.cpp
|
// dear imgui
|
||||||
|
// (binary_to_compressed_c.cpp)
|
||||||
// Helper tool to turn a file into a C array, if you want to embed font data in your source code.
|
// Helper tool to turn a file into a C array, if you want to embed font data in your source code.
|
||||||
|
|
||||||
// The data is first compressed with stb_compress() to reduce source code size,
|
// The data is first compressed with stb_compress() to reduce source code size,
|
||||||
// then encoded in Base85 to fit in a string so we can fit roughly 4 bytes of compressed data into 5 bytes of source code (suggested by @mmalex)
|
// then encoded in Base85 to fit in a string so we can fit roughly 4 bytes of compressed data into 5 bytes of source code (suggested by @mmalex)
|
||||||
// (If we used 32-bits constants it would require take 11 bytes of source code to encode 4 bytes, and be endianness dependent)
|
// (If we used 32-bit constants it would require take 11 bytes of source code to encode 4 bytes, and be endianness dependent)
|
||||||
// Note that even with compression, the output array is likely to be bigger than the binary file..
|
// Note that even with compression, the output array is likely to be bigger than the binary file..
|
||||||
// Load compressed TTF fonts with ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF()
|
// Load compressed TTF fonts with ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF()
|
||||||
|
|
||||||
@ -48,12 +49,15 @@ int main(int argc, char** argv)
|
|||||||
else if (strcmp(argv[argn], "-nocompress") == 0) { use_compression = false; argn++; }
|
else if (strcmp(argv[argn], "-nocompress") == 0) { use_compression = false; argn++; }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Unknown argument: '%s'\n", argv[argn]);
|
fprintf(stderr, "Unknown argument: '%s'\n", argv[argn]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return binary_to_compressed_c(argv[argn], argv[argn+1], use_base85_encoding, use_compression) ? 0 : 1;
|
bool ret = binary_to_compressed_c(argv[argn], argv[argn+1], use_base85_encoding, use_compression);
|
||||||
|
if (!ret)
|
||||||
|
fprintf(stderr, "Error opening or reading file: '%s'\n", argv[argn]);
|
||||||
|
return ret ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char Encode85Byte(unsigned int x)
|
char Encode85Byte(unsigned int x)
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
|
#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
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -544,7 +545,7 @@ bool ImFontAtlasBuildWithFreeType(FT_Library ft_library, ImFontAtlas* atlas, uns
|
|||||||
const float descent = src_tmp.Font.Info.Descender;
|
const float descent = src_tmp.Font.Info.Descender;
|
||||||
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 + (float)(int)(dst_font->Ascent + 0.5f);
|
const float font_off_y = cfg.GlyphOffset.y + IM_ROUND(dst_font->Ascent);
|
||||||
|
|
||||||
const int padding = atlas->TexGlyphPadding;
|
const int padding = atlas->TexGlyphPadding;
|
||||||
for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++)
|
for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++)
|
||||||
@ -571,7 +572,7 @@ bool ImFontAtlasBuildWithFreeType(FT_Library ft_library, ImFontAtlas* atlas, uns
|
|||||||
float char_advance_x_mod = ImClamp(char_advance_x_org, cfg.GlyphMinAdvanceX, cfg.GlyphMaxAdvanceX);
|
float char_advance_x_mod = ImClamp(char_advance_x_org, cfg.GlyphMinAdvanceX, cfg.GlyphMaxAdvanceX);
|
||||||
float char_off_x = font_off_x;
|
float char_off_x = font_off_x;
|
||||||
if (char_advance_x_org != char_advance_x_mod)
|
if (char_advance_x_org != char_advance_x_mod)
|
||||||
char_off_x += cfg.PixelSnapH ? (float)(int)((char_advance_x_mod - char_advance_x_org) * 0.5f) : (char_advance_x_mod - char_advance_x_org) * 0.5f;
|
char_off_x += cfg.PixelSnapH ? IM_FLOOR((char_advance_x_mod - char_advance_x_org) * 0.5f) : (char_advance_x_mod - char_advance_x_org) * 0.5f;
|
||||||
|
|
||||||
// Register glyph
|
// Register glyph
|
||||||
float x0 = info.OffsetX + char_off_x;
|
float x0 = info.OffsetX + char_off_x;
|
||||||
@ -645,7 +646,8 @@ static void* FreeType_Realloc(FT_Memory /*memory*/, long cur_size, long new_size
|
|||||||
bool ImGuiFreeType::BuildFontAtlas(ImFontAtlas* atlas, unsigned int extra_flags)
|
bool ImGuiFreeType::BuildFontAtlas(ImFontAtlas* atlas, unsigned int extra_flags)
|
||||||
{
|
{
|
||||||
// FreeType memory management: https://www.freetype.org/freetype2/docs/design/design-4.html
|
// FreeType memory management: https://www.freetype.org/freetype2/docs/design/design-4.html
|
||||||
FT_MemoryRec_ memory_rec = { 0 };
|
FT_MemoryRec_ memory_rec = {};
|
||||||
|
memory_rec.user = NULL;
|
||||||
memory_rec.alloc = &FreeType_Alloc;
|
memory_rec.alloc = &FreeType_Alloc;
|
||||||
memory_rec.free = &FreeType_Free;
|
memory_rec.free = &FreeType_Free;
|
||||||
memory_rec.realloc = &FreeType_Realloc;
|
memory_rec.realloc = &FreeType_Realloc;
|
||||||
|
17
misc/single_file/imgui_single_file.h
Normal file
17
misc/single_file/imgui_single_file.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// imgui_single_file.h
|
||||||
|
// We use this to validate compiling all *.cpp files in a same compilation unit.
|
||||||
|
// Users of that technique (also called "Unity builds") can generally provide this themselves,
|
||||||
|
// so we don't really recommend you use this in your projects.
|
||||||
|
|
||||||
|
// Do this:
|
||||||
|
// #define IMGUI_IMPLEMENTATION
|
||||||
|
// Before you include this file in *one* C++ file to create the implementation.
|
||||||
|
// Using this in your project will leak the contents of imgui_internal.h and ImVec2 operators in this compilation unit.
|
||||||
|
#include "../../imgui.h"
|
||||||
|
|
||||||
|
#ifdef IMGUI_IMPLEMENTATION
|
||||||
|
#include "../../imgui.cpp"
|
||||||
|
#include "../../imgui_demo.cpp"
|
||||||
|
#include "../../imgui_draw.cpp"
|
||||||
|
#include "../../imgui_widgets.cpp"
|
||||||
|
#endif
|
Reference in New Issue
Block a user