mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-13 08:19:55 +02:00
Compare commits
560 Commits
Author | SHA1 | Date | |
---|---|---|---|
e916310b2e | |||
3d48f5b8c2 | |||
3849bb4470 | |||
78f48bb795 | |||
8d54b1b7af | |||
3a4a2bb27c | |||
ce13426a1a | |||
1b86e7343f | |||
cead207535 | |||
bb8dfe4a34 | |||
e9ceef4762 | |||
d976e4ea23 | |||
9cda86d55a | |||
a5739a0aa3 | |||
983d8f5f8e | |||
53b24ff79a | |||
69879dd4f3 | |||
8e8b5498f7 | |||
6172e93272 | |||
b263bc5689 | |||
1f26652944 | |||
cf9b893841 | |||
46dcd9aa50 | |||
471bcf8b5e | |||
e1a103b251 | |||
8d21ee56d2 | |||
c8c872c753 | |||
996dfb21cf | |||
d139bd088d | |||
14cb8177d0 | |||
531c11d5c7 | |||
230f826ef5 | |||
6193f46af2 | |||
b366dd9322 | |||
7fed4eb82d | |||
55c0d2b9ab | |||
abaf347deb | |||
b1d90b565d | |||
b9391d1692 | |||
0c6e260f73 | |||
6effcf21d6 | |||
51433e26af | |||
eefea0588a | |||
ac8e708c3e | |||
07ed9f8451 | |||
fa68cb5364 | |||
45bca7851d | |||
5f39758202 | |||
f265e16b84 | |||
3905816082 | |||
ddbcda8c1b | |||
ba71e1c0e4 | |||
f7c5f420e7 | |||
e8e84a6ad6 | |||
4ae5c7e227 | |||
b016215c80 | |||
3a31a75e3b | |||
78320aa633 | |||
027ffd91ea | |||
8b59ed0708 | |||
90788a1242 | |||
7c7a7baf76 | |||
b174fcc9af | |||
d0a1be0de0 | |||
ab049c6fc0 | |||
7faa5b16bb | |||
02e0a078f4 | |||
28bbf1ade6 | |||
d561a43a4d | |||
ef1a683ebe | |||
e98df91dc4 | |||
7ec934f439 | |||
052b6021dd | |||
6190ab0084 | |||
c22657985a | |||
ee7f1921e8 | |||
08b72eb5c0 | |||
8d8f4934fb | |||
fa179d0ad8 | |||
de4a851f95 | |||
c65124f415 | |||
f42d7b89e2 | |||
4a555d35f0 | |||
185c1eaaf3 | |||
f93945540f | |||
45f440bb7d | |||
6b168b43ff | |||
2b9d8ab91d | |||
f06f68f3ce | |||
9fd15defe4 | |||
6d93011fdf | |||
e67f3809ed | |||
71296910a0 | |||
4b8857d536 | |||
1096e14356 | |||
e3e0326ea9 | |||
080f61858f | |||
eab6333a0b | |||
7ac1583411 | |||
a9b01600ac | |||
20ba79aa56 | |||
b75acc21b0 | |||
0872020c5c | |||
f72b002da8 | |||
e23083a080 | |||
0365c524a2 | |||
a8c7b1a2a2 | |||
c9f0275e22 | |||
457011660e | |||
a263dce2f2 | |||
7ac5f11b29 | |||
befc58771c | |||
e998c7d3e3 | |||
a5e9392140 | |||
d9d231dc6b | |||
74f42baf3e | |||
541dfd7901 | |||
9872297a84 | |||
a4863e8084 | |||
7bf85db6c4 | |||
e118239f69 | |||
ca0bb000ad | |||
f658edc72a | |||
45466a8cf9 | |||
97edd42fc0 | |||
7f2b9ea4c0 | |||
8dcc1a8a20 | |||
e045eddd77 | |||
92f7bd3605 | |||
cc2c023880 | |||
3c9f9a455e | |||
8959c64b33 | |||
abe5ad3c7a | |||
94bf12f14b | |||
20c7aab60c | |||
8f41508c52 | |||
beda5fc5a0 | |||
ecacaf7f2d | |||
3b7e4eaf38 | |||
531e559e49 | |||
e103fe8c1f | |||
90ae1c59c4 | |||
fe2cf231a8 | |||
77d1a4b636 | |||
16d9fa30b2 | |||
5f7cd7fb1c | |||
be6384eb2a | |||
c860a0a85c | |||
aea3fe41b9 | |||
6ea744d8f4 | |||
0d53c8d480 | |||
b513fdce48 | |||
c36e586cce | |||
a20fe279c5 | |||
25c159fac8 | |||
52e475230f | |||
2e1013a0c6 | |||
7ae71e4984 | |||
35eb5c5c99 | |||
963259d128 | |||
63712d5f5c | |||
4a43632163 | |||
1a8a7c9d17 | |||
c8b5b569da | |||
e5ebe42207 | |||
4c4f1b0224 | |||
f3ec608c19 | |||
e000ee0116 | |||
7e2d0d734c | |||
d552cabd15 | |||
ade09b9e3c | |||
532f564fd3 | |||
0f955b818d | |||
d9c5d72962 | |||
ef5dd30625 | |||
6bd3b45b34 | |||
7763ab3fcc | |||
06a32a2b00 | |||
1b2ec35b8d | |||
aafa6cece5 | |||
3141df1459 | |||
21b456e567 | |||
176d8fbe74 | |||
302757447a | |||
195abc3d17 | |||
3f5b2a3fe3 | |||
31683cfe34 | |||
3c5e64db78 | |||
7f447c8270 | |||
ba095f81a5 | |||
8c0f2e4946 | |||
e996286c38 | |||
79f07f6ff0 | |||
8b2d449b16 | |||
dc2768503f | |||
92212b17aa | |||
28a31997b7 | |||
abbf836fd0 | |||
c433bc971f | |||
f7fe824805 | |||
39137ccc3e | |||
022f8c2342 | |||
9886b09a0a | |||
e605f21797 | |||
9a44d447cd | |||
538a704143 | |||
9289e8055c | |||
4cdd998be8 | |||
4022ada843 | |||
4daf377c9b | |||
8a7f03cbf9 | |||
d7af1a218e | |||
067605052d | |||
6f7b1bf2e1 | |||
0e4f1df1a4 | |||
0a61b7195c | |||
e7e81b265d | |||
58345b11e1 | |||
1c41603b31 | |||
c1b5eab868 | |||
331eac511e | |||
29e0078b66 | |||
bd4bc929ce | |||
4e62118b61 | |||
979fe30a6f | |||
da2be7bbdc | |||
f5871c0b92 | |||
834fa52c8e | |||
7746dd104c | |||
29d962069d | |||
4ad414c8d4 | |||
7c4be0a000 | |||
e9a7e73bba | |||
f36037b384 | |||
9b82d9fbef | |||
f5bdf443c9 | |||
5ea6e80da1 | |||
5027311e7f | |||
44b761b308 | |||
27fd1b913b | |||
ae060b1d67 | |||
64e79035d5 | |||
6001d9c7a4 | |||
0858c3d7cb | |||
ffad688fc8 | |||
852ece3a0e | |||
3e06450d27 | |||
7908cce25f | |||
4d00dd8326 | |||
30bf40195b | |||
669498ff26 | |||
a1c736fa6a | |||
631bd8a9f8 | |||
161670418b | |||
9daac64ff8 | |||
ba09de3a39 | |||
8451855a30 | |||
4b94738c7e | |||
b1653cd361 | |||
2df8fa95df | |||
a4cc3d4637 | |||
9ac8820ee2 | |||
b6504b8eee | |||
2ab27be3de | |||
41862b8c0e | |||
aae52522c3 | |||
1870738880 | |||
571b08f315 | |||
8e6adc78af | |||
2c7ba21417 | |||
f0b4097c54 | |||
de1e7dc088 | |||
8b725c94cb | |||
16a5da9521 | |||
553bdeedf7 | |||
3461a2f296 | |||
982ce50b37 | |||
ff4d4ca651 | |||
803ac3a5c6 | |||
1e7cc23867 | |||
2a3a25e792 | |||
c547b97e4e | |||
78f9511f4d | |||
6fb43f2011 | |||
66f42324ad | |||
db190c16f6 | |||
fba704bf5d | |||
59323b54da | |||
6ab20ff9bf | |||
e55caf0b95 | |||
7f06d385a1 | |||
9e3f9fc2dd | |||
5956fff7e2 | |||
a810619555 | |||
1d7d8f8574 | |||
b13d281356 | |||
d46772b429 | |||
0e775807b4 | |||
acf78da742 | |||
b5f714e9f9 | |||
c5536e49ef | |||
fd88bc270a | |||
53f9e28c77 | |||
ae3dc66214 | |||
f793562b4e | |||
36f00811b9 | |||
cb38caeda4 | |||
3185a3a697 | |||
f962ca0b01 | |||
c503a50cff | |||
77df1ba9e0 | |||
b422f35872 | |||
9f200d10d5 | |||
267ea506de | |||
8dd7648db2 | |||
ccdb58b17e | |||
3b83cd24f5 | |||
3656f2c769 | |||
a6edd10ee6 | |||
6243252d5a | |||
d42f6bb6cc | |||
c432fcf2bb | |||
a6ff14d66e | |||
c5027d4fa1 | |||
daef33e268 | |||
4faf99eff5 | |||
efcd53a0c3 | |||
1f3372b7f1 | |||
8fd5620277 | |||
7d2cd0e6ff | |||
70cb427469 | |||
bc447bc0a4 | |||
5b062c4c29 | |||
d2c65aa3e8 | |||
0260fdd1c6 | |||
e9ff7162bc | |||
de72e9cc87 | |||
97bf2131e2 | |||
e7922b3fa0 | |||
50f5be9266 | |||
d6a9956781 | |||
c14a66970b | |||
cb10da02f9 | |||
a96f095deb | |||
3e0765ee22 | |||
e03198bb0f | |||
c36e7fae93 | |||
1bc1751670 | |||
b177f2432d | |||
b52e207758 | |||
7f880674e5 | |||
fce41d0b55 | |||
08e411c310 | |||
f7259e60ee | |||
6ab737a4bb | |||
aca23fd3f0 | |||
59a89774d7 | |||
43df7eb5ea | |||
3cc10d25a9 | |||
695ea45fca | |||
564ff2dfd3 | |||
d29a6a5a5a | |||
e6f06627e9 | |||
3b485cda51 | |||
87ae40843c | |||
853018dd4d | |||
5f7299e15a | |||
2a32a2e662 | |||
e384078d7a | |||
5b699517d4 | |||
22977ffedb | |||
d3c2e904d8 | |||
370a48c10b | |||
a03093b2d4 | |||
ef3f87eec5 | |||
1c4af303bf | |||
bf778ebb7e | |||
03b76bf05b | |||
78a85ba3fe | |||
2739b6ebcd | |||
4aa9d2089d | |||
55d873875e | |||
839067fda9 | |||
1a35766356 | |||
c76f014292 | |||
633f60cdb2 | |||
e32569dd5a | |||
bebc49bc2a | |||
7a8eb5bdc9 | |||
ce7b04e8b9 | |||
251bc6c22c | |||
b498856c9d | |||
dbab9b248a | |||
4be967823f | |||
43b4a81b3e | |||
578a588c1d | |||
4cfec4813e | |||
c6e370a77a | |||
042153d254 | |||
acb6f12d2c | |||
335c8dd159 | |||
d851775c80 | |||
726dcf0dd2 | |||
a0d724b450 | |||
a8788e51a7 | |||
63cd2bf9b1 | |||
b3099d650c | |||
67ac7da30f | |||
89ab4b5e07 | |||
ae1a6dc075 | |||
b36a043bbf | |||
2ca1884a39 | |||
6ec50d6bf5 | |||
7f58bb03c1 | |||
cbc9730798 | |||
c38526d14b | |||
9912f7eef8 | |||
fba9353c60 | |||
3b85a8b6a0 | |||
164f22d5b7 | |||
c0cf123e0b | |||
e8f7c83138 | |||
926c1cf9a4 | |||
f99348711b | |||
9142002121 | |||
0106dcbd02 | |||
fafe65a8fc | |||
2159629e9e | |||
eca74d55c7 | |||
2b7d4c713e | |||
c5a79deb38 | |||
7bcb1d3816 | |||
0adcddac39 | |||
19e22baa06 | |||
344d48be31 | |||
c075786d8b | |||
99c7622a1b | |||
e87ad328e4 | |||
842e88a8e3 | |||
e56eba44fe | |||
8374a454da | |||
09f6f564d9 | |||
bbd6d5d5b5 | |||
3fe2ecfd4c | |||
501e73feed | |||
9e1ad7295f | |||
10bb9524eb | |||
072d6d8cb5 | |||
2170b0b278 | |||
529ca279a4 | |||
be03882a15 | |||
c7a606ab7e | |||
728deff56c | |||
99b9f1c93c | |||
82748df71a | |||
69d0d33451 | |||
24f21bd4d4 | |||
c0547d358d | |||
4b2781fe87 | |||
0d56140b4a | |||
a34edb810e | |||
4b82759598 | |||
0a55573288 | |||
9f34925b2a | |||
0a5fb24f10 | |||
3dd3d0b248 | |||
229921541b | |||
9b2672a99f | |||
2fc07c1b7d | |||
ba12d37719 | |||
479e532f18 | |||
d5d825debb | |||
1ff27d7db8 | |||
79ce9b74d5 | |||
105f3b14e4 | |||
564c97b87e | |||
f0f86213db | |||
b409d399c8 | |||
9693fd5351 | |||
7c9e38f60a | |||
709653c330 | |||
2aa9a538c0 | |||
c4c042bcec | |||
052999a6ab | |||
83645aa593 | |||
2fcdeb7f12 | |||
4c794be41d | |||
54d30d758f | |||
65632d2682 | |||
3420080a35 | |||
cf6ba9dd2d | |||
cb2775ae54 | |||
f63c03c464 | |||
51fcef0c21 | |||
9e2f202f05 | |||
2169bf6895 | |||
790605e359 | |||
8971d70149 | |||
e1a7aa41cb | |||
2600b28f5d | |||
6400f2900a | |||
a9c6a0f6ec | |||
89cae37b49 | |||
8fbe8709f9 | |||
e8dbf1c795 | |||
5658675e9d | |||
804ee78731 | |||
fd684ba974 | |||
b8ade0b94f | |||
4abce8af58 | |||
5665f1d3e3 | |||
d9016964ad | |||
c47e5fc76a | |||
7d1f2c0dc5 | |||
d165817880 | |||
cf48e28932 | |||
670d40642f | |||
6a1ba317c7 | |||
96d2942373 | |||
35e4fa7b85 | |||
6cca4025ee | |||
ddf41b0398 | |||
550dc09998 | |||
aef041f948 | |||
c9298c2657 | |||
287a4b6b38 | |||
358e7a194e | |||
1f1e63f705 | |||
ee42fae468 | |||
0ba3cadb88 | |||
f8eef49575 | |||
01d4bf299a | |||
f0fa17b5e0 | |||
7a9ea281be | |||
808d631e35 | |||
e1d81f4dc5 | |||
1f51e8f39d | |||
7a7327adde | |||
0d4b08a851 | |||
b295e185ff | |||
419b22a487 | |||
5938f1ba61 | |||
f72ca6d22c | |||
304de0ee1b | |||
a02210a455 | |||
92a6faca6f | |||
37f3a718c6 | |||
40f608ce9b | |||
24a78767d2 | |||
1e162dfc74 | |||
18f217e631 | |||
5429bd892e | |||
668a4bf1bc | |||
0f935248e3 | |||
18b50f8eba | |||
f8f382221c | |||
032c222d57 | |||
c26b29b254 | |||
ad3c1e68ab | |||
8df58e2cfd |
@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2014-2015 Omar Cornut and ImGui contributors
|
Copyright (c) 2014-2017 Omar Cornut and ImGui contributors
|
||||||
|
|
||||||
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
|
||||||
|
141
README.md
141
README.md
@ -11,13 +11,13 @@ Monthly donations via Patreon:
|
|||||||
One-off donations via PayPal:
|
One-off donations via PayPal:
|
||||||
<br>[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
|
<br>[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5Q73FPZ9C526U)
|
||||||
|
|
||||||
dear imgui (AKA 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).
|
||||||
|
|
||||||
ImGui is designed to enable fast iteration and 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 thus lacks certain features normally found in more high-level libraries.
|
Dear ImGui is designed to enable fast iteration and 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 thus lacks certain features normally found in more high-level libraries.
|
||||||
|
|
||||||
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
|
Dear ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
|
||||||
|
|
||||||
ImGui is self-contained within a few files that you can easily copy and compile into your application/engine:
|
Dear ImGui is self-contained within a few files that you can easily copy and compile into your application/engine:
|
||||||
|
|
||||||
- imgui.cpp
|
- imgui.cpp
|
||||||
- imgui.h
|
- imgui.h
|
||||||
@ -31,57 +31,62 @@ ImGui is self-contained within a few files that you can easily copy and compile
|
|||||||
|
|
||||||
No specific build process is required. You can add the .cpp files to your project or #include them from an existing file.
|
No specific build process is required. You can add the .cpp files to your project or #include them from an existing file.
|
||||||
|
|
||||||
Your code passes mouse/keyboard inputs and settings to ImGui (see example applications for more details). After ImGui is setup, you can use it like in this example:
|
Your code passes mouse/keyboard inputs and settings to Dear ImGui (see example applications for more details). After Dear ImGui is setup, you can use it like in this example:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands 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 ImGui with your existing codebase.
|
Dear ImGui outputs vertex buffers and simple command-lists that you can render in your application. The number of draw calls and state changes is typically very small. Because it doesn't know or touch graphics state directly, you can call ImGui commands 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 think that immediate mode gui == 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 by the user. 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 think that immediate mode gui == 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 by the user. 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._
|
||||||
|
|
||||||
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue 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! 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.
|
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 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.
|
||||||
|
|
||||||
Binaries/Demo
|
Binaries/Demo
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
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 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-20170723.zip](http://www.miracleworld.net/imgui/binaries/imgui-demo-binaries-20170723.zip) (Windows binaries, ImGui 1.51+ 2017/07/23, 5 executables, 808 KB)
|
- [imgui-demo-binaries-20171013.zip](http://www.miracleworld.net/imgui/binaries/imgui-demo-binaries-20171013.zip) (Windows binaries, Dear ImGui 1.52 WIP built 2017/10/13, 5 executables)
|
||||||
|
|
||||||
Bindings
|
Bindings
|
||||||
--------
|
--------
|
||||||
|
|
||||||
_NB: those third-party bindings may be more or less maintained, more or less close to the spirit of original API and therefore I cannot give much guarantee about them. People who create language bindings sometimes haven't used the C++ API themselves (for the good reason that they aren't C++ users). 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 wiring mouse/keyboard inputs and providing a render function that can bind a texture and render simple textured triangles. The examples/ folder is populated with applications doing just that. If you are an experienced programmer it should take you less than an hour to integrate Dear ImGui in your custom engine, but make sure to spend time reading the FAQ, the comments and other documentation!
|
||||||
|
|
||||||
_Integrating Dear ImGui within your custom engine is a matter of wiring mouse/keyboard inputs and providing a render function that can bind a texture and render simple textured triangles. The examples/ folder is populated with applications doing just that. If you are an experienced programmer it should take you less than an hour to integrate Dear ImGui in your custom engine, but make sure to spend time reading the FAQ, the comments and other documentation!_
|
_NB: those third-party bindings may be more or less maintained, more or less close to the spirit of original API and therefore I cannot give much guarantee about them. 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!_
|
||||||
|
|
||||||
Languages:
|
Languages:
|
||||||
- cimgui: thin c-api wrapper for ImGui https://github.com/Extrawurst/cimgui
|
- C (cimgui): https://github.com/Extrawurst/cimgui
|
||||||
- ImGui.NET: An ImGui wrapper for .NET Core https://github.com/mellinoe/ImGui.NET
|
- C#/.Net (ImGui.NET): https://github.com/mellinoe/ImGui.NET
|
||||||
- imgui-rs: Rust bindings for dear imgui https://github.com/Gekkio/imgui-rs
|
- ChaiScript: https://github.com/JuJuBoSc/imgui-chaiscript
|
||||||
- DerelictImgui: Dynamic bindings for the D programming language: https://github.com/Extrawurst/DerelictImgui
|
- D (DerelictImgui): https://github.com/Extrawurst/DerelictImgui
|
||||||
- CyImGui: Python bindings for dear imgui using Cython: https://github.com/chromy/cyimgui
|
- Go (go-imgui): https://github.com/Armored-Dragon/go-imgui
|
||||||
- pyimgui: Another Python bindings for dear imgui: https://github.com/swistakm/pyimgui
|
- Lua: https://github.com/patrickriordan/imgui_lua_bindings
|
||||||
- LUA: https://github.com/patrickriordan/imgui_lua_bindings
|
- Odin: https://github.com/ThisDrunkDane/odin-dear_imgui
|
||||||
- imgui-pas: P ascal bindings for imgui https://github.com/dpethes/imgui-pas
|
- Pascal (imgui-pas): https://github.com/dpethes/imgui-pas
|
||||||
|
- Python (CyImGui): https://github.com/chromy/cyimgui
|
||||||
|
- Python (pyimgui): https://github.com/swistakm/pyimgui
|
||||||
|
- Rust (imgui-rs): https://github.com/Gekkio/imgui-rs
|
||||||
|
|
||||||
Frameworks:
|
Frameworks:
|
||||||
- Main ImGui repository include examples for DirectX9, DirectX10, DirectX11, OpenGL2/3, Vulkan, Allegro 5, SDL+GL2/3, iOS and Marmalade: https://github.com/ocornut/imgui/tree/master/examples
|
- Main ImGui repository include examples for DirectX9, DirectX10, DirectX11, OpenGL2/3, Vulkan, Allegro 5, SDL+GL2/3, iOS and Marmalade: https://github.com/ocornut/imgui/tree/master/examples
|
||||||
- Unmerged PR: DirectX12 example (with issues) https://github.com/ocornut/imgui/pull/301
|
- Unmerged PR: DirectX12: https://github.com/ocornut/imgui/pull/301
|
||||||
- Unmerged PR: SDL2 + OpenGLES + Emscripten example https://github.com/ocornut/imgui/pull/336
|
- Unmerged PR: SDL2 + OpenGLES + Emscripten: https://github.com/ocornut/imgui/pull/336
|
||||||
- Unmerged PR: FreeGlut + OpenGL2 example https://github.com/ocornut/imgui/pull/801
|
- Unmerged PR: FreeGlut + OpenGL2: https://github.com/ocornut/imgui/pull/801
|
||||||
- Unmerged PR: Native Win32 and OSX example https://github.com/ocornut/imgui/pull/281
|
- Unmerged PR: Native Win32 and OSX: https://github.com/ocornut/imgui/pull/281
|
||||||
- Unmerged PR: Android Example https://github.com/ocornut/imgui/pull/421
|
- Unmerged PR: Android: https://github.com/ocornut/imgui/pull/421
|
||||||
- Cinder backend for dear imgui https://github.com/simongeilfus/Cinder-ImGui
|
- Cinder: https://github.com/simongeilfus/Cinder-ImGui
|
||||||
- FlexGUI: Flexium/SFML backend for dear imgui https://github.com/DXsmiley/FlexGUI
|
- cocos2d-x: https://github.com/c0i/imguix https://github.com/ocornut/imgui/issues/551
|
||||||
- IrrIMGUI: Irrlicht backend for dear imgui https://github.com/ZahlGraf/IrrIMGUI
|
- Flexium/SFML (FlexGUI): https://github.com/DXsmiley/FlexGUI
|
||||||
- UnrealEngine_ImGui: Unreal Engine 4 backend for dear imgui https://github.com/sronsse/UnrealEngine_ImGui
|
- GML/GameMakerStudio2 (ImGuiGML): https://marketplace.yoyogames.com/assets/6221/imguigml
|
||||||
- LÖVE backend for dear imgui https://github.com/slages/love-imgui
|
- Irrlicht (IrrIMGUI): https://github.com/ZahlGraf/IrrIMGUI
|
||||||
- Ogre backend for dear imgui https://bitbucket.org/LMCrashy/ogreimgui/src
|
- Ogre: https://bitbucket.org/LMCrashy/ogreimgui/src
|
||||||
- ofxImGui: openFrameworks backend for dear imgui https://github.com/jvcleave/ofxImGui
|
- openFrameworks (ofxImGui): https://github.com/jvcleave/ofxImGui
|
||||||
- SFML backend for dear imgui https://github.com/EliasD/imgui-sfml
|
- OpenSceneGraph/OSG: https://gist.github.com/fulezi/d2442ca7626bf270226014501357042c
|
||||||
- SFML backend for dear imgui https://github.com/Mischa-Alff/imgui-backends
|
- LÖVE: https://github.com/slages/love-imgui
|
||||||
- cocos2d-x with imgui https://github.com/c0i/imguix https://github.com/ocornut/imgui/issues/551
|
- NanoRT (software raytraced) https://github.com/syoyo/imgui/tree/nanort/examples/raytrace_example
|
||||||
- NanoRT: software raytraced version https://github.com/syoyo/imgui/tree/nanort/examples/raytrace_example
|
- Qt3d https://github.com/alpqr/imgui-qt3d
|
||||||
|
- Unreal Engine 4: https://github.com/segross/UnrealImGui or https://github.com/sronsse/UnrealEngine_ImGui
|
||||||
|
- SFML: https://github.com/EliasD/imgui-sfml or https://github.com/Mischa-Alff/imgui-backends
|
||||||
|
|
||||||
For other bindings: see [this page](https://github.com/ocornut/imgui/wiki/Links/).
|
For other bindings: see [this page](https://github.com/ocornut/imgui/wiki/Links/).
|
||||||
Please contact me with the Issues tracker or Twitter to fix/update this list.
|
Please contact me with the Issues tracker or Twitter to fix/update this list.
|
||||||
@ -90,6 +95,7 @@ Gallery
|
|||||||
-------
|
-------
|
||||||
|
|
||||||
See the [Screenshots Thread](https://github.com/ocornut/imgui/issues/123) for some user creations.
|
See the [Screenshots Thread](https://github.com/ocornut/imgui/issues/123) for some user creations.
|
||||||
|
Also see the [Mega screenshots](https://github.com/ocornut/imgui/issues/1273) for an idea of the available features.
|
||||||
|
|
||||||

|

|
||||||
[](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)
|
||||||
@ -97,13 +103,13 @@ See the [Screenshots Thread](https://github.com/ocornut/imgui/issues/123) for so
|
|||||||
|
|
||||||
[](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v148/profiler.png)
|
[](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v148/profiler.png)
|
||||||
|
|
||||||

|

|
||||||

|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
ImGui can load TTF/OTF fonts. UTF-8 is supported for text display and input. Here using Arial Unicode font to display Japanese. Initialize custom font with:
|
Dear ImGui can load TTF/OTF fonts. UTF-8 is supported for text display and input. Here using Arial Unicode font to display Japanese. Initialize custom font with:
|
||||||
```
|
```
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.Fonts->AddFontFromFileTTF("ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
io.Fonts->AddFontFromFileTTF("ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
||||||
@ -124,6 +130,8 @@ The Immediate Mode GUI paradigm may at first appear unusual to some users. This
|
|||||||
- [Nicolas Guillemot's CppCon'16 flashtalk about Dear ImGui](https://www.youtube.com/watch?v=LSRJ1jZq90k).
|
- [Nicolas Guillemot's CppCon'16 flashtalk about Dear ImGui](https://www.youtube.com/watch?v=LSRJ1jZq90k).
|
||||||
- [Thierry Excoffier's Zero Memory Widget](http://perso.univ-lyon1.fr/thierry.excoffier/ZMW/).
|
- [Thierry Excoffier's Zero Memory Widget](http://perso.univ-lyon1.fr/thierry.excoffier/ZMW/).
|
||||||
|
|
||||||
|
See the [Software using dear imgui page](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) for an incomplete list of software which are publicly known to use dear migui.
|
||||||
|
|
||||||
See the [Links page](https://github.com/ocornut/imgui/wiki/Links) for third-party bindings to different languages and frameworks.
|
See the [Links page](https://github.com/ocornut/imgui/wiki/Links) for third-party bindings to different languages and frameworks.
|
||||||
|
|
||||||
Frequently Asked Question (FAQ)
|
Frequently Asked Question (FAQ)
|
||||||
@ -132,41 +140,45 @@ Frequently Asked Question (FAQ)
|
|||||||
<b>Where is the documentation?</b>
|
<b>Where is the documentation?</b>
|
||||||
|
|
||||||
- The documentation is at the top of imgui.cpp + effectively imgui.h.
|
- The documentation is at the top of imgui.cpp + effectively imgui.h.
|
||||||
- Example code is in imgui_demo.cpp and particularly the ImGui::ShowTestWindow() function. It covers most features of ImGui so you can read the code and call the function itself to see its output.
|
- Example code is in imgui_demo.cpp and particularly the ImGui::ShowDemoWindow() function. It covers most features of ImGui so you can read the code and call the function itself to see its output.
|
||||||
- Standalone example applications using e.g. OpenGL/DirectX are provided in the examples/ folder.
|
- Standalone example applications using e.g. OpenGL/DirectX are provided in the examples/ folder.
|
||||||
- We obviously needs better documentation! Consider contributing or becoming a [Patron](http://www.patreon.com/imgui) to promote this effort.
|
- We obviously needs better documentation! Consider contributing or becoming a [Patron](http://www.patreon.com/imgui) to promote this effort.
|
||||||
|
|
||||||
|
<b>Which version should I get?</b>
|
||||||
|
|
||||||
|
I occasionally tag [Releases](https://github.com/ocornut/imgui/releases) but it is generally safe and recommended to sync to master. The library is fairly stable and regressions tend to be fixed fast when reported. You may also want to checkout the [navigation branch](https://github.com/ocornut/imgui/tree/navigation) if you want to use Dear ImGui with a gamepad (it is also possible to map keyboard inputs to some degree). The Navigation branch is being kept up to date with Master.
|
||||||
|
|
||||||
<b>Why the odd dual naming, "dear imgui" vs "ImGui"?</b>
|
<b>Why the odd dual naming, "dear imgui" vs "ImGui"?</b>
|
||||||
|
|
||||||
The library started its life and is best known as "ImGui" only due to the fact that I didn't give it a proper name when I released it. However, the term IMGUI (immediate-mode graphical user interface) was coined before and is being used in variety of other situations. It seemed confusing and unfair to hog the name. To reduce the 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 in ambiguous situations.
|
The library started its life and is best known as "ImGui" only due to the fact that I didn't give it a proper name when I released it. However, the term IMGUI (immediate-mode graphical user interface) was coined before and is being used in variety of other situations. It seemed confusing and unfair to hog the name. To reduce the 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 in ambiguous situations.
|
||||||
|
|
||||||
<br><b>What is ImTextureID and how do I display an image?</b>
|
<b>What is ImTextureID and how do I display an image?</b>
|
||||||
<br><b>I integrated ImGui in my engine and the text or lines are blurry..</b>
|
<br><b>I integrated Dear ImGui in my engine and the text or lines are blurry..</b>
|
||||||
<br><b>I integrated ImGui in my engine and some elements are disappearing when I move windows around..</b>
|
<br><b>I integrated Dear ImGui in my engine and some elements are disappearing when I move windows around..</b>
|
||||||
<br><b>How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on labels/IDs.</b>
|
<br><b>How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on labels/IDs.</b>
|
||||||
<br><b>How can I tell when ImGui wants my mouse/keyboard inputs VS when I can pass them to my application?</b>
|
<br><b>How can I tell when Dear ImGui wants my mouse/keyboard inputs VS when I can pass them to my application?</b>
|
||||||
<br><b>How can I load a different font than the default?</b>
|
<br><b>How can I load a different font than the default?</b>
|
||||||
<br><b>How can I easily use icons in my application?</b>
|
<br><b>How can I easily use icons in my application?</b>
|
||||||
<br><b>How can I load multiple fonts?</b>
|
<br><b>How can I load multiple fonts?</b>
|
||||||
<br><b>How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?</b>
|
<br><b>How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?</b>
|
||||||
<br><b>How can I preserve my ImGui context across reloading a DLL? (loss of the global/static variables)</b>
|
<br><b>How can I preserve my Dear ImGui context across reloading a DLL? (loss of the global/static variables)</b>
|
||||||
<br><b>How can I use the drawing facilities without an ImGui window? (using ImDrawList API)</b>
|
<br><b>How can I use the drawing facilities without an Dear ImGui window? (using ImDrawList API)</b>
|
||||||
|
|
||||||
See the FAQ in imgui.cpp for answers.
|
See the FAQ in imgui.cpp for answers.
|
||||||
|
|
||||||
<b>How do you use ImGui on a platform that may not have a mouse or keyboard?</b>
|
<b>How do you use Dear ImGui on a platform that may not have a mouse or keyboard?</b>
|
||||||
|
|
||||||
I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. ImGui allows to increase the hit box of widgets (via the _TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate.
|
I recommend using [Synergy](http://synergy-project.org) ([sources](https://github.com/symless/synergy)). In particular, the _src/micro/uSynergy.c_ file contains a small client that you can use on any platform to connect to your host PC. You can seamlessly use your PC input devices from a video game console or a tablet. Dear ImGui allows to increase the hit box of widgets (via the _style.TouchPadding_ setting) to accommodate a little for the lack of precision of touch inputs, but it is recommended you use a mouse to allow optimising for screen real-estate. You can also checkout the beta [navigation branch](https://github.com/ocornut/imgui/tree/navigation) which provides support for using Dear ImGui with a game controller.
|
||||||
|
|
||||||
<b>Can you create elaborate/serious tools with ImGui?</b>
|
<b>Can you create elaborate/serious tools with Dear ImGui?</b>
|
||||||
|
|
||||||
Yes. I have written 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).
|
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).
|
||||||
|
|
||||||
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. Many programmers have unfortunately been taught by their environment to make unnecessarily complicated things. ImGui is about making things that are simple, efficient and powerful.
|
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.
|
||||||
|
|
||||||
<b>Is ImGui fast?</b>
|
<b>Is Dear ImGui fast?</b>
|
||||||
|
|
||||||
Probably fast enough for most uses. Down to the foundation of its visual design, ImGui is engineered to be fairly performant both in term of CPU and GPU usage. Running elaborate code and creating elaborate UI will of course have a cost but ImGui aims to minimize it.
|
Probably fast enough for most uses. Down to the foundation of its visual design, Dear ImGui is engineered to be fairly performant both in term of CPU and GPU usage. Running elaborate code and creating elaborate UI will of course have a cost but Dear ImGui aims to minimize it.
|
||||||
|
|
||||||
Mileage may vary but the following screenshot can give you a rough idea of the cost of running and rendering UI code (In the case of a trivial demo application like this one, your driver/os setup are likely to be the bottleneck. Testing performance as part of a real application is recommended).
|
Mileage may vary but the following screenshot can give you a rough idea of the cost of running and rendering UI code (In the case of a trivial demo application like this one, your driver/os setup are likely to be the bottleneck. Testing performance as part of a real application is recommended).
|
||||||
|
|
||||||
@ -174,21 +186,19 @@ Mileage may vary but the following screenshot can give you a rough idea of the c
|
|||||||
|
|
||||||
This is showing framerate for the full application loop on my 2011 iMac running Windows 7, OpenGL, AMD Radeon HD 6700M with an optimized executable. In contrast, librairies featuring higher-quality rendering and layouting techniques may have a higher resources footprint.
|
This is showing framerate for the full application loop on my 2011 iMac running Windows 7, OpenGL, AMD Radeon HD 6700M with an optimized executable. In contrast, librairies featuring higher-quality rendering and layouting techniques may have a higher resources footprint.
|
||||||
|
|
||||||
If you intend to display large lists of items (say, 1000+) it can be beneficial for your code to perform clipping manually - one way is using helpers such as ImGuiListClipper - in order to avoid submitting them to ImGui in the first place. Even though ImGui will discard your clipped items it still needs to calculate their size and that overhead will add up if you have thousands of items. If you can handle clipping and height positionning yourself then browsing a list with millions of items isn't a problem.
|
If you intend to display large lists of items (say, 1000+) it can be beneficial for your code to perform clipping manually - one way is using helpers such as ImGuiListClipper - in order to avoid submitting them to Dear ImGui in the first place. Even though ImGui will discard your clipped items it still needs to calculate their size and that overhead will add up if you have thousands of items. If you can handle clipping and height positionning yourself then browsing a list with millions of items isn't a problem.
|
||||||
|
|
||||||
<b>Can you reskin the look of ImGui?</b>
|
<b>Can you reskin the look of Dear ImGui?</b>
|
||||||
|
|
||||||
You can alter the look of the interface to some degree: changing colors, sizes, padding, rounding, fonts. However, as ImGui is designed and optimised 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.
|
You can alter the look of the interface to some degree: changing colors, sizes, padding, rounding, fonts. However, as Dear ImGui is designed and optimised 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):
|
||||||
|
|
||||||
This is [LumixEngine](https://github.com/nem0/LumixEngine) with a minor skinning hack + a docking/tabs extension (both of which you can find in the Issues section and will eventually be merged).
|

|
||||||
|
|
||||||
[](https://cloud.githubusercontent.com/assets/8225057/13044612/59f07aec-d3cf-11e5-8ccb-39adf2e13e69.png)
|
|
||||||
|
|
||||||
<b>Why using C++ (as opposed to C)?</b>
|
<b>Why using C++ (as opposed to C)?</b>
|
||||||
|
|
||||||
ImGui takes advantage of a few C++ languages features for convenience but nothing anywhere Boost-insanity/quagmire. 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.
|
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 unofficial but reasonably maintained [c-api for ImGui](https://github.com/Extrawurst/cimgui) by Stephan Dilly. I would suggest using your target language functionality to try replicating the function overloading and default parameters used in C++ else the API may be harder to use. It was really designed with C++ in mind and may not make the same amount of sense with another language. Also see [Links](https://github.com/ocornut/imgui/wiki/Links) for third-party bindings to other languages.
|
There is an reasonably maintained [c-api for ImGui](https://github.com/Extrawurst/cimgui) by Stephan Dilly designed for binding in other languages. 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 [Links](https://github.com/ocornut/imgui/wiki/Links) for third-party bindings to other languages.
|
||||||
|
|
||||||
Support dear imgui
|
Support dear imgui
|
||||||
------------------
|
------------------
|
||||||
@ -225,14 +235,17 @@ Double-chocolate sponsors:
|
|||||||
- Mobigame
|
- Mobigame
|
||||||
- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
|
- Insomniac Games (sponsored the gamepad/keyboard navigation branch)
|
||||||
- Aras Pranckevičius
|
- Aras Pranckevičius
|
||||||
|
- Lizardcube
|
||||||
|
- Greggman
|
||||||
|
|
||||||
Salty caramel supporters:
|
Salty caramel supporters:
|
||||||
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Recognition Robotics, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko.
|
- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Recognition Robotics, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko, Mercury Labs, Singularity Demo Group, Mischa Alff, Sebastien Ronsse.
|
||||||
|
|
||||||
Caramel supporters:
|
Caramel supporters:
|
||||||
- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, [Kit framework](http://svkonsult.se/kit), Josh Faust, Martin Donlon, Quinton, Felix.
|
- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, Kit framework, Josh Faust, Martin Donlon, Quinton, Felix, Andrew Belt, Codecat, Cort Stratton, Claudio Canepa, Doug McNabb, Emmanuel Julien, Guillaume Chereau, Jeffrey Slutter, Jeremiah Deckard, r-lyeh, Roger Clark, Nekith, Joshua Fisher, Malte Hoffmann, Mustafa Karaalioglu, Merlyn Morgan-Graham, Per Vognsen, Fabian Giesen, Jan Staubach, Matt Hargett, John Shearer, Jesse Chounard, kingcoopa, Miloš Tošić.
|
||||||
|
|
||||||
And other supporters; thanks!
|
And other supporters; thanks!
|
||||||
|
(Please contact me or PR if you would like to be added or removed from this list)
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
90
TODO.txt
90
TODO.txt
@ -7,6 +7,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?
|
||||||
- project: folder or separate repository with maintained helpers (e.g. imgui_memory_editor.h, imgui_stl.h, maybe imgui_dock would be there?)
|
- project: folder or separate repository with maintained helpers (e.g. imgui_memory_editor.h, imgui_stl.h, maybe imgui_dock would be there?)
|
||||||
|
|
||||||
- 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)
|
||||||
@ -14,27 +15,29 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- window: auto-fit feedback loop when user relies on any dynamic layout (window width multiplier, column) appears weird to end-user. clarify.
|
- window: auto-fit feedback loop when user relies on any dynamic layout (window width multiplier, column) appears weird to end-user. clarify.
|
||||||
- window: allow resizing of child windows (possibly given min/max for each axis?.)
|
- window: allow resizing of child windows (possibly given min/max for each axis?.)
|
||||||
- window: background options for child windows, border option (disable rounding).
|
- window: background options for child windows, border option (disable rounding).
|
||||||
- window: resizing from any sides? + mouse cursor directives for app. (#822)
|
- window: resizing from any sides? done. > need backends to honor mouse cursors properly. (#822)
|
||||||
!- window: begin with *p_open == false should return false.
|
- window: resize from borders: support some form of outer padding to make it easier to grab borders. (#822)
|
||||||
|
- window: begin with *p_open == false should return false.
|
||||||
- window: get size/pos helpers given names (see discussion in #249)
|
- window: get size/pos helpers given names (see discussion in #249)
|
||||||
- window: a collapsed window can be stuck behind the main menu bar?
|
- window: a collapsed window can be stuck behind the main menu bar?
|
||||||
- window: when window is very small, prioritize resize button over close button.
|
- window: when window is very small, prioritize resize button over close button.
|
||||||
- window: detect extra End() call that pop the "Debug" window out and assert at End() call site instead of at end of frame.
|
- window: detect extra End() call that pop the "Debug" window out and assert at End() call site instead of at end of frame.
|
||||||
- window/tooltip: allow to set the width of a tooltip to allow TextWrapped() etc. while keeping the height automatic.
|
|
||||||
- window: increase minimum size of a window with menus or fix the menu rendering so that it doesn't look odd.
|
- window: increase minimum size of a window with menus or fix the menu rendering so that it doesn't look odd.
|
||||||
- window: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon?
|
- window: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon?
|
||||||
- window: expose contents size. (#1045)
|
- window: expose contents size. (#1045)
|
||||||
- window: GetWindowSize() returns (0,0) when not calculated? (#1045)
|
- window: GetWindowSize() returns (0,0) when not calculated? (#1045)
|
||||||
|
- window: freeze window flag: if not focused/hovered, return false, render with previous ImDrawList. and/or reduce refresh rate.
|
||||||
!- 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/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)
|
||||||
|
|
||||||
- drawlist: move Font, FontSize, FontTexUvWhitePixel inside ImDrawList and make it self-contained (apart from drawing settings?)
|
|
||||||
- drawlist: make it easier to toggle AA per primitive, so we can use e.g. non-AA fill + AA borders more naturally
|
|
||||||
- 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).
|
||||||
- drawlist: avoid passing null (-9999,+9999) rectangle to end-user, instead perhaps pass rectangle based on io.DisplaySize?
|
|
||||||
- drawlist: primtiives/helpers to manipulate vertices post submission, so e.g. a quad/rect can be resized to fit later submitted content, _without_ using the ChannelSplit api
|
- drawlist: primtiives/helpers to manipulate vertices post submission, so e.g. a quad/rect can be resized to fit later submitted content, _without_ using the ChannelSplit api
|
||||||
|
- drawlist: make it easier to toggle AA per primitive, so we can use e.g. non-AA fill + AA borders more naturally
|
||||||
|
- drawlist: non-AA strokes have gaps between points (#593, #288), especially RenderCheckmark().
|
||||||
|
- drawlist: would be good to be able to deep copy a draw list (ImVector= op?).
|
||||||
|
- drawlist/opt: AddRect() axis aligned pixel aligned (no-aa) could use 8 triangles instead of 16 and no normal calculation.
|
||||||
|
|
||||||
- main: considering adding an Init() function? some constructs are awkward in the implementation because of the lack of them.
|
- main: considering adding an Init() function? some constructs are awkward in the implementation because of the lack of them.
|
||||||
- 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
|
||||||
@ -43,7 +46,8 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
|
|
||||||
- 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 disabled and read-only modes (#211)
|
- widgets: add visauls for Disabled/ReadOnly mode and expose publicly (#211)
|
||||||
|
- widgets: add always-allow-overlap mode.
|
||||||
- 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)
|
||||||
|
|
||||||
@ -54,6 +58,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- 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: way to dynamically grow the buffer without forcing the user to initially allocate for worse case, e.g. more natural std::string (follow up on #200)
|
- input text: way to dynamically grow the buffer without forcing the user to initially allocate for worse case, e.g. more natural std::string (follow up on #200)
|
||||||
- input text: hover tooltip could show unclamped text
|
- input text: hover tooltip could show unclamped text
|
||||||
|
- input text: option to Tab after an Enter validation.
|
||||||
- input text: add ImGuiInputTextFlags_EnterToApply? (off #218)
|
- input text: add ImGuiInputTextFlags_EnterToApply? (off #218)
|
||||||
- input text: easier ways to update buffer (from source char*) while owned. preserve some sort of cursor position for multi-line text.
|
- input text: easier ways to update buffer (from source char*) while owned. preserve some sort of cursor position for multi-line text.
|
||||||
- input text: add discard flag (e.g. ImGuiInputTextFlags_DiscardActiveBuffer) or make it easier to clear active focus for text replacement during edition (#725)
|
- input text: add discard flag (e.g. ImGuiInputTextFlags_DiscardActiveBuffer) or make it easier to clear active focus for text replacement during edition (#725)
|
||||||
@ -74,13 +79,16 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- layout: horizontal flow until no space left (#404)
|
- layout: horizontal flow until no space left (#404)
|
||||||
- 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: BeginGroup() needs a border option.
|
- layout: BeginGroup() needs a border option. (~#1496)
|
||||||
- layout: vertical alignement of mixed height items (e.g. buttons) within a same line (#1284)
|
- layout: vertical alignement of mixed height items (e.g. buttons) within a same line (#1284)
|
||||||
|
|
||||||
- columns: sizing policy (e.g. for each column: fixed size, %, fill, distribute default size among fills) (#513, #125)
|
- columns: sizing policy (e.g. for each column: fixed size, %, fill, distribute default size among fills) (#513, #125)
|
||||||
- columns: add a conditional parameter to SetColumnOffset() (#513, #125)
|
- columns: add a conditional parameter to SetColumnOffset() (#513, #125)
|
||||||
- columns: headers. with sort op/button. reorderable. (#513, #125)
|
- columns: headers. reorderable. (#513, #125)
|
||||||
|
- columns: optional sorting modifiers (up/down), sort list so sorting can be done multi-critera. notify user when sort order changed.
|
||||||
|
- 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: 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)
|
||||||
@ -98,7 +106,9 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- plot: option/feature: draw unit
|
- plot: option/feature: draw unit
|
||||||
- plot: add a helper e.g. Plot(char* label, float value, float time_span=2.0f) that stores values and Plot them for you - probably another function name. and/or automatically allow to plot ANY displayed value (more reliance on stable ID)
|
- plot: add a helper e.g. Plot(char* label, float value, float time_span=2.0f) that stores values and Plot them for you - probably another function name. and/or automatically allow to plot ANY displayed value (more reliance on stable ID)
|
||||||
|
|
||||||
- clipper: ability to force display 1 item in the list would be convenient.
|
- clipper: ability to force display 1 item in the list would be convenient (for patterns where we need to set active id etc.)
|
||||||
|
- clipper: ability to disable the clipping through a simple flag/bool.
|
||||||
|
- clipper: ability to run without knowing full count in advance.
|
||||||
|
|
||||||
- splitter/separator: formalize the splitter idiom into an official api (we want to handle n-way split) (#319)
|
- splitter/separator: formalize the splitter idiom into an official api (we want to handle n-way split) (#319)
|
||||||
|
|
||||||
@ -124,29 +134,27 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- drag float: up/down axis
|
- drag float: up/down axis
|
||||||
- drag float: added leeway on edge (e.g. a few invisible steps past the clamp limits)
|
- drag float: added leeway on edge (e.g. a few invisible steps past the clamp limits)
|
||||||
|
|
||||||
- combo: sparse combo boxes (via function call?) / iterators
|
- combo: use clipper: make it easier to disable clipper with a single flag.
|
||||||
- combo: active item type could be anything else e.g. void*
|
- combo: option for BeginCombo to not return true when unchanged (#1182)
|
||||||
- combo: use clipper
|
|
||||||
- combo: contents should extends to fit label if combo widget is small
|
|
||||||
- combo: option for ComboEx to not return true when unchanged (#1182)
|
|
||||||
- combo/listbox: keyboard control. need InputText-like non-active focus + key handling. considering keyboard for custom listbox (pr #203)
|
- combo/listbox: keyboard control. need InputText-like non-active focus + key handling. considering keyboard for custom listbox (pr #203)
|
||||||
- listbox: multiple selection.
|
- listbox: multiple selection.
|
||||||
- listbox: unselect (#1208)
|
- listbox: unselect option (#1208)
|
||||||
- listbox: make it easier/more natural to implement range-select (need some sort of info/ref about the last clicked/focused item that user can translate to an index?)
|
- listbox: make it easier/more natural to implement range-select (need some sort of info/ref about the last clicked/focused item that user can translate to an index?) (wip stash)
|
||||||
- listbox: user may want to initial scroll to focus on the one selected value?
|
- listbox: user may want to initial scroll to focus on the one selected value?
|
||||||
- listbox: expose hovered item for a basic ListBox
|
- listbox: expose hovered item for a basic ListBox
|
||||||
- listbox: keyboard navigation.
|
- listbox: keyboard navigation.
|
||||||
- listbox: scrolling should track modified selection.
|
- listbox: scrolling should track modified selection.
|
||||||
|
|
||||||
!- popups/menus: clarify usage of popups id, how MenuItem/Selectable closing parent popups affects the ID, etc. this is quite fishy needs improvement! (#331, #402)
|
!- popups/menus: clarify usage of popups id, how MenuItem/Selectable closing parent popups affects the ID, etc. this is quite fishy needs improvement! (#331, #402)
|
||||||
- popups/nav: esc/enter default behavior for popups.
|
- popups: reopening context menu at new position should be the behavior by default? (equivalent to internal OpenPopupEx() with reopen_existing=true) (~#1497)
|
||||||
- popups: reopening context menu at new position should be the behavior by default? (equivalent to internal OpenPopupEx() with reopen_existing=true)
|
|
||||||
- popups: if the popup functions took explicit ImGuiID it would allow the user to manage the scope of those ID. (#331)
|
- popups: if the popup functions took explicit ImGuiID it would allow the user to manage the scope of those ID. (#331)
|
||||||
- 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: 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 tooltips with timers? or general timer policy? (instaneous vs timed)
|
||||||
|
|
||||||
- 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)
|
||||||
- statusbar: add a per-window status bar helper similar to what menubar does.
|
- statusbar: add a per-window status bar helper similar to what menubar does.
|
||||||
- shortcuts: local-style shortcut api, e.g. parse "&Save"
|
- shortcuts: local-style shortcut api, e.g. parse "&Save"
|
||||||
@ -154,8 +162,11 @@ 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: menubars: main menu-bar could affect clamping of windows position (~ akin to modifying DisplayMin)
|
- menus: menubars: main menu-bar could affect clamping of windows position (~ akin to modifying DisplayMin)
|
||||||
|
|
||||||
|
- text: selectable text (for copy) as a generic feature (ItemFlags?)
|
||||||
- text: proper alignment options in imgui_internal.h
|
- 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 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 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 / optimization: avoid formatting when clipped.
|
||||||
- tree node: tree-node/header right-most side doesn't take account of horizontal scrolling.
|
- tree node: tree-node/header right-most side doesn't take account of horizontal scrolling.
|
||||||
@ -165,16 +176,14 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- 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)
|
||||||
|
|
||||||
!- settings: expose enough to save/load .ini from RAM instead of fopen
|
!- settings: expose enough to save/load .ini from RAM instead of fopen
|
||||||
- settings: write more decent code to allow saving/loading new fields
|
- 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
|
- stb: add defines to disable stb implementations
|
||||||
|
|
||||||
!- style: better default styles.
|
!- style: better default styles. (#707)
|
||||||
!- style: move border to style structure, remove _ShowBorder flag.
|
- style: border types: out-screen, in-screen, etc. (#447)
|
||||||
- style: border types: out-screen, in-screen, etc.
|
|
||||||
- style/optimization: store rounded corners in texture to use 1 quad per corner (filled and wireframe) to lower the cost of rounding.
|
- style/optimization: store rounded corners in texture to use 1 quad per corner (filled and wireframe) to lower the cost of rounding.
|
||||||
- style: add window shadow (fading away from the window. Paint-style calculation of vertices alpha after drawlist would be easier)
|
- style: add window shadow (fading away from the window. Paint-style calculation of vertices alpha after drawlist would be easier)
|
||||||
- style: color-box not always square?
|
|
||||||
- style: a concept of "compact style" that the end-user can easily rely on (e.g. PushStyleCompact()?) that maps to other settings? avoid implementing duplicate helpers such as SmallCheckbox(), etc.
|
- style: a concept of "compact style" that the end-user can easily rely on (e.g. PushStyleCompact()?) that maps to other settings? avoid implementing duplicate helpers such as SmallCheckbox(), etc.
|
||||||
- style: try to make PushStyleVar() more robust to incorrect parameters (to be more friendly to edit & continues situation).
|
- style: try to make PushStyleVar() more robust to incorrect parameters (to be more friendly to edit & continues situation).
|
||||||
- style: global scale setting.
|
- style: global scale setting.
|
||||||
@ -192,12 +201,18 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- filters: handle wildcards (with implicit leading/trailing *), regexps
|
- filters: handle wildcards (with implicit leading/trailing *), regexps
|
||||||
- filters: fuzzy matches (may use code at blog.forrestthewoods.com/4cffeed33fdb)
|
- filters: fuzzy matches (may use code at blog.forrestthewoods.com/4cffeed33fdb)
|
||||||
|
|
||||||
- drag'n drop, dragging helpers, demo (carry dragging info, visualize drag source before clicking, drop target, etc.) (#143, #479)
|
- drag and drop: add demo. (#143, #479)
|
||||||
|
- drag and drop: test with reordering nodes (in a list, or a tree node). (#143)
|
||||||
|
- drag and drop: test integrating with os drag and drop.
|
||||||
- node/graph editor (#306)
|
- node/graph editor (#306)
|
||||||
- pie menus patterns (#434)
|
- pie menus patterns (#434)
|
||||||
- markup: simple markup language for color change?
|
- markup: simple markup language for color change? (#902)
|
||||||
|
|
||||||
|
- font: better vertical centering (based e.g on height of lowercase 'x'?). currently Roboto-Medium size 16 px isn't currently centered.
|
||||||
|
- 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: 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: PushFontSize API (#1018)
|
- font: PushFontSize API (#1018)
|
||||||
- font/atlas: incremental updates
|
- font/atlas: incremental updates
|
||||||
- font/atlas: dynamic font atlas to avoid baking huge ranges into bitmap and make scaling easier.
|
- font/atlas: dynamic font atlas to avoid baking huge ranges into bitmap and make scaling easier.
|
||||||
@ -211,24 +226,31 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- font: fix AddRemapChar() to work before font has been built.
|
- font: fix AddRemapChar() to work before font has been built.
|
||||||
- font: (api breaking) removed "TTF" from symbol names. also because it now supports OTF.
|
- font: (api breaking) removed "TTF" from symbol names. also because it now supports OTF.
|
||||||
|
|
||||||
!- keyboard: tooltip & combo boxes are messing up / not honoring keyboard tabbing.
|
!- nav/keyboard: tooltip & combo boxes are messing up / not honoring keyboard tabbing.
|
||||||
- keyboard: full keyboard navigation and focus. (#323)
|
- nav: integrate navigation branch into master. (#787)
|
||||||
|
- nav: integrate/design keyboard controls.
|
||||||
|
- nav: once tab should go through most/all widgets (in submission order?)
|
||||||
|
- nav: currently cannot access menubar of a child window with Alt/menu key.
|
||||||
|
- 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.
|
||||||
- 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)
|
||||||
- inputs: rework IO system to be able to pass actual ordered/timestamped events. use an event queue? (~#335, #71)
|
- inputs: rework IO system to be able to pass actual ordered/timestamped events. use an event queue? (~#335, #71)
|
||||||
- inputs: allow to decide and pass explicit double-clicks (e.g. for windows by the CS_DBLCLKS style).
|
- inputs: allow to pass explicit double-clicks if that's the only thing the user's backend can get them. (e.g. for windows by the CS_DBLCLKS style).
|
||||||
- inputs: support track pad style scrolling & slider edit.
|
- inputs: support track pad style scrolling & slider edit.
|
||||||
|
|
||||||
|
- misc: idle refresh: expose cursor blink animation timer for backend to be able to lower framerate.
|
||||||
|
- 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: provide HoveredTime and ActivatedTime to ease the creation of animations.
|
|
||||||
- misc: fix for compilation settings where stdcall isn't the default (e.g. vectorcall) (#1230)
|
- misc: fix for compilation settings where stdcall isn't the default (e.g. vectorcall) (#1230)
|
||||||
- remote: make a system like RemoteImGui first-class citizen/project (#75)
|
- remote: make a system like RemoteImGui first-class citizen/project (#75)
|
||||||
|
|
||||||
- demo: demo: add a virtual scrolling example?
|
- demo: add vertical separator demo
|
||||||
|
- demo: add virtual scrolling example?
|
||||||
- examples: directx9: save/restore device state more thoroughly.
|
- examples: directx9: save/restore device state more thoroughly.
|
||||||
- examples: window minimize, maximize (#583)
|
- examples: window minimize, maximize (#583)
|
||||||
- examples: provide a zero-framerate/idle example.
|
- examples: provide a zero-framerate/idle example.
|
||||||
- examples: document WantCaptureKeyboard, WantCaptureMouse in example apps. (#446)
|
- examples: glfw: could go idle when minimized? if (glfwGetWindowAttrib(window, GLFW_ICONIFIED)) { glfwWaitEvents(); continue; } // the problem is that DeltaTime will be super high on resume, perhaps provide a way to let impl know (#440)
|
||||||
- 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)
|
||||||
|
@ -8,15 +8,16 @@ Third party languages and frameworks bindings: https://github.com/ocornut/imgui/
|
|||||||
|
|
||||||
TL;DR;
|
TL;DR;
|
||||||
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
|
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
|
||||||
- To LEARN how the library is setup, you may refer to 'opengl2_example' because is the simplest one.
|
|
||||||
The other examples requires more boilerplate and are harder to read.
|
|
||||||
However, USE 'opengl3_example' in your application if you are using any modern OpenGL3+ calls.
|
|
||||||
Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by some drivers.
|
|
||||||
If you are not sure, in doubt, use 'opengl3_example'.
|
|
||||||
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
|
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
|
||||||
to your project and use them unmodified.
|
to your project and use them unmodified.
|
||||||
- If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
|
- To LEARN how the library is setup, you may refer to 'opengl2_example' because is the simplest one to read.
|
||||||
your engine, but you can read the other examples as well.
|
However, do NOT USE the 'opengl2_example' if your code is using any modern GL3+ calls.
|
||||||
|
Mixing old fixed-pipeline OpenGL2 and modern OpenGL3+ is going to make everything more complicated.
|
||||||
|
Read comments below for details. If you are not sure, in doubt, use 'opengl3_example'.
|
||||||
|
- If you have your own engine, you probably want to read a few of the examples first then adapt it to
|
||||||
|
your engine. Please note that if your engine is based on OpenGL/DirectX you can perfectly use the
|
||||||
|
existing rendering backends, don't feel forced to rewrite them with your own engine API, or you can
|
||||||
|
do that later when you already got things to work.
|
||||||
|
|
||||||
ImGui is highly portable and only requires a few things to run:
|
ImGui is highly portable and only requires a few things to run:
|
||||||
- Providing mouse/keyboard inputs
|
- Providing mouse/keyboard inputs
|
||||||
@ -45,17 +46,18 @@ Also note that some setup or GPU drivers may be causing extra lag (possibly by e
|
|||||||
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
|
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
|
||||||
|
|
||||||
opengl2_example/
|
opengl2_example/
|
||||||
GLFW + OpenGL example (old, fixed graphic pipeline).
|
**DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
This is only provided as a reference to learn how ImGui integration works, because it is easier to read.
|
**Prefer using the code in the opengl3_example/ folder**
|
||||||
However, if your code is using GL3+ context, using this may confuse your driver. Please use the GL3 example below.
|
GLFW + OpenGL example (legacy, fixed pipeline).
|
||||||
(You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
|
This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read.
|
||||||
pipeline by calling "glUseProgram(0)" before ImGui::Render. It appears that many librairies and drivers
|
If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more
|
||||||
are having issues mixing GL2 calls and newer GL3/GL4 calls. So it isn't recommended that you use that.)
|
complicated, will require your code to reset every single OpenGL attributes to their initial state, and might
|
||||||
|
confuse your GPU driver.
|
||||||
|
|
||||||
opengl3_example/
|
opengl3_example/
|
||||||
GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
|
GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
|
||||||
This uses more modern OpenGL calls and custom shaders.
|
This uses more modern OpenGL calls and custom shaders.
|
||||||
Prefer using that if you are using modern OpenGL3/4 in your application.
|
Prefer using that if you are using modern OpenGL in your application (anything with shaders, vbo, vao, etc.).
|
||||||
|
|
||||||
directx9_example/
|
directx9_example/
|
||||||
DirectX9 example, Windows only.
|
DirectX9 example, Windows only.
|
||||||
@ -74,10 +76,18 @@ apple_example/
|
|||||||
Synergy keyboard integration is rather hacky.
|
Synergy keyboard integration is rather hacky.
|
||||||
|
|
||||||
sdl_opengl2_example/
|
sdl_opengl2_example/
|
||||||
SDL2 + OpenGL example (old fixed pipeline).
|
**DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
|
**Prefer using the code in the sdl_opengl3_example/ folder**
|
||||||
|
SDL2 + OpenGL example (legacy, fixed pipeline).
|
||||||
|
This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read.
|
||||||
|
If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more
|
||||||
|
complicated, will require your code to reset every single OpenGL attributes to their initial state, and might
|
||||||
|
confuse your GPU driver.
|
||||||
|
|
||||||
sdl_opengl3_example/
|
sdl_opengl3_example/
|
||||||
SDL2 + OpenGL3 example.
|
SDL2 + OpenGL3 example.
|
||||||
|
This uses more modern OpenGL calls and custom shaders.
|
||||||
|
Prefer using that if you are using modern OpenGL in your application (anything with shaders, vbo, vao, etc.).
|
||||||
|
|
||||||
allegro5_example/
|
allegro5_example/
|
||||||
Allegro 5 example.
|
Allegro 5 example.
|
||||||
@ -89,3 +99,4 @@ vulkan_example/
|
|||||||
Vulkan example.
|
Vulkan example.
|
||||||
This is quite long and tedious, because: Vulkan.
|
This is quite long and tedious, because: Vulkan.
|
||||||
|
|
||||||
|
TODO: Apple, SDL GL/GL3, Allegro, Marmalade, Vulkan examples do not honor the io.WantMoveMouse flag.
|
||||||
|
@ -204,6 +204,10 @@ void ImGui_ImplA5_Shutdown()
|
|||||||
ImGui::Shutdown();
|
ImGui::Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.
|
||||||
bool ImGui_ImplA5_ProcessEvent(ALLEGRO_EVENT *ev)
|
bool ImGui_ImplA5_ProcessEvent(ALLEGRO_EVENT *ev)
|
||||||
{
|
{
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
ImGuiIO &io = ImGui::GetIO();
|
||||||
@ -227,7 +231,6 @@ bool ImGui_ImplA5_ProcessEvent(ALLEGRO_EVENT *ev)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ImGui_ImplA5_NewFrame()
|
void ImGui_ImplA5_NewFrame()
|
||||||
{
|
{
|
||||||
if (!g_Texture)
|
if (!g_Texture)
|
||||||
@ -262,7 +265,7 @@ void ImGui_ImplA5_NewFrame()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
io.MousePos = ImVec2(-1, -1);
|
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
al_get_mouse_state(&mouse);
|
al_get_mouse_state(&mouse);
|
||||||
@ -290,6 +293,6 @@ void ImGui_ImplA5_NewFrame()
|
|||||||
al_set_system_mouse_cursor(g_Display, cursor_id);
|
al_set_system_mouse_cursor(g_Display, cursor_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the frame
|
// Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
@ -25,29 +25,44 @@ int main(int, char**)
|
|||||||
// Setup ImGui binding
|
// Setup ImGui binding
|
||||||
ImGui_ImplA5_Init(display);
|
ImGui_ImplA5_Init(display);
|
||||||
|
|
||||||
|
// Setup style
|
||||||
|
ImGui::StyleColorsClassic();
|
||||||
|
//ImGui::StyleColorsDark();
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
|
// - 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 'extra_fonts/README.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 \\ !
|
||||||
//ImGuiIO& io = ImGui::GetIO();
|
//ImGuiIO& io = ImGui::GetIO();
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
||||||
//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);
|
||||||
|
|
||||||
bool show_test_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_color = ImColor(114, 144, 154);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
bool running = true;
|
bool running = true;
|
||||||
while (running)
|
while (running)
|
||||||
{
|
{
|
||||||
|
// 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.
|
||||||
ALLEGRO_EVENT ev;
|
ALLEGRO_EVENT ev;
|
||||||
while (al_get_next_event(queue, &ev))
|
while (al_get_next_event(queue, &ev))
|
||||||
{
|
{
|
||||||
ImGui_ImplA5_ProcessEvent(&ev);
|
ImGui_ImplA5_ProcessEvent(&ev);
|
||||||
if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) running = false;
|
if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
|
||||||
|
running = false;
|
||||||
if (ev.type == ALLEGRO_EVENT_DISPLAY_RESIZE)
|
if (ev.type == ALLEGRO_EVENT_DISPLAY_RESIZE)
|
||||||
{
|
{
|
||||||
ImGui_ImplA5_InvalidateDeviceObjects();
|
ImGui_ImplA5_InvalidateDeviceObjects();
|
||||||
@ -57,32 +72,33 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
ImGui_ImplA5_NewFrame();
|
ImGui_ImplA5_NewFrame();
|
||||||
|
|
||||||
// 1. Show a simple window
|
// 1. Show a simple window.
|
||||||
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
|
||||||
{
|
{
|
||||||
static float f;
|
static float f = 0.0f;
|
||||||
ImGui::Text("Hello, world!");
|
ImGui::Text("Hello, world!"); // Some text (you can use a format string too)
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float as a slider from 0.0f to 1.0f
|
||||||
ImGui::ColorEdit3("clear color", (float*)&clear_color);
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats as a color
|
||||||
if (ImGui::Button("Test Window")) show_test_window ^= 1;
|
if (ImGui::Button("Demo Window")) // Use buttons to toggle our bools. We could use Checkbox() as well.
|
||||||
if (ImGui::Button("Another Window")) show_another_window ^= 1;
|
show_demo_window ^= 1;
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f/ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
if (ImGui::Button("Another Window"))
|
||||||
|
show_another_window ^= 1;
|
||||||
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Show another simple window, this time using an explicit Begin/End pair
|
// 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name the window.
|
||||||
if (show_another_window)
|
if (show_another_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(200, 100), ImGuiCond_FirstUseEver);
|
|
||||||
ImGui::Begin("Another Window", &show_another_window);
|
ImGui::Begin("Another Window", &show_another_window);
|
||||||
ImGui::Text("Hello");
|
ImGui::Text("Hello from another window!");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
|
// 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow().
|
||||||
if (show_test_window)
|
if (show_demo_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
||||||
ImGui::ShowTestWindow(&show_test_window);
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
void DebugHUD_InitDefaults( DebugHUD *hud )
|
void DebugHUD_InitDefaults( DebugHUD *hud )
|
||||||
{
|
{
|
||||||
hud->show_test_window = true;
|
hud->show_demo_window = true;
|
||||||
hud->show_example_window = true;
|
hud->show_example_window = true;
|
||||||
hud->rotation_speed = 15.0f;
|
hud->rotation_speed = 15.0f;
|
||||||
|
|
||||||
@ -26,16 +26,16 @@ void DebugHUD_InitDefaults( DebugHUD *hud )
|
|||||||
|
|
||||||
void DebugHUD_DoInterface(DebugHUD *hud)
|
void DebugHUD_DoInterface(DebugHUD *hud)
|
||||||
{
|
{
|
||||||
if (hud->show_test_window)
|
if (hud->show_demo_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
||||||
ImGui::ShowTestWindow(&hud->show_test_window );
|
ImGui::ShowDemoWindow(&hud->show_demo_window );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hud->show_example_window)
|
if (hud->show_example_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(350, 200), ImGuiCond_FirstUseEver);
|
|
||||||
ImGui::Begin("Another Window", &hud->show_example_window);
|
ImGui::Begin("Another Window", &hud->show_example_window);
|
||||||
|
ImGui::Text("Hello from another window!");
|
||||||
ImGui::ColorEdit3("Cube 1 Color", hud->cubeColor1);
|
ImGui::ColorEdit3("Cube 1 Color", hud->cubeColor1);
|
||||||
ImGui::ColorEdit3("Cube 2 Color", hud->cubeColor2);
|
ImGui::ColorEdit3("Cube 2 Color", hud->cubeColor2);
|
||||||
ImGui::SliderFloat("Rotation Speed", &hud->rotation_speed, 0.0f, 200.0f);
|
ImGui::SliderFloat("Rotation Speed", &hud->rotation_speed, 0.0f, 200.0f);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
typedef struct DebugHUD
|
typedef struct DebugHUD
|
||||||
{
|
{
|
||||||
bool show_test_window;
|
bool show_demo_window;
|
||||||
bool show_example_window;
|
bool show_example_window;
|
||||||
float rotation_speed;
|
float rotation_speed;
|
||||||
float cubeColor1[4];
|
float cubeColor1[4];
|
||||||
|
@ -225,49 +225,74 @@ void ImGui_ImplDX10_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release();
|
ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
IMGUI_API LRESULT ImGui_ImplDX10_WndProcHandler(HWND, UINT msg, WPARAM wParam, LPARAM lParam)
|
static bool IsAnyMouseButtonDown()
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
for (int n = 0; n < IM_ARRAYSIZE(io.MouseDown); n++)
|
||||||
|
if (io.MouseDown[n])
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process Win32 mouse/keyboard inputs.
|
||||||
|
// 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.
|
||||||
|
// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinations when dragging mouse outside of our window bounds.
|
||||||
|
IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
io.MouseDown[0] = true;
|
|
||||||
return true;
|
|
||||||
case WM_LBUTTONUP:
|
|
||||||
io.MouseDown[0] = false;
|
|
||||||
return true;
|
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
io.MouseDown[1] = true;
|
|
||||||
return true;
|
|
||||||
case WM_RBUTTONUP:
|
|
||||||
io.MouseDown[1] = false;
|
|
||||||
return true;
|
|
||||||
case WM_MBUTTONDOWN:
|
case WM_MBUTTONDOWN:
|
||||||
io.MouseDown[2] = true;
|
{
|
||||||
return true;
|
int button = 0;
|
||||||
|
if (msg == WM_LBUTTONDOWN) button = 0;
|
||||||
|
if (msg == WM_RBUTTONDOWN) button = 1;
|
||||||
|
if (msg == WM_MBUTTONDOWN) button = 2;
|
||||||
|
if (!IsAnyMouseButtonDown() && GetCapture() == NULL)
|
||||||
|
SetCapture(hwnd);
|
||||||
|
io.MouseDown[button] = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
case WM_LBUTTONUP:
|
||||||
|
case WM_RBUTTONUP:
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
io.MouseDown[2] = false;
|
{
|
||||||
return true;
|
int button = 0;
|
||||||
|
if (msg == WM_LBUTTONUP) button = 0;
|
||||||
|
if (msg == WM_RBUTTONUP) button = 1;
|
||||||
|
if (msg == WM_MBUTTONUP) button = 2;
|
||||||
|
io.MouseDown[button] = false;
|
||||||
|
if (!IsAnyMouseButtonDown() && GetCapture() == hwnd)
|
||||||
|
ReleaseCapture();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
|
io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
|
||||||
return true;
|
return 0;
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
io.MousePos.x = (signed short)(lParam);
|
io.MousePos.x = (signed short)(lParam);
|
||||||
io.MousePos.y = (signed short)(lParam >> 16);
|
io.MousePos.y = (signed short)(lParam >> 16);
|
||||||
return true;
|
return 0;
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
|
case WM_SYSKEYDOWN:
|
||||||
if (wParam < 256)
|
if (wParam < 256)
|
||||||
io.KeysDown[wParam] = 1;
|
io.KeysDown[wParam] = 1;
|
||||||
return true;
|
return 0;
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
|
case WM_SYSKEYUP:
|
||||||
if (wParam < 256)
|
if (wParam < 256)
|
||||||
io.KeysDown[wParam] = 0;
|
io.KeysDown[wParam] = 0;
|
||||||
return true;
|
return 0;
|
||||||
case WM_CHAR:
|
case WM_CHAR:
|
||||||
// You can also use ToAscii()+GetKeyboardState() to retrieve characters.
|
// You can also use ToAscii()+GetKeyboardState() to retrieve characters.
|
||||||
if (wParam > 0 && wParam < 0x10000)
|
if (wParam > 0 && wParam < 0x10000)
|
||||||
io.AddInputCharacter((unsigned short)wParam);
|
io.AddInputCharacter((unsigned short)wParam);
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -572,10 +597,18 @@ void ImGui_ImplDX10_NewFrame()
|
|||||||
// io.MouseDown : filled by WM_*BUTTON* events
|
// io.MouseDown : filled by WM_*BUTTON* events
|
||||||
// io.MouseWheel : filled by WM_MOUSEWHEEL events
|
// io.MouseWheel : filled by WM_MOUSEWHEEL events
|
||||||
|
|
||||||
|
// Set OS mouse position if requested last frame by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
|
||||||
|
if (io.WantMoveMouse)
|
||||||
|
{
|
||||||
|
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
|
||||||
|
ClientToScreen(g_hWnd, &pos);
|
||||||
|
SetCursorPos(pos.x, pos.y);
|
||||||
|
}
|
||||||
|
|
||||||
// Hide OS mouse cursor if ImGui is drawing it
|
// Hide OS mouse cursor if ImGui is drawing it
|
||||||
if (io.MouseDrawCursor)
|
if (io.MouseDrawCursor)
|
||||||
SetCursor(NULL);
|
SetCursor(NULL);
|
||||||
|
|
||||||
// Start the frame
|
// Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
@ -20,5 +20,5 @@ IMGUI_API bool ImGui_ImplDX10_CreateDeviceObjects();
|
|||||||
// 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.
|
||||||
// Commented out to avoid dragging dependencies on <windows.h> types. You can copy the extern declaration in your code.
|
// Commented out to avoid dragging dependencies on <windows.h> types. You can copy the extern declaration in your code.
|
||||||
/*
|
/*
|
||||||
IMGUI_API LRESULT ImGui_ImplDX10_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
*/
|
*/
|
||||||
|
@ -27,7 +27,6 @@ void CreateRenderTarget()
|
|||||||
render_target_view_desc.ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2D;
|
render_target_view_desc.ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2D;
|
||||||
g_pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&pBackBuffer);
|
g_pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&pBackBuffer);
|
||||||
g_pd3dDevice->CreateRenderTargetView(pBackBuffer, &render_target_view_desc, &g_mainRenderTargetView);
|
g_pd3dDevice->CreateRenderTargetView(pBackBuffer, &render_target_view_desc, &g_mainRenderTargetView);
|
||||||
g_pd3dDevice->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL);
|
|
||||||
pBackBuffer->Release();
|
pBackBuffer->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,10 +73,10 @@ void CleanupDeviceD3D()
|
|||||||
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
|
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
|
||||||
}
|
}
|
||||||
|
|
||||||
extern LRESULT ImGui_ImplDX10_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (ImGui_ImplDX10_WndProcHandler(hWnd, msg, wParam, lParam))
|
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
switch (msg)
|
switch (msg)
|
||||||
@ -125,25 +124,39 @@ int main(int, char**)
|
|||||||
// Setup ImGui binding
|
// Setup ImGui binding
|
||||||
ImGui_ImplDX10_Init(hwnd, g_pd3dDevice);
|
ImGui_ImplDX10_Init(hwnd, g_pd3dDevice);
|
||||||
|
|
||||||
|
// Setup style
|
||||||
|
ImGui::StyleColorsClassic();
|
||||||
|
//ImGui::StyleColorsDark();
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
|
// - 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 'extra_fonts/README.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 \\ !
|
||||||
//ImGuiIO& io = ImGui::GetIO();
|
//ImGuiIO& io = ImGui::GetIO();
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
||||||
//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);
|
||||||
|
|
||||||
bool show_test_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_col = ImColor(114, 144, 154);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
MSG msg;
|
MSG msg;
|
||||||
ZeroMemory(&msg, sizeof(msg));
|
ZeroMemory(&msg, sizeof(msg));
|
||||||
while (msg.message != WM_QUIT)
|
while (msg.message != WM_QUIT)
|
||||||
{
|
{
|
||||||
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||||
|
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||||
|
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
||||||
|
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||||
if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
|
if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
|
||||||
{
|
{
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
@ -152,36 +165,38 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
ImGui_ImplDX10_NewFrame();
|
ImGui_ImplDX10_NewFrame();
|
||||||
|
|
||||||
// 1. Show a simple window
|
// 1. Show a simple window.
|
||||||
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
|
||||||
{
|
{
|
||||||
static float f = 0.0f;
|
static float f = 0.0f;
|
||||||
ImGui::Text("Hello, world!");
|
ImGui::Text("Hello, world!"); // Some text (you can use a format string too)
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float as a slider from 0.0f to 1.0f
|
||||||
ImGui::ColorEdit3("clear color", (float*)&clear_col);
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats as a color
|
||||||
if (ImGui::Button("Test Window")) show_test_window ^= 1;
|
if (ImGui::Button("Demo Window")) // Use buttons to toggle our bools. We could use Checkbox() as well.
|
||||||
if (ImGui::Button("Another Window")) show_another_window ^= 1;
|
show_demo_window ^= 1;
|
||||||
|
if (ImGui::Button("Another Window"))
|
||||||
|
show_another_window ^= 1;
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Show another simple window, this time using an explicit Begin/End pair
|
// 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name the window.
|
||||||
if (show_another_window)
|
if (show_another_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiCond_FirstUseEver);
|
|
||||||
ImGui::Begin("Another Window", &show_another_window);
|
ImGui::Begin("Another Window", &show_another_window);
|
||||||
ImGui::Text("Hello");
|
ImGui::Text("Hello from another window!");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
|
// 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow().
|
||||||
if (show_test_window)
|
if (show_demo_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
||||||
ImGui::ShowTestWindow(&show_test_window);
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, (float*)&clear_col);
|
g_pd3dDevice->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL);
|
||||||
|
g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, (float*)&clear_color);
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
|
||||||
g_pSwapChain->Present(1, 0); // Present with vsync
|
g_pSwapChain->Present(1, 0); // Present with vsync
|
||||||
|
@ -232,49 +232,74 @@ void ImGui_ImplDX11_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release();
|
ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
IMGUI_API LRESULT ImGui_ImplDX11_WndProcHandler(HWND, UINT msg, WPARAM wParam, LPARAM lParam)
|
static bool IsAnyMouseButtonDown()
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
for (int n = 0; n < IM_ARRAYSIZE(io.MouseDown); n++)
|
||||||
|
if (io.MouseDown[n])
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process Win32 mouse/keyboard inputs.
|
||||||
|
// 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.
|
||||||
|
// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinations when dragging mouse outside of our window bounds.
|
||||||
|
IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
io.MouseDown[0] = true;
|
|
||||||
return true;
|
|
||||||
case WM_LBUTTONUP:
|
|
||||||
io.MouseDown[0] = false;
|
|
||||||
return true;
|
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
io.MouseDown[1] = true;
|
|
||||||
return true;
|
|
||||||
case WM_RBUTTONUP:
|
|
||||||
io.MouseDown[1] = false;
|
|
||||||
return true;
|
|
||||||
case WM_MBUTTONDOWN:
|
case WM_MBUTTONDOWN:
|
||||||
io.MouseDown[2] = true;
|
{
|
||||||
return true;
|
int button = 0;
|
||||||
|
if (msg == WM_LBUTTONDOWN) button = 0;
|
||||||
|
if (msg == WM_RBUTTONDOWN) button = 1;
|
||||||
|
if (msg == WM_MBUTTONDOWN) button = 2;
|
||||||
|
if (!IsAnyMouseButtonDown() && GetCapture() == NULL)
|
||||||
|
SetCapture(hwnd);
|
||||||
|
io.MouseDown[button] = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
case WM_LBUTTONUP:
|
||||||
|
case WM_RBUTTONUP:
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
io.MouseDown[2] = false;
|
{
|
||||||
return true;
|
int button = 0;
|
||||||
|
if (msg == WM_LBUTTONUP) button = 0;
|
||||||
|
if (msg == WM_RBUTTONUP) button = 1;
|
||||||
|
if (msg == WM_MBUTTONUP) button = 2;
|
||||||
|
io.MouseDown[button] = false;
|
||||||
|
if (!IsAnyMouseButtonDown() && GetCapture() == hwnd)
|
||||||
|
ReleaseCapture();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
|
io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
|
||||||
return true;
|
return 0;
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
io.MousePos.x = (signed short)(lParam);
|
io.MousePos.x = (signed short)(lParam);
|
||||||
io.MousePos.y = (signed short)(lParam >> 16);
|
io.MousePos.y = (signed short)(lParam >> 16);
|
||||||
return true;
|
return 0;
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
|
case WM_SYSKEYDOWN:
|
||||||
if (wParam < 256)
|
if (wParam < 256)
|
||||||
io.KeysDown[wParam] = 1;
|
io.KeysDown[wParam] = 1;
|
||||||
return true;
|
return 0;
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
|
case WM_SYSKEYUP:
|
||||||
if (wParam < 256)
|
if (wParam < 256)
|
||||||
io.KeysDown[wParam] = 0;
|
io.KeysDown[wParam] = 0;
|
||||||
return true;
|
return 0;
|
||||||
case WM_CHAR:
|
case WM_CHAR:
|
||||||
// You can also use ToAscii()+GetKeyboardState() to retrieve characters.
|
// You can also use ToAscii()+GetKeyboardState() to retrieve characters.
|
||||||
if (wParam > 0 && wParam < 0x10000)
|
if (wParam > 0 && wParam < 0x10000)
|
||||||
io.AddInputCharacter((unsigned short)wParam);
|
io.AddInputCharacter((unsigned short)wParam);
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -575,10 +600,18 @@ void ImGui_ImplDX11_NewFrame()
|
|||||||
// io.MouseDown : filled by WM_*BUTTON* events
|
// io.MouseDown : filled by WM_*BUTTON* events
|
||||||
// io.MouseWheel : filled by WM_MOUSEWHEEL events
|
// io.MouseWheel : filled by WM_MOUSEWHEEL events
|
||||||
|
|
||||||
|
// Set OS mouse position if requested last frame by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
|
||||||
|
if (io.WantMoveMouse)
|
||||||
|
{
|
||||||
|
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
|
||||||
|
ClientToScreen(g_hWnd, &pos);
|
||||||
|
SetCursorPos(pos.x, pos.y);
|
||||||
|
}
|
||||||
|
|
||||||
// Hide OS mouse cursor if ImGui is drawing it
|
// Hide OS mouse cursor if ImGui is drawing it
|
||||||
if (io.MouseDrawCursor)
|
if (io.MouseDrawCursor)
|
||||||
SetCursor(NULL);
|
SetCursor(NULL);
|
||||||
|
|
||||||
// Start the frame
|
// Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
@ -21,5 +21,5 @@ IMGUI_API bool ImGui_ImplDX11_CreateDeviceObjects();
|
|||||||
// 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.
|
||||||
// Commented out to avoid dragging dependencies on <windows.h> types. You can copy the extern declaration in your code.
|
// Commented out to avoid dragging dependencies on <windows.h> types. You can copy the extern declaration in your code.
|
||||||
/*
|
/*
|
||||||
IMGUI_API LRESULT ImGui_ImplDX11_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
*/
|
*/
|
||||||
|
@ -27,7 +27,6 @@ void CreateRenderTarget()
|
|||||||
render_target_view_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
render_target_view_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||||
g_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer);
|
g_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer);
|
||||||
g_pd3dDevice->CreateRenderTargetView(pBackBuffer, &render_target_view_desc, &g_mainRenderTargetView);
|
g_pd3dDevice->CreateRenderTargetView(pBackBuffer, &render_target_view_desc, &g_mainRenderTargetView);
|
||||||
g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL);
|
|
||||||
pBackBuffer->Release();
|
pBackBuffer->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,8 +59,8 @@ HRESULT CreateDeviceD3D(HWND hWnd)
|
|||||||
UINT createDeviceFlags = 0;
|
UINT createDeviceFlags = 0;
|
||||||
//createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
//createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||||
D3D_FEATURE_LEVEL featureLevel;
|
D3D_FEATURE_LEVEL featureLevel;
|
||||||
const D3D_FEATURE_LEVEL featureLevelArray[1] = { D3D_FEATURE_LEVEL_11_0, };
|
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, 1, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext) != S_OK)
|
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 E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
CreateRenderTarget();
|
CreateRenderTarget();
|
||||||
@ -77,10 +76,10 @@ void CleanupDeviceD3D()
|
|||||||
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
|
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
|
||||||
}
|
}
|
||||||
|
|
||||||
extern LRESULT ImGui_ImplDX11_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (ImGui_ImplDX11_WndProcHandler(hWnd, msg, wParam, lParam))
|
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
switch (msg)
|
switch (msg)
|
||||||
@ -128,25 +127,39 @@ int main(int, char**)
|
|||||||
// Setup ImGui binding
|
// Setup ImGui binding
|
||||||
ImGui_ImplDX11_Init(hwnd, g_pd3dDevice, g_pd3dDeviceContext);
|
ImGui_ImplDX11_Init(hwnd, g_pd3dDevice, g_pd3dDeviceContext);
|
||||||
|
|
||||||
|
// Setup style
|
||||||
|
ImGui::StyleColorsClassic();
|
||||||
|
//ImGui::StyleColorsDark();
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
|
// - 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 'extra_fonts/README.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 \\ !
|
||||||
//ImGuiIO& io = ImGui::GetIO();
|
//ImGuiIO& io = ImGui::GetIO();
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
||||||
//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);
|
||||||
|
|
||||||
bool show_test_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_col = ImColor(114, 144, 154);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
MSG msg;
|
MSG msg;
|
||||||
ZeroMemory(&msg, sizeof(msg));
|
ZeroMemory(&msg, sizeof(msg));
|
||||||
while (msg.message != WM_QUIT)
|
while (msg.message != WM_QUIT)
|
||||||
{
|
{
|
||||||
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||||
|
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||||
|
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
||||||
|
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||||
if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
|
if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
|
||||||
{
|
{
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
@ -155,36 +168,38 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
ImGui_ImplDX11_NewFrame();
|
ImGui_ImplDX11_NewFrame();
|
||||||
|
|
||||||
// 1. Show a simple window
|
// 1. Show a simple window.
|
||||||
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
|
||||||
{
|
{
|
||||||
static float f = 0.0f;
|
static float f = 0.0f;
|
||||||
ImGui::Text("Hello, world!");
|
ImGui::Text("Hello, world!"); // Some text (you can use a format string too)
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float as a slider from 0.0f to 1.0f
|
||||||
ImGui::ColorEdit3("clear color", (float*)&clear_col);
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats as a color
|
||||||
if (ImGui::Button("Test Window")) show_test_window ^= 1;
|
if (ImGui::Button("Demo Window")) // Use buttons to toggle our bools. We could use Checkbox() as well.
|
||||||
if (ImGui::Button("Another Window")) show_another_window ^= 1;
|
show_demo_window ^= 1;
|
||||||
|
if (ImGui::Button("Another Window"))
|
||||||
|
show_another_window ^= 1;
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Show another simple window, this time using an explicit Begin/End pair
|
// 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name the window.
|
||||||
if (show_another_window)
|
if (show_another_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiCond_FirstUseEver);
|
|
||||||
ImGui::Begin("Another Window", &show_another_window);
|
ImGui::Begin("Another Window", &show_another_window);
|
||||||
ImGui::Text("Hello");
|
ImGui::Text("Hello from another window!");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
|
// 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow().
|
||||||
if (show_test_window)
|
if (show_demo_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
||||||
ImGui::ShowTestWindow(&show_test_window);
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, (float*)&clear_col);
|
g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL);
|
||||||
|
g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, (float*)&clear_color);
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
|
||||||
g_pSwapChain->Present(1, 0); // Present with vsync
|
g_pSwapChain->Present(1, 0); // Present with vsync
|
||||||
|
@ -171,49 +171,74 @@ void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
d3d9_state_block->Release();
|
d3d9_state_block->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
IMGUI_API LRESULT ImGui_ImplDX9_WndProcHandler(HWND, UINT msg, WPARAM wParam, LPARAM lParam)
|
static bool IsAnyMouseButtonDown()
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
for (int n = 0; n < IM_ARRAYSIZE(io.MouseDown); n++)
|
||||||
|
if (io.MouseDown[n])
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process Win32 mouse/keyboard inputs.
|
||||||
|
// 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.
|
||||||
|
// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinations when dragging mouse outside of our window bounds.
|
||||||
|
IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
io.MouseDown[0] = true;
|
|
||||||
return true;
|
|
||||||
case WM_LBUTTONUP:
|
|
||||||
io.MouseDown[0] = false;
|
|
||||||
return true;
|
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
io.MouseDown[1] = true;
|
|
||||||
return true;
|
|
||||||
case WM_RBUTTONUP:
|
|
||||||
io.MouseDown[1] = false;
|
|
||||||
return true;
|
|
||||||
case WM_MBUTTONDOWN:
|
case WM_MBUTTONDOWN:
|
||||||
io.MouseDown[2] = true;
|
{
|
||||||
return true;
|
int button = 0;
|
||||||
|
if (msg == WM_LBUTTONDOWN) button = 0;
|
||||||
|
if (msg == WM_RBUTTONDOWN) button = 1;
|
||||||
|
if (msg == WM_MBUTTONDOWN) button = 2;
|
||||||
|
if (!IsAnyMouseButtonDown() && GetCapture() == NULL)
|
||||||
|
SetCapture(hwnd);
|
||||||
|
io.MouseDown[button] = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
case WM_LBUTTONUP:
|
||||||
|
case WM_RBUTTONUP:
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
io.MouseDown[2] = false;
|
{
|
||||||
return true;
|
int button = 0;
|
||||||
|
if (msg == WM_LBUTTONUP) button = 0;
|
||||||
|
if (msg == WM_RBUTTONUP) button = 1;
|
||||||
|
if (msg == WM_MBUTTONUP) button = 2;
|
||||||
|
io.MouseDown[button] = false;
|
||||||
|
if (!IsAnyMouseButtonDown() && GetCapture() == hwnd)
|
||||||
|
ReleaseCapture();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
|
io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
|
||||||
return true;
|
return 0;
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
io.MousePos.x = (signed short)(lParam);
|
io.MousePos.x = (signed short)(lParam);
|
||||||
io.MousePos.y = (signed short)(lParam >> 16);
|
io.MousePos.y = (signed short)(lParam >> 16);
|
||||||
return true;
|
return 0;
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
|
case WM_SYSKEYDOWN:
|
||||||
if (wParam < 256)
|
if (wParam < 256)
|
||||||
io.KeysDown[wParam] = 1;
|
io.KeysDown[wParam] = 1;
|
||||||
return true;
|
return 0;
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
|
case WM_SYSKEYUP:
|
||||||
if (wParam < 256)
|
if (wParam < 256)
|
||||||
io.KeysDown[wParam] = 0;
|
io.KeysDown[wParam] = 0;
|
||||||
return true;
|
return 0;
|
||||||
case WM_CHAR:
|
case WM_CHAR:
|
||||||
// You can also use ToAscii()+GetKeyboardState() to retrieve characters.
|
// You can also use ToAscii()+GetKeyboardState() to retrieve characters.
|
||||||
if (wParam > 0 && wParam < 0x10000)
|
if (wParam > 0 && wParam < 0x10000)
|
||||||
io.AddInputCharacter((unsigned short)wParam);
|
io.AddInputCharacter((unsigned short)wParam);
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -349,10 +374,18 @@ void ImGui_ImplDX9_NewFrame()
|
|||||||
// io.MouseDown : filled by WM_*BUTTON* events
|
// io.MouseDown : filled by WM_*BUTTON* events
|
||||||
// io.MouseWheel : filled by WM_MOUSEWHEEL events
|
// io.MouseWheel : filled by WM_MOUSEWHEEL events
|
||||||
|
|
||||||
|
// Set OS mouse position if requested last frame by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
|
||||||
|
if (io.WantMoveMouse)
|
||||||
|
{
|
||||||
|
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
|
||||||
|
ClientToScreen(g_hWnd, &pos);
|
||||||
|
SetCursorPos(pos.x, pos.y);
|
||||||
|
}
|
||||||
|
|
||||||
// Hide OS mouse cursor if ImGui is drawing it
|
// Hide OS mouse cursor if ImGui is drawing it
|
||||||
if (io.MouseDrawCursor)
|
if (io.MouseDrawCursor)
|
||||||
SetCursor(NULL);
|
SetCursor(NULL);
|
||||||
|
|
||||||
// Start the frame
|
// Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
@ -20,5 +20,5 @@ IMGUI_API bool ImGui_ImplDX9_CreateDeviceObjects();
|
|||||||
// 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.
|
||||||
// Commented out to avoid dragging dependencies on <windows.h> types. You can copy the extern declaration in your code.
|
// Commented out to avoid dragging dependencies on <windows.h> types. You can copy the extern declaration in your code.
|
||||||
/*
|
/*
|
||||||
IMGUI_API LRESULT ImGui_ImplDX9_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
IMGUI_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
*/
|
*/
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
|
static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
|
||||||
static D3DPRESENT_PARAMETERS g_d3dpp;
|
static D3DPRESENT_PARAMETERS g_d3dpp;
|
||||||
|
|
||||||
extern LRESULT ImGui_ImplDX9_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (ImGui_ImplDX9_WndProcHandler(hWnd, msg, wParam, lParam))
|
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
switch (msg)
|
switch (msg)
|
||||||
@ -77,19 +77,29 @@ int main(int, char**)
|
|||||||
// Setup ImGui binding
|
// Setup ImGui binding
|
||||||
ImGui_ImplDX9_Init(hwnd, g_pd3dDevice);
|
ImGui_ImplDX9_Init(hwnd, g_pd3dDevice);
|
||||||
|
|
||||||
|
// Setup style
|
||||||
|
ImGui::StyleColorsClassic();
|
||||||
|
//ImGui::StyleColorsDark();
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
|
// - 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 'extra_fonts/README.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 \\ !
|
||||||
//ImGuiIO& io = ImGui::GetIO();
|
//ImGuiIO& io = ImGui::GetIO();
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
||||||
//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);
|
||||||
|
|
||||||
bool show_test_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_col = ImColor(114, 144, 154);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
MSG msg;
|
MSG msg;
|
||||||
@ -98,6 +108,10 @@ int main(int, char**)
|
|||||||
UpdateWindow(hwnd);
|
UpdateWindow(hwnd);
|
||||||
while (msg.message != WM_QUIT)
|
while (msg.message != WM_QUIT)
|
||||||
{
|
{
|
||||||
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||||
|
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||||
|
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
||||||
|
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||||
if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
|
if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
|
||||||
{
|
{
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
@ -106,46 +120,56 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
ImGui_ImplDX9_NewFrame();
|
ImGui_ImplDX9_NewFrame();
|
||||||
|
|
||||||
// 1. Show a simple window
|
// 1. Show a simple window.
|
||||||
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
|
||||||
{
|
{
|
||||||
static float f = 0.0f;
|
static float f = 0.0f;
|
||||||
ImGui::Text("Hello, world!");
|
ImGui::Text("Hello, world!"); // Some text (you can use a format string too)
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float as a slider from 0.0f to 1.0f
|
||||||
ImGui::ColorEdit3("clear color", (float*)&clear_col);
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats as a color
|
||||||
if (ImGui::Button("Test Window")) show_test_window ^= 1;
|
if (ImGui::Button("Demo Window")) // Use buttons to toggle our bools. We could use Checkbox() as well.
|
||||||
if (ImGui::Button("Another Window")) show_another_window ^= 1;
|
show_demo_window ^= 1;
|
||||||
|
if (ImGui::Button("Another Window"))
|
||||||
|
show_another_window ^= 1;
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Show another simple window, this time using an explicit Begin/End pair
|
// 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name the window.
|
||||||
if (show_another_window)
|
if (show_another_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiCond_FirstUseEver);
|
|
||||||
ImGui::Begin("Another Window", &show_another_window);
|
ImGui::Begin("Another Window", &show_another_window);
|
||||||
ImGui::Text("Hello");
|
ImGui::Text("Hello from another window!");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
|
// 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow().
|
||||||
if (show_test_window)
|
if (show_demo_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
||||||
ImGui::ShowTestWindow(&show_test_window);
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
|
ImGui::EndFrame();
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, false);
|
g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, false);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
|
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, false);
|
g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, false);
|
||||||
D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_col.x*255.0f), (int)(clear_col.y*255.0f), (int)(clear_col.z*255.0f), (int)(clear_col.w*255.0f));
|
D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_color.x*255.0f), (int)(clear_color.y*255.0f), (int)(clear_color.z*255.0f), (int)(clear_color.w*255.0f));
|
||||||
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, clear_col_dx, 1.0f, 0);
|
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, clear_col_dx, 1.0f, 0);
|
||||||
if (g_pd3dDevice->BeginScene() >= 0)
|
if (g_pd3dDevice->BeginScene() >= 0)
|
||||||
{
|
{
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
g_pd3dDevice->EndScene();
|
g_pd3dDevice->EndScene();
|
||||||
}
|
}
|
||||||
g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
|
HRESULT result = g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
// Handle loss of D3D9 device
|
||||||
|
if (result == D3DERR_DEVICELOST && g_pd3dDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX9_InvalidateDeviceObjects();
|
||||||
|
g_pd3dDevice->Reset(&g_d3dpp);
|
||||||
|
ImGui_ImplDX9_CreateDeviceObjects();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplDX9_Shutdown();
|
ImGui_ImplDX9_Shutdown();
|
||||||
|
@ -27,7 +27,7 @@ static char* g_ClipboardText = NULL;
|
|||||||
static bool g_osdKeyboardEnabled = false;
|
static bool g_osdKeyboardEnabled = false;
|
||||||
|
|
||||||
// use this setting to scale the interface - e.g. on device you could use 2 or 3 scale factor
|
// use this setting to scale the interface - e.g. on device you could use 2 or 3 scale factor
|
||||||
static ImVec2 g_scale = ImVec2(1.0f,1.0f);
|
static ImVec2 g_RenderScale = ImVec2(1.0f,1.0f);
|
||||||
|
|
||||||
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
|
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
|
||||||
void ImGui_Marmalade_RenderDrawLists(ImDrawData* draw_data)
|
void ImGui_Marmalade_RenderDrawLists(ImDrawData* draw_data)
|
||||||
@ -48,9 +48,9 @@ void ImGui_Marmalade_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
|
|
||||||
for( int i=0; i < nVert; i++ )
|
for( int i=0; i < nVert; i++ )
|
||||||
{
|
{
|
||||||
// TODO: optimize multiplication on gpu using vertex shader
|
// TODO: optimize multiplication on gpu using vertex shader/projection matrix.
|
||||||
pVertStream[i].x = cmd_list->VtxBuffer[i].pos.x * g_scale.x;
|
pVertStream[i].x = cmd_list->VtxBuffer[i].pos.x * g_RenderScale.x;
|
||||||
pVertStream[i].y = cmd_list->VtxBuffer[i].pos.y * g_scale.y;
|
pVertStream[i].y = cmd_list->VtxBuffer[i].pos.y * g_RenderScale.y;
|
||||||
pUVStream[i].x = cmd_list->VtxBuffer[i].uv.x;
|
pUVStream[i].x = cmd_list->VtxBuffer[i].uv.x;
|
||||||
pUVStream[i].y = cmd_list->VtxBuffer[i].uv.y;
|
pUVStream[i].y = cmd_list->VtxBuffer[i].uv.y;
|
||||||
pColStream[i] = cmd_list->VtxBuffer[i].col;
|
pColStream[i] = cmd_list->VtxBuffer[i].col;
|
||||||
@ -287,7 +287,7 @@ void ImGui_Marmalade_NewFrame()
|
|||||||
// TODO: Hide OS mouse cursor if ImGui is drawing it
|
// TODO: Hide OS mouse cursor if ImGui is drawing it
|
||||||
// s3ePointerSetInt(S3E_POINTER_HIDE_CURSOR,(io.MouseDrawCursor ? 0 : 1));
|
// s3ePointerSetInt(S3E_POINTER_HIDE_CURSOR,(io.MouseDrawCursor ? 0 : 1));
|
||||||
|
|
||||||
// Start the frame
|
// Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
// Show/hide OSD keyboard
|
// Show/hide OSD keyboard
|
||||||
|
@ -17,60 +17,75 @@ int main(int, char**)
|
|||||||
// Setup ImGui binding
|
// Setup ImGui binding
|
||||||
ImGui_Marmalade_Init(true);
|
ImGui_Marmalade_Init(true);
|
||||||
|
|
||||||
|
// Setup style
|
||||||
|
ImGui::StyleColorsClassic();
|
||||||
|
//ImGui::StyleColorsDark();
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
|
// - 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 'extra_fonts/README.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 \\ !
|
||||||
//ImGuiIO& io = ImGui::GetIO();
|
//ImGuiIO& io = ImGui::GetIO();
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
||||||
//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);
|
||||||
|
|
||||||
bool show_test_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_color = ImColor(114, 144, 154);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (s3eDeviceCheckQuitRequest())
|
if (s3eDeviceCheckQuitRequest())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
s3eKeyboardUpdate();
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||||
s3ePointerUpdate();
|
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||||
ImGui_Marmalade_NewFrame();
|
// - 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.
|
||||||
|
s3eKeyboardUpdate();
|
||||||
|
s3ePointerUpdate();
|
||||||
|
ImGui_Marmalade_NewFrame();
|
||||||
|
|
||||||
// 1. Show a simple window
|
// 1. Show a simple window.
|
||||||
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
|
||||||
{
|
{
|
||||||
static float f = 0.0f;
|
static float f = 0.0f;
|
||||||
ImGui::Text("Hello, world!");
|
ImGui::Text("Hello, world!"); // Some text (you can use a format string too)
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float as a slider from 0.0f to 1.0f
|
||||||
ImGui::ColorEdit3("clear color", (float*)&clear_color);
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats as a color
|
||||||
if (ImGui::Button("Test Window")) show_test_window ^= 1;
|
if (ImGui::Button("Demo Window")) // Use buttons to toggle our bools. We could use Checkbox() as well.
|
||||||
if (ImGui::Button("Another Window")) show_another_window ^= 1;
|
show_demo_window ^= 1;
|
||||||
|
if (ImGui::Button("Another Window"))
|
||||||
|
show_another_window ^= 1;
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Show another simple window, this time using an explicit Begin/End pair
|
// 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name the window.
|
||||||
if (show_another_window)
|
if (show_another_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiCond_FirstUseEver);
|
|
||||||
ImGui::Begin("Another Window", &show_another_window);
|
ImGui::Begin("Another Window", &show_another_window);
|
||||||
ImGui::Text("Hello");
|
ImGui::Text("Hello from another window!");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
|
// 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow().
|
||||||
if (show_test_window)
|
if (show_demo_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
||||||
ImGui::ShowTestWindow(&show_test_window);
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
IwGxSetColClear(clear_color.x*255,clear_color.y*255,clear_color.z*255,clear_color.w*255) ;
|
IwGxSetColClear(clear_color.x * 255, clear_color.y * 255, clear_color.z * 255, clear_color.w * 255);
|
||||||
IwGxClear();
|
IwGxClear();
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
IwGxSwapBuffers();
|
IwGxSwapBuffers();
|
||||||
|
3
examples/null_example/build_win32.bat
Normal file
3
examples/null_example/build_win32.bat
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
|
||||||
|
mkdir Debug
|
||||||
|
cl /nologo /Zi /MD /I ..\.. *.cpp ..\..\*.cpp /FeDebug/null_example.exe /FoDebug/ /link gdi32.lib shell32.lib
|
33
examples/null_example/main.cpp
Normal file
33
examples/null_example/main.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// ImGui - null/dummy example application (compile and link imgui with no inputs, no outputs)
|
||||||
|
#include <imgui.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
// Build atlas
|
||||||
|
unsigned char* tex_pixels = NULL;
|
||||||
|
int tex_w, tex_h;
|
||||||
|
io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_w, &tex_h);
|
||||||
|
|
||||||
|
for (int n = 0; n < 50; n++)
|
||||||
|
{
|
||||||
|
printf("NewFrame() %d\n", n);
|
||||||
|
io.DisplaySize = ImVec2(1920, 1080);
|
||||||
|
io.DeltaTime = 1.0f / 60.0f;
|
||||||
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
static float f = 0.0f;
|
||||||
|
ImGui::Text("Hello, world!");
|
||||||
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
||||||
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
||||||
|
ImGui::ShowDemoWindow(NULL);
|
||||||
|
|
||||||
|
ImGui::Render();
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Shutdown()\n");
|
||||||
|
ImGui::Shutdown();
|
||||||
|
return 0;
|
||||||
|
}
|
@ -1,10 +1,14 @@
|
|||||||
// ImGui GLFW binding with OpenGL
|
// ImGui GLFW binding with OpenGL (legacy, fixed pipeline)
|
||||||
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||||
|
|
||||||
// If your context or own usage of OpenGL involve anything GL3/GL4, prefer using the code in opengl3_example.
|
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
// If you are not sure what that means, prefer using the code in opengl3_example.
|
// **Prefer using the code in the opengl3_example/ folder**
|
||||||
// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
|
// This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read.
|
||||||
// We cannot do that from GL2 code because the function doesn't exist. Mixing GL2 calls and GL3/GL4 calls is giving trouble to many librairies/drivers.
|
// If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more
|
||||||
|
// complicated, will require your code to reset every single OpenGL attributes to their initial state, and might
|
||||||
|
// confuse your GPU driver.
|
||||||
|
// The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API.
|
||||||
|
|
||||||
// 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 use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
@ -26,14 +30,14 @@
|
|||||||
// Data
|
// Data
|
||||||
static GLFWwindow* g_Window = NULL;
|
static GLFWwindow* g_Window = NULL;
|
||||||
static double g_Time = 0.0f;
|
static double g_Time = 0.0f;
|
||||||
static bool g_MousePressed[3] = { false, false, false };
|
static bool g_MouseJustPressed[3] = { false, false, false };
|
||||||
static float g_MouseWheel = 0.0f;
|
static float g_MouseWheel = 0.0f;
|
||||||
static GLuint g_FontTexture = 0;
|
static GLuint g_FontTexture = 0;
|
||||||
|
|
||||||
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
|
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
|
||||||
// If text or lines are blurry when integrating ImGui in your engine:
|
void ImGui_ImplGlfwGL2_RenderDrawLists(ImDrawData* draw_data)
|
||||||
// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
|
||||||
void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
|
// If text or lines are blurry when integrating ImGui in your engine: in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@ -44,8 +48,9 @@ void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
||||||
|
|
||||||
// We are using the OpenGL fixed pipeline to make the example code simpler to read!
|
// We are using the OpenGL fixed pipeline to make the example code simpler to read!
|
||||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
|
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill.
|
||||||
GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
|
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);
|
||||||
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
|
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
|
||||||
@ -58,6 +63,7 @@ void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
//glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound
|
//glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound
|
||||||
|
|
||||||
// Setup viewport, orthographic projection matrix
|
// Setup viewport, orthographic projection matrix
|
||||||
@ -109,32 +115,33 @@ void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
|
glPolygonMode(GL_FRONT, last_polygon_mode[0]); glPolygonMode(GL_BACK, 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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* ImGui_ImplGlfw_GetClipboardText(void* user_data)
|
static const char* ImGui_ImplGlfwGL2_GetClipboardText(void* user_data)
|
||||||
{
|
{
|
||||||
return glfwGetClipboardString((GLFWwindow*)user_data);
|
return glfwGetClipboardString((GLFWwindow*)user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplGlfw_SetClipboardText(void* user_data, const char* text)
|
static void ImGui_ImplGlfwGL2_SetClipboardText(void* user_data, const char* text)
|
||||||
{
|
{
|
||||||
glfwSetClipboardString((GLFWwindow*)user_data, text);
|
glfwSetClipboardString((GLFWwindow*)user_data, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
|
void ImGui_ImplGlfwGL2_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
|
||||||
{
|
{
|
||||||
if (action == GLFW_PRESS && button >= 0 && button < 3)
|
if (action == GLFW_PRESS && button >= 0 && button < 3)
|
||||||
g_MousePressed[button] = true;
|
g_MouseJustPressed[button] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
|
void ImGui_ImplGlfwGL2_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
|
||||||
{
|
{
|
||||||
g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
|
g_MouseWheel += (float)yoffset; // Use fractional mouse wheel.
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
|
void ImGui_ImplGlfwGL2_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
if (action == GLFW_PRESS)
|
if (action == GLFW_PRESS)
|
||||||
@ -149,14 +156,14 @@ void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
|
|||||||
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];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
|
void ImGui_ImplGlfwGL2_CharCallback(GLFWwindow*, unsigned int c)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
if (c > 0 && c < 0x10000)
|
if (c > 0 && c < 0x10000)
|
||||||
io.AddInputCharacter((unsigned short)c);
|
io.AddInputCharacter((unsigned short)c);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplGlfw_CreateDeviceObjects()
|
bool ImGui_ImplGlfwGL2_CreateDeviceObjects()
|
||||||
{
|
{
|
||||||
// Build texture atlas
|
// Build texture atlas
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@ -182,7 +189,7 @@ bool ImGui_ImplGlfw_CreateDeviceObjects()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_InvalidateDeviceObjects()
|
void ImGui_ImplGlfwGL2_InvalidateDeviceObjects()
|
||||||
{
|
{
|
||||||
if (g_FontTexture)
|
if (g_FontTexture)
|
||||||
{
|
{
|
||||||
@ -192,7 +199,7 @@ void ImGui_ImplGlfw_InvalidateDeviceObjects()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
|
bool ImGui_ImplGlfwGL2_Init(GLFWwindow* window, bool install_callbacks)
|
||||||
{
|
{
|
||||||
g_Window = window;
|
g_Window = window;
|
||||||
|
|
||||||
@ -217,9 +224,9 @@ bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
|
|||||||
io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
|
io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
|
||||||
io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
|
io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
|
||||||
|
|
||||||
io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
|
io.RenderDrawListsFn = ImGui_ImplGlfwGL2_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
|
||||||
io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
|
io.SetClipboardTextFn = ImGui_ImplGlfwGL2_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
|
io.GetClipboardTextFn = ImGui_ImplGlfwGL2_GetClipboardText;
|
||||||
io.ClipboardUserData = g_Window;
|
io.ClipboardUserData = g_Window;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
io.ImeWindowHandle = glfwGetWin32Window(g_Window);
|
io.ImeWindowHandle = glfwGetWin32Window(g_Window);
|
||||||
@ -227,25 +234,25 @@ bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
|
|||||||
|
|
||||||
if (install_callbacks)
|
if (install_callbacks)
|
||||||
{
|
{
|
||||||
glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
|
glfwSetMouseButtonCallback(window, ImGui_ImplGlfwGL2_MouseButtonCallback);
|
||||||
glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
|
glfwSetScrollCallback(window, ImGui_ImplGlfwGL2_ScrollCallback);
|
||||||
glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
|
glfwSetKeyCallback(window, ImGui_ImplGlfwGL2_KeyCallback);
|
||||||
glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
|
glfwSetCharCallback(window, ImGui_ImplGlfwGL2_CharCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_Shutdown()
|
void ImGui_ImplGlfwGL2_Shutdown()
|
||||||
{
|
{
|
||||||
ImGui_ImplGlfw_InvalidateDeviceObjects();
|
ImGui_ImplGlfwGL2_InvalidateDeviceObjects();
|
||||||
ImGui::Shutdown();
|
ImGui::Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_NewFrame()
|
void ImGui_ImplGlfwGL2_NewFrame()
|
||||||
{
|
{
|
||||||
if (!g_FontTexture)
|
if (!g_FontTexture)
|
||||||
ImGui_ImplGlfw_CreateDeviceObjects();
|
ImGui_ImplGlfwGL2_CreateDeviceObjects();
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
@ -266,19 +273,27 @@ void ImGui_ImplGlfw_NewFrame()
|
|||||||
// (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
|
// (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
|
||||||
if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
|
if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
|
||||||
{
|
{
|
||||||
double mouse_x, mouse_y;
|
if (io.WantMoveMouse)
|
||||||
glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
|
{
|
||||||
io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
|
glfwSetCursorPos(g_Window, (double)io.MousePos.x, (double)io.MousePos.y); // Set mouse position if requested by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double mouse_x, mouse_y;
|
||||||
|
glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
|
||||||
|
io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Get mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
io.MousePos = ImVec2(-1,-1);
|
io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
|
// If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
|
||||||
g_MousePressed[i] = false;
|
io.MouseDown[i] = g_MouseJustPressed[i] || glfwGetMouseButton(g_Window, i) != 0;
|
||||||
|
g_MouseJustPressed[i] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
io.MouseWheel = g_MouseWheel;
|
io.MouseWheel = g_MouseWheel;
|
||||||
@ -287,6 +302,6 @@ void ImGui_ImplGlfw_NewFrame()
|
|||||||
// Hide OS mouse cursor if ImGui is drawing it
|
// Hide OS mouse cursor if ImGui is drawing it
|
||||||
glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
|
glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
|
||||||
|
|
||||||
// Start the frame
|
// Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
// ImGui GLFW binding with OpenGL
|
// ImGui GLFW binding with OpenGL (legacy, fixed pipeline)
|
||||||
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||||
|
|
||||||
// If your context is GL3/GL3 then prefer using the code in opengl3_example.
|
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
|
// **Prefer using the code in the opengl3_example/ folder**
|
||||||
// We cannot do that from GL2 code because the function doesn't exist.
|
// See imgui_impl_glfw.cpp for details.
|
||||||
|
|
||||||
// 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 use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
@ -12,18 +13,17 @@
|
|||||||
|
|
||||||
struct GLFWwindow;
|
struct GLFWwindow;
|
||||||
|
|
||||||
IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
|
IMGUI_API bool ImGui_ImplGlfwGL2_Init(GLFWwindow* window, bool install_callbacks);
|
||||||
IMGUI_API void ImGui_ImplGlfw_Shutdown();
|
IMGUI_API void ImGui_ImplGlfwGL2_Shutdown();
|
||||||
IMGUI_API void ImGui_ImplGlfw_NewFrame();
|
IMGUI_API void ImGui_ImplGlfwGL2_NewFrame();
|
||||||
|
|
||||||
// Use if you want to reset your rendering device without losing ImGui state.
|
// Use if you want to reset your rendering device without losing ImGui state.
|
||||||
IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
|
IMGUI_API void ImGui_ImplGlfwGL2_InvalidateDeviceObjects();
|
||||||
IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
|
IMGUI_API bool ImGui_ImplGlfwGL2_CreateDeviceObjects();
|
||||||
|
|
||||||
// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
|
// GLFW callbacks (registered by default to GLFW if you enable 'install_callbacks' during initialization)
|
||||||
// Provided here if you want to chain callbacks.
|
// Provided here if you want to chain callbacks yourself. You may also handle inputs yourself and use those as a reference.
|
||||||
// You can also handle inputs yourself and use those as a reference.
|
IMGUI_API void ImGui_ImplGlfwGL2_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
|
||||||
IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
|
IMGUI_API void ImGui_ImplGlfwGL2_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
IMGUI_API void ImGui_ImplGlfwGL2_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||||
IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
IMGUI_API void ImGui_ImplGlfwGL2_CharCallback(GLFWwindow* window, unsigned int c);
|
||||||
IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
// ImGui - standalone example application for Glfw + OpenGL 2, using fixed pipeline
|
// ImGui - standalone example application for GLFW + OpenGL2, using legacy fixed pipeline
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||||
|
|
||||||
|
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
|
// **Prefer using the code in the opengl3_example/ folder**
|
||||||
|
// See imgui_impl_glfw.cpp for details.
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include "imgui_impl_glfw.h"
|
#include "imgui_impl_glfw.h"
|
||||||
@ -22,54 +27,69 @@ int main(int, char**)
|
|||||||
glfwSwapInterval(1); // Enable vsync
|
glfwSwapInterval(1); // Enable vsync
|
||||||
|
|
||||||
// Setup ImGui binding
|
// Setup ImGui binding
|
||||||
ImGui_ImplGlfw_Init(window, true);
|
ImGui_ImplGlfwGL2_Init(window, true);
|
||||||
|
|
||||||
|
// Setup style
|
||||||
|
ImGui::StyleColorsClassic();
|
||||||
|
//ImGui::StyleColorsDark();
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
|
// - 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 'extra_fonts/README.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 \\ !
|
||||||
//ImGuiIO& io = ImGui::GetIO();
|
//ImGuiIO& io = ImGui::GetIO();
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
||||||
//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);
|
||||||
|
|
||||||
bool show_test_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_color = ImColor(114, 144, 154);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
|
// 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();
|
glfwPollEvents();
|
||||||
ImGui_ImplGlfw_NewFrame();
|
ImGui_ImplGlfwGL2_NewFrame();
|
||||||
|
|
||||||
// 1. Show a simple window
|
// 1. Show a simple window.
|
||||||
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
|
||||||
{
|
{
|
||||||
static float f = 0.0f;
|
static float f = 0.0f;
|
||||||
ImGui::Text("Hello, world!");
|
ImGui::Text("Hello, world!"); // Some text (you can use a format string too)
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float as a slider from 0.0f to 1.0f
|
||||||
ImGui::ColorEdit3("clear color", (float*)&clear_color);
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats as a color
|
||||||
if (ImGui::Button("Test Window")) show_test_window ^= 1;
|
if (ImGui::Button("Demo Window")) // Use buttons to toggle our bools. We could use Checkbox() as well.
|
||||||
if (ImGui::Button("Another Window")) show_another_window ^= 1;
|
show_demo_window ^= 1;
|
||||||
|
if (ImGui::Button("Another Window"))
|
||||||
|
show_another_window ^= 1;
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Show another simple window, this time using an explicit Begin/End pair
|
// 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name the window.
|
||||||
if (show_another_window)
|
if (show_another_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiCond_FirstUseEver);
|
|
||||||
ImGui::Begin("Another Window", &show_another_window);
|
ImGui::Begin("Another Window", &show_another_window);
|
||||||
ImGui::Text("Hello");
|
ImGui::Text("Hello from another window!");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
|
// 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow().
|
||||||
if (show_test_window)
|
if (show_demo_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
||||||
ImGui::ShowTestWindow(&show_test_window);
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
@ -78,13 +98,13 @@ int main(int, char**)
|
|||||||
glViewport(0, 0, display_w, display_h);
|
glViewport(0, 0, display_w, display_h);
|
||||||
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
//glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound
|
//glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code.
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
ImGui_ImplGlfw_Shutdown();
|
ImGui_ImplGlfwGL2_Shutdown();
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
// ImGui GLFW binding with OpenGL3 + shaders
|
// ImGui GLFW binding with OpenGL3 + shaders
|
||||||
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||||
|
// (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.)
|
||||||
|
|
||||||
// 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 use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
@ -22,7 +24,7 @@
|
|||||||
// Data
|
// Data
|
||||||
static GLFWwindow* g_Window = NULL;
|
static GLFWwindow* g_Window = NULL;
|
||||||
static double g_Time = 0.0f;
|
static double g_Time = 0.0f;
|
||||||
static bool g_MousePressed[3] = { false, false, false };
|
static bool g_MouseJustPressed[3] = { false, false, false };
|
||||||
static float g_MouseWheel = 0.0f;
|
static float g_MouseWheel = 0.0f;
|
||||||
static GLuint g_FontTexture = 0;
|
static GLuint g_FontTexture = 0;
|
||||||
static int g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
|
static int g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
|
||||||
@ -31,8 +33,8 @@ static int g_AttribLocationPosition = 0, g_AttribLocationUV = 0, g_Attr
|
|||||||
static unsigned int g_VboHandle = 0, g_VaoHandle = 0, g_ElementsHandle = 0;
|
static unsigned int g_VboHandle = 0, g_VaoHandle = 0, g_ElementsHandle = 0;
|
||||||
|
|
||||||
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
|
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
|
||||||
// If text or lines are blurry when integrating ImGui in your engine:
|
// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
|
||||||
// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
// If text or lines are blurry when integrating ImGui in your engine: in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
||||||
void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||||
@ -48,9 +50,11 @@ void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
GLint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
|
GLint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
|
||||||
GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
|
GLint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, &last_sampler);
|
||||||
GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
||||||
GLint last_element_array_buffer; glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_element_array_buffer);
|
GLint last_element_array_buffer; glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_element_array_buffer);
|
||||||
GLint last_vertex_array; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
GLint last_vertex_array; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
||||||
|
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);
|
||||||
GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb);
|
GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb);
|
||||||
@ -64,13 +68,14 @@ void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
|
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
|
||||||
GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
|
GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled
|
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
|
|
||||||
// Setup viewport, orthographic projection matrix
|
// Setup viewport, orthographic projection matrix
|
||||||
glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
|
glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
|
||||||
@ -85,6 +90,7 @@ void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
glUniform1i(g_AttribLocationTex, 0);
|
glUniform1i(g_AttribLocationTex, 0);
|
||||||
glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
||||||
glBindVertexArray(g_VaoHandle);
|
glBindVertexArray(g_VaoHandle);
|
||||||
|
glBindSampler(0, 0); // Rely on combined texture/sampler state.
|
||||||
|
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
@ -117,6 +123,7 @@ void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
// Restore modified GL state
|
// Restore modified GL state
|
||||||
glUseProgram(last_program);
|
glUseProgram(last_program);
|
||||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
|
glBindSampler(0, last_sampler);
|
||||||
glActiveTexture(last_active_texture);
|
glActiveTexture(last_active_texture);
|
||||||
glBindVertexArray(last_vertex_array);
|
glBindVertexArray(last_vertex_array);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||||
@ -127,6 +134,7 @@ void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE);
|
if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE);
|
||||||
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
|
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
|
||||||
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
|
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, last_polygon_mode[0]);
|
||||||
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]);
|
||||||
}
|
}
|
||||||
@ -144,12 +152,12 @@ static void ImGui_ImplGlfwGL3_SetClipboardText(void* user_data, const char* text
|
|||||||
void ImGui_ImplGlfwGL3_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
|
void ImGui_ImplGlfwGL3_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
|
||||||
{
|
{
|
||||||
if (action == GLFW_PRESS && button >= 0 && button < 3)
|
if (action == GLFW_PRESS && button >= 0 && button < 3)
|
||||||
g_MousePressed[button] = true;
|
g_MouseJustPressed[button] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfwGL3_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
|
void ImGui_ImplGlfwGL3_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
|
||||||
{
|
{
|
||||||
g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
|
g_MouseWheel += (float)yoffset; // Use fractional mouse wheel.
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
|
void ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
|
||||||
@ -377,19 +385,27 @@ void ImGui_ImplGlfwGL3_NewFrame()
|
|||||||
// (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
|
// (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
|
||||||
if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
|
if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
|
||||||
{
|
{
|
||||||
double mouse_x, mouse_y;
|
if (io.WantMoveMouse)
|
||||||
glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
|
{
|
||||||
io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
|
glfwSetCursorPos(g_Window, (double)io.MousePos.x, (double)io.MousePos.y); // Set mouse position if requested by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double mouse_x, mouse_y;
|
||||||
|
glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
|
||||||
|
io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Get mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
io.MousePos = ImVec2(-1,-1);
|
io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
|
// If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
|
||||||
g_MousePressed[i] = false;
|
io.MouseDown[i] = g_MouseJustPressed[i] || glfwGetMouseButton(g_Window, i) != 0;
|
||||||
|
g_MouseJustPressed[i] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
io.MouseWheel = g_MouseWheel;
|
io.MouseWheel = g_MouseWheel;
|
||||||
@ -398,6 +414,6 @@ void ImGui_ImplGlfwGL3_NewFrame()
|
|||||||
// Hide OS mouse cursor if ImGui is drawing it
|
// Hide OS mouse cursor if ImGui is drawing it
|
||||||
glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
|
glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
|
||||||
|
|
||||||
// Start the frame
|
// Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
// ImGui GLFW binding with OpenGL3 + shaders
|
// ImGui GLFW binding with OpenGL3 + shaders
|
||||||
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||||
|
// (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.)
|
||||||
|
|
||||||
// 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 use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
// ImGui - standalone example application for Glfw + OpenGL 3, using programmable pipeline
|
// ImGui - standalone example application for GLFW + OpenGL 3, using programmable pipeline
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||||
|
// (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.)
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include "imgui_impl_glfw_gl3.h"
|
#include "imgui_impl_glfw_gl3.h"
|
||||||
@ -32,52 +34,67 @@ int main(int, char**)
|
|||||||
// Setup ImGui binding
|
// Setup ImGui binding
|
||||||
ImGui_ImplGlfwGL3_Init(window, true);
|
ImGui_ImplGlfwGL3_Init(window, true);
|
||||||
|
|
||||||
|
// Setup style
|
||||||
|
ImGui::StyleColorsClassic();
|
||||||
|
//ImGui::StyleColorsDark();
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
|
// - 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 'extra_fonts/README.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 \\ !
|
||||||
//ImGuiIO& io = ImGui::GetIO();
|
//ImGuiIO& io = ImGui::GetIO();
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
||||||
//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);
|
||||||
|
|
||||||
bool show_test_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_color = ImColor(114, 144, 154);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
|
// 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();
|
glfwPollEvents();
|
||||||
ImGui_ImplGlfwGL3_NewFrame();
|
ImGui_ImplGlfwGL3_NewFrame();
|
||||||
|
|
||||||
// 1. Show a simple window
|
// 1. Show a simple window.
|
||||||
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
|
||||||
{
|
{
|
||||||
static float f = 0.0f;
|
static float f = 0.0f;
|
||||||
ImGui::Text("Hello, world!");
|
ImGui::Text("Hello, world!"); // Some text (you can use a format string too)
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float as a slider from 0.0f to 1.0f
|
||||||
ImGui::ColorEdit3("clear color", (float*)&clear_color);
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats as a color
|
||||||
if (ImGui::Button("Test Window")) show_test_window ^= 1;
|
if (ImGui::Button("Demo Window")) // Use buttons to toggle our bools. We could use Checkbox() as well.
|
||||||
if (ImGui::Button("Another Window")) show_another_window ^= 1;
|
show_demo_window ^= 1;
|
||||||
|
if (ImGui::Button("Another Window"))
|
||||||
|
show_another_window ^= 1;
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Show another simple window, this time using an explicit Begin/End pair
|
// 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name the window.
|
||||||
if (show_another_window)
|
if (show_another_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiCond_FirstUseEver);
|
|
||||||
ImGui::Begin("Another Window", &show_another_window);
|
ImGui::Begin("Another Window", &show_another_window);
|
||||||
ImGui::Text("Hello");
|
ImGui::Text("Hello from another window!");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
|
// 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow().
|
||||||
if (show_test_window)
|
if (show_demo_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
||||||
ImGui::ShowTestWindow(&show_test_window);
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
// ImGui SDL2 binding with OpenGL
|
// ImGui SDL2 binding with OpenGL (legacy, fixed pipeline)
|
||||||
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||||
|
|
||||||
// If your context or own usage of OpenGL involve anything GL3/GL4, prefer using the code in sdl_opengl3_example.
|
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
// If you are not sure what that means, prefer using the code in sdl_opengl3_example.
|
// **Prefer using the code in the sdl_opengl3_example/ folder**
|
||||||
|
// This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read.
|
||||||
|
// If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more
|
||||||
|
// complicated, will require your code to reset every single OpenGL attributes to their initial state, and might
|
||||||
|
// confuse your GPU driver.
|
||||||
|
// The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API.
|
||||||
|
|
||||||
// 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 use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
@ -22,8 +28,8 @@ static float g_MouseWheel = 0.0f;
|
|||||||
static GLuint g_FontTexture = 0;
|
static GLuint g_FontTexture = 0;
|
||||||
|
|
||||||
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
|
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
|
||||||
// If text or lines are blurry when integrating ImGui in your engine:
|
// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
|
||||||
// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
// If text or lines are blurry when integrating ImGui in your engine: in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
||||||
void ImGui_ImplSdl_RenderDrawLists(ImDrawData* draw_data)
|
void ImGui_ImplSdl_RenderDrawLists(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||||
@ -35,8 +41,9 @@ void ImGui_ImplSdl_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
||||||
|
|
||||||
// We are using the OpenGL fixed pipeline to make the example code simpler to read!
|
// We are using the OpenGL fixed pipeline to make the example code simpler to read!
|
||||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
|
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill.
|
||||||
GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
|
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);
|
||||||
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
|
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
|
||||||
@ -49,6 +56,7 @@ void ImGui_ImplSdl_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
//glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound
|
//glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound
|
||||||
|
|
||||||
// Setup viewport, orthographic projection matrix
|
// Setup viewport, orthographic projection matrix
|
||||||
@ -100,6 +108,7 @@ void ImGui_ImplSdl_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
|
glPolygonMode(GL_FRONT, last_polygon_mode[0]); glPolygonMode(GL_BACK, 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]);
|
||||||
}
|
}
|
||||||
@ -114,7 +123,11 @@ static void ImGui_ImplSdl_SetClipboardText(void*, const char* text)
|
|||||||
SDL_SetClipboardText(text);
|
SDL_SetClipboardText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSdl_ProcessEvent(SDL_Event* event)
|
// 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.
|
||||||
|
bool ImGui_ImplSdlGL2_ProcessEvent(SDL_Event* event)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
@ -154,7 +167,7 @@ bool ImGui_ImplSdl_ProcessEvent(SDL_Event* event)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSdl_CreateDeviceObjects()
|
bool ImGui_ImplSdlGL2_CreateDeviceObjects()
|
||||||
{
|
{
|
||||||
// Build texture atlas
|
// Build texture atlas
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@ -181,7 +194,7 @@ bool ImGui_ImplSdl_CreateDeviceObjects()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSdl_InvalidateDeviceObjects()
|
void ImGui_ImplSdlGL2_InvalidateDeviceObjects()
|
||||||
{
|
{
|
||||||
if (g_FontTexture)
|
if (g_FontTexture)
|
||||||
{
|
{
|
||||||
@ -191,7 +204,7 @@ void ImGui_ImplSdl_InvalidateDeviceObjects()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSdl_Init(SDL_Window* window)
|
bool ImGui_ImplSdlGL2_Init(SDL_Window* window)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.KeyMap[ImGuiKey_Tab] = SDLK_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
|
io.KeyMap[ImGuiKey_Tab] = SDLK_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
|
||||||
@ -231,16 +244,16 @@ bool ImGui_ImplSdl_Init(SDL_Window* window)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSdl_Shutdown()
|
void ImGui_ImplSdlGL2_Shutdown()
|
||||||
{
|
{
|
||||||
ImGui_ImplSdl_InvalidateDeviceObjects();
|
ImGui_ImplSdlGL2_InvalidateDeviceObjects();
|
||||||
ImGui::Shutdown();
|
ImGui::Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSdl_NewFrame(SDL_Window *window)
|
void ImGui_ImplSdlGL2_NewFrame(SDL_Window *window)
|
||||||
{
|
{
|
||||||
if (!g_FontTexture)
|
if (!g_FontTexture)
|
||||||
ImGui_ImplSdl_CreateDeviceObjects();
|
ImGui_ImplSdlGL2_CreateDeviceObjects();
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
@ -265,7 +278,7 @@ void ImGui_ImplSdl_NewFrame(SDL_Window *window)
|
|||||||
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_FOCUS)
|
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_FOCUS)
|
||||||
io.MousePos = ImVec2((float)mx, (float)my); // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
io.MousePos = ImVec2((float)mx, (float)my); // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
||||||
else
|
else
|
||||||
io.MousePos = ImVec2(-1,-1);
|
io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX);
|
||||||
|
|
||||||
io.MouseDown[0] = g_MousePressed[0] || (mouseMask & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
|
io.MouseDown[0] = g_MousePressed[0] || (mouseMask & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
|
||||||
io.MouseDown[1] = g_MousePressed[1] || (mouseMask & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
|
io.MouseDown[1] = g_MousePressed[1] || (mouseMask & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
|
||||||
@ -278,6 +291,6 @@ void ImGui_ImplSdl_NewFrame(SDL_Window *window)
|
|||||||
// Hide OS mouse cursor if ImGui is drawing it
|
// Hide OS mouse cursor if ImGui is drawing it
|
||||||
SDL_ShowCursor(io.MouseDrawCursor ? 0 : 1);
|
SDL_ShowCursor(io.MouseDrawCursor ? 0 : 1);
|
||||||
|
|
||||||
// Start the frame
|
// Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
// ImGui SDL2 binding with OpenGL
|
// ImGui SDL2 binding with OpenGL (legacy, fixed pipeline)
|
||||||
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||||
|
|
||||||
|
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
|
// **Prefer using the code in the sdl_opengl3_example/ folder**
|
||||||
|
// See imgui_impl_sdl.cpp for details.
|
||||||
|
|
||||||
// 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 use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
@ -9,11 +14,11 @@
|
|||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
typedef union SDL_Event SDL_Event;
|
typedef union SDL_Event SDL_Event;
|
||||||
|
|
||||||
IMGUI_API bool ImGui_ImplSdl_Init(SDL_Window* window);
|
IMGUI_API bool ImGui_ImplSdlGL2_Init(SDL_Window* window);
|
||||||
IMGUI_API void ImGui_ImplSdl_Shutdown();
|
IMGUI_API void ImGui_ImplSdlGL2_Shutdown();
|
||||||
IMGUI_API void ImGui_ImplSdl_NewFrame(SDL_Window* window);
|
IMGUI_API void ImGui_ImplSdlGL2_NewFrame(SDL_Window* window);
|
||||||
IMGUI_API bool ImGui_ImplSdl_ProcessEvent(SDL_Event* event);
|
IMGUI_API bool ImGui_ImplSdlGL2_ProcessEvent(SDL_Event* event);
|
||||||
|
|
||||||
// Use if you want to reset your rendering device without losing ImGui state.
|
// Use if you want to reset your rendering device without losing ImGui state.
|
||||||
IMGUI_API void ImGui_ImplSdl_InvalidateDeviceObjects();
|
IMGUI_API void ImGui_ImplSdlGL2_InvalidateDeviceObjects();
|
||||||
IMGUI_API bool ImGui_ImplSdl_CreateDeviceObjects();
|
IMGUI_API bool ImGui_ImplSdlGL2_CreateDeviceObjects();
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
// ImGui - standalone example application for SDL2 + OpenGL
|
// ImGui - standalone example application for SDL2 + OpenGL
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to 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.)
|
||||||
|
|
||||||
|
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
|
// **Prefer using the code in the sdl_opengl3_example/ folder**
|
||||||
|
// See imgui_impl_sdl.cpp for details.
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include "imgui_impl_sdl.h"
|
#include "imgui_impl_sdl.h"
|
||||||
@ -28,61 +33,76 @@ int main(int, char**)
|
|||||||
SDL_GLContext glcontext = SDL_GL_CreateContext(window);
|
SDL_GLContext glcontext = SDL_GL_CreateContext(window);
|
||||||
|
|
||||||
// Setup ImGui binding
|
// Setup ImGui binding
|
||||||
ImGui_ImplSdl_Init(window);
|
ImGui_ImplSdlGL2_Init(window);
|
||||||
|
|
||||||
|
// Setup style
|
||||||
|
ImGui::StyleColorsClassic();
|
||||||
|
//ImGui::StyleColorsDark();
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
|
// - 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 'extra_fonts/README.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 \\ !
|
||||||
//ImGuiIO& io = ImGui::GetIO();
|
//ImGuiIO& io = ImGui::GetIO();
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
||||||
//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);
|
||||||
|
|
||||||
bool show_test_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_color = ImColor(114, 144, 154);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
bool done = false;
|
bool done = false;
|
||||||
while (!done)
|
while (!done)
|
||||||
{
|
{
|
||||||
|
// 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;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event))
|
while (SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
ImGui_ImplSdl_ProcessEvent(&event);
|
ImGui_ImplSdlGL2_ProcessEvent(&event);
|
||||||
if (event.type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
ImGui_ImplSdl_NewFrame(window);
|
ImGui_ImplSdlGL2_NewFrame(window);
|
||||||
|
|
||||||
// 1. Show a simple window
|
// 1. Show a simple window
|
||||||
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
|
||||||
{
|
{
|
||||||
static float f = 0.0f;
|
static float f = 0.0f;
|
||||||
ImGui::Text("Hello, world!");
|
ImGui::Text("Hello, world!"); // Some text (you can use a format string too)
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float as a slider from 0.0f to 1.0f
|
||||||
ImGui::ColorEdit3("clear color", (float*)&clear_color);
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats as a color
|
||||||
if (ImGui::Button("Test Window")) show_test_window ^= 1;
|
if (ImGui::Button("Demo Window")) // Use buttons to toggle our bools. We could use Checkbox() as well.
|
||||||
if (ImGui::Button("Another Window")) show_another_window ^= 1;
|
show_demo_window ^= 1;
|
||||||
|
if (ImGui::Button("Another Window"))
|
||||||
|
show_another_window ^= 1;
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Show another simple window, this time using an explicit Begin/End pair
|
// 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name the window.
|
||||||
if (show_another_window)
|
if (show_another_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiCond_FirstUseEver);
|
|
||||||
ImGui::Begin("Another Window", &show_another_window);
|
ImGui::Begin("Another Window", &show_another_window);
|
||||||
ImGui::Text("Hello");
|
ImGui::Text("Hello from another window!");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
|
// 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow().
|
||||||
if (show_test_window)
|
if (show_demo_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
||||||
ImGui::ShowTestWindow(&show_test_window);
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
@ -95,7 +115,7 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
ImGui_ImplSdl_Shutdown();
|
ImGui_ImplSdlGL2_Shutdown();
|
||||||
SDL_GL_DeleteContext(glcontext);
|
SDL_GL_DeleteContext(glcontext);
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
// ImGui SDL2 binding with OpenGL3
|
// ImGui SDL2 binding with OpenGL3
|
||||||
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||||
|
// (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.)
|
||||||
|
|
||||||
// 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 use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
@ -25,8 +27,8 @@ static int g_AttribLocationPosition = 0, g_AttribLocationUV = 0, g_Attr
|
|||||||
static unsigned int g_VboHandle = 0, g_VaoHandle = 0, g_ElementsHandle = 0;
|
static unsigned int g_VboHandle = 0, g_VaoHandle = 0, g_ElementsHandle = 0;
|
||||||
|
|
||||||
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
|
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
|
||||||
// If text or lines are blurry when integrating ImGui in your engine:
|
// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
|
||||||
// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
// If text or lines are blurry when integrating ImGui in your engine: in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
||||||
void ImGui_ImplSdlGL3_RenderDrawLists(ImDrawData* draw_data)
|
void ImGui_ImplSdlGL3_RenderDrawLists(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||||
@ -42,9 +44,11 @@ void ImGui_ImplSdlGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
GLint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
|
GLint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
|
||||||
GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
|
GLint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, &last_sampler);
|
||||||
GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
||||||
GLint last_element_array_buffer; glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_element_array_buffer);
|
GLint last_element_array_buffer; glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_element_array_buffer);
|
||||||
GLint last_vertex_array; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
GLint last_vertex_array; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
||||||
|
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);
|
||||||
GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb);
|
GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb);
|
||||||
@ -58,13 +62,14 @@ void ImGui_ImplSdlGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
|
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
|
||||||
GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
|
GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled
|
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
|
|
||||||
// Setup viewport, orthographic projection matrix
|
// Setup viewport, orthographic projection matrix
|
||||||
glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
|
glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
|
||||||
@ -79,6 +84,7 @@ void ImGui_ImplSdlGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
glUniform1i(g_AttribLocationTex, 0);
|
glUniform1i(g_AttribLocationTex, 0);
|
||||||
glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
||||||
glBindVertexArray(g_VaoHandle);
|
glBindVertexArray(g_VaoHandle);
|
||||||
|
glBindSampler(0, 0); // Rely on combined texture/sampler state.
|
||||||
|
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
@ -111,6 +117,7 @@ void ImGui_ImplSdlGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
// Restore modified GL state
|
// Restore modified GL state
|
||||||
glUseProgram(last_program);
|
glUseProgram(last_program);
|
||||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
|
glBindSampler(0, last_sampler);
|
||||||
glActiveTexture(last_active_texture);
|
glActiveTexture(last_active_texture);
|
||||||
glBindVertexArray(last_vertex_array);
|
glBindVertexArray(last_vertex_array);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||||
@ -121,6 +128,7 @@ void ImGui_ImplSdlGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE);
|
if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE);
|
||||||
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
|
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
|
||||||
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
|
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, last_polygon_mode[0]);
|
||||||
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]);
|
||||||
}
|
}
|
||||||
@ -135,6 +143,10 @@ static void ImGui_ImplSdlGL3_SetClipboardText(void*, const char* text)
|
|||||||
SDL_SetClipboardText(text);
|
SDL_SetClipboardText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||||
|
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||||
|
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
||||||
|
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||||
bool ImGui_ImplSdlGL3_ProcessEvent(SDL_Event* event)
|
bool ImGui_ImplSdlGL3_ProcessEvent(SDL_Event* event)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@ -377,7 +389,7 @@ void ImGui_ImplSdlGL3_NewFrame(SDL_Window* window)
|
|||||||
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_FOCUS)
|
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_FOCUS)
|
||||||
io.MousePos = ImVec2((float)mx, (float)my); // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
io.MousePos = ImVec2((float)mx, (float)my); // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
||||||
else
|
else
|
||||||
io.MousePos = ImVec2(-1, -1);
|
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||||
|
|
||||||
io.MouseDown[0] = g_MousePressed[0] || (mouseMask & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
|
io.MouseDown[0] = g_MousePressed[0] || (mouseMask & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
|
||||||
io.MouseDown[1] = g_MousePressed[1] || (mouseMask & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
|
io.MouseDown[1] = g_MousePressed[1] || (mouseMask & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
|
||||||
@ -390,6 +402,6 @@ void ImGui_ImplSdlGL3_NewFrame(SDL_Window* window)
|
|||||||
// Hide OS mouse cursor if ImGui is drawing it
|
// Hide OS mouse cursor if ImGui is drawing it
|
||||||
SDL_ShowCursor(io.MouseDrawCursor ? 0 : 1);
|
SDL_ShowCursor(io.MouseDrawCursor ? 0 : 1);
|
||||||
|
|
||||||
// Start the frame
|
// Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
// ImGui SDL2 binding with OpenGL3
|
// ImGui SDL2 binding with OpenGL3
|
||||||
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||||
|
// (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.)
|
||||||
|
|
||||||
// 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 use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
// ImGui - standalone example application for SDL2 + OpenGL
|
// ImGui - standalone example application for SDL2 + OpenGL
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to 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.)
|
||||||
|
// (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.)
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include "imgui_impl_sdl_gl3.h"
|
#include "imgui_impl_sdl_gl3.h"
|
||||||
@ -33,24 +35,38 @@ int main(int, char**)
|
|||||||
// Setup ImGui binding
|
// Setup ImGui binding
|
||||||
ImGui_ImplSdlGL3_Init(window);
|
ImGui_ImplSdlGL3_Init(window);
|
||||||
|
|
||||||
|
// Setup style
|
||||||
|
ImGui::StyleColorsClassic();
|
||||||
|
//ImGui::StyleColorsDark();
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
|
// - 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 'extra_fonts/README.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 \\ !
|
||||||
//ImGuiIO& io = ImGui::GetIO();
|
//ImGuiIO& io = ImGui::GetIO();
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
||||||
//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);
|
||||||
|
|
||||||
bool show_test_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_color = ImColor(114, 144, 154);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
bool done = false;
|
bool done = false;
|
||||||
while (!done)
|
while (!done)
|
||||||
{
|
{
|
||||||
|
// 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;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event))
|
while (SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
@ -60,32 +76,33 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
ImGui_ImplSdlGL3_NewFrame(window);
|
ImGui_ImplSdlGL3_NewFrame(window);
|
||||||
|
|
||||||
// 1. Show a simple window
|
// 1. Show a simple window.
|
||||||
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
|
||||||
{
|
{
|
||||||
static float f = 0.0f;
|
static float f = 0.0f;
|
||||||
ImGui::Text("Hello, world!");
|
ImGui::Text("Hello, world!"); // Some text (you can use a format string too)
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float as a slider from 0.0f to 1.0f
|
||||||
ImGui::ColorEdit3("clear color", (float*)&clear_color);
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats as a color
|
||||||
if (ImGui::Button("Test Window")) show_test_window ^= 1;
|
if (ImGui::Button("Demo Window")) // Use buttons to toggle our bools. We could use Checkbox() as well.
|
||||||
if (ImGui::Button("Another Window")) show_another_window ^= 1;
|
show_demo_window ^= 1;
|
||||||
|
if (ImGui::Button("Another Window"))
|
||||||
|
show_another_window ^= 1;
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Show another simple window, this time using an explicit Begin/End pair
|
// 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name the window.
|
||||||
if (show_another_window)
|
if (show_another_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiCond_FirstUseEver);
|
|
||||||
ImGui::Begin("Another Window", &show_another_window);
|
ImGui::Begin("Another Window", &show_another_window);
|
||||||
ImGui::Text("Hello");
|
ImGui::Text("Hello from another window!");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
|
// 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow().
|
||||||
if (show_test_window)
|
if (show_demo_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
||||||
ImGui::ShowTestWindow(&show_test_window);
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
|
@ -332,7 +332,7 @@ void ImGui_ImplGlfwVulkan_MouseButtonCallback(GLFWwindow*, int button, int actio
|
|||||||
|
|
||||||
void ImGui_ImplGlfwVulkan_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
|
void ImGui_ImplGlfwVulkan_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
|
||||||
{
|
{
|
||||||
g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
|
g_MouseWheel += (float)yoffset; // Use fractional mouse wheel.
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfwVulkan_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
|
void ImGui_ImplGlfwVulkan_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
|
||||||
@ -815,7 +815,7 @@ void ImGui_ImplGlfwVulkan_NewFrame()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
io.MousePos = ImVec2(-1,-1);
|
io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
@ -830,7 +830,7 @@ void ImGui_ImplGlfwVulkan_NewFrame()
|
|||||||
// Hide OS mouse cursor if ImGui is drawing it
|
// Hide OS mouse cursor if ImGui is drawing it
|
||||||
glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
|
glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
|
||||||
|
|
||||||
// Start the frame
|
// Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -625,15 +625,25 @@ int main(int, char**)
|
|||||||
init_data.check_vk_result = check_vk_result;
|
init_data.check_vk_result = check_vk_result;
|
||||||
ImGui_ImplGlfwVulkan_Init(window, true, &init_data);
|
ImGui_ImplGlfwVulkan_Init(window, true, &init_data);
|
||||||
|
|
||||||
|
// Setup style
|
||||||
|
ImGui::StyleColorsClassic();
|
||||||
|
//ImGui::StyleColorsDark();
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
|
// - 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 'extra_fonts/README.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 \\ !
|
||||||
//ImGuiIO& io = ImGui::GetIO();
|
//ImGuiIO& io = ImGui::GetIO();
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
|
|
||||||
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
|
||||||
//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);
|
||||||
|
|
||||||
// Upload Fonts
|
// Upload Fonts
|
||||||
{
|
{
|
||||||
@ -662,9 +672,9 @@ int main(int, char**)
|
|||||||
ImGui_ImplGlfwVulkan_InvalidateFontUploadObjects();
|
ImGui_ImplGlfwVulkan_InvalidateFontUploadObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool show_test_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_color = ImColor(114, 144, 154);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
|
||||||
// When IMGUI_UNLIMITED_FRAME_RATE is defined we render into latest image acquired from the swapchain but we display the image which was rendered before.
|
// When IMGUI_UNLIMITED_FRAME_RATE is defined we render into latest image acquired from the swapchain but we display the image which was rendered before.
|
||||||
// Hence we must render once and increase the g_FrameIndex without presenting, which we do before entering the render loop.
|
// Hence we must render once and increase the g_FrameIndex without presenting, which we do before entering the render loop.
|
||||||
@ -680,42 +690,43 @@ int main(int, char**)
|
|||||||
// Main loop
|
// Main loop
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
|
// 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();
|
glfwPollEvents();
|
||||||
ImGui_ImplGlfwVulkan_NewFrame();
|
ImGui_ImplGlfwVulkan_NewFrame();
|
||||||
|
|
||||||
// 1. Show a simple window
|
// 1. Show a simple window.
|
||||||
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
|
||||||
{
|
{
|
||||||
static float f = 0.0f;
|
static float f = 0.0f;
|
||||||
ImGui::Text("Hello, world!");
|
ImGui::Text("Hello, world!"); // Some text (you can use a format string too)
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float as a slider from 0.0f to 1.0f
|
||||||
ImGui::ColorEdit3("clear color", (float*)&clear_color);
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats as a color
|
||||||
if (ImGui::Button("Test Window")) show_test_window ^= 1;
|
if (ImGui::Button("Demo Window")) // Use buttons to toggle our bools. We could use Checkbox() as well.
|
||||||
if (ImGui::Button("Another Window")) show_another_window ^= 1;
|
show_demo_window ^= 1;
|
||||||
|
if (ImGui::Button("Another Window"))
|
||||||
|
show_another_window ^= 1;
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Show another simple window, this time using an explicit Begin/End pair
|
// 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name the window.
|
||||||
if (show_another_window)
|
if (show_another_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiCond_FirstUseEver);
|
|
||||||
ImGui::Begin("Another Window", &show_another_window);
|
ImGui::Begin("Another Window", &show_another_window);
|
||||||
ImGui::Text("Hello");
|
ImGui::Text("Hello from another window!");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
|
// 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow().
|
||||||
if (show_test_window)
|
if (show_demo_window)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
||||||
ImGui::ShowTestWindow(&show_test_window);
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_ClearValue.color.float32[0] = clear_color.x;
|
memcpy(&g_ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
||||||
g_ClearValue.color.float32[1] = clear_color.y;
|
|
||||||
g_ClearValue.color.float32[2] = clear_color.z;
|
|
||||||
g_ClearValue.color.float32[3] = clear_color.w;
|
|
||||||
|
|
||||||
frame_begin();
|
frame_begin();
|
||||||
ImGui_ImplGlfwVulkan_Render(g_CommandBuffer[g_FrameIndex]);
|
ImGui_ImplGlfwVulkan_Render(g_CommandBuffer[g_FrameIndex]);
|
||||||
frame_end();
|
frame_end();
|
||||||
|
@ -1,22 +1,48 @@
|
|||||||
|
|
||||||
The code in imgui.cpp embeds a copy of 'ProggyClean.ttf' that you can use without any external files.
|
The code in imgui.cpp embeds a copy of 'ProggyClean.ttf' (by Tristan Grimmer) that is used by default.
|
||||||
The files in this folder are only provided as a convenience, you can use any .TTF/.OTF.
|
We embed the font in source code so you can use Dear ImGui without any file system access.
|
||||||
(Note: .OTF support in stb_truetype.h currently doesn't appear to load every font)
|
You may also load external .TTF/.OTF files.
|
||||||
|
The files in this folder are suggested fonts, provided as a convenience.
|
||||||
|
(Note: .OTF support in stb_truetype.h currently doesn't appear to load every font)
|
||||||
|
|
||||||
Fonts are rasterized in a single texture at the time of calling either of io.Fonts.GetTexDataAsAlpha8()/GetTexDataAsRGBA32()/Build().
|
Fonts are rasterized in a single texture at the time of calling either of io.Fonts.GetTexDataAsAlpha8()/GetTexDataAsRGBA32()/Build().
|
||||||
|
Also read dear imgui FAQ in imgui.cpp!
|
||||||
|
|
||||||
---------------------------------
|
In this document:
|
||||||
|
|
||||||
|
- Using Icons
|
||||||
|
- Fonts Loading Instructions
|
||||||
|
- FreeType rasterizer, Small font sizes
|
||||||
|
- Building Custom Glyph Ranges
|
||||||
|
- Remapping Codepoints
|
||||||
|
- Embedding Fonts in Source Code
|
||||||
|
- Credits/Licences for fonts included in this folder
|
||||||
|
- Links, Other fonts
|
||||||
|
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
USING ICONS
|
USING ICONS
|
||||||
---------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
Using an icon font (such as FontAwesome: http://fontawesome.io) is an easy and practical way to use icons in your ImGui application.
|
Using an icon font (such as FontAwesome: http://fontawesome.io) is an easy and practical way to use icons in your ImGui application.
|
||||||
A common pattern is to merge the icon font within your main font, so you can refer to the icons directly from your strings without having to change fonts back and forth.
|
A common pattern is to merge the icon font within your main font, so you can embed icons directly from your strings without
|
||||||
To refer to the icon from your C++ code, you can use headers files created by Juliette Foucaut, at https://github.com/juliettef/IconFontCppHeaders
|
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:
|
||||||
|
|
||||||
// Merge icons into default tool font
|
// Merge icons into default tool font
|
||||||
#include "IconsFontAwesome.h"
|
#include "IconsFontAwesome.h"
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.Fonts->AddFontDefault();
|
io.Fonts->AddFontDefault();
|
||||||
|
|
||||||
ImFontConfig config;
|
ImFontConfig config;
|
||||||
config.MergeMode = true;
|
config.MergeMode = true;
|
||||||
static const ImWchar icon_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
|
static const ImWchar icon_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
|
||||||
@ -25,10 +51,12 @@
|
|||||||
// Usage, e.g.
|
// Usage, e.g.
|
||||||
ImGui::Text("%s Search", ICON_FA_SEARCH);
|
ImGui::Text("%s Search", ICON_FA_SEARCH);
|
||||||
|
|
||||||
|
See Links below for other icons fonts and related tools.
|
||||||
|
|
||||||
---------------------------------
|
|
||||||
|
---------------------------------------
|
||||||
FONTS LOADING INSTRUCTIONS
|
FONTS LOADING INSTRUCTIONS
|
||||||
---------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
Load default font with:
|
Load default font with:
|
||||||
|
|
||||||
@ -40,7 +68,7 @@
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
|
io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
|
||||||
|
|
||||||
Detailed options:
|
For advanced options create a ImFontConfig structure and pass it to the AddFont function (it will be copied internally)
|
||||||
|
|
||||||
ImFontConfig config;
|
ImFontConfig config;
|
||||||
config.OversampleH = 3;
|
config.OversampleH = 3;
|
||||||
@ -86,9 +114,23 @@
|
|||||||
font->DisplayOffset.y += 1; // Render 1 pixel down
|
font->DisplayOffset.y += 1; // Render 1 pixel down
|
||||||
|
|
||||||
|
|
||||||
---------------------------------
|
---------------------------------------
|
||||||
|
FREETYPE RASTERIZER, SMALL FONT SIZES
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
|
Dear Imgui uses stb_truetype.h to rasterize fonts (with optional oversampling).
|
||||||
|
This technique and implementation are not ideal for fonts rendered at _small sizes_, which may appear a little blurry.
|
||||||
|
There is an implementation of the ImFontAtlas builder using FreeType that you can use:
|
||||||
|
|
||||||
|
https://github.com/ocornut/imgui_club
|
||||||
|
|
||||||
|
FreeType supports auto-hinting which tends to improve the readability of small fonts.
|
||||||
|
Note that this code currently creates textures that are unoptimally too large (could be fixed with some work)
|
||||||
|
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
BUILDING CUSTOM GLYPH RANGES
|
BUILDING CUSTOM GLYPH RANGES
|
||||||
---------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
You can use the ImFontAtlas::GlyphRangesBuilder helper to create glyph ranges based on text input.
|
You can use the ImFontAtlas::GlyphRangesBuilder helper to create glyph ranges based on text input.
|
||||||
For exemple: for a game where your script is known, if you can feed your entire script to it and only build the characters the game needs.
|
For exemple: for a game where your script is known, if you can feed your entire script to it and only build the characters the game needs.
|
||||||
@ -102,21 +144,27 @@
|
|||||||
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, ranges.Data);
|
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, ranges.Data);
|
||||||
|
|
||||||
|
|
||||||
---------------------------------
|
---------------------------------------
|
||||||
REMAPPING CODEPOINTS
|
REMAPPING CODEPOINTS
|
||||||
---------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
All your strings needs to use UTF-8 encoding. Specifying literal in your source code using a local code page (such as CP-923 for Japanese CP-1251 for Cyrillic) will NOT work!
|
All your strings needs to use UTF-8 encoding. 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!
|
||||||
In C++11 you can encode a string literal in UTF-8 by using the u8"hello" syntax. Otherwise you can convert yourself to UTF-8 or load text data from file already saved as UTF-8.
|
In C++11 you can encode a string literal in UTF-8 by using the u8"hello" syntax. Otherwise you can convert yourself to UTF-8 or load text data from file already saved as UTF-8.
|
||||||
You can also try to remap your local codepage characters to their Unicode codepoint using font->AddRemapChar(), but international users may have problems reading/editing your source code.
|
e.g.
|
||||||
|
u8"hello"
|
||||||
|
u8"こんにちは"
|
||||||
|
You may also try to remap your local codepage characters to their Unicode codepoint using font->AddRemapChar(), but international users may have problems reading/editing your source code.
|
||||||
|
|
||||||
|
|
||||||
---------------------------------
|
---------------------------------------
|
||||||
EMBEDDING FONT IN SOURCE CODE
|
EMBEDDING FONTS IN SOURCE CODE
|
||||||
---------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
Compile and use 'binary_to_compressed_c.cpp' to create a compressed C style array.
|
Compile and use 'binary_to_compressed_c.cpp' to create a compressed C style array that you can embed in source code.
|
||||||
See the documentation in binary_to_compressed_c.cpp for instruction on how to use the tool.
|
See the documentation in binary_to_compressed_c.cpp for instruction on how to use the tool.
|
||||||
|
You may find a precompiled version binary_to_compressed_c.exe for Windows instead of demo binaries package (see README).
|
||||||
|
The tool optionally used Base85 encoding to reduce the size of _source code_ but the read-only arrays will be about 20% bigger.
|
||||||
|
|
||||||
Then load the font with:
|
Then load the font with:
|
||||||
|
|
||||||
ImFont* font = io.Fonts->AddFontFromMemoryCompressedTTF(compressed_data, compressed_data_size, size_pixels, ...);
|
ImFont* font = io.Fonts->AddFontFromMemoryCompressedTTF(compressed_data, compressed_data_size, size_pixels, ...);
|
||||||
@ -126,9 +174,9 @@
|
|||||||
ImFont* font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(compressed_data_base85, size_pixels, ...);
|
ImFont* font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(compressed_data_base85, size_pixels, ...);
|
||||||
|
|
||||||
|
|
||||||
---------------------------------
|
---------------------------------------
|
||||||
FONT FILES INCLUDED IN THIS FOLDER
|
CREDITS/LICENSES FOR FONTS INCLUDED IN THIS FOLDER
|
||||||
---------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
Roboto-Medium.ttf
|
Roboto-Medium.ttf
|
||||||
Apache License 2.0
|
Apache License 2.0
|
||||||
@ -144,7 +192,7 @@
|
|||||||
DroidSans.ttf
|
DroidSans.ttf
|
||||||
Copyright (c) Steve Matteson
|
Copyright (c) Steve Matteson
|
||||||
Apache License, version 2.0
|
Apache License, version 2.0
|
||||||
http://www.google.com/fonts/specimen/Droid+Sans
|
https://www.fontsquirrel.com/fonts/droid-sans
|
||||||
|
|
||||||
ProggyClean.ttf
|
ProggyClean.ttf
|
||||||
Copyright (c) 2004, 2005 Tristan Grimmer
|
Copyright (c) 2004, 2005 Tristan Grimmer
|
||||||
@ -163,40 +211,45 @@
|
|||||||
SIL OPEN FONT LICENSE Version 1.1
|
SIL OPEN FONT LICENSE Version 1.1
|
||||||
|
|
||||||
|
|
||||||
---------------------------------
|
---------------------------------------
|
||||||
LINKS
|
LINKS, OTHER FONTS
|
||||||
---------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
Icon fonts
|
(Icons) Icon fonts
|
||||||
https://fortawesome.github.io/Font-Awesome/
|
https://fortawesome.github.io/Font-Awesome/
|
||||||
https://github.com/SamBrishes/kenney-icon-font
|
https://github.com/SamBrishes/kenney-icon-font
|
||||||
https://design.google.com/icons/
|
https://design.google.com/icons/
|
||||||
|
You can use https://github.com/juliettef/IconFontCppHeaders for C/C++ header files with name #define to access icon codepoint in source code.
|
||||||
|
|
||||||
IcoMoon - Custom Icon font builder
|
(Icons) IcoMoon - Custom Icon font builder
|
||||||
https://icomoon.io/app
|
https://icomoon.io/app
|
||||||
|
|
||||||
Typefaces for source code beautification
|
(Regular) Open Sans Fonts
|
||||||
https://github.com/chrissimpkins/codeface
|
https://fonts.google.com/specimen/Open+Sans
|
||||||
|
|
||||||
|
(Regular) Google Noto Fonts (worldwide languages)
|
||||||
|
https://www.google.com/get/noto/
|
||||||
|
|
||||||
Programmation fonts
|
(Monospace) Typefaces for source code beautification
|
||||||
|
https://github.com/chrissimpkins/codeface
|
||||||
|
|
||||||
|
(Monospace) Programmation fonts
|
||||||
http://s9w.github.io/font_compare/
|
http://s9w.github.io/font_compare/
|
||||||
|
|
||||||
Proggy Programming Fonts
|
(Monospace) Proggy Programming Fonts
|
||||||
http://upperbounds.net
|
http://upperbounds.net
|
||||||
|
|
||||||
Inconsolata
|
(Monospace) Inconsolata
|
||||||
http://www.levien.com/type/myfonts/inconsolata.html
|
http://www.levien.com/type/myfonts/inconsolata.html
|
||||||
|
|
||||||
Google Noto Fonts (worldwide languages)
|
(Monospace) Adobe Source Code Pro: Monospaced font family for user interface and coding environments
|
||||||
https://www.google.com/get/noto/
|
|
||||||
|
|
||||||
Adobe Source Code Pro: Monospaced font family for user interface and coding environments
|
|
||||||
https://github.com/adobe-fonts/source-code-pro
|
https://github.com/adobe-fonts/source-code-pro
|
||||||
|
|
||||||
Monospace/Fixed Width Programmer's Fonts
|
(Monospace) Monospace/Fixed Width Programmer's Fonts
|
||||||
http://www.lowing.org/fonts/
|
http://www.lowing.org/fonts/
|
||||||
|
|
||||||
(Japanese) M+ fonts by Coji Morishita are free and include most useful Kanjis you would need.
|
(Japanese) M+ fonts by Coji Morishita are free and include most useful Kanjis you would need.
|
||||||
http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/index-en.html
|
http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/index-en.html
|
||||||
|
|
||||||
Or use Arial Unicode or other Unicode fonts provided with Windows for full characters coverage (not sure of their licensing).
|
Or use Arial Unicode or other Unicode fonts provided with Windows for full characters coverage (not sure of their licensing).
|
||||||
|
|
||||||
|
@ -53,8 +53,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binary_to_compressed_c(argv[argn], argv[argn+1], use_base85_encoding, use_compression);
|
return binary_to_compressed_c(argv[argn], argv[argn+1], use_base85_encoding, use_compression) ? 0 : 1;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char Encode85Byte(unsigned int x)
|
char Encode85Byte(unsigned int x)
|
||||||
|
19
imconfig.h
19
imconfig.h
@ -13,24 +13,27 @@
|
|||||||
//#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 names. Consider enabling from time to time or when updating to reduce like hood of using already obsolete function/names
|
||||||
|
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
|
||||||
//---- Include imgui_user.h at the end of imgui.h
|
//---- Include imgui_user.h at the end of imgui.h
|
||||||
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
||||||
|
|
||||||
//---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions)
|
//---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions)
|
||||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS
|
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS
|
||||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS
|
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS
|
||||||
|
|
||||||
//---- Don't implement test window functionality (ShowTestWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty)
|
//---- Don't implement demo windows functionality (ShowDemoWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty)
|
||||||
//---- It is very strongly recommended to NOT disable the test windows. Please read the comment at the top of imgui_demo.cpp to learn why.
|
//---- It is very strongly recommended to NOT disable the demo windows. Please read the comment at the top of imgui_demo.cpp to learn why.
|
||||||
//#define IMGUI_DISABLE_TEST_WINDOWS
|
//#define IMGUI_DISABLE_DEMO_WINDOWS
|
||||||
|
|
||||||
//---- Don't define obsolete functions names. Consider enabling from time to time or when updating to reduce like hood of using already obsolete function/names
|
//---- Don't implement ImFormatString(), ImFormatStringV() so you can reimplement them yourself.
|
||||||
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
//#define IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
|
||||||
|
|
||||||
//---- Pack colors to BGRA instead of RGBA (remove need to post process vertex buffer in back ends)
|
//---- Pack colors to BGRA instead of RGBA (remove need to post process vertex buffer in back ends)
|
||||||
//#define IMGUI_USE_BGRA_PACKED_COLOR
|
//#define IMGUI_USE_BGRA_PACKED_COLOR
|
||||||
|
|
||||||
//---- Implement STB libraries in a namespace to avoid conflicts
|
//---- Implement STB libraries in a namespace to avoid linkage conflicts
|
||||||
//#define IMGUI_STB_NAMESPACE ImGuiStb
|
//#define IMGUI_STB_NAMESPACE ImGuiStb
|
||||||
|
|
||||||
//---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4.
|
//---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4.
|
||||||
|
687
imgui_demo.cpp
687
imgui_demo.cpp
File diff suppressed because it is too large
Load Diff
745
imgui_draw.cpp
745
imgui_draw.cpp
File diff suppressed because it is too large
Load Diff
417
imgui_internal.h
417
imgui_internal.h
@ -1,11 +1,10 @@
|
|||||||
// dear imgui, v1.51
|
// dear imgui, v1.53
|
||||||
// (internals)
|
// (internals)
|
||||||
|
|
||||||
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
||||||
// Implement maths operators for ImVec2 (disabled by default to not collide with using IM_VEC2_CLASS_EXTRA along with your own math types+operators)
|
// Set:
|
||||||
// #define IMGUI_DEFINE_MATH_OPERATORS
|
// #define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
// Define IM_PLACEMENT_NEW() macro helper.
|
// To implement maths operators for ImVec2 (disabled by default to not collide with using IM_VEC2_CLASS_EXTRA along with your own math types+operators)
|
||||||
// #define IMGUI_DEFINE_PLACEMENT_NEW
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@ -39,15 +38,16 @@ struct ImGuiGroupData;
|
|||||||
struct ImGuiSimpleColumns;
|
struct ImGuiSimpleColumns;
|
||||||
struct ImGuiDrawContext;
|
struct ImGuiDrawContext;
|
||||||
struct ImGuiTextEditState;
|
struct ImGuiTextEditState;
|
||||||
struct ImGuiIniData;
|
|
||||||
struct ImGuiMouseCursorData;
|
struct ImGuiMouseCursorData;
|
||||||
struct ImGuiPopupRef;
|
struct ImGuiPopupRef;
|
||||||
struct ImGuiWindow;
|
struct ImGuiWindow;
|
||||||
|
struct ImGuiWindowSettings;
|
||||||
|
|
||||||
typedef int ImGuiLayoutType; // enum ImGuiLayoutType_
|
typedef int ImGuiLayoutType; // enum: horizontal or vertical // enum ImGuiLayoutType_
|
||||||
typedef int ImGuiButtonFlags; // enum ImGuiButtonFlags_
|
typedef int ImGuiButtonFlags; // flags: for ButtonEx(), ButtonBehavior() // enum ImGuiButtonFlags_
|
||||||
typedef int ImGuiTreeNodeFlags; // enum ImGuiTreeNodeFlags_
|
typedef int ImGuiItemFlags; // flags: for PushItemFlag() // enum ImGuiItemFlags_
|
||||||
typedef int ImGuiSliderFlags; // enum ImGuiSliderFlags_
|
typedef int ImGuiSeparatorFlags; // flags: for Separator() - internal // enum ImGuiSeparatorFlags_
|
||||||
|
typedef int ImGuiSliderFlags; // flags: for SliderBehavior() // enum ImGuiSliderFlags_
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// STB libraries
|
// STB libraries
|
||||||
@ -77,9 +77,8 @@ extern IMGUI_API ImGuiContext* GImGui; // Current implicit ImGui context pointe
|
|||||||
// Helpers
|
// Helpers
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR)))
|
#define IM_PI 3.14159265358979323846f
|
||||||
#define IM_PI 3.14159265358979323846f
|
#define IM_OFFSETOF(_TYPE,_ELM) ((size_t)&(((_TYPE*)0)->_ELM))
|
||||||
#define IM_OFFSETOF(_TYPE,_ELM) ((size_t)&(((_TYPE*)0)->_ELM))
|
|
||||||
|
|
||||||
// Helpers: UTF-8 <> wchar
|
// Helpers: UTF-8 <> wchar
|
||||||
IMGUI_API int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count
|
IMGUI_API int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count
|
||||||
@ -104,13 +103,15 @@ IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec
|
|||||||
|
|
||||||
// Helpers: String
|
// Helpers: String
|
||||||
IMGUI_API int ImStricmp(const char* str1, const char* str2);
|
IMGUI_API int ImStricmp(const char* str1, const char* str2);
|
||||||
IMGUI_API int ImStrnicmp(const char* str1, const char* str2, int count);
|
IMGUI_API int ImStrnicmp(const char* str1, const char* str2, size_t count);
|
||||||
|
IMGUI_API void ImStrncpy(char* dst, const char* src, size_t count);
|
||||||
IMGUI_API char* ImStrdup(const char* str);
|
IMGUI_API char* ImStrdup(const char* str);
|
||||||
|
IMGUI_API char* ImStrchrRange(const char* str_begin, const char* str_end, char c);
|
||||||
IMGUI_API int ImStrlenW(const ImWchar* str);
|
IMGUI_API int ImStrlenW(const ImWchar* str);
|
||||||
IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line
|
IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line
|
||||||
IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end);
|
IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end);
|
||||||
IMGUI_API int ImFormatString(char* buf, int buf_size, const char* fmt, ...) IM_PRINTFARGS(3);
|
IMGUI_API int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3);
|
||||||
IMGUI_API int ImFormatStringV(char* buf, int buf_size, const char* fmt, va_list args);
|
IMGUI_API int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) IM_FMTLIST(3);
|
||||||
|
|
||||||
// Helpers: Math
|
// Helpers: Math
|
||||||
// We are keeping those not leaking to the user by default, in the case the user has implicit cast operators between ImVec2 and its own types (when IM_VEC2_CLASS_EXTRA is defined)
|
// We are keeping those not leaking to the user by default, in the case the user has implicit cast operators between ImVec2 and its own types (when IM_VEC2_CLASS_EXTRA is defined)
|
||||||
@ -125,7 +126,9 @@ static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs)
|
|||||||
static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
|
static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
|
||||||
static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
|
static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
|
||||||
static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
|
static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
|
||||||
|
static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x+rhs.x, lhs.y+rhs.y, lhs.z+rhs.z, lhs.w+rhs.w); }
|
||||||
static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x-rhs.x, lhs.y-rhs.y, lhs.z-rhs.z, lhs.w-rhs.w); }
|
static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x-rhs.x, lhs.y-rhs.y, lhs.z-rhs.z, lhs.w-rhs.w); }
|
||||||
|
static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z, lhs.w*rhs.w); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline int ImMin(int lhs, int rhs) { return lhs < rhs ? lhs : rhs; }
|
static inline int ImMin(int lhs, int rhs) { return lhs < rhs ? lhs : rhs; }
|
||||||
@ -138,10 +141,13 @@ static inline int ImClamp(int v, int mn, int mx)
|
|||||||
static inline float ImClamp(float v, float mn, float mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
|
static inline float ImClamp(float v, float mn, float mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
|
||||||
static inline ImVec2 ImClamp(const ImVec2& f, const ImVec2& mn, ImVec2 mx) { return ImVec2(ImClamp(f.x,mn.x,mx.x), ImClamp(f.y,mn.y,mx.y)); }
|
static inline ImVec2 ImClamp(const ImVec2& f, const ImVec2& mn, ImVec2 mx) { return ImVec2(ImClamp(f.x,mn.x,mx.x), ImClamp(f.y,mn.y,mx.y)); }
|
||||||
static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
|
static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
|
||||||
|
static inline void ImSwap(int& a, int& b) { int tmp = a; a = b; b = tmp; }
|
||||||
|
static inline void ImSwap(float& a, float& b) { float tmp = a; a = b; b = tmp; }
|
||||||
static inline int ImLerp(int a, int b, float t) { return (int)(a + (b - a) * t); }
|
static inline int ImLerp(int a, int b, float t) { return (int)(a + (b - a) * t); }
|
||||||
static inline float ImLerp(float a, float b, float t) { return a + (b - a) * t; }
|
static inline float ImLerp(float a, float b, float t) { return a + (b - a) * t; }
|
||||||
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); }
|
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); }
|
||||||
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); }
|
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); }
|
||||||
|
static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); }
|
||||||
static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; }
|
static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; }
|
||||||
static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; }
|
static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; }
|
||||||
static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / sqrtf(d); return fail_value; }
|
static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / sqrtf(d); return fail_value; }
|
||||||
@ -149,33 +155,40 @@ static inline float ImFloor(float f)
|
|||||||
static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)v.x, (float)(int)v.y); }
|
static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)v.x, (float)(int)v.y); }
|
||||||
static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; }
|
static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; }
|
||||||
static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
|
static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
|
||||||
|
static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; }
|
||||||
|
static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
|
||||||
|
|
||||||
// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax.
|
// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax.
|
||||||
// Defining a custom placement new() with a dummy parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
|
// Defining a custom placement new() with a dummy parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
|
||||||
#ifdef IMGUI_DEFINE_PLACEMENT_NEW
|
struct ImNewPlacementDummy {};
|
||||||
struct ImPlacementNewDummy {};
|
inline void* operator new(size_t, ImNewPlacementDummy, void* ptr) { return ptr; }
|
||||||
inline void* operator new(size_t, ImPlacementNewDummy, void* ptr) { return ptr; }
|
inline void operator delete(void*, ImNewPlacementDummy, void*) {} // This is only required so we can use the symetrical new()
|
||||||
inline void operator delete(void*, ImPlacementNewDummy, void*) {}
|
#define IM_PLACEMENT_NEW(_PTR) new(ImNewPlacementDummy(), _PTR)
|
||||||
#define IM_PLACEMENT_NEW(_PTR) new(ImPlacementNewDummy(), _PTR)
|
#define IM_NEW(_TYPE) new(ImNewPlacementDummy(), ImGui::MemAlloc(sizeof(_TYPE))) _TYPE
|
||||||
#endif
|
template <typename T> void IM_DELETE(T*& p) { if (p) { p->~T(); ImGui::MemFree(p); p = NULL; } }
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Types
|
// Types
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Internal Drag and Drop payload types. String starting with '_' are reserved for Dear ImGui.
|
||||||
|
#define IMGUI_PAYLOAD_TYPE_DOCKABLE "_IMDOCK" // ImGuiWindow* // [Internal] Docking/tabs
|
||||||
|
|
||||||
enum ImGuiButtonFlags_
|
enum ImGuiButtonFlags_
|
||||||
{
|
{
|
||||||
ImGuiButtonFlags_Repeat = 1 << 0, // hold to repeat
|
ImGuiButtonFlags_Repeat = 1 << 0, // hold to repeat
|
||||||
ImGuiButtonFlags_PressedOnClickRelease = 1 << 1, // (default) return pressed on click+release on same item (default if no PressedOn** flag is set)
|
ImGuiButtonFlags_PressedOnClickRelease = 1 << 1, // return true on click + release on same item [DEFAULT if no PressedOn* flag is set]
|
||||||
ImGuiButtonFlags_PressedOnClick = 1 << 2, // return pressed on click (default requires click+release)
|
ImGuiButtonFlags_PressedOnClick = 1 << 2, // return true on click (default requires click+release)
|
||||||
ImGuiButtonFlags_PressedOnRelease = 1 << 3, // return pressed on release (default requires click+release)
|
ImGuiButtonFlags_PressedOnRelease = 1 << 3, // return true on release (default requires click+release)
|
||||||
ImGuiButtonFlags_PressedOnDoubleClick = 1 << 4, // return pressed on double-click (default requires click+release)
|
ImGuiButtonFlags_PressedOnDoubleClick = 1 << 4, // return true on double-click (default requires click+release)
|
||||||
ImGuiButtonFlags_FlattenChilds = 1 << 5, // allow interaction even if a child window is overlapping
|
ImGuiButtonFlags_FlattenChildren = 1 << 5, // allow interactions even if a child window is overlapping
|
||||||
ImGuiButtonFlags_DontClosePopups = 1 << 6, // disable automatically closing parent popup on press
|
ImGuiButtonFlags_AllowItemOverlap = 1 << 6, // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap()
|
||||||
ImGuiButtonFlags_Disabled = 1 << 7, // disable interaction
|
ImGuiButtonFlags_DontClosePopups = 1 << 7, // disable automatically closing parent popup on press // [UNUSED]
|
||||||
ImGuiButtonFlags_AlignTextBaseLine = 1 << 8, // vertically align button to match text baseline - ButtonEx() only
|
ImGuiButtonFlags_Disabled = 1 << 8, // disable interactions
|
||||||
ImGuiButtonFlags_NoKeyModifiers = 1 << 9, // disable interaction if a key modifier is held
|
ImGuiButtonFlags_AlignTextBaseLine = 1 << 9, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
|
||||||
ImGuiButtonFlags_AllowOverlapMode = 1 << 10 // require previous frame HoveredId to either match id or be null before being usable
|
ImGuiButtonFlags_NoKeyModifiers = 1 << 10, // disable interaction if a key modifier is held
|
||||||
|
ImGuiButtonFlags_NoHoldingActiveID = 1 << 11, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
|
||||||
|
ImGuiButtonFlags_PressedOnDragDropHold = 1 << 12 // press when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ImGuiSliderFlags_
|
enum ImGuiSliderFlags_
|
||||||
@ -189,18 +202,25 @@ enum ImGuiColumnsFlags_
|
|||||||
ImGuiColumnsFlags_NoBorder = 1 << 0, // Disable column dividers
|
ImGuiColumnsFlags_NoBorder = 1 << 0, // Disable column dividers
|
||||||
ImGuiColumnsFlags_NoResize = 1 << 1, // Disable resizing columns when clicking on the dividers
|
ImGuiColumnsFlags_NoResize = 1 << 1, // Disable resizing columns when clicking on the dividers
|
||||||
ImGuiColumnsFlags_NoPreserveWidths = 1 << 2, // Disable column width preservation when adjusting columns
|
ImGuiColumnsFlags_NoPreserveWidths = 1 << 2, // Disable column width preservation when adjusting columns
|
||||||
ImGuiColumnsFlags_NoForceWithinWindow = 1 << 3 // Disable forcing columns to fit within window
|
ImGuiColumnsFlags_NoForceWithinWindow = 1 << 3, // Disable forcing columns to fit within window
|
||||||
|
ImGuiColumnsFlags_GrowParentContentsSize= 1 << 4 // (WIP) Restore pre-1.51 behavior of extending the parent window contents size but _without affecting the columns width at all_. Will eventually remove.
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ImGuiSelectableFlagsPrivate_
|
enum ImGuiSelectableFlagsPrivate_
|
||||||
{
|
{
|
||||||
// NB: need to be in sync with last value of ImGuiSelectableFlags_
|
// NB: need to be in sync with last value of ImGuiSelectableFlags_
|
||||||
ImGuiSelectableFlags_Menu = 1 << 3,
|
ImGuiSelectableFlags_Menu = 1 << 3, // -> PressedOnClick
|
||||||
ImGuiSelectableFlags_MenuItem = 1 << 4,
|
ImGuiSelectableFlags_MenuItem = 1 << 4, // -> PressedOnRelease
|
||||||
ImGuiSelectableFlags_Disabled = 1 << 5,
|
ImGuiSelectableFlags_Disabled = 1 << 5,
|
||||||
ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 6
|
ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 6
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ImGuiSeparatorFlags_
|
||||||
|
{
|
||||||
|
ImGuiSeparatorFlags_Horizontal = 1 << 0, // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
|
||||||
|
ImGuiSeparatorFlags_Vertical = 1 << 1
|
||||||
|
};
|
||||||
|
|
||||||
// FIXME: this is in development, not exposed/functional as a generic feature yet.
|
// FIXME: this is in development, not exposed/functional as a generic feature yet.
|
||||||
enum ImGuiLayoutType_
|
enum ImGuiLayoutType_
|
||||||
{
|
{
|
||||||
@ -208,6 +228,13 @@ enum ImGuiLayoutType_
|
|||||||
ImGuiLayoutType_Horizontal
|
ImGuiLayoutType_Horizontal
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ImGuiAxis
|
||||||
|
{
|
||||||
|
ImGuiAxis_None = -1,
|
||||||
|
ImGuiAxis_X = 0,
|
||||||
|
ImGuiAxis_Y = 1
|
||||||
|
};
|
||||||
|
|
||||||
enum ImGuiPlotType
|
enum ImGuiPlotType
|
||||||
{
|
{
|
||||||
ImGuiPlotType_Lines,
|
ImGuiPlotType_Lines,
|
||||||
@ -218,7 +245,7 @@ enum ImGuiDataType
|
|||||||
{
|
{
|
||||||
ImGuiDataType_Int,
|
ImGuiDataType_Int,
|
||||||
ImGuiDataType_Float,
|
ImGuiDataType_Float,
|
||||||
ImGuiDataType_Float2,
|
ImGuiDataType_Float2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ImGuiDir
|
enum ImGuiDir
|
||||||
@ -228,15 +255,7 @@ enum ImGuiDir
|
|||||||
ImGuiDir_Right = 1,
|
ImGuiDir_Right = 1,
|
||||||
ImGuiDir_Up = 2,
|
ImGuiDir_Up = 2,
|
||||||
ImGuiDir_Down = 3,
|
ImGuiDir_Down = 3,
|
||||||
};
|
ImGuiDir_Count_
|
||||||
|
|
||||||
enum ImGuiCorner
|
|
||||||
{
|
|
||||||
ImGuiCorner_TopLeft = 1 << 0, // 1
|
|
||||||
ImGuiCorner_TopRight = 1 << 1, // 2
|
|
||||||
ImGuiCorner_BottomRight = 1 << 2, // 4
|
|
||||||
ImGuiCorner_BottomLeft = 1 << 3, // 8
|
|
||||||
ImGuiCorner_All = 0x0F
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 2D axis aligned bounding-box
|
// 2D axis aligned bounding-box
|
||||||
@ -269,6 +288,8 @@ struct IMGUI_API ImRect
|
|||||||
void Translate(const ImVec2& v) { Min.x += v.x; Min.y += v.y; Max.x += v.x; Max.y += v.y; }
|
void Translate(const ImVec2& v) { Min.x += v.x; Min.y += v.y; Max.x += v.x; Max.y += v.y; }
|
||||||
void ClipWith(const ImRect& clip) { if (Min.x < clip.Min.x) Min.x = clip.Min.x; if (Min.y < clip.Min.y) Min.y = clip.Min.y; if (Max.x > clip.Max.x) Max.x = clip.Max.x; if (Max.y > clip.Max.y) Max.y = clip.Max.y; }
|
void ClipWith(const ImRect& clip) { if (Min.x < clip.Min.x) Min.x = clip.Min.x; if (Min.y < clip.Min.y) Min.y = clip.Min.y; if (Max.x > clip.Max.x) Max.x = clip.Max.x; if (Max.y > clip.Max.y) Max.y = clip.Max.y; }
|
||||||
void Floor() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
|
void Floor() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
|
||||||
|
void FixInverted() { if (Min.x > Max.x) ImSwap(Min.x, Max.x); if (Min.y > Max.y) ImSwap(Min.y, Max.y); }
|
||||||
|
bool IsFinite() const { return Min.x != FLT_MAX; }
|
||||||
ImVec2 GetClosestPoint(ImVec2 p, bool on_edge) const
|
ImVec2 GetClosestPoint(ImVec2 p, bool on_edge) const
|
||||||
{
|
{
|
||||||
if (!on_edge && Contains(p))
|
if (!on_edge && Contains(p))
|
||||||
@ -312,14 +333,6 @@ struct ImGuiGroupData
|
|||||||
bool AdvanceCursor;
|
bool AdvanceCursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Per column data for Columns()
|
|
||||||
struct ImGuiColumnData
|
|
||||||
{
|
|
||||||
float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
|
|
||||||
ImRect ClipRect;
|
|
||||||
//float IndentX;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Simple column measurement currently used for MenuItem() only. This is very short-sighted/throw-away code and NOT a generic helper.
|
// Simple column measurement currently used for MenuItem() only. This is very short-sighted/throw-away code and NOT a generic helper.
|
||||||
struct IMGUI_API ImGuiSimpleColumns
|
struct IMGUI_API ImGuiSimpleColumns
|
||||||
{
|
{
|
||||||
@ -359,13 +372,24 @@ struct IMGUI_API ImGuiTextEditState
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Data saved in imgui.ini file
|
// Data saved in imgui.ini file
|
||||||
struct ImGuiIniData
|
struct ImGuiWindowSettings
|
||||||
{
|
{
|
||||||
char* Name;
|
char* Name;
|
||||||
ImGuiID Id;
|
ImGuiID Id;
|
||||||
ImVec2 Pos;
|
ImVec2 Pos;
|
||||||
ImVec2 Size;
|
ImVec2 Size;
|
||||||
bool Collapsed;
|
bool Collapsed;
|
||||||
|
|
||||||
|
ImGuiWindowSettings() { Name = NULL; Id = 0; Pos = Size = ImVec2(0,0); Collapsed = false; }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ImGuiSettingsHandler
|
||||||
|
{
|
||||||
|
const char* TypeName; // Short description stored in .ini file. Disallowed characters: '[' ']'
|
||||||
|
ImGuiID TypeHash; // == ImHash(TypeName, 0, 0)
|
||||||
|
void* (*ReadOpenFn)(ImGuiContext& ctx, const char* name);
|
||||||
|
void (*ReadLineFn)(ImGuiContext& ctx, void* entry, const char* line);
|
||||||
|
void (*WriteAllFn)(ImGuiContext& ctx, ImGuiTextBuffer* out_buf);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Mouse cursor data (used when io.MouseDrawCursor is set)
|
// Mouse cursor data (used when io.MouseDrawCursor is set)
|
||||||
@ -381,15 +405,71 @@ struct ImGuiMouseCursorData
|
|||||||
// Storage for current popup stack
|
// Storage for current popup stack
|
||||||
struct ImGuiPopupRef
|
struct ImGuiPopupRef
|
||||||
{
|
{
|
||||||
ImGuiID PopupId; // Set on OpenPopup()
|
ImGuiID PopupId; // Set on OpenPopup()
|
||||||
ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
|
ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
|
||||||
ImGuiWindow* ParentWindow; // Set on OpenPopup()
|
ImGuiWindow* ParentWindow; // Set on OpenPopup()
|
||||||
ImGuiID ParentMenuSet; // Set on OpenPopup()
|
ImGuiID ParentMenuSet; // Set on OpenPopup()
|
||||||
ImVec2 MousePosOnOpen; // Copy of mouse position at the time of opening popup
|
ImVec2 MousePosOnOpen; // Copy of mouse position at the time of opening popup
|
||||||
|
|
||||||
ImGuiPopupRef(ImGuiID id, ImGuiWindow* parent_window, ImGuiID parent_menu_set, const ImVec2& mouse_pos) { PopupId = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; MousePosOnOpen = mouse_pos; }
|
ImGuiPopupRef(ImGuiID id, ImGuiWindow* parent_window, ImGuiID parent_menu_set, const ImVec2& mouse_pos) { PopupId = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; MousePosOnOpen = mouse_pos; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ImGuiColumnData
|
||||||
|
{
|
||||||
|
float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
|
||||||
|
float OffsetNormBeforeResize;
|
||||||
|
ImGuiColumnsFlags Flags; // Not exposed
|
||||||
|
ImRect ClipRect;
|
||||||
|
|
||||||
|
ImGuiColumnData() { OffsetNorm = OffsetNormBeforeResize = 0.0f; Flags = 0; }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ImGuiColumnsSet
|
||||||
|
{
|
||||||
|
ImGuiID ID;
|
||||||
|
ImGuiColumnsFlags Flags;
|
||||||
|
bool IsFirstFrame;
|
||||||
|
bool IsBeingResized;
|
||||||
|
int Current;
|
||||||
|
int Count;
|
||||||
|
float MinX, MaxX;
|
||||||
|
float StartPosY;
|
||||||
|
float StartMaxPosX; // Backup of CursorMaxPos
|
||||||
|
float CellMinY, CellMaxY;
|
||||||
|
ImVector<ImGuiColumnData> Columns;
|
||||||
|
|
||||||
|
ImGuiColumnsSet() { Clear(); }
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
ID = 0;
|
||||||
|
Flags = 0;
|
||||||
|
IsFirstFrame = false;
|
||||||
|
IsBeingResized = false;
|
||||||
|
Current = 0;
|
||||||
|
Count = 1;
|
||||||
|
MinX = MaxX = 0.0f;
|
||||||
|
StartPosY = 0.0f;
|
||||||
|
StartMaxPosX = 0.0f;
|
||||||
|
CellMinY = CellMaxY = 0.0f;
|
||||||
|
Columns.clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ImDrawListSharedData
|
||||||
|
{
|
||||||
|
ImVec2 TexUvWhitePixel; // UV of white pixel in the atlas
|
||||||
|
ImFont* Font; // Current/default font (optional, for simplified AddText overload)
|
||||||
|
float FontSize; // Current/default font size (optional, for simplified AddText overload)
|
||||||
|
float CurveTessellationTol;
|
||||||
|
ImVec4 ClipRectFullscreen; // Value for PushClipRectFullscreen()
|
||||||
|
|
||||||
|
// Const data
|
||||||
|
// FIXME: Bake rounded corners fill/borders in atlas
|
||||||
|
ImVec2 CircleVtx12[12];
|
||||||
|
|
||||||
|
ImDrawListSharedData();
|
||||||
|
};
|
||||||
|
|
||||||
// Main state for ImGui
|
// Main state for ImGui
|
||||||
struct ImGuiContext
|
struct ImGuiContext
|
||||||
{
|
{
|
||||||
@ -399,7 +479,7 @@ struct ImGuiContext
|
|||||||
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
|
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
|
||||||
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
|
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
|
||||||
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
|
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
|
||||||
ImVec2 FontTexUvWhitePixel; // (Shortcut) == Font->TexUvWhitePixel
|
ImDrawListSharedData DrawListSharedData;
|
||||||
|
|
||||||
float Time;
|
float Time;
|
||||||
int FrameCount;
|
int FrameCount;
|
||||||
@ -408,6 +488,8 @@ struct ImGuiContext
|
|||||||
ImVector<ImGuiWindow*> Windows;
|
ImVector<ImGuiWindow*> Windows;
|
||||||
ImVector<ImGuiWindow*> WindowsSortBuffer;
|
ImVector<ImGuiWindow*> WindowsSortBuffer;
|
||||||
ImVector<ImGuiWindow*> CurrentWindowStack;
|
ImVector<ImGuiWindow*> CurrentWindowStack;
|
||||||
|
ImGuiStorage WindowsById;
|
||||||
|
int WindowsActiveCount;
|
||||||
ImGuiWindow* CurrentWindow; // Being drawn into
|
ImGuiWindow* CurrentWindow; // Being drawn into
|
||||||
ImGuiWindow* NavWindow; // Nav/focused window for navigation
|
ImGuiWindow* NavWindow; // Nav/focused window for navigation
|
||||||
ImGuiWindow* HoveredWindow; // Will catch mouse inputs
|
ImGuiWindow* HoveredWindow; // Will catch mouse inputs
|
||||||
@ -415,18 +497,17 @@ struct ImGuiContext
|
|||||||
ImGuiID HoveredId; // Hovered widget
|
ImGuiID HoveredId; // Hovered widget
|
||||||
bool HoveredIdAllowOverlap;
|
bool HoveredIdAllowOverlap;
|
||||||
ImGuiID HoveredIdPreviousFrame;
|
ImGuiID HoveredIdPreviousFrame;
|
||||||
|
float HoveredIdTimer;
|
||||||
ImGuiID ActiveId; // Active widget
|
ImGuiID ActiveId; // Active widget
|
||||||
ImGuiID ActiveIdPreviousFrame;
|
ImGuiID ActiveIdPreviousFrame;
|
||||||
|
float ActiveIdTimer;
|
||||||
bool ActiveIdIsAlive; // Active widget has been seen this frame
|
bool ActiveIdIsAlive; // Active widget has been seen this frame
|
||||||
bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
|
bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
|
||||||
bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
|
bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
|
||||||
|
|
||||||
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
||||||
ImGuiWindow* ActiveIdWindow;
|
ImGuiWindow* ActiveIdWindow;
|
||||||
ImGuiWindow* MovedWindow; // Track the child window we clicked on to move a window.
|
ImGuiWindow* MovingWindow; // Track the child window we clicked on to move a window.
|
||||||
ImGuiID MovedWindowMoveId; // == MovedWindow->RootWindow->MoveId
|
ImGuiID MovingWindowMoveId; // == MovingWindow->MoveId
|
||||||
ImVector<ImGuiIniData> Settings; // .ini Settings
|
|
||||||
float SettingsDirtyTimer; // Save .ini Settings on disk when time reaches zero
|
|
||||||
ImVector<ImGuiColMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
|
ImVector<ImGuiColMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
|
||||||
ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar()
|
ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar()
|
||||||
ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont()
|
ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont()
|
||||||
@ -435,6 +516,7 @@ struct ImGuiContext
|
|||||||
|
|
||||||
// Storage for SetNexWindow** and SetNextTreeNode*** functions
|
// Storage for SetNexWindow** and SetNextTreeNode*** functions
|
||||||
ImVec2 SetNextWindowPosVal;
|
ImVec2 SetNextWindowPosVal;
|
||||||
|
ImVec2 SetNextWindowPosPivot;
|
||||||
ImVec2 SetNextWindowSizeVal;
|
ImVec2 SetNextWindowSizeVal;
|
||||||
ImVec2 SetNextWindowContentSizeVal;
|
ImVec2 SetNextWindowContentSizeVal;
|
||||||
bool SetNextWindowCollapsedVal;
|
bool SetNextWindowCollapsedVal;
|
||||||
@ -458,6 +540,20 @@ struct ImGuiContext
|
|||||||
ImGuiMouseCursor MouseCursor;
|
ImGuiMouseCursor MouseCursor;
|
||||||
ImGuiMouseCursorData MouseCursorData[ImGuiMouseCursor_Count_];
|
ImGuiMouseCursorData MouseCursorData[ImGuiMouseCursor_Count_];
|
||||||
|
|
||||||
|
// Drag and Drop
|
||||||
|
bool DragDropActive;
|
||||||
|
ImGuiDragDropFlags DragDropSourceFlags;
|
||||||
|
int DragDropMouseButton;
|
||||||
|
ImGuiPayload DragDropPayload;
|
||||||
|
ImRect DragDropTargetRect;
|
||||||
|
ImGuiID DragDropTargetId;
|
||||||
|
float DragDropAcceptIdCurrRectSurface;
|
||||||
|
ImGuiID DragDropAcceptIdCurr; // Target item id (set at the time of accepting the payload)
|
||||||
|
ImGuiID DragDropAcceptIdPrev; // Target item id from previous frame (we need to store this to allow for overlapping drag and drop targets)
|
||||||
|
int DragDropAcceptFrameCount; // Last time a target expressed a desire to accept the source
|
||||||
|
ImVector<unsigned char> DragDropPayloadBufHeap; // We don't expose the ImVector<> directly
|
||||||
|
unsigned char DragDropPayloadBufLocal[8];
|
||||||
|
|
||||||
// Widget state
|
// Widget state
|
||||||
ImGuiTextEditState InputTextState;
|
ImGuiTextEditState InputTextState;
|
||||||
ImFont InputTextPasswordFont;
|
ImFont InputTextPasswordFont;
|
||||||
@ -474,6 +570,11 @@ struct ImGuiContext
|
|||||||
ImVector<char> PrivateClipboard; // If no custom clipboard handler is defined
|
ImVector<char> PrivateClipboard; // If no custom clipboard handler is defined
|
||||||
ImVec2 OsImePosRequest, OsImePosSet; // Cursor position request & last passed to the OS Input Method Editor
|
ImVec2 OsImePosRequest, OsImePosSet; // Cursor position request & last passed to the OS Input Method Editor
|
||||||
|
|
||||||
|
// Settings
|
||||||
|
float SettingsDirtyTimer; // Save .ini Settings on disk when time reaches zero
|
||||||
|
ImVector<ImGuiWindowSettings> SettingsWindows; // .ini settings for ImGuiWindow
|
||||||
|
ImVector<ImGuiSettingsHandler> SettingsHandlers; // List of .ini settings handlers
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
bool LogEnabled;
|
bool LogEnabled;
|
||||||
FILE* LogFile; // If != NULL log to stdout/ file
|
FILE* LogFile; // If != NULL log to stdout/ file
|
||||||
@ -485,20 +586,21 @@ struct ImGuiContext
|
|||||||
float FramerateSecPerFrame[120]; // calculate estimate of framerate for user
|
float FramerateSecPerFrame[120]; // calculate estimate of framerate for user
|
||||||
int FramerateSecPerFrameIdx;
|
int FramerateSecPerFrameIdx;
|
||||||
float FramerateSecPerFrameAccum;
|
float FramerateSecPerFrameAccum;
|
||||||
int CaptureMouseNextFrame; // explicit capture via CaptureInputs() sets those flags
|
int WantCaptureMouseNextFrame; // explicit capture via CaptureInputs() sets those flags
|
||||||
int CaptureKeyboardNextFrame;
|
int WantCaptureKeyboardNextFrame;
|
||||||
|
int WantTextInputNextFrame;
|
||||||
char TempBuffer[1024*3+1]; // temporary text buffer
|
char TempBuffer[1024*3+1]; // temporary text buffer
|
||||||
|
|
||||||
ImGuiContext()
|
ImGuiContext() : OverlayDrawList(NULL)
|
||||||
{
|
{
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
Font = NULL;
|
Font = NULL;
|
||||||
FontSize = FontBaseSize = 0.0f;
|
FontSize = FontBaseSize = 0.0f;
|
||||||
FontTexUvWhitePixel = ImVec2(0.0f, 0.0f);
|
|
||||||
|
|
||||||
Time = 0.0f;
|
Time = 0.0f;
|
||||||
FrameCount = 0;
|
FrameCount = 0;
|
||||||
FrameCountEnded = FrameCountRendered = -1;
|
FrameCountEnded = FrameCountRendered = -1;
|
||||||
|
WindowsActiveCount = 0;
|
||||||
CurrentWindow = NULL;
|
CurrentWindow = NULL;
|
||||||
NavWindow = NULL;
|
NavWindow = NULL;
|
||||||
HoveredWindow = NULL;
|
HoveredWindow = NULL;
|
||||||
@ -506,16 +608,17 @@ struct ImGuiContext
|
|||||||
HoveredId = 0;
|
HoveredId = 0;
|
||||||
HoveredIdAllowOverlap = false;
|
HoveredIdAllowOverlap = false;
|
||||||
HoveredIdPreviousFrame = 0;
|
HoveredIdPreviousFrame = 0;
|
||||||
|
HoveredIdTimer = 0.0f;
|
||||||
ActiveId = 0;
|
ActiveId = 0;
|
||||||
ActiveIdPreviousFrame = 0;
|
ActiveIdPreviousFrame = 0;
|
||||||
|
ActiveIdTimer = 0.0f;
|
||||||
ActiveIdIsAlive = false;
|
ActiveIdIsAlive = false;
|
||||||
ActiveIdIsJustActivated = false;
|
ActiveIdIsJustActivated = false;
|
||||||
ActiveIdAllowOverlap = false;
|
ActiveIdAllowOverlap = false;
|
||||||
ActiveIdClickOffset = ImVec2(-1,-1);
|
ActiveIdClickOffset = ImVec2(-1,-1);
|
||||||
ActiveIdWindow = NULL;
|
ActiveIdWindow = NULL;
|
||||||
MovedWindow = NULL;
|
MovingWindow = NULL;
|
||||||
MovedWindowMoveId = 0;
|
MovingWindowMoveId = 0;
|
||||||
SettingsDirtyTimer = 0.0f;
|
|
||||||
|
|
||||||
SetNextWindowPosVal = ImVec2(0.0f, 0.0f);
|
SetNextWindowPosVal = ImVec2(0.0f, 0.0f);
|
||||||
SetNextWindowSizeVal = ImVec2(0.0f, 0.0f);
|
SetNextWindowSizeVal = ImVec2(0.0f, 0.0f);
|
||||||
@ -532,22 +635,33 @@ struct ImGuiContext
|
|||||||
SetNextTreeNodeOpenVal = false;
|
SetNextTreeNodeOpenVal = false;
|
||||||
SetNextTreeNodeOpenCond = 0;
|
SetNextTreeNodeOpenCond = 0;
|
||||||
|
|
||||||
|
DragDropActive = false;
|
||||||
|
DragDropSourceFlags = 0;
|
||||||
|
DragDropMouseButton = -1;
|
||||||
|
DragDropTargetId = 0;
|
||||||
|
DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0;
|
||||||
|
DragDropAcceptFrameCount = -1;
|
||||||
|
memset(DragDropPayloadBufLocal, 0, sizeof(DragDropPayloadBufLocal));
|
||||||
|
|
||||||
ScalarAsInputTextId = 0;
|
ScalarAsInputTextId = 0;
|
||||||
ColorEditOptions = ImGuiColorEditFlags__OptionsDefault;
|
ColorEditOptions = ImGuiColorEditFlags__OptionsDefault;
|
||||||
DragCurrentValue = 0.0f;
|
DragCurrentValue = 0.0f;
|
||||||
DragLastMouseDelta = ImVec2(0.0f, 0.0f);
|
DragLastMouseDelta = ImVec2(0.0f, 0.0f);
|
||||||
DragSpeedDefaultRatio = 1.0f / 100.0f;
|
DragSpeedDefaultRatio = 1.0f / 100.0f;
|
||||||
DragSpeedScaleSlow = 0.01f;
|
DragSpeedScaleSlow = 1.0f / 100.0f;
|
||||||
DragSpeedScaleFast = 10.0f;
|
DragSpeedScaleFast = 10.0f;
|
||||||
ScrollbarClickDeltaToGrabCenter = ImVec2(0.0f, 0.0f);
|
ScrollbarClickDeltaToGrabCenter = ImVec2(0.0f, 0.0f);
|
||||||
TooltipOverrideCount = 0;
|
TooltipOverrideCount = 0;
|
||||||
OsImePosRequest = OsImePosSet = ImVec2(-1.0f, -1.0f);
|
OsImePosRequest = OsImePosSet = ImVec2(-1.0f, -1.0f);
|
||||||
|
|
||||||
ModalWindowDarkeningRatio = 0.0f;
|
ModalWindowDarkeningRatio = 0.0f;
|
||||||
|
OverlayDrawList._Data = &DrawListSharedData;
|
||||||
OverlayDrawList._OwnerName = "##Overlay"; // Give it a name for debugging
|
OverlayDrawList._OwnerName = "##Overlay"; // Give it a name for debugging
|
||||||
MouseCursor = ImGuiMouseCursor_Arrow;
|
MouseCursor = ImGuiMouseCursor_Arrow;
|
||||||
memset(MouseCursorData, 0, sizeof(MouseCursorData));
|
memset(MouseCursorData, 0, sizeof(MouseCursorData));
|
||||||
|
|
||||||
|
SettingsDirtyTimer = 0.0f;
|
||||||
|
|
||||||
LogEnabled = false;
|
LogEnabled = false;
|
||||||
LogFile = NULL;
|
LogFile = NULL;
|
||||||
LogClipboard = NULL;
|
LogClipboard = NULL;
|
||||||
@ -557,11 +671,23 @@ struct ImGuiContext
|
|||||||
memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
|
memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
|
||||||
FramerateSecPerFrameIdx = 0;
|
FramerateSecPerFrameIdx = 0;
|
||||||
FramerateSecPerFrameAccum = 0.0f;
|
FramerateSecPerFrameAccum = 0.0f;
|
||||||
CaptureMouseNextFrame = CaptureKeyboardNextFrame = -1;
|
WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = WantTextInputNextFrame = -1;
|
||||||
memset(TempBuffer, 0, sizeof(TempBuffer));
|
memset(TempBuffer, 0, sizeof(TempBuffer));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Transient per-window flags, reset at the beginning of the frame. For child window, inherited from parent on first Begin().
|
||||||
|
enum ImGuiItemFlags_
|
||||||
|
{
|
||||||
|
ImGuiItemFlags_AllowKeyboardFocus = 1 << 0, // true
|
||||||
|
ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
|
||||||
|
ImGuiItemFlags_Disabled = 1 << 2, // false // FIXME-WIP: Disable interactions but doesn't affect visuals. Should be: grey out and disable interactions with widgets that affect data + view widgets (WIP)
|
||||||
|
//ImGuiItemFlags_NoNav = 1 << 3, // false
|
||||||
|
//ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false
|
||||||
|
ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // MenuItem/Selectable() automatically closes current Popup window
|
||||||
|
ImGuiItemFlags_Default_ = ImGuiItemFlags_AllowKeyboardFocus
|
||||||
|
};
|
||||||
|
|
||||||
// Transient per-window data, reset at the beginning of the frame
|
// Transient per-window data, reset at the beginning of the frame
|
||||||
// FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiDrawContext is quite tenuous and could be reconsidered.
|
// FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiDrawContext is quite tenuous and could be reconsidered.
|
||||||
struct IMGUI_API ImGuiDrawContext
|
struct IMGUI_API ImGuiDrawContext
|
||||||
@ -569,7 +695,7 @@ struct IMGUI_API ImGuiDrawContext
|
|||||||
ImVec2 CursorPos;
|
ImVec2 CursorPos;
|
||||||
ImVec2 CursorPosPrevLine;
|
ImVec2 CursorPosPrevLine;
|
||||||
ImVec2 CursorStartPos;
|
ImVec2 CursorStartPos;
|
||||||
ImVec2 CursorMaxPos; // Implicitly calculate the size of our contents, always extending. Saved into window->SizeContents at the end of the frame
|
ImVec2 CursorMaxPos; // Used to implicitly calculate the size of our contents, always growing during the frame. Turned into window->SizeContents at the beginning of next frame
|
||||||
float CurrentLineHeight;
|
float CurrentLineHeight;
|
||||||
float CurrentLineTextBaseOffset;
|
float CurrentLineTextBaseOffset;
|
||||||
float PrevLineHeight;
|
float PrevLineHeight;
|
||||||
@ -578,8 +704,7 @@ struct IMGUI_API ImGuiDrawContext
|
|||||||
int TreeDepth;
|
int TreeDepth;
|
||||||
ImGuiID LastItemId;
|
ImGuiID LastItemId;
|
||||||
ImRect LastItemRect;
|
ImRect LastItemRect;
|
||||||
bool LastItemHoveredAndUsable; // Item rectangle is hovered, and its window is currently interactable with (not blocked by a popup preventing access to the window)
|
bool LastItemRectHoveredRect;
|
||||||
bool LastItemHoveredRect; // Item rectangle is hovered, but its window may or not be currently interactable with (might be blocked by a popup preventing access to the window)
|
|
||||||
bool MenuBarAppending;
|
bool MenuBarAppending;
|
||||||
float MenuBarOffsetX;
|
float MenuBarOffsetX;
|
||||||
ImVector<ImGuiWindow*> ChildWindows;
|
ImVector<ImGuiWindow*> ChildWindows;
|
||||||
@ -587,31 +712,19 @@ struct IMGUI_API ImGuiDrawContext
|
|||||||
ImGuiLayoutType LayoutType;
|
ImGuiLayoutType LayoutType;
|
||||||
|
|
||||||
// We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
|
// We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
|
||||||
|
ImGuiItemFlags ItemFlags; // == ItemFlagsStack.back() [empty == ImGuiItemFlags_Default]
|
||||||
float ItemWidth; // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
|
float ItemWidth; // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
|
||||||
float TextWrapPos; // == TextWrapPosStack.back() [empty == -1.0f]
|
float TextWrapPos; // == TextWrapPosStack.back() [empty == -1.0f]
|
||||||
bool AllowKeyboardFocus; // == AllowKeyboardFocusStack.back() [empty == true]
|
ImVector<ImGuiItemFlags>ItemFlagsStack;
|
||||||
bool ButtonRepeat; // == ButtonRepeatStack.back() [empty == false]
|
|
||||||
ImVector<float> ItemWidthStack;
|
ImVector<float> ItemWidthStack;
|
||||||
ImVector<float> TextWrapPosStack;
|
ImVector<float> TextWrapPosStack;
|
||||||
ImVector<bool> AllowKeyboardFocusStack;
|
|
||||||
ImVector<bool> ButtonRepeatStack;
|
|
||||||
ImVector<ImGuiGroupData>GroupStack;
|
ImVector<ImGuiGroupData>GroupStack;
|
||||||
int StackSizesBackup[6]; // Store size of various stacks for asserting
|
int StackSizesBackup[6]; // Store size of various stacks for asserting
|
||||||
|
|
||||||
float IndentX; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
|
float IndentX; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
|
||||||
float GroupOffsetX;
|
float GroupOffsetX;
|
||||||
float ColumnsOffsetX; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
|
float ColumnsOffsetX; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
|
||||||
int ColumnsCurrent;
|
ImGuiColumnsSet* ColumnsSet; // Current columns set
|
||||||
int ColumnsCount;
|
|
||||||
float ColumnsMinX;
|
|
||||||
float ColumnsMaxX;
|
|
||||||
float ColumnsStartPosY;
|
|
||||||
float ColumnsStartMaxPosX; // Backup of CursorMaxPos
|
|
||||||
float ColumnsCellMinY;
|
|
||||||
float ColumnsCellMaxY;
|
|
||||||
ImGuiColumnsFlags ColumnsFlags;
|
|
||||||
ImGuiID ColumnsSetId;
|
|
||||||
ImVector<ImGuiColumnData> ColumnsData;
|
|
||||||
|
|
||||||
ImGuiDrawContext()
|
ImGuiDrawContext()
|
||||||
{
|
{
|
||||||
@ -621,29 +734,21 @@ struct IMGUI_API ImGuiDrawContext
|
|||||||
LogLinePosY = -1.0f;
|
LogLinePosY = -1.0f;
|
||||||
TreeDepth = 0;
|
TreeDepth = 0;
|
||||||
LastItemId = 0;
|
LastItemId = 0;
|
||||||
LastItemRect = ImRect(0.0f,0.0f,0.0f,0.0f);
|
LastItemRect = ImRect();
|
||||||
LastItemHoveredAndUsable = LastItemHoveredRect = false;
|
LastItemRectHoveredRect = false;
|
||||||
MenuBarAppending = false;
|
MenuBarAppending = false;
|
||||||
MenuBarOffsetX = 0.0f;
|
MenuBarOffsetX = 0.0f;
|
||||||
StateStorage = NULL;
|
StateStorage = NULL;
|
||||||
LayoutType = ImGuiLayoutType_Vertical;
|
LayoutType = ImGuiLayoutType_Vertical;
|
||||||
ItemWidth = 0.0f;
|
ItemWidth = 0.0f;
|
||||||
ButtonRepeat = false;
|
ItemFlags = ImGuiItemFlags_Default_;
|
||||||
AllowKeyboardFocus = true;
|
|
||||||
TextWrapPos = -1.0f;
|
TextWrapPos = -1.0f;
|
||||||
memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
|
memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
|
||||||
|
|
||||||
IndentX = 0.0f;
|
IndentX = 0.0f;
|
||||||
GroupOffsetX = 0.0f;
|
GroupOffsetX = 0.0f;
|
||||||
ColumnsOffsetX = 0.0f;
|
ColumnsOffsetX = 0.0f;
|
||||||
ColumnsCurrent = 0;
|
ColumnsSet = NULL;
|
||||||
ColumnsCount = 1;
|
|
||||||
ColumnsMinX = ColumnsMaxX = 0.0f;
|
|
||||||
ColumnsStartPosY = 0.0f;
|
|
||||||
ColumnsStartMaxPosX = 0.0f;
|
|
||||||
ColumnsCellMinY = ColumnsCellMaxY = 0.0f;
|
|
||||||
ColumnsFlags = 0;
|
|
||||||
ColumnsSetId = 0;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -653,52 +758,60 @@ struct IMGUI_API ImGuiWindow
|
|||||||
char* Name;
|
char* Name;
|
||||||
ImGuiID ID; // == ImHash(Name)
|
ImGuiID ID; // == ImHash(Name)
|
||||||
ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_
|
ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_
|
||||||
int OrderWithinParent; // Order within immediate parent window, if we are a child window. Otherwise 0.
|
|
||||||
ImVec2 PosFloat;
|
ImVec2 PosFloat;
|
||||||
ImVec2 Pos; // Position rounded-up to nearest pixel
|
ImVec2 Pos; // Position rounded-up to nearest pixel
|
||||||
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
|
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
|
||||||
ImVec2 SizeFull; // Size when non collapsed
|
ImVec2 SizeFull; // Size when non collapsed
|
||||||
ImVec2 SizeContents; // Size of contents (== extents reach of the drawing cursor) from previous frame
|
ImVec2 SizeFullAtLastBegin; // Copy of SizeFull at the end of Begin. This is the reference value we'll use on the next frame to decide if we need scrollbars.
|
||||||
|
ImVec2 SizeContents; // Size of contents (== extents reach of the drawing cursor) from previous frame. Include decoration, window title, border, menu, etc.
|
||||||
ImVec2 SizeContentsExplicit; // Size of contents explicitly set by the user via SetNextWindowContentSize()
|
ImVec2 SizeContentsExplicit; // Size of contents explicitly set by the user via SetNextWindowContentSize()
|
||||||
ImRect ContentsRegionRect; // Maximum visible content position in window coordinates. ~~ (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis
|
ImRect ContentsRegionRect; // Maximum visible content position in window coordinates. ~~ (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis
|
||||||
ImVec2 WindowPadding; // Window padding at the time of begin. We need to lock it, in particular manipulation of the ShowBorder would have an effect
|
ImVec2 WindowPadding; // Window padding at the time of begin.
|
||||||
|
float WindowRounding; // Window rounding at the time of begin.
|
||||||
|
float WindowBorderSize; // Window border size at the time of begin.
|
||||||
ImGuiID MoveId; // == window->GetID("#MOVE")
|
ImGuiID MoveId; // == window->GetID("#MOVE")
|
||||||
ImVec2 Scroll;
|
ImVec2 Scroll;
|
||||||
ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
|
ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
|
||||||
ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
|
ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
|
||||||
bool ScrollbarX, ScrollbarY;
|
bool ScrollbarX, ScrollbarY;
|
||||||
ImVec2 ScrollbarSizes;
|
ImVec2 ScrollbarSizes;
|
||||||
float BorderSize;
|
|
||||||
bool Active; // Set to true on Begin()
|
bool Active; // Set to true on Begin()
|
||||||
bool WasActive;
|
bool WasActive;
|
||||||
bool Accessed; // Set to true when any widget access the current window
|
bool WriteAccessed; // Set to true when any widget access the current window
|
||||||
bool Collapsed; // Set when collapsing window to become only title-bar
|
bool Collapsed; // Set when collapsing window to become only title-bar
|
||||||
bool SkipItems; // == Visible && !Collapsed
|
bool SkipItems; // Set when items can safely be all clipped (e.g. window not visible or collapsed)
|
||||||
|
bool Appearing; // Set during the frame where the window is appearing (or re-appearing)
|
||||||
|
bool CloseButton; // Set when the window has a close button (p_open != NULL)
|
||||||
|
int BeginOrderWithinParent; // Order within immediate parent window, if we are a child window. Otherwise 0.
|
||||||
|
int BeginOrderWithinContext; // Order within entire imgui context. This is mostly used for debugging submission order related issues.
|
||||||
int BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
|
int BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
|
||||||
ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
|
ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
|
||||||
int AutoFitFramesX, AutoFitFramesY;
|
int AutoFitFramesX, AutoFitFramesY;
|
||||||
bool AutoFitOnlyGrows;
|
bool AutoFitOnlyGrows;
|
||||||
int AutoFitChildAxises;
|
int AutoFitChildAxises;
|
||||||
int AutoPosLastDirection;
|
ImGuiDir AutoPosLastDirection;
|
||||||
int HiddenFrames;
|
int HiddenFrames;
|
||||||
ImGuiCond SetWindowPosAllowFlags; // store condition flags for next SetWindowPos() call.
|
ImGuiCond SetWindowPosAllowFlags; // store condition flags for next SetWindowPos() call.
|
||||||
ImGuiCond SetWindowSizeAllowFlags; // store condition flags for next SetWindowSize() call.
|
ImGuiCond SetWindowSizeAllowFlags; // store condition flags for next SetWindowSize() call.
|
||||||
ImGuiCond SetWindowCollapsedAllowFlags; // store condition flags for next SetWindowCollapsed() call.
|
ImGuiCond SetWindowCollapsedAllowFlags; // store condition flags for next SetWindowCollapsed() call.
|
||||||
bool SetWindowPosCenterWanted;
|
ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
|
||||||
|
ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0,0) when positioning from top-left corner; ImVec2(0.5f,0.5f) for centering; ImVec2(1,1) for bottom right.
|
||||||
|
|
||||||
ImGuiDrawContext DC; // Temporary per-window data, reset at the beginning of the frame
|
ImGuiDrawContext DC; // Temporary per-window data, reset at the beginning of the frame
|
||||||
ImVector<ImGuiID> IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack
|
ImVector<ImGuiID> IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack
|
||||||
ImRect ClipRect; // = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
|
ImRect ClipRect; // = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
|
||||||
ImRect WindowRectClipped; // = WindowRect just after setup in Begin(). == window->Rect() for root window.
|
ImRect WindowRectClipped; // = WindowRect just after setup in Begin(). == window->Rect() for root window.
|
||||||
|
ImRect InnerRect;
|
||||||
int LastFrameActive;
|
int LastFrameActive;
|
||||||
float ItemWidthDefault;
|
float ItemWidthDefault;
|
||||||
ImGuiSimpleColumns MenuColumns; // Simplified columns storage for menu items
|
ImGuiSimpleColumns MenuColumns; // Simplified columns storage for menu items
|
||||||
ImGuiStorage StateStorage;
|
ImGuiStorage StateStorage;
|
||||||
|
ImVector<ImGuiColumnsSet> ColumnsStorage;
|
||||||
float FontWindowScale; // Scale multiplier per-window
|
float FontWindowScale; // Scale multiplier per-window
|
||||||
ImDrawList* DrawList;
|
ImDrawList* DrawList;
|
||||||
ImGuiWindow* RootWindow; // If we are a child window, this is pointing to the first non-child parent window. Else point to ourself.
|
ImGuiWindow* ParentWindow; // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL.
|
||||||
ImGuiWindow* RootNonPopupWindow; // If we are a child window, this is pointing to the first non-child non-popup parent window. Else point to ourself.
|
ImGuiWindow* RootWindow; // Generally point to ourself. If we are a child window, this is pointing to the first non-child parent window.
|
||||||
ImGuiWindow* ParentWindow; // If we are a child window, this is pointing to our parent window. Else point to NULL.
|
ImGuiWindow* RootNonPopupWindow; // Generally point to ourself. Used to display TitleBgActive color and for selecting which window to use for NavWindowing
|
||||||
|
|
||||||
// Navigation / Focus
|
// Navigation / Focus
|
||||||
int FocusIdxAllCounter; // Start at -1 and increase as assigned via FocusItemRegister()
|
int FocusIdxAllCounter; // Start at -1 and increase as assigned via FocusItemRegister()
|
||||||
@ -709,13 +822,15 @@ struct IMGUI_API ImGuiWindow
|
|||||||
int FocusIdxTabRequestNext; // "
|
int FocusIdxTabRequestNext; // "
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ImGuiWindow(const char* name);
|
ImGuiWindow(ImGuiContext* context, const char* name);
|
||||||
~ImGuiWindow();
|
~ImGuiWindow();
|
||||||
|
|
||||||
ImGuiID GetID(const char* str, const char* str_end = NULL);
|
ImGuiID GetID(const char* str, const char* str_end = NULL);
|
||||||
ImGuiID GetID(const void* ptr);
|
ImGuiID GetID(const void* ptr);
|
||||||
ImGuiID GetIDNoKeepAlive(const char* str, const char* str_end = NULL);
|
ImGuiID GetIDNoKeepAlive(const char* str, const char* str_end = NULL);
|
||||||
|
ImGuiID GetIDFromRectangle(const ImRect& r_abs);
|
||||||
|
|
||||||
|
// We don't use g.FontSize because the window may be != g.CurrentWidow.
|
||||||
ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x+Size.x, Pos.y+Size.y); }
|
ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x+Size.x, Pos.y+Size.y); }
|
||||||
float CalcFontSize() const { return GImGui->FontBaseSize * FontWindowScale; }
|
float CalcFontSize() const { return GImGui->FontBaseSize * FontWindowScale; }
|
||||||
float TitleBarHeight() const { return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f; }
|
float TitleBarHeight() const { return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f; }
|
||||||
@ -724,6 +839,18 @@ public:
|
|||||||
ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
|
ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Backup and restore just enough data to be able to use IsItemHovered() on item A after another B in the same window has overwritten the data.
|
||||||
|
struct ImGuiItemHoveredDataBackup
|
||||||
|
{
|
||||||
|
ImGuiID LastItemId;
|
||||||
|
ImRect LastItemRect;
|
||||||
|
bool LastItemRectHoveredRect;
|
||||||
|
|
||||||
|
ImGuiItemHoveredDataBackup() { Backup(); }
|
||||||
|
void Backup() { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemRect = window->DC.LastItemRect; LastItemRectHoveredRect = window->DC.LastItemRectHoveredRect; }
|
||||||
|
void Restore() const { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemRect = LastItemRect; window->DC.LastItemRectHoveredRect = LastItemRectHoveredRect; }
|
||||||
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Internal API
|
// Internal API
|
||||||
// No guarantee of forward compatibility here.
|
// No guarantee of forward compatibility here.
|
||||||
@ -736,12 +863,18 @@ namespace ImGui
|
|||||||
// - ImGui::NewFrame() has never been called, which is illegal.
|
// - ImGui::NewFrame() has never been called, which is illegal.
|
||||||
// - You are calling ImGui functions after ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
|
// - You are calling ImGui functions after ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
|
||||||
inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; }
|
inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; }
|
||||||
inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->Accessed = true; return g.CurrentWindow; }
|
inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; }
|
||||||
IMGUI_API ImGuiWindow* GetParentWindow();
|
|
||||||
IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
|
IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
|
||||||
IMGUI_API void FocusWindow(ImGuiWindow* window);
|
IMGUI_API void FocusWindow(ImGuiWindow* window);
|
||||||
|
IMGUI_API void BringWindowToFront(ImGuiWindow* window);
|
||||||
|
IMGUI_API void BringWindowToBack(ImGuiWindow* window);
|
||||||
|
IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
|
||||||
|
|
||||||
IMGUI_API void EndFrame(); // Ends the ImGui frame. Automatically called by Render()! you most likely don't need to ever call that yourself directly. If you don't need to render you can call EndFrame() but you'll have wasted CPU already. If you don't need to render, don't create any windows instead!
|
IMGUI_API void Initialize();
|
||||||
|
|
||||||
|
IMGUI_API void MarkIniSettingsDirty();
|
||||||
|
IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(ImGuiID type_id);
|
||||||
|
IMGUI_API ImGuiWindowSettings* FindWindowSettings(ImGuiID id);
|
||||||
|
|
||||||
IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
|
IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
|
||||||
IMGUI_API void ClearActiveID();
|
IMGUI_API void ClearActiveID();
|
||||||
@ -750,20 +883,36 @@ namespace ImGui
|
|||||||
|
|
||||||
IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
|
IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
|
||||||
IMGUI_API void ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
|
IMGUI_API void ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
|
||||||
IMGUI_API bool ItemAdd(const ImRect& bb, const ImGuiID* id);
|
IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id);
|
||||||
IMGUI_API bool IsClippedEx(const ImRect& bb, const ImGuiID* id, bool clip_even_when_logged);
|
IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id);
|
||||||
IMGUI_API bool IsHovered(const ImRect& bb, ImGuiID id, bool flatten_childs = false);
|
IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
|
||||||
IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, bool is_active, bool tab_stop = true); // Return true if focus is requested
|
IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id, bool tab_stop = true); // Return true if focus is requested
|
||||||
IMGUI_API void FocusableItemUnregister(ImGuiWindow* window);
|
IMGUI_API void FocusableItemUnregister(ImGuiWindow* window);
|
||||||
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_x, float default_y);
|
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_x, float default_y);
|
||||||
IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
|
IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
|
||||||
|
IMGUI_API void PushMultiItemsWidths(int components, float width_full = 0.0f);
|
||||||
|
IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled);
|
||||||
|
IMGUI_API void PopItemFlag();
|
||||||
|
|
||||||
IMGUI_API void OpenPopupEx(ImGuiID id, bool reopen_existing);
|
IMGUI_API void OpenPopupEx(ImGuiID id, bool reopen_existing);
|
||||||
|
IMGUI_API void ClosePopup(ImGuiID id);
|
||||||
IMGUI_API bool IsPopupOpen(ImGuiID id);
|
IMGUI_API bool IsPopupOpen(ImGuiID id);
|
||||||
|
IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
|
||||||
|
IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip = true);
|
||||||
|
|
||||||
// New Columns API
|
IMGUI_API int CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate);
|
||||||
IMGUI_API void BeginColumns(const char* id, int count, ImGuiColumnsFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns().
|
|
||||||
IMGUI_API void EndColumns(); // close columns
|
IMGUI_API void Scrollbar(ImGuiLayoutType direction);
|
||||||
|
IMGUI_API void VerticalSeparator(); // Vertical separator, for menu bars (use current line height). not exposed because it is misleading what it doesn't have an effect on regular layout.
|
||||||
|
IMGUI_API bool SplitterBehavior(ImGuiID id, const ImRect& bb, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend = 0.0f);
|
||||||
|
|
||||||
|
IMGUI_API bool BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id);
|
||||||
|
IMGUI_API void ClearDragDrop();
|
||||||
|
IMGUI_API bool IsDragDropPayloadBeingAccepted();
|
||||||
|
|
||||||
|
// FIXME-WIP: New Columns API
|
||||||
|
IMGUI_API void BeginColumns(const char* str_id, int count, ImGuiColumnsFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns().
|
||||||
|
IMGUI_API void EndColumns(); // close columns
|
||||||
IMGUI_API void PushColumnClipRect(int column_index = -1);
|
IMGUI_API void PushColumnClipRect(int column_index = -1);
|
||||||
|
|
||||||
// NB: All position are in absolute pixels coordinates (never using window coordinates internally)
|
// NB: All position are in absolute pixels coordinates (never using window coordinates internally)
|
||||||
@ -774,14 +923,16 @@ namespace ImGui
|
|||||||
IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
|
IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
|
||||||
IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f);
|
IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f);
|
||||||
IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, int rounding_corners_flags = ~0);
|
IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, int rounding_corners_flags = ~0);
|
||||||
IMGUI_API void RenderCollapseTriangle(ImVec2 pos, bool is_open, float scale = 1.0f);
|
IMGUI_API void RenderTriangle(ImVec2 pos, ImGuiDir dir, float scale = 1.0f);
|
||||||
IMGUI_API void RenderBullet(ImVec2 pos);
|
IMGUI_API void RenderBullet(ImVec2 pos);
|
||||||
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col);
|
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col, float sz);
|
||||||
|
IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
|
||||||
IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
|
IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
|
||||||
|
|
||||||
IMGUI_API bool ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
|
IMGUI_API bool ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
|
||||||
IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0,0), ImGuiButtonFlags flags = 0);
|
IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0,0), ImGuiButtonFlags flags = 0);
|
||||||
IMGUI_API bool CloseButton(ImGuiID id, const ImVec2& pos, float radius);
|
IMGUI_API bool CloseButton(ImGuiID id, const ImVec2& pos, float radius);
|
||||||
|
IMGUI_API bool ArrowButton(ImGuiID id, ImGuiDir dir, ImVec2 padding, ImGuiButtonFlags flags = 0);
|
||||||
|
|
||||||
IMGUI_API bool SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_min, float v_max, float power, int decimal_precision, ImGuiSliderFlags flags = 0);
|
IMGUI_API bool SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_min, float v_max, float power, int decimal_precision, ImGuiSliderFlags flags = 0);
|
||||||
IMGUI_API bool SliderFloatN(const char* label, float* v, int components, float v_min, float v_max, const char* display_format, float power);
|
IMGUI_API bool SliderFloatN(const char* label, float* v, int components, float v_min, float v_max, const char* display_format, float power);
|
||||||
@ -797,7 +948,8 @@ namespace ImGui
|
|||||||
IMGUI_API bool InputScalarEx(const char* label, ImGuiDataType data_type, void* data_ptr, void* step_ptr, void* step_fast_ptr, const char* scalar_format, ImGuiInputTextFlags extra_flags);
|
IMGUI_API bool InputScalarEx(const char* label, ImGuiDataType data_type, void* data_ptr, void* step_ptr, void* step_fast_ptr, const char* scalar_format, ImGuiInputTextFlags extra_flags);
|
||||||
IMGUI_API bool InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label, ImGuiDataType data_type, void* data_ptr, ImGuiID id, int decimal_precision);
|
IMGUI_API bool InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label, ImGuiDataType data_type, void* data_ptr, ImGuiID id, int decimal_precision);
|
||||||
|
|
||||||
IMGUI_API void ColorTooltip(const char* text, const float col[4], ImGuiColorEditFlags flags);
|
IMGUI_API void ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags);
|
||||||
|
IMGUI_API void ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags);
|
||||||
|
|
||||||
IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
|
IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
|
||||||
IMGUI_API bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextTreeNodeOpened() data, if any. May return true when logging
|
IMGUI_API bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextTreeNodeOpened() data, if any. May return true when logging
|
||||||
@ -808,6 +960,11 @@ namespace ImGui
|
|||||||
IMGUI_API int ParseFormatPrecision(const char* fmt, int default_value);
|
IMGUI_API int ParseFormatPrecision(const char* fmt, int default_value);
|
||||||
IMGUI_API float RoundScalar(float value, int decimal_precision);
|
IMGUI_API float RoundScalar(float value, int decimal_precision);
|
||||||
|
|
||||||
|
// Shade functions
|
||||||
|
IMGUI_API void ShadeVertsLinearColorGradientKeepAlpha(ImDrawVert* vert_start, ImDrawVert* vert_end, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1);
|
||||||
|
IMGUI_API void ShadeVertsLinearAlphaGradientForLeftToRightText(ImDrawVert* vert_start, ImDrawVert* vert_end, float gradient_p0_x, float gradient_p1_x);
|
||||||
|
IMGUI_API void ShadeVertsLinearUV(ImDrawVert* vert_start, ImDrawVert* vert_end, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp);
|
||||||
|
|
||||||
} // namespace ImGui
|
} // namespace ImGui
|
||||||
|
|
||||||
// ImFontAtlas internals
|
// ImFontAtlas internals
|
||||||
@ -815,7 +972,9 @@ IMGUI_API bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas);
|
|||||||
IMGUI_API void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas);
|
IMGUI_API void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas);
|
||||||
IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
|
IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
|
||||||
IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* spc);
|
IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* spc);
|
||||||
IMGUI_API void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas);
|
IMGUI_API void ImFontAtlasBuildFinish(ImFontAtlas* atlas);
|
||||||
|
IMGUI_API void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_multiply_factor);
|
||||||
|
IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride);
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
|
Reference in New Issue
Block a user