mirror of
https://github.com/ocornut/imgui.git
synced 2026-07-06 09:35:21 +00:00
Compare commits
1904 Commits
v1.89.5
...
v1.90.4-do
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6aa051629 | ||
|
|
277ae93c41 | ||
|
|
f5be90523d | ||
|
|
13d91ff918 | ||
|
|
34965cf23a | ||
|
|
659fb41d0a | ||
|
|
198c38f0b1 | ||
|
|
3b6d924acd | ||
|
|
2b662b1ab9 | ||
|
|
d3f1a7165c | ||
|
|
e78ce72eb6 | ||
|
|
014e0ac8c9 | ||
|
|
c16043c1d5 | ||
|
|
405e54ebd5 | ||
|
|
6655ab2e43 | ||
|
|
9159cd7b4a | ||
|
|
ccc5347e45 | ||
|
|
8a14b71f22 | ||
|
|
b19a4c5f2b | ||
|
|
8048b52498 | ||
|
|
c66a1e7d51 | ||
|
|
d79514c407 | ||
|
|
5b6f03213d | ||
|
|
f80e65a406 | ||
|
|
829f45df99 | ||
|
|
3cc37170ca | ||
|
|
891b81fc5d | ||
|
|
262e30e300 | ||
|
|
9dfa2397de | ||
|
|
d15e4100b8 | ||
|
|
f966da1f8f | ||
|
|
bf1c96d4fa | ||
|
|
fd8d6dc5d1 | ||
|
|
e0ba0d0433 | ||
|
|
11d73f03ee | ||
|
|
89019319dd | ||
|
|
1d6f0cea0e | ||
|
|
3af739a2d1 | ||
|
|
2af01baffd | ||
|
|
915c6393ad | ||
|
|
8490a262c4 | ||
|
|
71bcf350bd | ||
|
|
536090303a | ||
|
|
7b5357d817 | ||
|
|
30ba3c347c | ||
|
|
59c8db69eb | ||
|
|
70aa717a8e | ||
|
|
5cdc4a2a41 | ||
|
|
76e09c4b0f | ||
|
|
3a078466a7 | ||
|
|
7d67623d15 | ||
|
|
a5e0e90c16 | ||
|
|
1e8fc01ddd | ||
|
|
a06dd7a27b | ||
|
|
f104967c68 | ||
|
|
82eeafc196 | ||
|
|
06ce312745 | ||
|
|
f50ddc431e | ||
|
|
6172c22c5d | ||
|
|
96839b445e | ||
|
|
7194756370 | ||
|
|
f1960b60c1 | ||
|
|
8491cf36ad | ||
|
|
9176eedf24 | ||
|
|
1509842107 | ||
|
|
1ce41f6218 | ||
|
|
54ef4092a9 | ||
|
|
81e0be856a | ||
|
|
eb42e164dd | ||
|
|
a201af7354 | ||
|
|
4c2c09450a | ||
|
|
5b5e9bd0cb | ||
|
|
7c3fa7d049 | ||
|
|
9266c0d2d1 | ||
|
|
595eb86624 | ||
|
|
6850194f60 | ||
|
|
5fc0a361b2 | ||
|
|
831d42c1ab | ||
|
|
e3c7ff944d | ||
|
|
15908502ed | ||
|
|
788747f863 | ||
|
|
763100b385 | ||
|
|
c7edb446ca | ||
|
|
1844f903d5 | ||
|
|
5ddfbb80d8 | ||
|
|
01b99a974d | ||
|
|
2f48337335 | ||
|
|
cab7edd135 | ||
|
|
d7c2a0e38f | ||
|
|
3b828d3701 | ||
|
|
ff5f3aa38b | ||
|
|
1a48a63446 | ||
|
|
33fabdf392 | ||
|
|
d431d85839 | ||
|
|
f0d1f61fa5 | ||
|
|
095665977f | ||
|
|
d10641b04a | ||
|
|
03417cc77d | ||
|
|
5fdcdf7080 | ||
|
|
80d5cb1ab1 | ||
|
|
80c83a4277 | ||
|
|
cceff4684a | ||
|
|
1cc0eb4d32 | ||
|
|
69b64e2b73 | ||
|
|
a27f22f0e9 | ||
|
|
46e5f44ec8 | ||
|
|
e0c8c80ada | ||
|
|
4b20a0217e | ||
|
|
2156db7a07 | ||
|
|
dd0efdc637 | ||
|
|
8a3dfda8d0 | ||
|
|
6228c2e1ec | ||
|
|
32a3c61d00 | ||
|
|
70bb6d1e79 | ||
|
|
82df7c8bf4 | ||
|
|
29809d7220 | ||
|
|
db049db860 | ||
|
|
2dc85e6e43 | ||
|
|
d6cb3c923d | ||
|
|
6470e2279e | ||
|
|
fdf8d02be1 | ||
|
|
788bb58b6b | ||
|
|
a5dec42866 | ||
|
|
a3eea8a75a | ||
|
|
cf02023565 | ||
|
|
69bf3291df | ||
|
|
ebcfcd8da3 | ||
|
|
8deb1007cd | ||
|
|
a683033e49 | ||
|
|
af00b182e3 | ||
|
|
fc2e532f99 | ||
|
|
8323a06e6d | ||
|
|
58261dbe9a | ||
|
|
f1ae47c4b9 | ||
|
|
7f9533b840 | ||
|
|
27e83c2953 | ||
|
|
278cf1a7bc | ||
|
|
edeb8ee3ab | ||
|
|
c6716f5e9f | ||
|
|
a1b06823fe | ||
|
|
0461ade24b | ||
|
|
c528b688cf | ||
|
|
26eef4df87 | ||
|
|
7938550d52 | ||
|
|
4758f74676 | ||
|
|
e3d7cd665d | ||
|
|
6f10cef2a1 | ||
|
|
33d18c580b | ||
|
|
0ea99132c8 | ||
|
|
4778560e66 | ||
|
|
e8dd47effa | ||
|
|
718fa0eec6 | ||
|
|
2523c197bc | ||
|
|
240ab5890b | ||
|
|
4a2426449a | ||
|
|
20e1caec85 | ||
|
|
f039e69b9c | ||
|
|
4aa81116a5 | ||
|
|
8340a30d27 | ||
|
|
1e1013085b | ||
|
|
036a6c875e | ||
|
|
0bd6489721 | ||
|
|
0000739c08 | ||
|
|
33d426842d | ||
|
|
3cb805489b | ||
|
|
22a7d241ff | ||
|
|
b4c5a83cfe | ||
|
|
70f2aaff43 | ||
|
|
55073aa7a3 | ||
|
|
8764a1b7c4 | ||
|
|
089ed30323 | ||
|
|
e265610a0c | ||
|
|
f59b54c6f4 | ||
|
|
0d582dabf3 | ||
|
|
8add6bcb9f | ||
|
|
6cfe3ddf52 | ||
|
|
54c1bdeceb | ||
|
|
4afffa36e9 | ||
|
|
f6836ff37f | ||
|
|
07dbd46ddd | ||
|
|
34646627aa | ||
|
|
86512eac06 | ||
|
|
03298fe875 | ||
|
|
69f524ba95 | ||
|
|
9d8de45313 | ||
|
|
5366bd09bf | ||
|
|
c58d2c89c3 | ||
|
|
1fade35159 | ||
|
|
58ca5f6424 | ||
|
|
d72e1563d4 | ||
|
|
9a2985611c | ||
|
|
0b77980cab | ||
|
|
aaf157cfdd | ||
|
|
96b5b1724b | ||
|
|
1fd5ff7152 | ||
|
|
52886872f1 | ||
|
|
5768de79e2 | ||
|
|
b112d73edb | ||
|
|
2ee40d3cf9 | ||
|
|
b4b864e40a | ||
|
|
d2b0167610 | ||
|
|
7965494ff3 | ||
|
|
c1a3c7f445 | ||
|
|
c6ec69c7c1 | ||
|
|
888834c636 | ||
|
|
077e4db772 | ||
|
|
f6253b87d0 | ||
|
|
6f171a066d | ||
|
|
e07663d9a1 | ||
|
|
1f3090a48d | ||
|
|
86891b0986 | ||
|
|
f37f6f67f6 | ||
|
|
bce4db00bc | ||
|
|
65a10410e3 | ||
|
|
61b8197942 | ||
|
|
3733b5064e | ||
|
|
c5c1c4134b | ||
|
|
7bb0a525c3 | ||
|
|
3d083dbe1a | ||
|
|
ce0d0ac829 | ||
|
|
b81bd7ed98 | ||
|
|
6695006bea | ||
|
|
623bff23ce | ||
|
|
f298491a8a | ||
|
|
5de1312e1c | ||
|
|
afadf74a53 | ||
|
|
46843b683b | ||
|
|
ade4d0e08a | ||
|
|
ed29ff08ba | ||
|
|
abfb9269b5 | ||
|
|
0941adc931 | ||
|
|
add915bdc4 | ||
|
|
4ad5817aac | ||
|
|
75c46a3930 | ||
|
|
fe6544622b | ||
|
|
454f36d2af | ||
|
|
9d950444a2 | ||
|
|
44dbad64d7 | ||
|
|
450f1d7e7b | ||
|
|
79a9e2fdfb | ||
|
|
6e7b43b6c7 | ||
|
|
d0da79c572 | ||
|
|
ab522dd18c | ||
|
|
0f50b52da4 | ||
|
|
5170a9d6dc | ||
|
|
fea52e29aa | ||
|
|
37ea320b96 | ||
|
|
0d3b468cb3 | ||
|
|
44345c2108 | ||
|
|
fa4c49b4a7 | ||
|
|
cdbc21a191 | ||
|
|
ab47efd9a0 | ||
|
|
561af15d67 | ||
|
|
376035fd01 | ||
|
|
cfc71ab7c5 | ||
|
|
208b8242bc | ||
|
|
1ab63d925f | ||
|
|
4cde40dbe1 | ||
|
|
9298e310b2 | ||
|
|
c0bc43ccff | ||
|
|
f1d1a8d32b | ||
|
|
9235352400 | ||
|
|
34a0bc456e | ||
|
|
7713c29258 | ||
|
|
04e9a2fac1 | ||
|
|
88fec09715 | ||
|
|
313676d200 | ||
|
|
8ee85137d8 | ||
|
|
4e4042bc33 | ||
|
|
bc3c6e74e6 | ||
|
|
e2035a514c | ||
|
|
c95fbb4464 | ||
|
|
ade2acfd1d | ||
|
|
2a6d7b1eaa | ||
|
|
1b9cb52d7b | ||
|
|
f8dc03d702 | ||
|
|
56f7e853be | ||
|
|
9a5da23553 | ||
|
|
d6d00b4fcf | ||
|
|
99913b5051 | ||
|
|
a8bdbfddf9 | ||
|
|
8db02ef8df | ||
|
|
51d1a72e9b | ||
|
|
4521dec85d | ||
|
|
947255c3da | ||
|
|
0b8c6b9bce | ||
|
|
12a3c77c2f | ||
|
|
83c4336828 | ||
|
|
f96c5443b1 | ||
|
|
f7fc186408 | ||
|
|
32228d8add | ||
|
|
9f851ebfe4 | ||
|
|
be1311cfc1 | ||
|
|
08606714a3 | ||
|
|
5053d79a24 | ||
|
|
b9ebb8e06f | ||
|
|
feddcf3030 | ||
|
|
112d8fc41d | ||
|
|
001f102f38 | ||
|
|
7bbd758681 | ||
|
|
b0758c86d8 | ||
|
|
73346e4341 | ||
|
|
0312a29e4c | ||
|
|
1107bffe84 | ||
|
|
72ebd91567 | ||
|
|
2c07d581de | ||
|
|
085ed7bfbe | ||
|
|
0dd756bceb | ||
|
|
a63e2f0a33 | ||
|
|
64b1aeebf5 | ||
|
|
28b237f94d | ||
|
|
330d763477 | ||
|
|
9064dbd404 | ||
|
|
a61438740d | ||
|
|
d27b4ad366 | ||
|
|
17bfafda55 | ||
|
|
ff534b0d0a | ||
|
|
f8aed6499f | ||
|
|
701a047ac0 | ||
|
|
03e2a7f584 | ||
|
|
c21278eeae | ||
|
|
b7c250925f | ||
|
|
2f431a948c | ||
|
|
f1519efb16 | ||
|
|
456aa3bc0a | ||
|
|
9ece0bdc02 | ||
|
|
8175a47881 | ||
|
|
204ae8a407 | ||
|
|
bb2fb74645 | ||
|
|
94da5842ef | ||
|
|
c418685315 | ||
|
|
e5ca5351d5 | ||
|
|
72ae6f5200 | ||
|
|
12ee2dd789 | ||
|
|
d4869207e3 | ||
|
|
f4790f6f66 | ||
|
|
daf49e9d82 | ||
|
|
2c0007731f | ||
|
|
61acb34e32 | ||
|
|
3ce6b06feb | ||
|
|
d6360c1ba9 | ||
|
|
6c022f9bf1 | ||
|
|
ff36fe365e | ||
|
|
ef8ff1b5d8 | ||
|
|
64b1e448d2 | ||
|
|
ac3bc73c13 | ||
|
|
afd0d3fca1 | ||
|
|
72d760ba00 | ||
|
|
f693c3d806 | ||
|
|
7e246a7bb9 | ||
|
|
6addf28c4b | ||
|
|
1612813114 | ||
|
|
14f8b76c1a | ||
|
|
b101cf46b6 | ||
|
|
8a2cd81091 | ||
|
|
223b19f116 | ||
|
|
779568bb38 | ||
|
|
661a70fc79 | ||
|
|
32171a8b0c | ||
|
|
c32db3c72b | ||
|
|
c86ce70968 | ||
|
|
f336e639e9 | ||
|
|
9714594c35 | ||
|
|
6eb2681c09 | ||
|
|
bed492da70 | ||
|
|
556a1397a9 | ||
|
|
3aceb61059 | ||
|
|
da21b74313 | ||
|
|
5a483c2ffb | ||
|
|
a34071876f | ||
|
|
357f752bed | ||
|
|
b9ab6e2019 | ||
|
|
0e1ce76ea8 | ||
|
|
bd63a9f056 | ||
|
|
72dbe45adc | ||
|
|
0962c9fb72 | ||
|
|
7812039402 | ||
|
|
44a6b493ee | ||
|
|
becd75676f | ||
|
|
727c462069 | ||
|
|
c9d3c29aa3 | ||
|
|
e3d9b875c9 | ||
|
|
fa2e5710ac | ||
|
|
56a7b8b724 | ||
|
|
d8ef864b02 | ||
|
|
cf1c4a0cb1 | ||
|
|
fb9b006865 | ||
|
|
f24387fa2b | ||
|
|
c4dc8fd101 | ||
|
|
c6e0284ac5 | ||
|
|
1d8e48c161 | ||
|
|
a1b60fc1f5 | ||
|
|
fef3389157 | ||
|
|
7b5fb33296 | ||
|
|
bdc4dfebf5 | ||
|
|
9a93fb5716 | ||
|
|
e8a5c9e1b8 | ||
|
|
3816d478df | ||
|
|
8c497793f9 | ||
|
|
303dc091b4 | ||
|
|
b8f93a8fe0 | ||
|
|
a066074054 | ||
|
|
bdd9b96fa3 | ||
|
|
300464a487 | ||
|
|
7d6e83efca | ||
|
|
08b3a1a34a | ||
|
|
f93d0befaf | ||
|
|
d6e9fad60e | ||
|
|
82d177ccbd | ||
|
|
762ec445e6 | ||
|
|
33ea1e8b78 | ||
|
|
475453668d | ||
|
|
f617fe7890 | ||
|
|
200053771a | ||
|
|
4a7810e992 | ||
|
|
981abb4612 | ||
|
|
61d35972e2 | ||
|
|
676497fe05 | ||
|
|
4a81424492 | ||
|
|
b41811a68c | ||
|
|
040e818d72 | ||
|
|
162f8e01aa | ||
|
|
ba1fa904a9 | ||
|
|
a1a7a1bc03 | ||
|
|
a6857ede03 | ||
|
|
c06c796242 | ||
|
|
1161301386 | ||
|
|
1e17d59965 | ||
|
|
983b95bc87 | ||
|
|
d2c7cbcbf9 | ||
|
|
ac64b65634 | ||
|
|
f422e7826f | ||
|
|
8f5ce73140 | ||
|
|
1362fc0c56 | ||
|
|
63b6300c39 | ||
|
|
bc3c0ce772 | ||
|
|
edebb90a9a | ||
|
|
4d6fbaff11 | ||
|
|
226923fa7e | ||
|
|
2b1fc6f765 | ||
|
|
cf3726bcbc | ||
|
|
52587c28d6 | ||
|
|
f8c768760b | ||
|
|
c00e68102c | ||
|
|
b7a7d673b9 | ||
|
|
d6d94d90bf | ||
|
|
f8704cd085 | ||
|
|
f7eea63872 | ||
|
|
30594c37d0 | ||
|
|
ab490dc7b8 | ||
|
|
2ad8c60abc | ||
|
|
19ae142bdd | ||
|
|
dc2b0a2823 | ||
|
|
88a330ebef | ||
|
|
fa2f1bfbb0 | ||
|
|
7c5b0e8292 | ||
|
|
eefc9035f0 | ||
|
|
c87b9fdb15 | ||
|
|
556ce9f543 | ||
|
|
79d6f4e211 | ||
|
|
f1781c20a3 | ||
|
|
f8f805f046 | ||
|
|
1109de3827 | ||
|
|
db66e33e9e | ||
|
|
2bc5d17ac3 | ||
|
|
e5977f05d8 | ||
|
|
d342ec10cc | ||
|
|
52125a54a5 | ||
|
|
77eba4d0d1 | ||
|
|
3dc3aef8a4 | ||
|
|
0e8eb8c48e | ||
|
|
863ac31f01 | ||
|
|
07d1709ca2 | ||
|
|
33e13c85e1 | ||
|
|
023e59a5f2 | ||
|
|
6888e6cdff | ||
|
|
0110f4c8cc | ||
|
|
dbeeeae593 | ||
|
|
1a9ddd2396 | ||
|
|
c649aca20a | ||
|
|
cc4c37dbac | ||
|
|
51b348095c | ||
|
|
b7cdb5a31e | ||
|
|
f4942bca32 | ||
|
|
27c735e3e9 | ||
|
|
f6feddd1ee | ||
|
|
b79751ebad | ||
|
|
a5aff5fd3e | ||
|
|
5ce636b0ba | ||
|
|
140726d23f | ||
|
|
b32ef809c3 | ||
|
|
3349296370 | ||
|
|
6aa408c6af | ||
|
|
9a15730c2a | ||
|
|
3fe4319314 | ||
|
|
8566fec661 | ||
|
|
dc3e531ff2 | ||
|
|
d4ddc46e77 | ||
|
|
40aac5875a | ||
|
|
ac8573884d | ||
|
|
677c7b2258 | ||
|
|
cb9015e254 | ||
|
|
121072cfe6 | ||
|
|
7812e836e4 | ||
|
|
dcdb145713 | ||
|
|
1029f57b8a | ||
|
|
64172685d6 | ||
|
|
655aae5911 | ||
|
|
a02315e1c4 | ||
|
|
a88e5be7f4 | ||
|
|
6137443d24 | ||
|
|
4dee919bc0 | ||
|
|
10c7709f30 | ||
|
|
8439a73645 | ||
|
|
a9a5cbf431 | ||
|
|
07e24b4058 | ||
|
|
51f564eea6 | ||
|
|
06f5b46133 | ||
|
|
b03a4993b3 | ||
|
|
836aff3467 | ||
|
|
d5d4d709c7 | ||
|
|
a2f6581171 | ||
|
|
3ec128c5fd | ||
|
|
cada78917c | ||
|
|
0a53b45858 | ||
|
|
6b01114057 | ||
|
|
057fcae30c | ||
|
|
35b41949fb | ||
|
|
099e8533e2 | ||
|
|
66c09fc05b | ||
|
|
7d81a166f9 | ||
|
|
6b2e03c5b1 | ||
|
|
e4aeef4b9f | ||
|
|
94c46d7486 | ||
|
|
cb5542bce5 | ||
|
|
959a9c79bd | ||
|
|
e0583975cd | ||
|
|
1450d23b60 | ||
|
|
9214c28aad | ||
|
|
e7a4327eb8 | ||
|
|
b60acfa87d | ||
|
|
0f72652c2d | ||
|
|
b3b8cbd001 | ||
|
|
d4b94bd65b | ||
|
|
f09ef23ae6 | ||
|
|
d96bbf0aae | ||
|
|
194916135a | ||
|
|
15d74bad1d | ||
|
|
b9db5c566b | ||
|
|
89d3dabf2e | ||
|
|
eec344cc1e | ||
|
|
6cabad6e7a | ||
|
|
534340cd88 | ||
|
|
e95d66faa8 | ||
|
|
ef07ddf087 | ||
|
|
9c16976749 | ||
|
|
fa5d2656b0 | ||
|
|
3cc9d2051a | ||
|
|
3f63cee4c1 | ||
|
|
884e3fd21f | ||
|
|
dec082ff97 | ||
|
|
0664877998 | ||
|
|
4fab72b40e | ||
|
|
a134892a3d | ||
|
|
666b93e989 | ||
|
|
956a1a17fb | ||
|
|
31f11cf304 | ||
|
|
8fd0a04135 | ||
|
|
61ebb37843 | ||
|
|
f1777f9517 | ||
|
|
823a1385a2 | ||
|
|
5319d1cffa | ||
|
|
075b975fed | ||
|
|
b476184574 | ||
|
|
0b57c07c79 | ||
|
|
b709b02e96 | ||
|
|
88e7d773df | ||
|
|
216ae7db52 | ||
|
|
3418d50949 | ||
|
|
f0f3b927e0 | ||
|
|
6cc967a124 | ||
|
|
2e810d575c | ||
|
|
19b436f68d | ||
|
|
7e03ae3240 | ||
|
|
7947f327de | ||
|
|
47579f8a40 | ||
|
|
52e19113f3 | ||
|
|
08145bc45c | ||
|
|
54c1ac3e38 | ||
|
|
45c8c3b611 | ||
|
|
df8667b18b | ||
|
|
2c558d5741 | ||
|
|
e590b5114e | ||
|
|
c8579abb43 | ||
|
|
7348e99269 | ||
|
|
e489e40a85 | ||
|
|
ecb0aaa7c2 | ||
|
|
a550263d6c | ||
|
|
bcfc1ad8f6 | ||
|
|
530134d125 | ||
|
|
430c05991c | ||
|
|
513af1efc9 | ||
|
|
0397321be0 | ||
|
|
6656553fa4 | ||
|
|
39f7248d4a | ||
|
|
dd9db5e889 | ||
|
|
6cdedf5834 | ||
|
|
70cca1eac0 | ||
|
|
5dc6013713 | ||
|
|
7c291ba31b | ||
|
|
085fa42b7d | ||
|
|
031e152d29 | ||
|
|
15da1a9abc | ||
|
|
031148dc56 | ||
|
|
fd943182bd | ||
|
|
594cc4793a | ||
|
|
d3ad2f357f | ||
|
|
b47507951e | ||
|
|
eed7b0e9c5 | ||
|
|
da3d7e1587 | ||
|
|
565aa0b763 | ||
|
|
0fbf2888e7 | ||
|
|
d2291df551 | ||
|
|
bba39762dc | ||
|
|
4d42450a73 | ||
|
|
01ca196530 | ||
|
|
30eceaf95f | ||
|
|
f0fe1957a8 | ||
|
|
ac38c8e6fe | ||
|
|
c11128891e | ||
|
|
adf693c061 | ||
|
|
00d3f9295e | ||
|
|
8d9e50c807 | ||
|
|
662ce46971 | ||
|
|
07e07030a6 | ||
|
|
a89590b425 | ||
|
|
88ac2ced7c | ||
|
|
f498f084d6 | ||
|
|
4bc51c6ff4 | ||
|
|
1f2b84a654 | ||
|
|
4f692ba840 | ||
|
|
9308cfdcfb | ||
|
|
a566ecc58f | ||
|
|
a338b78eb9 | ||
|
|
d0836aa89a | ||
|
|
d6a7aca2f4 | ||
|
|
0948cfc19e | ||
|
|
e49d31a1c9 | ||
|
|
f94a8344f6 | ||
|
|
055e71518e | ||
|
|
f304603e13 | ||
|
|
064153fca4 | ||
|
|
0ea3b87bd6 | ||
|
|
bed11b35d1 | ||
|
|
aec062a8a5 | ||
|
|
1668693bcf | ||
|
|
ec461c6ccb | ||
|
|
63370be0e5 | ||
|
|
1f0b46b93c | ||
|
|
ed72fcd12a | ||
|
|
dcb6335bfe | ||
|
|
ee5ce36745 | ||
|
|
4fdafef54f | ||
|
|
bf87fbcbcc | ||
|
|
ad44f5831a | ||
|
|
5320a6ebd3 | ||
|
|
6b3435a2db | ||
|
|
85beda96de | ||
|
|
9e30fb0ec1 | ||
|
|
9937660b1c | ||
|
|
e2cede6542 | ||
|
|
f5c5a710aa | ||
|
|
4078abe14c | ||
|
|
702626dd8a | ||
|
|
e25e4526cd | ||
|
|
192196711a | ||
|
|
345184330b | ||
|
|
ea4565368e | ||
|
|
0d7d877cb5 | ||
|
|
95412ad3a5 | ||
|
|
a526ff8c30 | ||
|
|
e4233c6fb6 | ||
|
|
c807192abc | ||
|
|
b0a936e5d4 | ||
|
|
97a1f761c6 | ||
|
|
5ebb6a2954 | ||
|
|
5386ddcd05 | ||
|
|
887abe9578 | ||
|
|
88dfd85e92 | ||
|
|
6342275bbb | ||
|
|
d822c65317 | ||
|
|
fc3815bfe5 | ||
|
|
824baa6a4d | ||
|
|
42e166089a | ||
|
|
6939676372 | ||
|
|
16aaf60697 | ||
|
|
90de839445 | ||
|
|
c191faf0ba | ||
|
|
d3025cde37 | ||
|
|
5eda547e6f | ||
|
|
3ea0fad204 | ||
|
|
540909bddf | ||
|
|
fad8afd62a | ||
|
|
595a428baa | ||
|
|
d2f9c5dfb7 | ||
|
|
9964740a47 | ||
|
|
38cfe22b8b | ||
|
|
94e850fd6f | ||
|
|
d7aca168ee | ||
|
|
a571933f8b | ||
|
|
4d5da74c79 | ||
|
|
5728f2e15f | ||
|
|
849c8052b7 | ||
|
|
ced92d9c52 | ||
|
|
375ae5dce4 | ||
|
|
50c4234aca | ||
|
|
5370b46c4e | ||
|
|
f87e891f18 | ||
|
|
edf522b58a | ||
|
|
cb04326b46 | ||
|
|
fb0b9c7160 | ||
|
|
69beaa1d0b | ||
|
|
d91211f9f2 | ||
|
|
11f5be0caf | ||
|
|
8f434874c0 | ||
|
|
6fd2ee9416 | ||
|
|
1dc7d0e633 | ||
|
|
3af9ac320d | ||
|
|
64b88da21b | ||
|
|
caf4b7f1e6 | ||
|
|
aceab9a877 | ||
|
|
bc2002ab92 | ||
|
|
71a0701920 | ||
|
|
db798fd5be | ||
|
|
b78738ff23 | ||
|
|
8cbd391f09 | ||
|
|
ff1567e240 | ||
|
|
e9f50fb87c | ||
|
|
f573ebf31a | ||
|
|
b12e056c21 | ||
|
|
0abe7d1cc5 | ||
|
|
e21f462f6f | ||
|
|
28a123ca47 | ||
|
|
cb8ead1f71 | ||
|
|
77637fd936 | ||
|
|
21fc57f2cf | ||
|
|
ad5aa54166 | ||
|
|
5d0deebba4 | ||
|
|
58eb40db76 | ||
|
|
9cd9c2eff9 | ||
|
|
9764adc7bb | ||
|
|
506717390f | ||
|
|
101aec95d9 | ||
|
|
e135cdbc24 | ||
|
|
24dfebf455 | ||
|
|
e900ca355e | ||
|
|
4789c7e485 | ||
|
|
7b5a8e4f2b | ||
|
|
250333d895 | ||
|
|
36055213c5 | ||
|
|
6b5a2426d7 | ||
|
|
2fa60bec27 | ||
|
|
693b4c57fe | ||
|
|
d666a1d473 | ||
|
|
6868d11669 | ||
|
|
414165d23f | ||
|
|
ec48681455 | ||
|
|
8dd5425182 | ||
|
|
505f19e3b0 | ||
|
|
377b864bb4 | ||
|
|
9b0c26b0b2 | ||
|
|
f337378066 | ||
|
|
8639a2f9f8 | ||
|
|
64519c6875 | ||
|
|
7b0d58c5e5 | ||
|
|
9948535118 | ||
|
|
1e14cc5cae | ||
|
|
aa86800092 | ||
|
|
1ee252772a | ||
|
|
033538731c | ||
|
|
31762a8173 | ||
|
|
5017602752 | ||
|
|
37958ca1b5 | ||
|
|
8eb8689391 | ||
|
|
c1ab3c406f | ||
|
|
d378e4088f | ||
|
|
08350e53e7 | ||
|
|
27004aca70 | ||
|
|
d5f0d45ae4 | ||
|
|
f1a073186c | ||
|
|
3e0d6ec895 | ||
|
|
e278277d53 | ||
|
|
1338eb31f7 | ||
|
|
007a427e0a | ||
|
|
8567a4cca3 | ||
|
|
ec1e57ed4a | ||
|
|
e51a0a80ca | ||
|
|
0647ba3bad | ||
|
|
acfc7798fd | ||
|
|
9ce0f35ef3 | ||
|
|
ef681e7019 | ||
|
|
704ab1114a | ||
|
|
afb1180d7d | ||
|
|
9c8f288d1a | ||
|
|
2aa9959553 | ||
|
|
15b4a064f9 | ||
|
|
06d5f9297d | ||
|
|
248ed1b01d | ||
|
|
cd36acc88b | ||
|
|
747f7fdbba | ||
|
|
f605351307 | ||
|
|
e31d116d37 | ||
|
|
0647cf434c | ||
|
|
fc198fe1db | ||
|
|
c1b70e0391 | ||
|
|
06e4f4e370 | ||
|
|
1dc3af381a | ||
|
|
c122c0ef89 | ||
|
|
b16f738d04 | ||
|
|
bf80204e63 | ||
|
|
8733ca49b0 | ||
|
|
6afcfe3442 | ||
|
|
848d21b6b5 | ||
|
|
1ab3007752 | ||
|
|
5f5ba8eb11 | ||
|
|
719d931304 | ||
|
|
ea83d040e6 | ||
|
|
7f38773b73 | ||
|
|
b50b22d787 | ||
|
|
2080d12bd9 | ||
|
|
dc8c3618e8 | ||
|
|
b17dffffb3 | ||
|
|
c1d2793580 | ||
|
|
0b4edf4e94 | ||
|
|
bac748fa95 | ||
|
|
05877c14df | ||
|
|
9b59455184 | ||
|
|
29653273c1 | ||
|
|
1b215ecb01 | ||
|
|
1780579403 | ||
|
|
835a5344b0 | ||
|
|
65ad63de84 | ||
|
|
ca097c2c68 | ||
|
|
fa0a314f59 | ||
|
|
c58fb46411 | ||
|
|
e7cc534367 | ||
|
|
29828d0469 | ||
|
|
8dfb52245b | ||
|
|
5d95e7eef9 | ||
|
|
92a39f78b9 | ||
|
|
79d39b190b | ||
|
|
6b77668171 | ||
|
|
9a49c1ddbd | ||
|
|
6b1e094cfb | ||
|
|
cfb837203c | ||
|
|
40caab4748 | ||
|
|
fa9fc05ac6 | ||
|
|
53589092b2 | ||
|
|
dedb381c51 | ||
|
|
0eb45a0577 | ||
|
|
58f5092c53 | ||
|
|
6bd447c885 | ||
|
|
47fb332fb2 | ||
|
|
2e01952b35 | ||
|
|
5a7d18a441 | ||
|
|
9c3359ef39 | ||
|
|
0b06c4b2b0 | ||
|
|
80b5fb51ed | ||
|
|
f9b5168fb3 | ||
|
|
7bfc379a23 | ||
|
|
3d5dc0d939 | ||
|
|
a11f36811f | ||
|
|
eb6f4b1a6a | ||
|
|
cd4cc9ff0d | ||
|
|
9e8e5ac363 | ||
|
|
6136b3844b | ||
|
|
0a8ab75e4b | ||
|
|
36a0d1028c | ||
|
|
0f7eb00f67 | ||
|
|
682447306d | ||
|
|
ac35b4bba2 | ||
|
|
cce307a2be | ||
|
|
afabb2f3d8 | ||
|
|
9b417b26d9 | ||
|
|
90deb0959a | ||
|
|
db0338a1f2 | ||
|
|
4161a67b38 | ||
|
|
865b2ca6f9 | ||
|
|
a44d4da87c | ||
|
|
16abfa5eb6 | ||
|
|
f53db3541a | ||
|
|
5e528d9eea | ||
|
|
f03ab2a5c5 | ||
|
|
fa1f540e6c | ||
|
|
91704b773e | ||
|
|
1ad1429c6d | ||
|
|
1b435ae3e0 | ||
|
|
105d82d134 | ||
|
|
86c2b609ef | ||
|
|
2cdfcb8fd2 | ||
|
|
31290807dc | ||
|
|
33cdbe97b8 | ||
|
|
34d4bc620d | ||
|
|
76902c482f | ||
|
|
e5efa01920 | ||
|
|
3f16a524c8 | ||
|
|
646c873598 | ||
|
|
e87dd0e65d | ||
|
|
539de4387b | ||
|
|
65cd14502c | ||
|
|
6ddcdbe3e8 | ||
|
|
9251eac585 | ||
|
|
3ed07a8f0b | ||
|
|
0e0a783b8c | ||
|
|
5991851eb9 | ||
|
|
a4adf60576 | ||
|
|
b79b1cb9c0 | ||
|
|
d7051928d9 | ||
|
|
b305953bd1 | ||
|
|
e7577d570e | ||
|
|
ca34c81ce9 | ||
|
|
085cff2fe5 | ||
|
|
b17bfdd6f4 | ||
|
|
81e0b18e38 | ||
|
|
b202fa9063 | ||
|
|
2231e1a369 | ||
|
|
256594575d | ||
|
|
cfe83c4b44 | ||
|
|
0157502eab | ||
|
|
f1bf642e8f | ||
|
|
4b9bc49020 | ||
|
|
d5a4d53000 | ||
|
|
705f082674 | ||
|
|
80533ea5e1 | ||
|
|
6aee4bcdc5 | ||
|
|
b794ecc079 | ||
|
|
732cd837a9 | ||
|
|
839ecce571 | ||
|
|
3ec14186cb | ||
|
|
a4e4f57cb0 | ||
|
|
ffa863a3ba | ||
|
|
3d75f438bc | ||
|
|
7180e9ac66 | ||
|
|
239d09804d | ||
|
|
04f7ea818d | ||
|
|
ee59d7a266 | ||
|
|
3607c42bec | ||
|
|
2a5eaf239f | ||
|
|
6f5f80a544 | ||
|
|
7a516a266d | ||
|
|
73ccb7e4b8 | ||
|
|
1a3af8cb4c | ||
|
|
862bfc53d3 | ||
|
|
fa55b0cb60 | ||
|
|
22d9a61b33 | ||
|
|
84e8802891 | ||
|
|
577e7cb493 | ||
|
|
cff8162454 | ||
|
|
376c88a864 | ||
|
|
bb26751b94 | ||
|
|
ebbb98d519 | ||
|
|
9e4956d86b | ||
|
|
388ca563db | ||
|
|
70703da782 | ||
|
|
b11518d7d7 | ||
|
|
7b53551032 | ||
|
|
06e87014f2 | ||
|
|
dd4ca70b0d | ||
|
|
657589ab47 | ||
|
|
c1ffac2fee | ||
|
|
4da92b89ed | ||
|
|
3dcbcd8bf0 | ||
|
|
cecf6b4209 | ||
|
|
b2a91dc390 | ||
|
|
ac08593b96 | ||
|
|
e3ac52630a | ||
|
|
455c21df71 | ||
|
|
d3a80d9f1b | ||
|
|
b26f1530b7 | ||
|
|
bae2240eda | ||
|
|
042a3b01d2 | ||
|
|
682249396f | ||
|
|
958e58b06b | ||
|
|
c49330fc52 | ||
|
|
fa004ae79a | ||
|
|
42575d4a99 | ||
|
|
6bc526676c | ||
|
|
e230ec5a01 | ||
|
|
770c995365 | ||
|
|
78f753ffff | ||
|
|
aa8e09d7f1 | ||
|
|
36c331ff74 | ||
|
|
8dacb4da20 | ||
|
|
fc625d249f | ||
|
|
34077c0140 | ||
|
|
600b8f60b4 | ||
|
|
e9053515bb | ||
|
|
30f0900b1c | ||
|
|
831e2c920e | ||
|
|
cf312545e8 | ||
|
|
d6f3a8848d | ||
|
|
9d20a5f0a5 | ||
|
|
ad8fdc917f | ||
|
|
05bc204dbd | ||
|
|
b36d1d465d | ||
|
|
25a9209b75 | ||
|
|
a9626e1162 | ||
|
|
a5ba26806f | ||
|
|
dbc70f21a9 | ||
|
|
85a661d276 | ||
|
|
acf043a675 | ||
|
|
2c13a74a9d | ||
|
|
de1588928b | ||
|
|
70fa37527d | ||
|
|
3d4af15d1d | ||
|
|
cba52b66af | ||
|
|
f79f0e42f7 | ||
|
|
cbade7b16d | ||
|
|
b626dd57d3 | ||
|
|
cb1d578470 | ||
|
|
4f5aac319e | ||
|
|
fc9d6b6cb5 | ||
|
|
4bdbea8375 | ||
|
|
2b9d88196e | ||
|
|
90ea7e2f2f | ||
|
|
ddabfc3477 | ||
|
|
f4f04cb5ec | ||
|
|
d7ef56dca2 | ||
|
|
5628416bd3 | ||
|
|
7538bbabb6 | ||
|
|
e1d7e14717 | ||
|
|
a616ff5d4a | ||
|
|
76e40fe5d1 | ||
|
|
20d61f5f62 | ||
|
|
2665288b30 | ||
|
|
8baa4ccff5 | ||
|
|
5d472c4895 | ||
|
|
0fe5170bc4 | ||
|
|
615e9ae345 | ||
|
|
3b3af6b731 | ||
|
|
e4d8267188 | ||
|
|
1cd32d3afe | ||
|
|
03ea87ea28 | ||
|
|
c46b79846c | ||
|
|
6636cb9f2f | ||
|
|
1e7672acf4 | ||
|
|
8596f2b0fc | ||
|
|
538d28e29e | ||
|
|
574ff0a280 | ||
|
|
51e568f9dc | ||
|
|
582f4db59b | ||
|
|
5116eee108 | ||
|
|
7ddc1adefb | ||
|
|
266dff9bed | ||
|
|
7f8b076f2b | ||
|
|
36ac557df0 | ||
|
|
013013737f | ||
|
|
b8e2b2bd6b | ||
|
|
71eb4034eb | ||
|
|
c142540705 | ||
|
|
3930472f34 | ||
|
|
6d03f93067 | ||
|
|
0e884304ee | ||
|
|
9085c2cae2 | ||
|
|
e8568f3ec9 | ||
|
|
16a9488c13 | ||
|
|
ea0399414c | ||
|
|
1abb02fb67 | ||
|
|
fbaf65b8f6 | ||
|
|
f2c7f3b200 | ||
|
|
1b579a110d | ||
|
|
7e00cde8a9 | ||
|
|
1ecc1db226 | ||
|
|
a7ace918fe | ||
|
|
91ac93f9a6 | ||
|
|
05c3e0b898 | ||
|
|
103c5edaaa | ||
|
|
75de34e281 | ||
|
|
f032ad6b1f | ||
|
|
871727dd2f | ||
|
|
3ff13edad9 | ||
|
|
7d80a8f4f5 | ||
|
|
3c80d57dc7 | ||
|
|
bb1e6f8af6 | ||
|
|
8432d1bfc7 | ||
|
|
7e2d172ae5 | ||
|
|
3bde375078 | ||
|
|
365b639981 | ||
|
|
d4fc525614 | ||
|
|
5be649e082 | ||
|
|
4b4be11fd2 | ||
|
|
e7bfcb970e | ||
|
|
7794b104c5 | ||
|
|
3b828e6f96 | ||
|
|
bbe946fb6c | ||
|
|
377f730054 | ||
|
|
f5528001f6 | ||
|
|
f68075b333 | ||
|
|
f1b5c742ff | ||
|
|
7e068da2bd | ||
|
|
44174b1fa1 | ||
|
|
861f786d81 | ||
|
|
f6951bb67d | ||
|
|
3b1b5266e5 | ||
|
|
c163b856d7 | ||
|
|
07eb7adbb4 | ||
|
|
4c108d22f0 | ||
|
|
c706ff6f3a | ||
|
|
992736dc5d | ||
|
|
927580d4a8 | ||
|
|
a1e4af62d3 | ||
|
|
28dd8d7efd | ||
|
|
4dff49b2f1 | ||
|
|
71a58261f6 | ||
|
|
8d1b82d596 | ||
|
|
3096e7a9cd | ||
|
|
1c3a9c8e74 | ||
|
|
813e0c18e6 | ||
|
|
3a82994429 | ||
|
|
106184bbea | ||
|
|
3895363432 | ||
|
|
a1e43c682a | ||
|
|
c3fd4ae473 | ||
|
|
69b5c2f541 | ||
|
|
a704614b3e | ||
|
|
6024051a2f | ||
|
|
b3e94f5de8 | ||
|
|
32380a0112 | ||
|
|
664fb38e39 | ||
|
|
0cbb96895a | ||
|
|
7b77cb3bb8 | ||
|
|
6faad0c34f | ||
|
|
05c1f2795a | ||
|
|
7feccf9ab2 | ||
|
|
bf4880f6a2 | ||
|
|
e0c0e53edf | ||
|
|
6994bf10bc | ||
|
|
3233d85d2f | ||
|
|
13f00331da | ||
|
|
af93c21cf9 | ||
|
|
cf98290873 | ||
|
|
1ca6ff974c | ||
|
|
575df6f192 | ||
|
|
0bdc145343 | ||
|
|
d049a7988c | ||
|
|
a4af3cc814 | ||
|
|
a89a3cd2f1 | ||
|
|
09780b8b3d | ||
|
|
9e294be5c5 | ||
|
|
a01d149369 | ||
|
|
483534b525 | ||
|
|
e1fca8d982 | ||
|
|
10a202422a | ||
|
|
27431dcc6b | ||
|
|
d8f9f6ba2a | ||
|
|
72090b646f | ||
|
|
aedcd2fb1a | ||
|
|
76ccbb899d | ||
|
|
5d87ee8d82 | ||
|
|
451c756b01 | ||
|
|
3aa9aae0be | ||
|
|
967073ba3d | ||
|
|
b8d8355f10 | ||
|
|
07c52a25ff | ||
|
|
cb2de62bb1 | ||
|
|
949a9fa2cb | ||
|
|
a1164399b0 | ||
|
|
e5b905481d | ||
|
|
7c183dc6a1 | ||
|
|
7fbd72b735 | ||
|
|
969278fc0b | ||
|
|
efc4c0fe9d | ||
|
|
81b24bd728 | ||
|
|
db2581bee9 | ||
|
|
75136d3bea | ||
|
|
0e6a096afd | ||
|
|
6f8d34768d | ||
|
|
9cda3035fd | ||
|
|
47f5ad32b7 | ||
|
|
9f35ba8546 | ||
|
|
7fd34d4f30 | ||
|
|
bb2aa5e770 | ||
|
|
56e10f1c35 | ||
|
|
718e15c7de | ||
|
|
8bc6d976cb | ||
|
|
dd80db87a6 | ||
|
|
1f54c16f52 | ||
|
|
50d421fa19 | ||
|
|
adbbd17cb6 | ||
|
|
3e8eebfbec | ||
|
|
2cbc0f1287 | ||
|
|
e2c1f0a7cd | ||
|
|
ca43436cd3 | ||
|
|
b27fd87177 | ||
|
|
07d3083279 | ||
|
|
d3d998a885 | ||
|
|
5f409c6fcc | ||
|
|
63310acd58 | ||
|
|
e6850891cc | ||
|
|
440ad0b440 | ||
|
|
5cdd788f30 | ||
|
|
596d81a973 | ||
|
|
84f3ecc231 | ||
|
|
cc48f1e5dd | ||
|
|
8dc04a4c9f | ||
|
|
c72040a715 | ||
|
|
c7c1bf177b | ||
|
|
5b0e59d9d5 | ||
|
|
7c06d9f043 | ||
|
|
511e32e8ca | ||
|
|
e5dfa0855f | ||
|
|
afad952450 | ||
|
|
fda1365c15 | ||
|
|
04022114d9 | ||
|
|
1575a3fbcd | ||
|
|
7e772f6a51 | ||
|
|
2e5860b5a0 | ||
|
|
4158cba1ff | ||
|
|
b955e485f1 | ||
|
|
02d6d2d487 | ||
|
|
b668726a38 | ||
|
|
835a8b2c9b | ||
|
|
239c8732d7 | ||
|
|
9bf3f910c8 | ||
|
|
e6c982509d | ||
|
|
9ddb8493d5 | ||
|
|
76e61958fd | ||
|
|
4f22a45cb5 | ||
|
|
825b61e4ba | ||
|
|
7e67aba286 | ||
|
|
a649d904d7 | ||
|
|
dfb82d5c22 | ||
|
|
d0fb547dc1 | ||
|
|
20f0cb0281 | ||
|
|
03b64defa5 | ||
|
|
655ebe4eaf | ||
|
|
b89202824e | ||
|
|
f70eacee8e | ||
|
|
433a7556c7 | ||
|
|
712203dbcb | ||
|
|
800fb26606 | ||
|
|
224f087a5f | ||
|
|
092426bed2 | ||
|
|
c6f1b7b92a | ||
|
|
328e4fa7e7 | ||
|
|
f3110a57cd | ||
|
|
cf029b3e1c | ||
|
|
7056032483 | ||
|
|
50ceb25003 | ||
|
|
9c364b16ff | ||
|
|
d61caf5714 | ||
|
|
e70f866ed2 | ||
|
|
9acb158990 | ||
|
|
1ba79baab5 | ||
|
|
01de69de36 | ||
|
|
8ec24036d7 | ||
|
|
29269d2aa8 | ||
|
|
43a85dd02e | ||
|
|
9ba64f9fe3 | ||
|
|
49fb8e6c45 | ||
|
|
9bf6509c6e | ||
|
|
5af385ea78 | ||
|
|
47219dd5c6 | ||
|
|
b6ae8a0dca | ||
|
|
a33d45d7cd | ||
|
|
5a665e423c | ||
|
|
fc95da8aa3 | ||
|
|
fd5859ed04 | ||
|
|
75e3793f4d | ||
|
|
8d4b5fef1d | ||
|
|
04a9ce3a18 | ||
|
|
87883abd86 | ||
|
|
f20725eada | ||
|
|
26646f2450 | ||
|
|
f208fd7ebb | ||
|
|
9350158d61 | ||
|
|
7a5196601e | ||
|
|
c7619d4a6a | ||
|
|
7ba774a440 | ||
|
|
b1af4d36ce | ||
|
|
c3f20f6b81 | ||
|
|
e7dca4fec2 | ||
|
|
9afb849e16 | ||
|
|
e1acb0b1fa | ||
|
|
3ead9820f7 | ||
|
|
f7db4fad31 | ||
|
|
cf4fcc4735 | ||
|
|
3eedb542a6 | ||
|
|
ecf7666624 | ||
|
|
d77d3416d3 | ||
|
|
5ce93bc0cc | ||
|
|
54a129a2e2 | ||
|
|
bdf60dac6a | ||
|
|
bbb543fc16 | ||
|
|
28d8eb220b | ||
|
|
0a6c5bc234 | ||
|
|
e91d275b10 | ||
|
|
8b8ab1db5b | ||
|
|
e02d6014bf | ||
|
|
8414c0bb09 | ||
|
|
49eb5f0280 | ||
|
|
7a536f1bd2 | ||
|
|
ff0c6c2bde | ||
|
|
4eecf80a4b | ||
|
|
104294c7e4 | ||
|
|
6b43a314bf | ||
|
|
8915f7933a | ||
|
|
87ded34f9f | ||
|
|
ff0f9aa856 | ||
|
|
9dc02464a4 | ||
|
|
7573d10a4a | ||
|
|
5412cdf2c8 | ||
|
|
3de440fda2 | ||
|
|
5bf9029bf9 | ||
|
|
09c9bf2edb | ||
|
|
b46076458c | ||
|
|
8691b56136 | ||
|
|
7f6a025c93 | ||
|
|
2cada3c143 | ||
|
|
4a3a895be9 | ||
|
|
f6fbb99a9c | ||
|
|
be107ba8f8 | ||
|
|
f902435a53 | ||
|
|
80d51c692a | ||
|
|
7227454dca | ||
|
|
f087359621 | ||
|
|
e215809c4d | ||
|
|
03b0266b59 | ||
|
|
d1c45c0d76 | ||
|
|
e30babef09 | ||
|
|
a608156da3 | ||
|
|
65a2350a5f | ||
|
|
cbf24a9151 | ||
|
|
f906d53f7d | ||
|
|
1f2bdd37b3 | ||
|
|
dc8ff68871 | ||
|
|
5536edede9 | ||
|
|
578e15f006 | ||
|
|
e1143377c2 | ||
|
|
8563ef3ce4 | ||
|
|
37fb531d1c | ||
|
|
86d3bba157 | ||
|
|
2ccc6d2ed1 | ||
|
|
13a5f5ba8b | ||
|
|
737a3644fc | ||
|
|
07ff47bf1b | ||
|
|
0737433c71 | ||
|
|
0bda7f196d | ||
|
|
9f96fcff3c | ||
|
|
bfacbac7c4 | ||
|
|
86fce79a6c | ||
|
|
c81a5a6070 | ||
|
|
0947fa3de0 | ||
|
|
cb9a6b8a8b | ||
|
|
2d21a64fed | ||
|
|
f94af2f5c5 | ||
|
|
8079344cee | ||
|
|
82e31d34f0 | ||
|
|
acdb4823dd | ||
|
|
b5144e477f | ||
|
|
e9c625a1dc | ||
|
|
d1851ed6b7 | ||
|
|
32c4e01267 | ||
|
|
2f9bae140b | ||
|
|
8a45c56c2c | ||
|
|
9391a97fbf | ||
|
|
79d497edae | ||
|
|
515ad62335 | ||
|
|
73353fad64 | ||
|
|
ff4bd758ca | ||
|
|
e24674fc0e | ||
|
|
529fccd9c2 | ||
|
|
4ee4f65c70 | ||
|
|
7cc86d4bc9 | ||
|
|
8011197c50 | ||
|
|
c96aaef132 | ||
|
|
6b32570644 | ||
|
|
5af930f97a | ||
|
|
515ecbddc2 | ||
|
|
7f7e8eeecd | ||
|
|
4e98d4329b | ||
|
|
5278da98d2 | ||
|
|
e1ed27aeaa | ||
|
|
c8349d3305 | ||
|
|
606175b98f | ||
|
|
05bc323be0 | ||
|
|
599a52629a | ||
|
|
c3efccaa9c | ||
|
|
b26f16a27f | ||
|
|
a0c2e55e8c | ||
|
|
5aebfedfad | ||
|
|
ce1626a51e | ||
|
|
0cabe4dedf | ||
|
|
0d6e3ab2b0 | ||
|
|
cfcad42b89 | ||
|
|
4a6f95acc8 | ||
|
|
5305c32242 | ||
|
|
951c9dd68b | ||
|
|
4ea9fdbbea | ||
|
|
e194219f2e | ||
|
|
a71d3c8cb3 | ||
|
|
238321c159 | ||
|
|
e181b0c3fc | ||
|
|
9d0bc3f9ab | ||
|
|
afe9c5c5f7 | ||
|
|
81a2546cea | ||
|
|
ee5560a958 | ||
|
|
62cfdceac1 | ||
|
|
d9fda22763 | ||
|
|
8dd83c5fe8 | ||
|
|
5794c0491a | ||
|
|
e043b89814 | ||
|
|
8fc19d2194 | ||
|
|
02501f07c3 | ||
|
|
a0e5bb9532 | ||
|
|
088ef6623a | ||
|
|
9c916cdaf9 | ||
|
|
ac9512e095 | ||
|
|
5d20da1b36 | ||
|
|
9b09c7597f | ||
|
|
2a1e903f43 | ||
|
|
e50894c95e | ||
|
|
991b16cc6a | ||
|
|
2886e0b6f5 | ||
|
|
067b691fd8 | ||
|
|
c40feabe4d | ||
|
|
2d4018aa89 | ||
|
|
e6439e1a16 | ||
|
|
26b9e2d0a5 | ||
|
|
3a5e758ee3 | ||
|
|
f768727284 | ||
|
|
a03846bd9e | ||
|
|
f3a0b17bb8 | ||
|
|
ac52d9d44c | ||
|
|
e2082a675c | ||
|
|
b94f0241f1 | ||
|
|
b96b1f2412 | ||
|
|
6644f1ff64 | ||
|
|
8cac70d8af | ||
|
|
5105c6c0d0 | ||
|
|
3a678d48b1 | ||
|
|
8bac6d428d | ||
|
|
2da200fc16 | ||
|
|
f6b6ad1959 | ||
|
|
3e84f7cd1d | ||
|
|
ac10889bde | ||
|
|
89a530b442 | ||
|
|
65e579e558 | ||
|
|
34e18ef771 | ||
|
|
8289e5f6b4 | ||
|
|
025e00cccc | ||
|
|
f78b5a0cdb | ||
|
|
ec49a486c7 | ||
|
|
afeefadb4e | ||
|
|
a423f032ee | ||
|
|
4ef06f5aa2 | ||
|
|
753223bd7b | ||
|
|
f663277591 | ||
|
|
1c7be88a1a | ||
|
|
3c114b280a | ||
|
|
2fbbcaa339 | ||
|
|
36cbe1e521 | ||
|
|
19d17ed274 | ||
|
|
01f940dc9a | ||
|
|
19c4fa8dd5 | ||
|
|
3bcc25f588 | ||
|
|
4cadb57c46 | ||
|
|
99c32ed4a5 | ||
|
|
c08b4b46f4 | ||
|
|
e138a5fcb5 | ||
|
|
fc16e54612 | ||
|
|
4575354bc0 | ||
|
|
3f51c831de | ||
|
|
962dcb466d | ||
|
|
b8d9c5c130 | ||
|
|
1a0d2578a1 | ||
|
|
12a1e7d04e | ||
|
|
4a8efd7e68 | ||
|
|
66cfbbff5e | ||
|
|
d23c69d319 | ||
|
|
1e7b50aeae | ||
|
|
c93e92671a | ||
|
|
ddc3f8f069 | ||
|
|
5261e5a6ba | ||
|
|
379733aba1 | ||
|
|
131de7ab62 | ||
|
|
d8ab2c1ac9 | ||
|
|
862781b195 | ||
|
|
cae4d020dc | ||
|
|
1f78e08427 | ||
|
|
760c1d95b9 | ||
|
|
510f0e505c | ||
|
|
d9c54826bb | ||
|
|
2515413080 | ||
|
|
d87b80c6c1 | ||
|
|
4a43f347bb | ||
|
|
dcbf976a8e | ||
|
|
f2d577c33f | ||
|
|
ae34241f8b | ||
|
|
1546153ca2 | ||
|
|
a3d6554e8e | ||
|
|
565af90958 | ||
|
|
797f2044cd | ||
|
|
5ea08394f5 | ||
|
|
9ee86f22b7 | ||
|
|
52ca91ca57 | ||
|
|
168af9b377 | ||
|
|
1a6eea012d | ||
|
|
50f6e12d31 | ||
|
|
c547b2e8ee | ||
|
|
56ba60ee68 | ||
|
|
f270c81c49 | ||
|
|
745fda081e | ||
|
|
5f8c9ae0ef | ||
|
|
056af2b1af | ||
|
|
5f79a28a07 | ||
|
|
69db792bf0 | ||
|
|
8b956216b7 | ||
|
|
e6cc547a94 | ||
|
|
e73217d6f7 | ||
|
|
2eaf5b03df | ||
|
|
c398153b40 | ||
|
|
33994bbfa1 | ||
|
|
7525637804 | ||
|
|
15ec78e9d8 | ||
|
|
3a7828de6b | ||
|
|
7b3433c68b | ||
|
|
84507cc744 | ||
|
|
cb76c086e0 | ||
|
|
407822e6a5 | ||
|
|
4e30698706 | ||
|
|
2dd8338e7d | ||
|
|
059560d28b | ||
|
|
d348d86df4 | ||
|
|
1d3862b6b3 | ||
|
|
bd82539ad5 | ||
|
|
83f55c9de5 | ||
|
|
33b88a0339 | ||
|
|
44bfa24cc3 | ||
|
|
2cff3f6a65 | ||
|
|
b48ed9ebc0 | ||
|
|
4e717b524c | ||
|
|
ae657a349a | ||
|
|
ed3c015f4e | ||
|
|
9cfc40c2cc | ||
|
|
6ebc63d3ef | ||
|
|
1ae0a1e658 | ||
|
|
46dff42239 | ||
|
|
35d1fb7b34 | ||
|
|
876a3299fc | ||
|
|
93896d550e | ||
|
|
18ffb7dd86 | ||
|
|
c0a89f8f4e | ||
|
|
c6193d0605 | ||
|
|
6cc380fc41 | ||
|
|
4053d9d638 | ||
|
|
45731cca19 | ||
|
|
dc92431328 | ||
|
|
d3e8e5731a | ||
|
|
53a5d32df1 | ||
|
|
85e1e2b0c8 | ||
|
|
9960ccddb2 | ||
|
|
4021776d0f | ||
|
|
fa0ce4b7d5 | ||
|
|
2a5ce1849a | ||
|
|
ae4b838840 | ||
|
|
79c075ca09 | ||
|
|
1127804109 | ||
|
|
67be485e24 | ||
|
|
fda57f48d5 | ||
|
|
840652830d | ||
|
|
5eabf44021 | ||
|
|
599d5f185c | ||
|
|
7abc368927 | ||
|
|
b57baa5ba0 | ||
|
|
3e47978a80 | ||
|
|
e647f89c33 | ||
|
|
82978fc88f | ||
|
|
95d49c3b98 | ||
|
|
455dc6e229 | ||
|
|
291bfe6841 | ||
|
|
35032d41fa | ||
|
|
28094b7cea | ||
|
|
b55b9aee9b | ||
|
|
0f1c21a6c9 | ||
|
|
175bab4f5f | ||
|
|
ba7b68798d | ||
|
|
e32256b4b4 | ||
|
|
132d8c5a99 | ||
|
|
b85f345369 | ||
|
|
85a3fb3bef | ||
|
|
6d91055462 | ||
|
|
136fc56af0 | ||
|
|
c355ed1267 | ||
|
|
1cefc48f13 | ||
|
|
211a9c8fd2 | ||
|
|
f29b3b4033 | ||
|
|
df65d4a14f | ||
|
|
c4e26f4b92 | ||
|
|
416918429d | ||
|
|
d5692bff00 | ||
|
|
dcef0c0237 | ||
|
|
a68c98bb67 | ||
|
|
b872aa5c8e | ||
|
|
a82be53407 | ||
|
|
49533bc86e | ||
|
|
e381f22ac1 | ||
|
|
9ac1e93aa1 | ||
|
|
bd5b38e232 | ||
|
|
5adcb9ce6d | ||
|
|
2ec135c9f7 | ||
|
|
58d46e1fe6 | ||
|
|
c039a77d21 | ||
|
|
741bdf151a | ||
|
|
5070c769b8 | ||
|
|
52e0de84a9 | ||
|
|
b974fffea0 | ||
|
|
a2616c79fe | ||
|
|
31b5b18611 | ||
|
|
8601c39571 | ||
|
|
af27ec296b | ||
|
|
a848807847 | ||
|
|
bdb30d7145 | ||
|
|
897e5c6231 | ||
|
|
1007873d94 | ||
|
|
fd201a90f1 | ||
|
|
a52ce7ac8b | ||
|
|
fd90afef43 | ||
|
|
5207afa0dd | ||
|
|
0699310b9c | ||
|
|
0c24fe276c | ||
|
|
c83391262e | ||
|
|
00262d51ad | ||
|
|
d7c04ccbfb | ||
|
|
b1f263b34b | ||
|
|
a58e4dfd0f | ||
|
|
18d6490dbd | ||
|
|
346f83e014 | ||
|
|
fefcc77f13 | ||
|
|
b6cdfef442 | ||
|
|
172e426ba9 | ||
|
|
f74d9ec7f7 | ||
|
|
9093166eea | ||
|
|
f5ed5478e1 | ||
|
|
9a4234ea8e | ||
|
|
af002dc861 | ||
|
|
adeb993122 | ||
|
|
81bc4265e5 | ||
|
|
a44c5f7afe | ||
|
|
66b51940bd | ||
|
|
d4e49a2697 | ||
|
|
521405488b | ||
|
|
24dfa0c957 | ||
|
|
158a65c98f | ||
|
|
6caf074bd5 | ||
|
|
905e14f384 | ||
|
|
4be79a8955 | ||
|
|
2d952504ed | ||
|
|
43219d36a6 | ||
|
|
99b27488e7 | ||
|
|
18972c5513 | ||
|
|
e312363007 | ||
|
|
6c34bffbb5 | ||
|
|
36b2f64051 | ||
|
|
705ff49400 | ||
|
|
f81caac459 | ||
|
|
0ada716184 | ||
|
|
e9c849884a | ||
|
|
a4191857c1 | ||
|
|
9d7480774f | ||
|
|
5d630c930d | ||
|
|
9852649e97 | ||
|
|
1722a31155 | ||
|
|
e5f2295398 | ||
|
|
8ef0ca9765 | ||
|
|
c031ea088a | ||
|
|
9824bf1ba1 | ||
|
|
0095b7a0ea | ||
|
|
6b4f6cd2c5 | ||
|
|
1b646a4440 | ||
|
|
f22024cb19 | ||
|
|
049c515840 | ||
|
|
352695bc57 | ||
|
|
74077491ce | ||
|
|
23b67e6ff5 | ||
|
|
7b4fbf4301 | ||
|
|
b8b74970d7 | ||
|
|
defbf1c4b3 | ||
|
|
16c6734bcb | ||
|
|
ee98a069f0 | ||
|
|
b30b82835a | ||
|
|
d107146687 | ||
|
|
88df66ec83 | ||
|
|
ce18371d1b | ||
|
|
9dea27b273 | ||
|
|
140ece0aeb | ||
|
|
7abf72ec78 | ||
|
|
574185426c | ||
|
|
dd61c4802a | ||
|
|
14cef31467 | ||
|
|
6277781e83 | ||
|
|
770cba0bd0 | ||
|
|
c38fe6b0e1 | ||
|
|
d3ee3e7ab5 | ||
|
|
ce500f8727 | ||
|
|
9a5f742e63 | ||
|
|
7e6700d261 | ||
|
|
c71522adc5 | ||
|
|
70b0bd13aa | ||
|
|
087ab2acbf | ||
|
|
24aeca3d0c | ||
|
|
9660657e95 | ||
|
|
13a3a2d0f3 | ||
|
|
ff4f40de41 | ||
|
|
24fc7c30dd | ||
|
|
06aa9d8d9a | ||
|
|
8c374512fd | ||
|
|
77d51ebf24 | ||
|
|
93b032ea92 | ||
|
|
03c8a78f04 | ||
|
|
002e513b82 | ||
|
|
ed84b2aaeb | ||
|
|
1176460e44 | ||
|
|
01429e7d16 | ||
|
|
4c35e00f49 | ||
|
|
7f960616e0 | ||
|
|
1cafdb5b46 | ||
|
|
b0fb340b57 | ||
|
|
85f3ba844c | ||
|
|
090eb437ed | ||
|
|
d574604a5d | ||
|
|
6eacddb50f | ||
|
|
4ff23d3306 | ||
|
|
c7687fc1d6 | ||
|
|
c47d34cf70 | ||
|
|
cd51f37fc0 | ||
|
|
da70c837da | ||
|
|
f1ae07e532 | ||
|
|
d9cd494eaf | ||
|
|
5979233a3c | ||
|
|
0b1d6a0d52 | ||
|
|
7b433605f9 | ||
|
|
3b9b1956cd | ||
|
|
7a41e0b1ea | ||
|
|
cc882b0723 | ||
|
|
6d6580f6be | ||
|
|
7684f53328 | ||
|
|
e3e4b7bdf5 | ||
|
|
679f4882a5 | ||
|
|
cb78e62df9 | ||
|
|
376f2aec54 | ||
|
|
010757266e | ||
|
|
d268471285 | ||
|
|
423577e14e | ||
|
|
f1c31ebc67 | ||
|
|
4433ce4312 | ||
|
|
456bbffcc4 | ||
|
|
17a7f352b5 | ||
|
|
637d9c42bf | ||
|
|
1c385c2ca4 | ||
|
|
25f25d546d | ||
|
|
6ac50634e3 | ||
|
|
50e453a3e2 | ||
|
|
4649bf042e | ||
|
|
2bd0ee27f0 | ||
|
|
0d16492eb7 | ||
|
|
2ae19801a9 | ||
|
|
950539b768 | ||
|
|
f270d6c52c | ||
|
|
22d6f00110 | ||
|
|
38e357ef10 | ||
|
|
0b7f3edc26 | ||
|
|
285269ef55 | ||
|
|
e25da4230b | ||
|
|
8be6f40ae1 | ||
|
|
83bd3595a4 | ||
|
|
32ee0a3947 | ||
|
|
7ddc22b326 | ||
|
|
0d5042f0f3 | ||
|
|
0eaddb4dcd | ||
|
|
74a11e2087 | ||
|
|
d4dd448511 | ||
|
|
56ad2a2d74 | ||
|
|
f421e73b40 | ||
|
|
72899318e6 | ||
|
|
84c6ea0cee | ||
|
|
c23b5463c7 | ||
|
|
9d8bc79025 | ||
|
|
0cad274b87 | ||
|
|
ac8931b2e9 | ||
|
|
4f112f898e | ||
|
|
e5ba982be0 | ||
|
|
200754b013 | ||
|
|
42ad3c1dd3 | ||
|
|
172570acae | ||
|
|
c29971cf72 | ||
|
|
ccc9a22db3 | ||
|
|
c00523dba4 | ||
|
|
9d5ec05150 | ||
|
|
2fecd332fc | ||
|
|
0e09032750 | ||
|
|
46b61427e1 | ||
|
|
bcf4ed28a9 | ||
|
|
6cfc9e6256 | ||
|
|
1ab236d9df | ||
|
|
2e1ac0f683 | ||
|
|
8364d1ca6c | ||
|
|
09d8943967 | ||
|
|
6e58a95a01 | ||
|
|
207ad45983 | ||
|
|
83ef61fa56 | ||
|
|
d0e0b106f0 | ||
|
|
98b66a5fc9 | ||
|
|
921bb92eec | ||
|
|
c50198debe | ||
|
|
6371474031 | ||
|
|
8657201257 | ||
|
|
b88492746e | ||
|
|
f6fc28dfd2 | ||
|
|
cdeef65b05 | ||
|
|
1e81a53e75 | ||
|
|
5e63711084 | ||
|
|
a2fbcc9ad4 | ||
|
|
10030ff3ec | ||
|
|
648735a4cf | ||
|
|
a4629b0b36 | ||
|
|
64cbbed152 | ||
|
|
43f375b2f2 | ||
|
|
1eb89d7e3b | ||
|
|
4d46383100 | ||
|
|
aa3fe81c87 | ||
|
|
9ea16e344a | ||
|
|
d8719cf59b | ||
|
|
9dcc07422e | ||
|
|
52c78820aa | ||
|
|
19b92751b9 | ||
|
|
f318f2d5ea | ||
|
|
21ff03978a | ||
|
|
25fd9d6132 | ||
|
|
3637193556 | ||
|
|
8e3274e137 | ||
|
|
c4a158656e | ||
|
|
e026c8d3b7 | ||
|
|
cab41d954e | ||
|
|
e0cbfd74d7 | ||
|
|
426930e028 | ||
|
|
e9fa17e1bf | ||
|
|
b807347e94 | ||
|
|
7113fc7dee | ||
|
|
e0f283cfcb | ||
|
|
7b968b098e | ||
|
|
e927a6ac4a | ||
|
|
9da475e4e8 | ||
|
|
5b282bdd48 | ||
|
|
fc80f2b41a | ||
|
|
68e9ef9885 | ||
|
|
296db2ed33 | ||
|
|
3171d61dfc | ||
|
|
00b9e70ba2 | ||
|
|
57e9f61852 | ||
|
|
cf365ed00b | ||
|
|
d98a5d54aa | ||
|
|
8074d56bdd | ||
|
|
fc3c3de70d | ||
|
|
997d1bd0eb | ||
|
|
baef79415b | ||
|
|
cb601d79e8 | ||
|
|
4cee46f909 | ||
|
|
25349b31d7 | ||
|
|
735267d27c | ||
|
|
b5ced477f4 | ||
|
|
67319a71e5 | ||
|
|
184a6f1198 | ||
|
|
b32bb4e6e3 | ||
|
|
0e62b7d68a | ||
|
|
a761779b12 | ||
|
|
29510fcb83 | ||
|
|
3f335b0d42 | ||
|
|
ffda84cfae | ||
|
|
e6bc840f6f | ||
|
|
0b26387a2b | ||
|
|
f7ef10e547 | ||
|
|
91cadc1130 | ||
|
|
47d1360124 | ||
|
|
f67699456c | ||
|
|
387f724d33 | ||
|
|
bcdfd5d61c | ||
|
|
e660d92fa5 | ||
|
|
9fdf72e42b | ||
|
|
df9051ded2 | ||
|
|
230c5ca735 | ||
|
|
3bd3693fb7 | ||
|
|
45cbebad64 | ||
|
|
6d0f9244b8 | ||
|
|
80a8aea7e3 | ||
|
|
4f0db01f7c | ||
|
|
6cd4e30b58 | ||
|
|
19540479d4 | ||
|
|
90dffb5a06 | ||
|
|
ef521d1e0b | ||
|
|
42c32bf00c | ||
|
|
c8a9969511 | ||
|
|
b0a8734c92 | ||
|
|
8d0723c2c3 |
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
90
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
Normal file
90
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
name: "Ask a question, report a bug, request a feature, etc."
|
||||||
|
description: "Ask any question, discuss best practices, report a bug, request a feature."
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
FOR FIRST-TIME USERS ISSUES COMPILING/LINKING/RUNNING or LOADING FONTS, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions)
|
||||||
|
For anything else: we are happy to use 'GitHub Issues' for many types of open-ended questions. We are encouraging 'Issues' becoming a large, centralized and cross-referenced database of Dear ImGui contents.
|
||||||
|
|
||||||
|
Be mindful that messages are being sent to the e-mail box of "Watching" users. Try to proof-read your messages before sending them. Edits are not seen by those users.
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
**Prerequisites:**
|
||||||
|
- I have read [Frequently Asked Questions](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md).
|
||||||
|
- I have read [Contributing Guidelines -> General Advices](https://github.com/ocornut/imgui/blob/master/docs/CONTRIBUTING.md#getting-started--general-advice).
|
||||||
|
- I have read [Contributing Guidelines -> How to open an Issue](https://github.com/ocornut/imgui/blob/master/docs/CONTRIBUTING.md#how-to-open-an-issue).
|
||||||
|
- I have searched [Github Issues and PR](https://github.com/ocornut/imgui/issues?q=) for discussion of similar topics.
|
||||||
|
|
||||||
|
----
|
||||||
|
- type: input
|
||||||
|
id: specs_version
|
||||||
|
attributes:
|
||||||
|
label: "Version/Branch of Dear ImGui:"
|
||||||
|
description: "(please specify if you have made substantial modifications to your copy)"
|
||||||
|
value: "Version 1.XX, Branch: XXX (master/docking/etc.)"
|
||||||
|
placeholder: "Version 1.XX, Branch: XXX (master/docking/etc.)"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: specs_backend
|
||||||
|
attributes:
|
||||||
|
label: "Back-ends:"
|
||||||
|
description: (or specify when using custom engine/back-ends)
|
||||||
|
value: "imgui_impl_XXX.cpp + imgui_impl_XXX.cpp"
|
||||||
|
placeholder: "imgui_impl_XXX.cpp + imgui_impl_XXX.cpp or n/a"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: specs_compiler_os
|
||||||
|
attributes:
|
||||||
|
label: "Compiler, OS:"
|
||||||
|
placeholder: "e.g. Windows 11 + MSVC 2022, macOS + Clang 12, Linux + GCC etc."
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: specs_full
|
||||||
|
attributes:
|
||||||
|
label: "Full config/build information:"
|
||||||
|
placeholder: |
|
||||||
|
(If you can run, you may go to 'Demo->Tools->About Dear ImGui->Config/Build Info' to obtain detailed information that you can paste here)
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: textarea
|
||||||
|
id: issue_description
|
||||||
|
attributes:
|
||||||
|
label: "Details:"
|
||||||
|
description: "Try to be explicit with your goals, your expectations and what you have tried. Be mindful of [The XY Problem](https://xyproblem.info). What you have in mind or in your code is not obvious to other people. People frequently discuss problems and suggest incorrect solutions without first clarifying their goals. When requesting a new feature, please describe the usage context (how you intend to use it, why you need it, etc.). If you tried something and it failed, show us what you tried. If you are reporting a bug, explain what's the bug, how does it occur, etc. If you are reporting a crash, please include a debugger callstack."
|
||||||
|
value: |
|
||||||
|
**My Issue/Question:**
|
||||||
|
|
||||||
|
XXX _(please provide as much context as possible)_
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: screenshots
|
||||||
|
attributes:
|
||||||
|
label: "Screenshots/Video:"
|
||||||
|
description: "Attach screenshots or gif/videos to clarify the context. They often convey useful information that is omitted by the description."
|
||||||
|
placeholder: "(You can drag files here)"
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: textarea
|
||||||
|
id: repro_code
|
||||||
|
attributes:
|
||||||
|
label: "Minimal, Complete and Verifiable Example code:"
|
||||||
|
description: "Provide an [MCVE](https://stackoverflow.com/help/mcve) to demonstrate your problem. An ideal submission includes a small piece of code that anyone can paste into one of the examples applications (examples/*/main.cpp) or the demo (imgui_demo.cpp) to understand and reproduce it. Narrowing your problem to its shortest and purest form is the easiest way to understand it, explain it and fix it. Please test your shortened code to ensure it exhibits the problem. Often while creating the MCVE you will solve the problem! Many questions that are missing a standalone verifiable example are missing the actual cause of their issue in the description, which ends up wasting everyone's time."
|
||||||
|
value: |
|
||||||
|
```cpp
|
||||||
|
// Here's some code anyone can copy and paste to reproduce your issue
|
||||||
|
ImGui::Begin("Example Bug");
|
||||||
|
MoreCodeToExplainMyIssue();
|
||||||
|
ImGui::End();
|
||||||
|
```
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Thank you for taking the time to read prerequisites, filling this template and double-checking your message and your code!
|
||||||
46
.github/issue_template.md
vendored
46
.github/issue_template.md
vendored
@@ -1,46 +0,0 @@
|
|||||||
(Click "Preview" above ^ to turn URL into clickable links)
|
|
||||||
|
|
||||||
1. FOR FIRST-TIME USERS ISSUES COMPILING/LINKING/RUNNING or LOADING FONTS, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions).
|
|
||||||
|
|
||||||
2. PLEASE CAREFULLY READ: [FAQ](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md)
|
|
||||||
|
|
||||||
3. PLEASE CAREFULLY READ: [Contributing Guidelines](https://github.com/ocornut/imgui/blob/master/docs/CONTRIBUTING.md)
|
|
||||||
|
|
||||||
4. PLEASE MAKE SURE that you have: read the FAQ; explored the contents of `ShowDemoWindow()` including the Examples menu; searched among Issues; used your IDE to search for keywords in all sources and text files; and read the links above.
|
|
||||||
|
|
||||||
5. Be mindful that messages are being sent to the e-mail box of "Watching" users. Try to proof-read your messages before sending them. Edits are not seen by those users.
|
|
||||||
|
|
||||||
6. Delete points 1-6 and PLEASE FILL THE TEMPLATE BELOW before submitting your issue.
|
|
||||||
|
|
||||||
Thank you!
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
_(you may also go to Demo>About Window, and click "Config/Build Information" to obtain a bunch of detailed information that you can paste here)_
|
|
||||||
|
|
||||||
**Version/Branch of Dear ImGui:**
|
|
||||||
|
|
||||||
Version: XXX
|
|
||||||
Branch: XXX _(master/viewport/docking/etc.)_
|
|
||||||
|
|
||||||
**Back-end/Renderer/Compiler/OS**
|
|
||||||
|
|
||||||
Back-ends: imgui_impl_XXX.cpp + imgui_impl_XXX.cpp _(or specify if using a custom engine/back-end)_
|
|
||||||
Compiler: XXX _(if the question is related to building or platform specific features)_
|
|
||||||
Operating System: XXX
|
|
||||||
|
|
||||||
**My Issue/Question:**
|
|
||||||
|
|
||||||
XXX _(please provide as much context as possible)_
|
|
||||||
|
|
||||||
**Screenshots/Video**
|
|
||||||
|
|
||||||
XXX _(you can drag files here)_
|
|
||||||
|
|
||||||
**Standalone, minimal, complete and verifiable example:** _(see https://github.com/ocornut/imgui/issues/2261)_
|
|
||||||
```
|
|
||||||
// Here's some code anyone can copy and paste to reproduce your issue
|
|
||||||
ImGui::Begin("Example Bug");
|
|
||||||
MoreCodeToExplainMyIssue();
|
|
||||||
ImGui::End();
|
|
||||||
```
|
|
||||||
14
.github/workflows/build.yml
vendored
14
.github/workflows/build.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
|||||||
VS_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\
|
VS_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\
|
||||||
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
|
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
shell: powershell
|
shell: powershell
|
||||||
@@ -209,7 +209,7 @@ jobs:
|
|||||||
Linux:
|
Linux:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
@@ -402,7 +402,7 @@ jobs:
|
|||||||
MacOS:
|
MacOS:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
@@ -462,7 +462,7 @@ jobs:
|
|||||||
iOS:
|
iOS:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Build example_apple_metal
|
- name: Build example_apple_metal
|
||||||
run: |
|
run: |
|
||||||
@@ -472,7 +472,7 @@ jobs:
|
|||||||
Emscripten:
|
Emscripten:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
@@ -494,12 +494,12 @@ jobs:
|
|||||||
pushd emsdk-master
|
pushd emsdk-master
|
||||||
source ./emsdk_env.sh
|
source ./emsdk_env.sh
|
||||||
popd
|
popd
|
||||||
make -C examples/example_emscripten_wgpu
|
make -C examples/example_emscripten_wgpu -f Makefile.emscripten
|
||||||
|
|
||||||
Android:
|
Android:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Build example_android_opengl3
|
- name: Build example_android_opengl3
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
2
.github/workflows/static-analysis.yml
vendored
2
.github/workflows/static-analysis.yml
vendored
@@ -12,7 +12,7 @@ jobs:
|
|||||||
PVS-Studio:
|
PVS-Studio:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -8,7 +8,6 @@ imgui.ini
|
|||||||
*.o
|
*.o
|
||||||
*.obj
|
*.obj
|
||||||
*.exe
|
*.exe
|
||||||
examples/build/*
|
|
||||||
examples/*/Debug/*
|
examples/*/Debug/*
|
||||||
examples/*/Release/*
|
examples/*/Release/*
|
||||||
examples/*/x64/*
|
examples/*/x64/*
|
||||||
@@ -30,7 +29,7 @@ ipch
|
|||||||
JSON/
|
JSON/
|
||||||
|
|
||||||
## Commonly used CMake directories
|
## Commonly used CMake directories
|
||||||
/build*/
|
build*/
|
||||||
|
|
||||||
## Xcode artifacts
|
## Xcode artifacts
|
||||||
project.xcworkspace
|
project.xcworkspace
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2014-2023 Omar Cornut
|
Copyright (c) 2014-2024 Omar Cornut
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -6,14 +6,18 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Clipboard support (from Allegro 5.1.12)
|
// [X] Platform: Clipboard support (from Allegro 5.1.12)
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// Issues:
|
// Missing features:
|
||||||
|
// [ ] Renderer: Multi-viewport support (multiple windows)..
|
||||||
// [ ] Renderer: The renderer is suboptimal as we need to convert vertices manually.
|
// [ ] Renderer: The renderer is suboptimal as we need to convert vertices manually.
|
||||||
// [ ] Platform: Missing gamepad support.
|
// [ ] Platform: Missing gamepad support.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
@@ -24,7 +28,7 @@
|
|||||||
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
// 2022-01-17: Inputs: always calling io.AddKeyModsEvent() next and before key event (not in NewFrame) to fix input queue with very low framerates.
|
// 2022-01-17: Inputs: always calling io.AddKeyModsEvent() next and before key event (not in NewFrame) to fix input queue with very low framerates.
|
||||||
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
// 2021-12-08: Renderer: Fixed mishandling of the the ImDrawCmd::IdxOffset field! This is an old bug but it never had an effect until some internal rendering changes in 1.86.
|
// 2021-12-08: Renderer: Fixed mishandling of the ImDrawCmd::IdxOffset field! This is an old bug but it never had an effect until some internal rendering changes in 1.86.
|
||||||
// 2021-08-17: Calling io.AddFocusEvent() on ALLEGRO_EVENT_DISPLAY_SWITCH_OUT/ALLEGRO_EVENT_DISPLAY_SWITCH_IN events.
|
// 2021-08-17: Calling io.AddFocusEvent() on ALLEGRO_EVENT_DISPLAY_SWITCH_OUT/ALLEGRO_EVENT_DISPLAY_SWITCH_IN events.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2021-05-19: Renderer: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
// 2021-05-19: Renderer: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
||||||
@@ -47,10 +51,11 @@
|
|||||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||||
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
|
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
#include "imgui_impl_allegro5.h"
|
||||||
#include <stdint.h> // uint64_t
|
#include <stdint.h> // uint64_t
|
||||||
#include <cstring> // memcpy
|
#include <cstring> // memcpy
|
||||||
#include "imgui.h"
|
|
||||||
#include "imgui_impl_allegro5.h"
|
|
||||||
|
|
||||||
// Allegro
|
// Allegro
|
||||||
#include <allegro5/allegro.h>
|
#include <allegro5/allegro.h>
|
||||||
@@ -434,9 +439,9 @@ bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
|
|||||||
// We still use a custom declaration to use 'ALLEGRO_PRIM_TEX_COORD' instead of 'ALLEGRO_PRIM_TEX_COORD_PIXEL' else we can't do a reliable conversion.
|
// We still use a custom declaration to use 'ALLEGRO_PRIM_TEX_COORD' instead of 'ALLEGRO_PRIM_TEX_COORD_PIXEL' else we can't do a reliable conversion.
|
||||||
ALLEGRO_VERTEX_ELEMENT elems[] =
|
ALLEGRO_VERTEX_ELEMENT elems[] =
|
||||||
{
|
{
|
||||||
{ ALLEGRO_PRIM_POSITION, ALLEGRO_PRIM_FLOAT_2, IM_OFFSETOF(ImDrawVertAllegro, pos) },
|
{ ALLEGRO_PRIM_POSITION, ALLEGRO_PRIM_FLOAT_2, offsetof(ImDrawVertAllegro, pos) },
|
||||||
{ ALLEGRO_PRIM_TEX_COORD, ALLEGRO_PRIM_FLOAT_2, IM_OFFSETOF(ImDrawVertAllegro, uv) },
|
{ ALLEGRO_PRIM_TEX_COORD, ALLEGRO_PRIM_FLOAT_2, offsetof(ImDrawVertAllegro, uv) },
|
||||||
{ ALLEGRO_PRIM_COLOR_ATTR, 0, IM_OFFSETOF(ImDrawVertAllegro, col) },
|
{ ALLEGRO_PRIM_COLOR_ATTR, 0, offsetof(ImDrawVertAllegro, col) },
|
||||||
{ 0, 0, 0 }
|
{ 0, 0, 0 }
|
||||||
};
|
};
|
||||||
bd->VertexDecl = al_create_vertex_decl(elems, sizeof(ImDrawVertAllegro));
|
bd->VertexDecl = al_create_vertex_decl(elems, sizeof(ImDrawVertAllegro));
|
||||||
@@ -462,8 +467,9 @@ void ImGui_ImplAllegro5_Shutdown()
|
|||||||
if (bd->ClipboardTextData)
|
if (bd->ClipboardTextData)
|
||||||
al_free(bd->ClipboardTextData);
|
al_free(bd->ClipboardTextData);
|
||||||
|
|
||||||
io.BackendPlatformUserData = nullptr;
|
|
||||||
io.BackendPlatformName = io.BackendRendererName = nullptr;
|
io.BackendPlatformName = io.BackendRendererName = nullptr;
|
||||||
|
io.BackendPlatformUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~ImGuiBackendFlags_HasMouseCursors;
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,3 +608,7 @@ void ImGui_ImplAllegro5_NewFrame()
|
|||||||
// Setup mouse cursor shape
|
// Setup mouse cursor shape
|
||||||
ImGui_ImplAllegro5_UpdateMouseCursor();
|
ImGui_ImplAllegro5_UpdateMouseCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -6,17 +6,22 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Clipboard support (from Allegro 5.1.12)
|
// [X] Platform: Clipboard support (from Allegro 5.1.12)
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// Issues:
|
// Missing features:
|
||||||
|
// [ ] Renderer: Multi-viewport support (multiple windows)..
|
||||||
// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually.
|
// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually.
|
||||||
// [ ] Platform: Missing gamepad support.
|
// [ ] Platform: Missing gamepad support.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct ALLEGRO_DISPLAY;
|
struct ALLEGRO_DISPLAY;
|
||||||
union ALLEGRO_EVENT;
|
union ALLEGRO_EVENT;
|
||||||
@@ -30,3 +35,5 @@ IMGUI_IMPL_API bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* event);
|
|||||||
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
||||||
IMGUI_IMPL_API bool ImGui_ImplAllegro5_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplAllegro5_CreateDeviceObjects();
|
||||||
IMGUI_IMPL_API void ImGui_ImplAllegro5_InvalidateDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplAllegro5_InvalidateDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
// [ ] Platform: Clipboard support.
|
// [ ] Platform: Clipboard support.
|
||||||
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
|
// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
|
||||||
|
// [ ] Platform: Multi-viewport support (multiple windows). Not meaningful on Android.
|
||||||
// Important:
|
// Important:
|
||||||
// - Consider using SDL or GLFW backend on Android, which will be more full-featured than this.
|
// - Consider using SDL or GLFW backend on Android, which will be more full-featured than this.
|
||||||
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)
|
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)
|
||||||
@@ -15,8 +16,11 @@
|
|||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
@@ -27,6 +31,7 @@
|
|||||||
// 2021-03-04: Initial version.
|
// 2021-03-04: Initial version.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_android.h"
|
#include "imgui_impl_android.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <android/native_window.h>
|
#include <android/native_window.h>
|
||||||
@@ -152,7 +157,7 @@ static ImGuiKey ImGui_ImplAndroid_KeyCodeToImGuiKey(int32_t key_code)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event)
|
int32_t ImGui_ImplAndroid_HandleInputEvent(const AInputEvent* input_event)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
int32_t event_type = AInputEvent_getType(input_event);
|
int32_t event_type = AInputEvent_getType(input_event);
|
||||||
@@ -179,7 +184,7 @@ int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event)
|
|||||||
case AKEY_EVENT_ACTION_UP:
|
case AKEY_EVENT_ACTION_UP:
|
||||||
{
|
{
|
||||||
ImGuiKey key = ImGui_ImplAndroid_KeyCodeToImGuiKey(event_key_code);
|
ImGuiKey key = ImGui_ImplAndroid_KeyCodeToImGuiKey(event_key_code);
|
||||||
if (key != ImGuiKey_None && (event_action == AKEY_EVENT_ACTION_DOWN || event_action == AKEY_EVENT_ACTION_UP))
|
if (key != ImGuiKey_None)
|
||||||
{
|
{
|
||||||
io.AddKeyEvent(key, event_action == AKEY_EVENT_ACTION_DOWN);
|
io.AddKeyEvent(key, event_action == AKEY_EVENT_ACTION_DOWN);
|
||||||
io.SetKeyEventNativeData(key, event_key_code, event_scan_code);
|
io.SetKeyEventNativeData(key, event_key_code, event_scan_code);
|
||||||
@@ -217,25 +222,27 @@ int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event)
|
|||||||
{
|
{
|
||||||
case AMOTION_EVENT_ACTION_DOWN:
|
case AMOTION_EVENT_ACTION_DOWN:
|
||||||
case AMOTION_EVENT_ACTION_UP:
|
case AMOTION_EVENT_ACTION_UP:
|
||||||
|
{
|
||||||
// Physical mouse buttons (and probably other physical devices) also invoke the actions AMOTION_EVENT_ACTION_DOWN/_UP,
|
// Physical mouse buttons (and probably other physical devices) also invoke the actions AMOTION_EVENT_ACTION_DOWN/_UP,
|
||||||
// but we have to process them separately to identify the actual button pressed. This is done below via
|
// but we have to process them separately to identify the actual button pressed. This is done below via
|
||||||
// AMOTION_EVENT_ACTION_BUTTON_PRESS/_RELEASE. Here, we only process "FINGER" input (and "UNKNOWN", as a fallback).
|
// AMOTION_EVENT_ACTION_BUTTON_PRESS/_RELEASE. Here, we only process "FINGER" input (and "UNKNOWN", as a fallback).
|
||||||
if((AMotionEvent_getToolType(input_event, event_pointer_index) == AMOTION_EVENT_TOOL_TYPE_FINGER)
|
int tool_type = AMotionEvent_getToolType(input_event, event_pointer_index);
|
||||||
|| (AMotionEvent_getToolType(input_event, event_pointer_index) == AMOTION_EVENT_TOOL_TYPE_UNKNOWN))
|
if (tool_type == AMOTION_EVENT_TOOL_TYPE_FINGER || tool_type == AMOTION_EVENT_TOOL_TYPE_UNKNOWN)
|
||||||
{
|
{
|
||||||
io.AddMousePosEvent(AMotionEvent_getX(input_event, event_pointer_index), AMotionEvent_getY(input_event, event_pointer_index));
|
io.AddMousePosEvent(AMotionEvent_getX(input_event, event_pointer_index), AMotionEvent_getY(input_event, event_pointer_index));
|
||||||
io.AddMouseButtonEvent(0, event_action == AMOTION_EVENT_ACTION_DOWN);
|
io.AddMouseButtonEvent(0, event_action == AMOTION_EVENT_ACTION_DOWN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case AMOTION_EVENT_ACTION_BUTTON_PRESS:
|
case AMOTION_EVENT_ACTION_BUTTON_PRESS:
|
||||||
case AMOTION_EVENT_ACTION_BUTTON_RELEASE:
|
case AMOTION_EVENT_ACTION_BUTTON_RELEASE:
|
||||||
{
|
{
|
||||||
int32_t button_state = AMotionEvent_getButtonState(input_event);
|
int32_t button_state = AMotionEvent_getButtonState(input_event);
|
||||||
io.AddMouseButtonEvent(0, (button_state & AMOTION_EVENT_BUTTON_PRIMARY) != 0);
|
io.AddMouseButtonEvent(0, (button_state & AMOTION_EVENT_BUTTON_PRIMARY) != 0);
|
||||||
io.AddMouseButtonEvent(1, (button_state & AMOTION_EVENT_BUTTON_SECONDARY) != 0);
|
io.AddMouseButtonEvent(1, (button_state & AMOTION_EVENT_BUTTON_SECONDARY) != 0);
|
||||||
io.AddMouseButtonEvent(2, (button_state & AMOTION_EVENT_BUTTON_TERTIARY) != 0);
|
io.AddMouseButtonEvent(2, (button_state & AMOTION_EVENT_BUTTON_TERTIARY) != 0);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case AMOTION_EVENT_ACTION_HOVER_MOVE: // Hovering: Tool moves while NOT pressed (such as a physical mouse)
|
case AMOTION_EVENT_ACTION_HOVER_MOVE: // Hovering: Tool moves while NOT pressed (such as a physical mouse)
|
||||||
case AMOTION_EVENT_ACTION_MOVE: // Touch pointer moves while DOWN
|
case AMOTION_EVENT_ACTION_MOVE: // Touch pointer moves while DOWN
|
||||||
io.AddMousePosEvent(AMotionEvent_getX(input_event, event_pointer_index), AMotionEvent_getY(input_event, event_pointer_index));
|
io.AddMousePosEvent(AMotionEvent_getX(input_event, event_pointer_index), AMotionEvent_getY(input_event, event_pointer_index));
|
||||||
@@ -269,6 +276,8 @@ bool ImGui_ImplAndroid_Init(ANativeWindow* window)
|
|||||||
|
|
||||||
void ImGui_ImplAndroid_Shutdown()
|
void ImGui_ImplAndroid_Shutdown()
|
||||||
{
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.BackendPlatformName = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplAndroid_NewFrame()
|
void ImGui_ImplAndroid_NewFrame()
|
||||||
@@ -292,3 +301,7 @@ void ImGui_ImplAndroid_NewFrame()
|
|||||||
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f / 60.0f);
|
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f / 60.0f);
|
||||||
g_Time = current_time;
|
g_Time = current_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
// [ ] Platform: Clipboard support.
|
// [ ] Platform: Clipboard support.
|
||||||
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
|
// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
|
||||||
|
// [ ] Platform: Multi-viewport support (multiple windows). Not meaningful on Android.
|
||||||
// Important:
|
// Important:
|
||||||
// - Consider using SDL or GLFW backend on Android, which will be more full-featured than this.
|
// - Consider using SDL or GLFW backend on Android, which will be more full-featured than this.
|
||||||
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)
|
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)
|
||||||
@@ -15,15 +16,22 @@
|
|||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct ANativeWindow;
|
struct ANativeWindow;
|
||||||
struct AInputEvent;
|
struct AInputEvent;
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplAndroid_Init(ANativeWindow* window);
|
IMGUI_IMPL_API bool ImGui_ImplAndroid_Init(ANativeWindow* window);
|
||||||
IMGUI_IMPL_API int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event);
|
IMGUI_IMPL_API int32_t ImGui_ImplAndroid_HandleInputEvent(const AInputEvent* input_event);
|
||||||
IMGUI_IMPL_API void ImGui_ImplAndroid_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplAndroid_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplAndroid_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplAndroid_NewFrame();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -4,14 +4,19 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2021-05-19: DirectX10: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
// 2021-05-19: DirectX10: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
||||||
@@ -30,6 +35,7 @@
|
|||||||
// 2016-05-07: DirectX10: Disabling depth-write.
|
// 2016-05-07: DirectX10: Disabling depth-write.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_dx10.h"
|
#include "imgui_impl_dx10.h"
|
||||||
|
|
||||||
// DirectX
|
// DirectX
|
||||||
@@ -75,6 +81,10 @@ static ImGui_ImplDX10_Data* ImGui_ImplDX10_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplDX10_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplDX10_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplDX10_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplDX10_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device* ctx)
|
static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device* ctx)
|
||||||
{
|
{
|
||||||
@@ -410,9 +420,9 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
|
|||||||
// Create the input layout
|
// Create the input layout
|
||||||
D3D10_INPUT_ELEMENT_DESC local_layout[] =
|
D3D10_INPUT_ELEMENT_DESC local_layout[] =
|
||||||
{
|
{
|
||||||
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, pos), D3D10_INPUT_PER_VERTEX_DATA, 0 },
|
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)offsetof(ImDrawVert, pos), D3D10_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), D3D10_INPUT_PER_VERTEX_DATA, 0 },
|
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)offsetof(ImDrawVert, uv), D3D10_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), D3D10_INPUT_PER_VERTEX_DATA, 0 },
|
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)offsetof(ImDrawVert, col), D3D10_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
};
|
};
|
||||||
if (bd->pd3dDevice->CreateInputLayout(local_layout, 3, vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), &bd->pInputLayout) != S_OK)
|
if (bd->pd3dDevice->CreateInputLayout(local_layout, 3, vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), &bd->pInputLayout) != S_OK)
|
||||||
{
|
{
|
||||||
@@ -537,6 +547,7 @@ bool ImGui_ImplDX10_Init(ID3D10Device* device)
|
|||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_dx10";
|
io.BackendRendererName = "imgui_impl_dx10";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||||
|
|
||||||
// Get factory from device
|
// Get factory from device
|
||||||
IDXGIDevice* pDXGIDevice = nullptr;
|
IDXGIDevice* pDXGIDevice = nullptr;
|
||||||
@@ -553,6 +564,8 @@ bool ImGui_ImplDX10_Init(ID3D10Device* device)
|
|||||||
if (pDXGIAdapter) pDXGIAdapter->Release();
|
if (pDXGIAdapter) pDXGIAdapter->Release();
|
||||||
bd->pd3dDevice->AddRef();
|
bd->pd3dDevice->AddRef();
|
||||||
|
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplDX10_InitPlatformInterface();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -562,11 +575,13 @@ void ImGui_ImplDX10_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplDX10_ShutdownPlatformInterface();
|
||||||
ImGui_ImplDX10_InvalidateDeviceObjects();
|
ImGui_ImplDX10_InvalidateDeviceObjects();
|
||||||
if (bd->pFactory) { bd->pFactory->Release(); }
|
if (bd->pFactory) { bd->pFactory->Release(); }
|
||||||
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,3 +593,130 @@ void ImGui_ImplDX10_NewFrame()
|
|||||||
if (!bd->pFontSampler)
|
if (!bd->pFontSampler)
|
||||||
ImGui_ImplDX10_CreateDeviceObjects();
|
ImGui_ImplDX10_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplDX10_ViewportData
|
||||||
|
{
|
||||||
|
IDXGISwapChain* SwapChain;
|
||||||
|
ID3D10RenderTargetView* RTView;
|
||||||
|
|
||||||
|
ImGui_ImplDX10_ViewportData() { SwapChain = nullptr; RTView = nullptr; }
|
||||||
|
~ImGui_ImplDX10_ViewportData() { IM_ASSERT(SwapChain == nullptr && RTView == nullptr); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplDX10_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
|
||||||
|
ImGui_ImplDX10_ViewportData* vd = IM_NEW(ImGui_ImplDX10_ViewportData)();
|
||||||
|
viewport->RendererUserData = vd;
|
||||||
|
|
||||||
|
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
|
||||||
|
// Some backends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the HWND.
|
||||||
|
HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle;
|
||||||
|
IM_ASSERT(hwnd != 0);
|
||||||
|
|
||||||
|
// Create swap chain
|
||||||
|
DXGI_SWAP_CHAIN_DESC sd;
|
||||||
|
ZeroMemory(&sd, sizeof(sd));
|
||||||
|
sd.BufferDesc.Width = (UINT)viewport->Size.x;
|
||||||
|
sd.BufferDesc.Height = (UINT)viewport->Size.y;
|
||||||
|
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
sd.SampleDesc.Count = 1;
|
||||||
|
sd.SampleDesc.Quality = 0;
|
||||||
|
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||||
|
sd.BufferCount = 1;
|
||||||
|
sd.OutputWindow = hwnd;
|
||||||
|
sd.Windowed = TRUE;
|
||||||
|
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||||
|
sd.Flags = 0;
|
||||||
|
|
||||||
|
IM_ASSERT(vd->SwapChain == nullptr && vd->RTView == nullptr);
|
||||||
|
bd->pFactory->CreateSwapChain(bd->pd3dDevice, &sd, &vd->SwapChain);
|
||||||
|
|
||||||
|
// Create the render target
|
||||||
|
if (vd->SwapChain)
|
||||||
|
{
|
||||||
|
ID3D10Texture2D* pBackBuffer;
|
||||||
|
vd->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
||||||
|
bd->pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &vd->RTView);
|
||||||
|
pBackBuffer->Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX10_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
// The main viewport (owned by the application) will always have RendererUserData == 0 here since we didn't create the data for it.
|
||||||
|
if (ImGui_ImplDX10_ViewportData* vd = (ImGui_ImplDX10_ViewportData*)viewport->RendererUserData)
|
||||||
|
{
|
||||||
|
if (vd->SwapChain)
|
||||||
|
vd->SwapChain->Release();
|
||||||
|
vd->SwapChain = nullptr;
|
||||||
|
if (vd->RTView)
|
||||||
|
vd->RTView->Release();
|
||||||
|
vd->RTView = nullptr;
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->RendererUserData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX10_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
|
||||||
|
ImGui_ImplDX10_ViewportData* vd = (ImGui_ImplDX10_ViewportData*)viewport->RendererUserData;
|
||||||
|
if (vd->RTView)
|
||||||
|
{
|
||||||
|
vd->RTView->Release();
|
||||||
|
vd->RTView = nullptr;
|
||||||
|
}
|
||||||
|
if (vd->SwapChain)
|
||||||
|
{
|
||||||
|
ID3D10Texture2D* pBackBuffer = nullptr;
|
||||||
|
vd->SwapChain->ResizeBuffers(0, (UINT)size.x, (UINT)size.y, DXGI_FORMAT_UNKNOWN, 0);
|
||||||
|
vd->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
||||||
|
if (pBackBuffer == nullptr) { fprintf(stderr, "ImGui_ImplDX10_SetWindowSize() failed creating buffers.\n"); return; }
|
||||||
|
bd->pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &vd->RTView);
|
||||||
|
pBackBuffer->Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX10_RenderViewport(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
|
||||||
|
ImGui_ImplDX10_ViewportData* vd = (ImGui_ImplDX10_ViewportData*)viewport->RendererUserData;
|
||||||
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
bd->pd3dDevice->OMSetRenderTargets(1, &vd->RTView, nullptr);
|
||||||
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
|
bd->pd3dDevice->ClearRenderTargetView(vd->RTView, (float*)&clear_color);
|
||||||
|
ImGui_ImplDX10_RenderDrawData(viewport->DrawData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX10_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX10_ViewportData* vd = (ImGui_ImplDX10_ViewportData*)viewport->RendererUserData;
|
||||||
|
vd->SwapChain->Present(0, 0); // Present without vsync
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplDX10_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_CreateWindow = ImGui_ImplDX10_CreateWindow;
|
||||||
|
platform_io.Renderer_DestroyWindow = ImGui_ImplDX10_DestroyWindow;
|
||||||
|
platform_io.Renderer_SetWindowSize = ImGui_ImplDX10_SetWindowSize;
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplDX10_RenderViewport;
|
||||||
|
platform_io.Renderer_SwapBuffers = ImGui_ImplDX10_SwapBuffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplDX10_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -4,14 +4,19 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct ID3D10Device;
|
struct ID3D10Device;
|
||||||
|
|
||||||
@@ -23,3 +28,5 @@ IMGUI_IMPL_API void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data);
|
|||||||
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
||||||
IMGUI_IMPL_API void ImGui_ImplDX10_InvalidateDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplDX10_InvalidateDeviceObjects();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplDX10_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplDX10_CreateDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -4,14 +4,19 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2021-05-19: DirectX11: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
// 2021-05-19: DirectX11: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
||||||
@@ -31,6 +36,7 @@
|
|||||||
// 2016-05-07: DirectX11: Disabling depth-write.
|
// 2016-05-07: DirectX11: Disabling depth-write.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_dx11.h"
|
#include "imgui_impl_dx11.h"
|
||||||
|
|
||||||
// DirectX
|
// DirectX
|
||||||
@@ -76,6 +82,10 @@ static ImGui_ImplDX11_Data* ImGui_ImplDX11_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplDX11_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplDX11_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplDX11_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplDX11_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceContext* ctx)
|
static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceContext* ctx)
|
||||||
{
|
{
|
||||||
@@ -422,9 +432,9 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
// Create the input layout
|
// Create the input layout
|
||||||
D3D11_INPUT_ELEMENT_DESC local_layout[] =
|
D3D11_INPUT_ELEMENT_DESC local_layout[] =
|
||||||
{
|
{
|
||||||
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, pos), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)offsetof(ImDrawVert, pos), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)offsetof(ImDrawVert, uv), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)offsetof(ImDrawVert, col), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
};
|
};
|
||||||
if (bd->pd3dDevice->CreateInputLayout(local_layout, 3, vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), &bd->pInputLayout) != S_OK)
|
if (bd->pd3dDevice->CreateInputLayout(local_layout, 3, vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), &bd->pInputLayout) != S_OK)
|
||||||
{
|
{
|
||||||
@@ -549,6 +559,7 @@ bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_co
|
|||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_dx11";
|
io.BackendRendererName = "imgui_impl_dx11";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||||
|
|
||||||
// Get factory from device
|
// Get factory from device
|
||||||
IDXGIDevice* pDXGIDevice = nullptr;
|
IDXGIDevice* pDXGIDevice = nullptr;
|
||||||
@@ -568,6 +579,9 @@ bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_co
|
|||||||
bd->pd3dDevice->AddRef();
|
bd->pd3dDevice->AddRef();
|
||||||
bd->pd3dDeviceContext->AddRef();
|
bd->pd3dDeviceContext->AddRef();
|
||||||
|
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplDX11_InitPlatformInterface();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,12 +591,14 @@ void ImGui_ImplDX11_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplDX11_ShutdownPlatformInterface();
|
||||||
ImGui_ImplDX11_InvalidateDeviceObjects();
|
ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||||
if (bd->pFactory) { bd->pFactory->Release(); }
|
if (bd->pFactory) { bd->pFactory->Release(); }
|
||||||
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
||||||
if (bd->pd3dDeviceContext) { bd->pd3dDeviceContext->Release(); }
|
if (bd->pd3dDeviceContext) { bd->pd3dDeviceContext->Release(); }
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,3 +610,130 @@ void ImGui_ImplDX11_NewFrame()
|
|||||||
if (!bd->pFontSampler)
|
if (!bd->pFontSampler)
|
||||||
ImGui_ImplDX11_CreateDeviceObjects();
|
ImGui_ImplDX11_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplDX11_ViewportData
|
||||||
|
{
|
||||||
|
IDXGISwapChain* SwapChain;
|
||||||
|
ID3D11RenderTargetView* RTView;
|
||||||
|
|
||||||
|
ImGui_ImplDX11_ViewportData() { SwapChain = nullptr; RTView = nullptr; }
|
||||||
|
~ImGui_ImplDX11_ViewportData() { IM_ASSERT(SwapChain == nullptr && RTView == nullptr); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplDX11_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
||||||
|
ImGui_ImplDX11_ViewportData* vd = IM_NEW(ImGui_ImplDX11_ViewportData)();
|
||||||
|
viewport->RendererUserData = vd;
|
||||||
|
|
||||||
|
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
|
||||||
|
// Some backends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the HWND.
|
||||||
|
HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle;
|
||||||
|
IM_ASSERT(hwnd != 0);
|
||||||
|
|
||||||
|
// Create swap chain
|
||||||
|
DXGI_SWAP_CHAIN_DESC sd;
|
||||||
|
ZeroMemory(&sd, sizeof(sd));
|
||||||
|
sd.BufferDesc.Width = (UINT)viewport->Size.x;
|
||||||
|
sd.BufferDesc.Height = (UINT)viewport->Size.y;
|
||||||
|
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
sd.SampleDesc.Count = 1;
|
||||||
|
sd.SampleDesc.Quality = 0;
|
||||||
|
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||||
|
sd.BufferCount = 1;
|
||||||
|
sd.OutputWindow = hwnd;
|
||||||
|
sd.Windowed = TRUE;
|
||||||
|
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||||
|
sd.Flags = 0;
|
||||||
|
|
||||||
|
IM_ASSERT(vd->SwapChain == nullptr && vd->RTView == nullptr);
|
||||||
|
bd->pFactory->CreateSwapChain(bd->pd3dDevice, &sd, &vd->SwapChain);
|
||||||
|
|
||||||
|
// Create the render target
|
||||||
|
if (vd->SwapChain)
|
||||||
|
{
|
||||||
|
ID3D11Texture2D* pBackBuffer;
|
||||||
|
vd->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
||||||
|
bd->pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &vd->RTView);
|
||||||
|
pBackBuffer->Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX11_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
// The main viewport (owned by the application) will always have RendererUserData == nullptr since we didn't create the data for it.
|
||||||
|
if (ImGui_ImplDX11_ViewportData* vd = (ImGui_ImplDX11_ViewportData*)viewport->RendererUserData)
|
||||||
|
{
|
||||||
|
if (vd->SwapChain)
|
||||||
|
vd->SwapChain->Release();
|
||||||
|
vd->SwapChain = nullptr;
|
||||||
|
if (vd->RTView)
|
||||||
|
vd->RTView->Release();
|
||||||
|
vd->RTView = nullptr;
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->RendererUserData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX11_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
||||||
|
ImGui_ImplDX11_ViewportData* vd = (ImGui_ImplDX11_ViewportData*)viewport->RendererUserData;
|
||||||
|
if (vd->RTView)
|
||||||
|
{
|
||||||
|
vd->RTView->Release();
|
||||||
|
vd->RTView = nullptr;
|
||||||
|
}
|
||||||
|
if (vd->SwapChain)
|
||||||
|
{
|
||||||
|
ID3D11Texture2D* pBackBuffer = nullptr;
|
||||||
|
vd->SwapChain->ResizeBuffers(0, (UINT)size.x, (UINT)size.y, DXGI_FORMAT_UNKNOWN, 0);
|
||||||
|
vd->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
||||||
|
if (pBackBuffer == nullptr) { fprintf(stderr, "ImGui_ImplDX11_SetWindowSize() failed creating buffers.\n"); return; }
|
||||||
|
bd->pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &vd->RTView);
|
||||||
|
pBackBuffer->Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX11_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
||||||
|
ImGui_ImplDX11_ViewportData* vd = (ImGui_ImplDX11_ViewportData*)viewport->RendererUserData;
|
||||||
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
bd->pd3dDeviceContext->OMSetRenderTargets(1, &vd->RTView, nullptr);
|
||||||
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
|
bd->pd3dDeviceContext->ClearRenderTargetView(vd->RTView, (float*)&clear_color);
|
||||||
|
ImGui_ImplDX11_RenderDrawData(viewport->DrawData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX11_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX11_ViewportData* vd = (ImGui_ImplDX11_ViewportData*)viewport->RendererUserData;
|
||||||
|
vd->SwapChain->Present(0, 0); // Present without vsync
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX11_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_CreateWindow = ImGui_ImplDX11_CreateWindow;
|
||||||
|
platform_io.Renderer_DestroyWindow = ImGui_ImplDX11_DestroyWindow;
|
||||||
|
platform_io.Renderer_SetWindowSize = ImGui_ImplDX11_SetWindowSize;
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplDX11_RenderWindow;
|
||||||
|
platform_io.Renderer_SwapBuffers = ImGui_ImplDX11_SwapBuffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX11_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -4,14 +4,19 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct ID3D11Device;
|
struct ID3D11Device;
|
||||||
struct ID3D11DeviceContext;
|
struct ID3D11DeviceContext;
|
||||||
@@ -24,3 +29,5 @@ IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data);
|
|||||||
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
||||||
IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
// FIXME: The transition from removing a viewport and moving the window in an existing hosted viewport tends to flicker.
|
||||||
|
|
||||||
// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
|
// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
|
||||||
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
|
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
|
||||||
@@ -15,11 +17,15 @@
|
|||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2021-05-19: DirectX12: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
// 2021-05-19: DirectX12: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
||||||
@@ -39,6 +45,7 @@
|
|||||||
// 2018-02-22: Merged into master with all Win32 code synchronized to other examples.
|
// 2018-02-22: Merged into master with all Win32 code synchronized to other examples.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_dx12.h"
|
#include "imgui_impl_dx12.h"
|
||||||
|
|
||||||
// DirectX
|
// DirectX
|
||||||
@@ -50,7 +57,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// DirectX data
|
// DirectX data
|
||||||
struct ImGui_ImplDX12_RenderBuffers;
|
|
||||||
struct ImGui_ImplDX12_Data
|
struct ImGui_ImplDX12_Data
|
||||||
{
|
{
|
||||||
ID3D12Device* pd3dDevice;
|
ID3D12Device* pd3dDevice;
|
||||||
@@ -63,10 +69,7 @@ struct ImGui_ImplDX12_Data
|
|||||||
ID3D12DescriptorHeap* pd3dSrvDescHeap;
|
ID3D12DescriptorHeap* pd3dSrvDescHeap;
|
||||||
UINT numFramesInFlight;
|
UINT numFramesInFlight;
|
||||||
|
|
||||||
ImGui_ImplDX12_RenderBuffers* pFrameResources;
|
ImGui_ImplDX12_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
UINT frameIndex;
|
|
||||||
|
|
||||||
ImGui_ImplDX12_Data() { memset((void*)this, 0, sizeof(*this)); frameIndex = UINT_MAX; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
|
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
|
||||||
@@ -85,11 +88,88 @@ struct ImGui_ImplDX12_RenderBuffers
|
|||||||
int VertexBufferSize;
|
int VertexBufferSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Buffers used for secondary viewports created by the multi-viewports systems
|
||||||
|
struct ImGui_ImplDX12_FrameContext
|
||||||
|
{
|
||||||
|
ID3D12CommandAllocator* CommandAllocator;
|
||||||
|
ID3D12Resource* RenderTarget;
|
||||||
|
D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetCpuDescriptors;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
// Main viewport created by application will only use the Resources field.
|
||||||
|
// Secondary viewports created by this backend will use all the fields (including Window fields),
|
||||||
|
struct ImGui_ImplDX12_ViewportData
|
||||||
|
{
|
||||||
|
// Window
|
||||||
|
ID3D12CommandQueue* CommandQueue;
|
||||||
|
ID3D12GraphicsCommandList* CommandList;
|
||||||
|
ID3D12DescriptorHeap* RtvDescHeap;
|
||||||
|
IDXGISwapChain3* SwapChain;
|
||||||
|
ID3D12Fence* Fence;
|
||||||
|
UINT64 FenceSignaledValue;
|
||||||
|
HANDLE FenceEvent;
|
||||||
|
UINT NumFramesInFlight;
|
||||||
|
ImGui_ImplDX12_FrameContext* FrameCtx;
|
||||||
|
|
||||||
|
// Render buffers
|
||||||
|
UINT FrameIndex;
|
||||||
|
ImGui_ImplDX12_RenderBuffers* FrameRenderBuffers;
|
||||||
|
|
||||||
|
ImGui_ImplDX12_ViewportData(UINT num_frames_in_flight)
|
||||||
|
{
|
||||||
|
CommandQueue = nullptr;
|
||||||
|
CommandList = nullptr;
|
||||||
|
RtvDescHeap = nullptr;
|
||||||
|
SwapChain = nullptr;
|
||||||
|
Fence = nullptr;
|
||||||
|
FenceSignaledValue = 0;
|
||||||
|
FenceEvent = nullptr;
|
||||||
|
NumFramesInFlight = num_frames_in_flight;
|
||||||
|
FrameCtx = new ImGui_ImplDX12_FrameContext[NumFramesInFlight];
|
||||||
|
FrameIndex = UINT_MAX;
|
||||||
|
FrameRenderBuffers = new ImGui_ImplDX12_RenderBuffers[NumFramesInFlight];
|
||||||
|
|
||||||
|
for (UINT i = 0; i < NumFramesInFlight; ++i)
|
||||||
|
{
|
||||||
|
FrameCtx[i].CommandAllocator = nullptr;
|
||||||
|
FrameCtx[i].RenderTarget = nullptr;
|
||||||
|
|
||||||
|
// Create buffers with a default size (they will later be grown as needed)
|
||||||
|
FrameRenderBuffers[i].IndexBuffer = nullptr;
|
||||||
|
FrameRenderBuffers[i].VertexBuffer = nullptr;
|
||||||
|
FrameRenderBuffers[i].VertexBufferSize = 5000;
|
||||||
|
FrameRenderBuffers[i].IndexBufferSize = 10000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
~ImGui_ImplDX12_ViewportData()
|
||||||
|
{
|
||||||
|
IM_ASSERT(CommandQueue == nullptr && CommandList == nullptr);
|
||||||
|
IM_ASSERT(RtvDescHeap == nullptr);
|
||||||
|
IM_ASSERT(SwapChain == nullptr);
|
||||||
|
IM_ASSERT(Fence == nullptr);
|
||||||
|
IM_ASSERT(FenceEvent == nullptr);
|
||||||
|
|
||||||
|
for (UINT i = 0; i < NumFramesInFlight; ++i)
|
||||||
|
{
|
||||||
|
IM_ASSERT(FrameCtx[i].CommandAllocator == nullptr && FrameCtx[i].RenderTarget == nullptr);
|
||||||
|
IM_ASSERT(FrameRenderBuffers[i].IndexBuffer == nullptr && FrameRenderBuffers[i].VertexBuffer == nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] FrameCtx; FrameCtx = nullptr;
|
||||||
|
delete[] FrameRenderBuffers; FrameRenderBuffers = nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct VERTEX_CONSTANT_BUFFER_DX12
|
struct VERTEX_CONSTANT_BUFFER_DX12
|
||||||
{
|
{
|
||||||
float mvp[4][4];
|
float mvp[4][4];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplDX12_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplDX12_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx, ImGui_ImplDX12_RenderBuffers* fr)
|
static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx, ImGui_ImplDX12_RenderBuffers* fr)
|
||||||
{
|
{
|
||||||
@@ -163,11 +243,10 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
|
|||||||
if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
|
if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// FIXME: I'm assuming that this only gets called once per frame!
|
|
||||||
// If not, we can't just re-allocate the IB or VB, we'll have to do a proper allocator.
|
|
||||||
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
bd->frameIndex = bd->frameIndex + 1;
|
ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)draw_data->OwnerViewport->RendererUserData;
|
||||||
ImGui_ImplDX12_RenderBuffers* fr = &bd->pFrameResources[bd->frameIndex % bd->numFramesInFlight];
|
vd->FrameIndex++;
|
||||||
|
ImGui_ImplDX12_RenderBuffers* fr = &vd->FrameRenderBuffers[vd->FrameIndex % bd->numFramesInFlight];
|
||||||
|
|
||||||
// Create and grow vertex/index buffers if needed
|
// Create and grow vertex/index buffers if needed
|
||||||
if (fr->VertexBuffer == nullptr || fr->VertexBufferSize < draw_data->TotalVtxCount)
|
if (fr->VertexBuffer == nullptr || fr->VertexBufferSize < draw_data->TotalVtxCount)
|
||||||
@@ -588,9 +667,9 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
|
|||||||
// Create the input layout
|
// Create the input layout
|
||||||
static D3D12_INPUT_ELEMENT_DESC local_layout[] =
|
static D3D12_INPUT_ELEMENT_DESC local_layout[] =
|
||||||
{
|
{
|
||||||
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, pos), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)offsetof(ImDrawVert, pos), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
||||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)offsetof(ImDrawVert, uv), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
||||||
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)offsetof(ImDrawVert, col), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
|
||||||
};
|
};
|
||||||
psoDesc.InputLayout = { local_layout, 3 };
|
psoDesc.InputLayout = { local_layout, 3 };
|
||||||
}
|
}
|
||||||
@@ -674,6 +753,13 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX12_DestroyRenderBuffers(ImGui_ImplDX12_RenderBuffers* render_buffers)
|
||||||
|
{
|
||||||
|
SafeRelease(render_buffers->IndexBuffer);
|
||||||
|
SafeRelease(render_buffers->VertexBuffer);
|
||||||
|
render_buffers->IndexBufferSize = render_buffers->VertexBufferSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplDX12_InvalidateDeviceObjects()
|
void ImGui_ImplDX12_InvalidateDeviceObjects()
|
||||||
{
|
{
|
||||||
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
@@ -685,13 +771,6 @@ void ImGui_ImplDX12_InvalidateDeviceObjects()
|
|||||||
SafeRelease(bd->pPipelineState);
|
SafeRelease(bd->pPipelineState);
|
||||||
SafeRelease(bd->pFontTextureResource);
|
SafeRelease(bd->pFontTextureResource);
|
||||||
io.Fonts->SetTexID(0); // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
io.Fonts->SetTexID(0); // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
||||||
|
|
||||||
for (UINT i = 0; i < bd->numFramesInFlight; i++)
|
|
||||||
{
|
|
||||||
ImGui_ImplDX12_RenderBuffers* fr = &bd->pFrameResources[i];
|
|
||||||
SafeRelease(fr->IndexBuffer);
|
|
||||||
SafeRelease(fr->VertexBuffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap,
|
bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap,
|
||||||
@@ -705,25 +784,21 @@ bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FO
|
|||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_dx12";
|
io.BackendRendererName = "imgui_impl_dx12";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplDX12_InitPlatformInterface();
|
||||||
|
|
||||||
bd->pd3dDevice = device;
|
bd->pd3dDevice = device;
|
||||||
bd->RTVFormat = rtv_format;
|
bd->RTVFormat = rtv_format;
|
||||||
bd->hFontSrvCpuDescHandle = font_srv_cpu_desc_handle;
|
bd->hFontSrvCpuDescHandle = font_srv_cpu_desc_handle;
|
||||||
bd->hFontSrvGpuDescHandle = font_srv_gpu_desc_handle;
|
bd->hFontSrvGpuDescHandle = font_srv_gpu_desc_handle;
|
||||||
bd->pFrameResources = new ImGui_ImplDX12_RenderBuffers[num_frames_in_flight];
|
|
||||||
bd->numFramesInFlight = num_frames_in_flight;
|
bd->numFramesInFlight = num_frames_in_flight;
|
||||||
bd->pd3dSrvDescHeap = cbv_srv_heap;
|
bd->pd3dSrvDescHeap = cbv_srv_heap;
|
||||||
bd->frameIndex = UINT_MAX;
|
|
||||||
|
|
||||||
// Create buffers with a default size (they will later be grown as needed)
|
// Create a dummy ImGui_ImplDX12_ViewportData holder for the main viewport,
|
||||||
for (int i = 0; i < num_frames_in_flight; i++)
|
// Since this is created and managed by the application, we will only use the ->Resources[] fields.
|
||||||
{
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
ImGui_ImplDX12_RenderBuffers* fr = &bd->pFrameResources[i];
|
main_viewport->RendererUserData = IM_NEW(ImGui_ImplDX12_ViewportData)(bd->numFramesInFlight);
|
||||||
fr->IndexBuffer = nullptr;
|
|
||||||
fr->VertexBuffer = nullptr;
|
|
||||||
fr->IndexBufferSize = 10000;
|
|
||||||
fr->VertexBufferSize = 5000;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -734,11 +809,24 @@ void ImGui_ImplDX12_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
// Manually delete main viewport render resources in-case we haven't initialized for viewports
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
if (ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)main_viewport->RendererUserData)
|
||||||
|
{
|
||||||
|
// We could just call ImGui_ImplDX12_DestroyWindow(main_viewport) as a convenience but that would be misleading since we only use data->Resources[]
|
||||||
|
for (UINT i = 0; i < bd->numFramesInFlight; i++)
|
||||||
|
ImGui_ImplDX12_DestroyRenderBuffers(&vd->FrameRenderBuffers[i]);
|
||||||
|
IM_DELETE(vd);
|
||||||
|
main_viewport->RendererUserData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// Clean up windows and device objects
|
// Clean up windows and device objects
|
||||||
|
ImGui_ImplDX12_ShutdownPlatformInterface();
|
||||||
ImGui_ImplDX12_InvalidateDeviceObjects();
|
ImGui_ImplDX12_InvalidateDeviceObjects();
|
||||||
delete[] bd->pFrameResources;
|
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -750,3 +838,247 @@ void ImGui_ImplDX12_NewFrame()
|
|||||||
if (!bd->pPipelineState)
|
if (!bd->pPipelineState)
|
||||||
ImGui_ImplDX12_CreateDeviceObjects();
|
ImGui_ImplDX12_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void ImGui_ImplDX12_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
|
ImGui_ImplDX12_ViewportData* vd = IM_NEW(ImGui_ImplDX12_ViewportData)(bd->numFramesInFlight);
|
||||||
|
viewport->RendererUserData = vd;
|
||||||
|
|
||||||
|
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
|
||||||
|
// Some backends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the HWND.
|
||||||
|
HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle;
|
||||||
|
IM_ASSERT(hwnd != 0);
|
||||||
|
|
||||||
|
vd->FrameIndex = UINT_MAX;
|
||||||
|
|
||||||
|
// Create command queue.
|
||||||
|
D3D12_COMMAND_QUEUE_DESC queue_desc = {};
|
||||||
|
queue_desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
|
||||||
|
queue_desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||||
|
|
||||||
|
HRESULT res = S_OK;
|
||||||
|
res = bd->pd3dDevice->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&vd->CommandQueue));
|
||||||
|
IM_ASSERT(res == S_OK);
|
||||||
|
|
||||||
|
// Create command allocator.
|
||||||
|
for (UINT i = 0; i < bd->numFramesInFlight; ++i)
|
||||||
|
{
|
||||||
|
res = bd->pd3dDevice->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&vd->FrameCtx[i].CommandAllocator));
|
||||||
|
IM_ASSERT(res == S_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create command list.
|
||||||
|
res = bd->pd3dDevice->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, vd->FrameCtx[0].CommandAllocator, nullptr, IID_PPV_ARGS(&vd->CommandList));
|
||||||
|
IM_ASSERT(res == S_OK);
|
||||||
|
vd->CommandList->Close();
|
||||||
|
|
||||||
|
// Create fence.
|
||||||
|
res = bd->pd3dDevice->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&vd->Fence));
|
||||||
|
IM_ASSERT(res == S_OK);
|
||||||
|
|
||||||
|
vd->FenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
||||||
|
IM_ASSERT(vd->FenceEvent != nullptr);
|
||||||
|
|
||||||
|
// Create swap chain
|
||||||
|
// FIXME-VIEWPORT: May want to copy/inherit swap chain settings from the user/application.
|
||||||
|
DXGI_SWAP_CHAIN_DESC1 sd1;
|
||||||
|
ZeroMemory(&sd1, sizeof(sd1));
|
||||||
|
sd1.BufferCount = bd->numFramesInFlight;
|
||||||
|
sd1.Width = (UINT)viewport->Size.x;
|
||||||
|
sd1.Height = (UINT)viewport->Size.y;
|
||||||
|
sd1.Format = bd->RTVFormat;
|
||||||
|
sd1.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||||
|
sd1.SampleDesc.Count = 1;
|
||||||
|
sd1.SampleDesc.Quality = 0;
|
||||||
|
sd1.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
||||||
|
sd1.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
|
||||||
|
sd1.Scaling = DXGI_SCALING_NONE;
|
||||||
|
sd1.Stereo = FALSE;
|
||||||
|
|
||||||
|
IDXGIFactory4* dxgi_factory = nullptr;
|
||||||
|
res = ::CreateDXGIFactory1(IID_PPV_ARGS(&dxgi_factory));
|
||||||
|
IM_ASSERT(res == S_OK);
|
||||||
|
|
||||||
|
IDXGISwapChain1* swap_chain = nullptr;
|
||||||
|
res = dxgi_factory->CreateSwapChainForHwnd(vd->CommandQueue, hwnd, &sd1, nullptr, nullptr, &swap_chain);
|
||||||
|
IM_ASSERT(res == S_OK);
|
||||||
|
|
||||||
|
dxgi_factory->Release();
|
||||||
|
|
||||||
|
// Or swapChain.As(&mSwapChain)
|
||||||
|
IM_ASSERT(vd->SwapChain == nullptr);
|
||||||
|
swap_chain->QueryInterface(IID_PPV_ARGS(&vd->SwapChain));
|
||||||
|
swap_chain->Release();
|
||||||
|
|
||||||
|
// Create the render targets
|
||||||
|
if (vd->SwapChain)
|
||||||
|
{
|
||||||
|
D3D12_DESCRIPTOR_HEAP_DESC desc = {};
|
||||||
|
desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
|
||||||
|
desc.NumDescriptors = bd->numFramesInFlight;
|
||||||
|
desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
|
||||||
|
desc.NodeMask = 1;
|
||||||
|
|
||||||
|
HRESULT hr = bd->pd3dDevice->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&vd->RtvDescHeap));
|
||||||
|
IM_ASSERT(hr == S_OK);
|
||||||
|
|
||||||
|
SIZE_T rtv_descriptor_size = bd->pd3dDevice->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
|
||||||
|
D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle = vd->RtvDescHeap->GetCPUDescriptorHandleForHeapStart();
|
||||||
|
for (UINT i = 0; i < bd->numFramesInFlight; i++)
|
||||||
|
{
|
||||||
|
vd->FrameCtx[i].RenderTargetCpuDescriptors = rtv_handle;
|
||||||
|
rtv_handle.ptr += rtv_descriptor_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
ID3D12Resource* back_buffer;
|
||||||
|
for (UINT i = 0; i < bd->numFramesInFlight; i++)
|
||||||
|
{
|
||||||
|
IM_ASSERT(vd->FrameCtx[i].RenderTarget == nullptr);
|
||||||
|
vd->SwapChain->GetBuffer(i, IID_PPV_ARGS(&back_buffer));
|
||||||
|
bd->pd3dDevice->CreateRenderTargetView(back_buffer, nullptr, vd->FrameCtx[i].RenderTargetCpuDescriptors);
|
||||||
|
vd->FrameCtx[i].RenderTarget = back_buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (UINT i = 0; i < bd->numFramesInFlight; i++)
|
||||||
|
ImGui_ImplDX12_DestroyRenderBuffers(&vd->FrameRenderBuffers[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_WaitForPendingOperations(ImGui_ImplDX12_ViewportData* vd)
|
||||||
|
{
|
||||||
|
HRESULT hr = S_FALSE;
|
||||||
|
if (vd && vd->CommandQueue && vd->Fence && vd->FenceEvent)
|
||||||
|
{
|
||||||
|
hr = vd->CommandQueue->Signal(vd->Fence, ++vd->FenceSignaledValue);
|
||||||
|
IM_ASSERT(hr == S_OK);
|
||||||
|
::WaitForSingleObject(vd->FenceEvent, 0); // Reset any forgotten waits
|
||||||
|
hr = vd->Fence->SetEventOnCompletion(vd->FenceSignaledValue, vd->FenceEvent);
|
||||||
|
IM_ASSERT(hr == S_OK);
|
||||||
|
::WaitForSingleObject(vd->FenceEvent, INFINITE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX12_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
// The main viewport (owned by the application) will always have RendererUserData == 0 since we didn't create the data for it.
|
||||||
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
|
if (ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)viewport->RendererUserData)
|
||||||
|
{
|
||||||
|
ImGui_WaitForPendingOperations(vd);
|
||||||
|
|
||||||
|
SafeRelease(vd->CommandQueue);
|
||||||
|
SafeRelease(vd->CommandList);
|
||||||
|
SafeRelease(vd->SwapChain);
|
||||||
|
SafeRelease(vd->RtvDescHeap);
|
||||||
|
SafeRelease(vd->Fence);
|
||||||
|
::CloseHandle(vd->FenceEvent);
|
||||||
|
vd->FenceEvent = nullptr;
|
||||||
|
|
||||||
|
for (UINT i = 0; i < bd->numFramesInFlight; i++)
|
||||||
|
{
|
||||||
|
SafeRelease(vd->FrameCtx[i].RenderTarget);
|
||||||
|
SafeRelease(vd->FrameCtx[i].CommandAllocator);
|
||||||
|
ImGui_ImplDX12_DestroyRenderBuffers(&vd->FrameRenderBuffers[i]);
|
||||||
|
}
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->RendererUserData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX12_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
|
ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)viewport->RendererUserData;
|
||||||
|
|
||||||
|
ImGui_WaitForPendingOperations(vd);
|
||||||
|
|
||||||
|
for (UINT i = 0; i < bd->numFramesInFlight; i++)
|
||||||
|
SafeRelease(vd->FrameCtx[i].RenderTarget);
|
||||||
|
|
||||||
|
if (vd->SwapChain)
|
||||||
|
{
|
||||||
|
ID3D12Resource* back_buffer = nullptr;
|
||||||
|
vd->SwapChain->ResizeBuffers(0, (UINT)size.x, (UINT)size.y, DXGI_FORMAT_UNKNOWN, 0);
|
||||||
|
for (UINT i = 0; i < bd->numFramesInFlight; i++)
|
||||||
|
{
|
||||||
|
vd->SwapChain->GetBuffer(i, IID_PPV_ARGS(&back_buffer));
|
||||||
|
bd->pd3dDevice->CreateRenderTargetView(back_buffer, nullptr, vd->FrameCtx[i].RenderTargetCpuDescriptors);
|
||||||
|
vd->FrameCtx[i].RenderTarget = back_buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX12_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
|
ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)viewport->RendererUserData;
|
||||||
|
|
||||||
|
ImGui_ImplDX12_FrameContext* frame_context = &vd->FrameCtx[vd->FrameIndex % bd->numFramesInFlight];
|
||||||
|
UINT back_buffer_idx = vd->SwapChain->GetCurrentBackBufferIndex();
|
||||||
|
|
||||||
|
const ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
D3D12_RESOURCE_BARRIER barrier = {};
|
||||||
|
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
|
||||||
|
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
|
||||||
|
barrier.Transition.pResource = vd->FrameCtx[back_buffer_idx].RenderTarget;
|
||||||
|
barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
|
||||||
|
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
|
||||||
|
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
ID3D12GraphicsCommandList* cmd_list = vd->CommandList;
|
||||||
|
|
||||||
|
frame_context->CommandAllocator->Reset();
|
||||||
|
cmd_list->Reset(frame_context->CommandAllocator, nullptr);
|
||||||
|
cmd_list->ResourceBarrier(1, &barrier);
|
||||||
|
cmd_list->OMSetRenderTargets(1, &vd->FrameCtx[back_buffer_idx].RenderTargetCpuDescriptors, FALSE, nullptr);
|
||||||
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
|
cmd_list->ClearRenderTargetView(vd->FrameCtx[back_buffer_idx].RenderTargetCpuDescriptors, (float*)&clear_color, 0, nullptr);
|
||||||
|
cmd_list->SetDescriptorHeaps(1, &bd->pd3dSrvDescHeap);
|
||||||
|
|
||||||
|
ImGui_ImplDX12_RenderDrawData(viewport->DrawData, cmd_list);
|
||||||
|
|
||||||
|
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
|
||||||
|
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT;
|
||||||
|
cmd_list->ResourceBarrier(1, &barrier);
|
||||||
|
cmd_list->Close();
|
||||||
|
|
||||||
|
vd->CommandQueue->Wait(vd->Fence, vd->FenceSignaledValue);
|
||||||
|
vd->CommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&cmd_list);
|
||||||
|
vd->CommandQueue->Signal(vd->Fence, ++vd->FenceSignaledValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX12_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)viewport->RendererUserData;
|
||||||
|
|
||||||
|
vd->SwapChain->Present(0, 0);
|
||||||
|
while (vd->Fence->GetCompletedValue() < vd->FenceSignaledValue)
|
||||||
|
::SwitchToThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplDX12_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_CreateWindow = ImGui_ImplDX12_CreateWindow;
|
||||||
|
platform_io.Renderer_DestroyWindow = ImGui_ImplDX12_DestroyWindow;
|
||||||
|
platform_io.Renderer_SetWindowSize = ImGui_ImplDX12_SetWindowSize;
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplDX12_RenderWindow;
|
||||||
|
platform_io.Renderer_SwapBuffers = ImGui_ImplDX12_SwapBuffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplDX12_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -4,17 +4,22 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
|
// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
|
||||||
// See imgui_impl_dx12.cpp file for details.
|
// See imgui_impl_dx12.cpp file for details.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include <dxgiformat.h> // DXGI_FORMAT
|
#include <dxgiformat.h> // DXGI_FORMAT
|
||||||
|
|
||||||
struct ID3D12Device;
|
struct ID3D12Device;
|
||||||
@@ -36,3 +41,5 @@ IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3
|
|||||||
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
||||||
IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -4,14 +4,20 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2024-02-12: DirectX9: Using RGBA format when supported by the driver to avoid CPU side conversion. (#6575)
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2021-06-25: DirectX9: Explicitly disable texture state stages after >= 1.
|
// 2021-06-25: DirectX9: Explicitly disable texture state stages after >= 1.
|
||||||
@@ -32,6 +38,7 @@
|
|||||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_dx9.h"
|
#include "imgui_impl_dx9.h"
|
||||||
|
|
||||||
// DirectX
|
// DirectX
|
||||||
@@ -71,6 +78,12 @@ static ImGui_ImplDX9_Data* ImGui_ImplDX9_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplDX9_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplDX9_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplDX9_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplDX9_ShutdownPlatformInterface();
|
||||||
|
static void ImGui_ImplDX9_CreateDeviceObjectsForPlatformWindows();
|
||||||
|
static void ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data)
|
static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
@@ -267,6 +280,11 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
global_vtx_offset += cmd_list->VtxBuffer.Size;
|
global_vtx_offset += cmd_list->VtxBuffer.Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When using multi-viewports, it appears that there's an odd logic in DirectX9 which prevent subsequent windows
|
||||||
|
// from rendering until the first window submits at least one draw call, even once. That's our workaround. (see #2560)
|
||||||
|
if (global_vtx_offset == 0)
|
||||||
|
bd->pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
// Restore the DX9 transform
|
// Restore the DX9 transform
|
||||||
bd->pd3dDevice->SetTransform(D3DTS_WORLD, &last_world);
|
bd->pd3dDevice->SetTransform(D3DTS_WORLD, &last_world);
|
||||||
bd->pd3dDevice->SetTransform(D3DTS_VIEW, &last_view);
|
bd->pd3dDevice->SetTransform(D3DTS_VIEW, &last_view);
|
||||||
@@ -287,10 +305,14 @@ bool ImGui_ImplDX9_Init(IDirect3DDevice9* device)
|
|||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_dx9";
|
io.BackendRendererName = "imgui_impl_dx9";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||||
|
|
||||||
bd->pd3dDevice = device;
|
bd->pd3dDevice = device;
|
||||||
bd->pd3dDevice->AddRef();
|
bd->pd3dDevice->AddRef();
|
||||||
|
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplDX9_InitPlatformInterface();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,13 +322,33 @@ void ImGui_ImplDX9_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplDX9_ShutdownPlatformInterface();
|
||||||
ImGui_ImplDX9_InvalidateDeviceObjects();
|
ImGui_ImplDX9_InvalidateDeviceObjects();
|
||||||
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplDX9_CheckFormatSupport(IDirect3DDevice9* pDevice, D3DFORMAT format)
|
||||||
|
{
|
||||||
|
IDirect3D9* pd3d = nullptr;
|
||||||
|
if (pDevice->GetDirect3D(&pd3d) != D3D_OK)
|
||||||
|
return false;
|
||||||
|
D3DDEVICE_CREATION_PARAMETERS param = {};
|
||||||
|
D3DDISPLAYMODE mode = {};
|
||||||
|
if (pDevice->GetCreationParameters(¶m) != D3D_OK || pDevice->GetDisplayMode(0, &mode) != D3D_OK)
|
||||||
|
{
|
||||||
|
pd3d->Release();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Font texture should support linear filter, color blend and write to render-target
|
||||||
|
bool support = (pd3d->CheckDeviceFormat(param.AdapterOrdinal, param.DeviceType, mode.Format, D3DUSAGE_DYNAMIC | D3DUSAGE_QUERY_FILTER | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, format)) == D3D_OK;
|
||||||
|
pd3d->Release();
|
||||||
|
return support;
|
||||||
|
}
|
||||||
|
|
||||||
static bool ImGui_ImplDX9_CreateFontsTexture()
|
static bool ImGui_ImplDX9_CreateFontsTexture()
|
||||||
{
|
{
|
||||||
// Build texture atlas
|
// Build texture atlas
|
||||||
@@ -318,18 +360,21 @@ static bool ImGui_ImplDX9_CreateFontsTexture()
|
|||||||
|
|
||||||
// Convert RGBA32 to BGRA32 (because RGBA32 is not well supported by DX9 devices)
|
// Convert RGBA32 to BGRA32 (because RGBA32 is not well supported by DX9 devices)
|
||||||
#ifndef IMGUI_USE_BGRA_PACKED_COLOR
|
#ifndef IMGUI_USE_BGRA_PACKED_COLOR
|
||||||
if (io.Fonts->TexPixelsUseColors)
|
const bool rgba_support = ImGui_ImplDX9_CheckFormatSupport(bd->pd3dDevice, D3DFMT_A8B8G8R8);
|
||||||
|
if (!rgba_support && io.Fonts->TexPixelsUseColors)
|
||||||
{
|
{
|
||||||
ImU32* dst_start = (ImU32*)ImGui::MemAlloc((size_t)width * height * bytes_per_pixel);
|
ImU32* dst_start = (ImU32*)ImGui::MemAlloc((size_t)width * height * bytes_per_pixel);
|
||||||
for (ImU32* src = (ImU32*)pixels, *dst = dst_start, *dst_end = dst_start + (size_t)width * height; dst < dst_end; src++, dst++)
|
for (ImU32* src = (ImU32*)pixels, *dst = dst_start, *dst_end = dst_start + (size_t)width * height; dst < dst_end; src++, dst++)
|
||||||
*dst = IMGUI_COL_TO_DX9_ARGB(*src);
|
*dst = IMGUI_COL_TO_DX9_ARGB(*src);
|
||||||
pixels = (unsigned char*)dst_start;
|
pixels = (unsigned char*)dst_start;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
const bool rgba_support = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Upload texture to graphics system
|
// Upload texture to graphics system
|
||||||
bd->FontTexture = nullptr;
|
bd->FontTexture = nullptr;
|
||||||
if (bd->pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bd->FontTexture, nullptr) < 0)
|
if (bd->pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, rgba_support ? D3DFMT_A8B8G8R8 : D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bd->FontTexture, nullptr) < 0)
|
||||||
return false;
|
return false;
|
||||||
D3DLOCKED_RECT tex_locked_rect;
|
D3DLOCKED_RECT tex_locked_rect;
|
||||||
if (bd->FontTexture->LockRect(0, &tex_locked_rect, nullptr, 0) != D3D_OK)
|
if (bd->FontTexture->LockRect(0, &tex_locked_rect, nullptr, 0) != D3D_OK)
|
||||||
@@ -342,7 +387,7 @@ static bool ImGui_ImplDX9_CreateFontsTexture()
|
|||||||
io.Fonts->SetTexID((ImTextureID)bd->FontTexture);
|
io.Fonts->SetTexID((ImTextureID)bd->FontTexture);
|
||||||
|
|
||||||
#ifndef IMGUI_USE_BGRA_PACKED_COLOR
|
#ifndef IMGUI_USE_BGRA_PACKED_COLOR
|
||||||
if (io.Fonts->TexPixelsUseColors)
|
if (!rgba_support && io.Fonts->TexPixelsUseColors)
|
||||||
ImGui::MemFree(pixels);
|
ImGui::MemFree(pixels);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -356,6 +401,7 @@ bool ImGui_ImplDX9_CreateDeviceObjects()
|
|||||||
return false;
|
return false;
|
||||||
if (!ImGui_ImplDX9_CreateFontsTexture())
|
if (!ImGui_ImplDX9_CreateFontsTexture())
|
||||||
return false;
|
return false;
|
||||||
|
ImGui_ImplDX9_CreateDeviceObjectsForPlatformWindows();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,6 +413,7 @@ void ImGui_ImplDX9_InvalidateDeviceObjects()
|
|||||||
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
||||||
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
||||||
if (bd->FontTexture) { bd->FontTexture->Release(); bd->FontTexture = nullptr; ImGui::GetIO().Fonts->SetTexID(0); } // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
if (bd->FontTexture) { bd->FontTexture->Release(); bd->FontTexture = nullptr; ImGui::GetIO().Fonts->SetTexID(0); } // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
||||||
|
ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplDX9_NewFrame()
|
void ImGui_ImplDX9_NewFrame()
|
||||||
@@ -377,3 +424,149 @@ void ImGui_ImplDX9_NewFrame()
|
|||||||
if (!bd->FontTexture)
|
if (!bd->FontTexture)
|
||||||
ImGui_ImplDX9_CreateDeviceObjects();
|
ImGui_ImplDX9_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplDX9_ViewportData
|
||||||
|
{
|
||||||
|
IDirect3DSwapChain9* SwapChain;
|
||||||
|
D3DPRESENT_PARAMETERS d3dpp;
|
||||||
|
|
||||||
|
ImGui_ImplDX9_ViewportData() { SwapChain = nullptr; ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS)); }
|
||||||
|
~ImGui_ImplDX9_ViewportData() { IM_ASSERT(SwapChain == nullptr); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||||
|
ImGui_ImplDX9_ViewportData* vd = IM_NEW(ImGui_ImplDX9_ViewportData)();
|
||||||
|
viewport->RendererUserData = vd;
|
||||||
|
|
||||||
|
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
|
||||||
|
// Some backends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the HWND.
|
||||||
|
HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle;
|
||||||
|
IM_ASSERT(hwnd != 0);
|
||||||
|
|
||||||
|
ZeroMemory(&vd->d3dpp, sizeof(D3DPRESENT_PARAMETERS));
|
||||||
|
vd->d3dpp.Windowed = TRUE;
|
||||||
|
vd->d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||||
|
vd->d3dpp.BackBufferWidth = (UINT)viewport->Size.x;
|
||||||
|
vd->d3dpp.BackBufferHeight = (UINT)viewport->Size.y;
|
||||||
|
vd->d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
|
||||||
|
vd->d3dpp.hDeviceWindow = hwnd;
|
||||||
|
vd->d3dpp.EnableAutoDepthStencil = FALSE;
|
||||||
|
vd->d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
|
||||||
|
vd->d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // Present without vsync
|
||||||
|
|
||||||
|
HRESULT hr = bd->pd3dDevice->CreateAdditionalSwapChain(&vd->d3dpp, &vd->SwapChain); IM_UNUSED(hr);
|
||||||
|
IM_ASSERT(hr == D3D_OK);
|
||||||
|
IM_ASSERT(vd->SwapChain != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
// The main viewport (owned by the application) will always have RendererUserData == 0 since we didn't create the data for it.
|
||||||
|
if (ImGui_ImplDX9_ViewportData* vd = (ImGui_ImplDX9_ViewportData*)viewport->RendererUserData)
|
||||||
|
{
|
||||||
|
if (vd->SwapChain)
|
||||||
|
vd->SwapChain->Release();
|
||||||
|
vd->SwapChain = nullptr;
|
||||||
|
ZeroMemory(&vd->d3dpp, sizeof(D3DPRESENT_PARAMETERS));
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->RendererUserData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||||
|
ImGui_ImplDX9_ViewportData* vd = (ImGui_ImplDX9_ViewportData*)viewport->RendererUserData;
|
||||||
|
if (vd->SwapChain)
|
||||||
|
{
|
||||||
|
vd->SwapChain->Release();
|
||||||
|
vd->SwapChain = nullptr;
|
||||||
|
vd->d3dpp.BackBufferWidth = (UINT)size.x;
|
||||||
|
vd->d3dpp.BackBufferHeight = (UINT)size.y;
|
||||||
|
HRESULT hr = bd->pd3dDevice->CreateAdditionalSwapChain(&vd->d3dpp, &vd->SwapChain); IM_UNUSED(hr);
|
||||||
|
IM_ASSERT(hr == D3D_OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||||
|
ImGui_ImplDX9_ViewportData* vd = (ImGui_ImplDX9_ViewportData*)viewport->RendererUserData;
|
||||||
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
LPDIRECT3DSURFACE9 render_target = nullptr;
|
||||||
|
LPDIRECT3DSURFACE9 last_render_target = nullptr;
|
||||||
|
LPDIRECT3DSURFACE9 last_depth_stencil = nullptr;
|
||||||
|
vd->SwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &render_target);
|
||||||
|
bd->pd3dDevice->GetRenderTarget(0, &last_render_target);
|
||||||
|
bd->pd3dDevice->GetDepthStencilSurface(&last_depth_stencil);
|
||||||
|
bd->pd3dDevice->SetRenderTarget(0, render_target);
|
||||||
|
bd->pd3dDevice->SetDepthStencilSurface(nullptr);
|
||||||
|
|
||||||
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
|
{
|
||||||
|
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));
|
||||||
|
bd->pd3dDevice->Clear(0, nullptr, D3DCLEAR_TARGET, clear_col_dx, 1.0f, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui_ImplDX9_RenderDrawData(viewport->DrawData);
|
||||||
|
|
||||||
|
// Restore render target
|
||||||
|
bd->pd3dDevice->SetRenderTarget(0, last_render_target);
|
||||||
|
bd->pd3dDevice->SetDepthStencilSurface(last_depth_stencil);
|
||||||
|
render_target->Release();
|
||||||
|
last_render_target->Release();
|
||||||
|
if (last_depth_stencil) last_depth_stencil->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX9_ViewportData* vd = (ImGui_ImplDX9_ViewportData*)viewport->RendererUserData;
|
||||||
|
HRESULT hr = vd->SwapChain->Present(nullptr, nullptr, vd->d3dpp.hDeviceWindow, nullptr, 0);
|
||||||
|
// Let main application handle D3DERR_DEVICELOST by resetting the device.
|
||||||
|
IM_ASSERT(SUCCEEDED(hr) || hr == D3DERR_DEVICELOST);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_CreateWindow = ImGui_ImplDX9_CreateWindow;
|
||||||
|
platform_io.Renderer_DestroyWindow = ImGui_ImplDX9_DestroyWindow;
|
||||||
|
platform_io.Renderer_SetWindowSize = ImGui_ImplDX9_SetWindowSize;
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplDX9_RenderWindow;
|
||||||
|
platform_io.Renderer_SwapBuffers = ImGui_ImplDX9_SwapBuffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_CreateDeviceObjectsForPlatformWindows()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
for (int i = 1; i < platform_io.Viewports.Size; i++)
|
||||||
|
if (!platform_io.Viewports[i]->RendererUserData)
|
||||||
|
ImGui_ImplDX9_CreateWindow(platform_io.Viewports[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
for (int i = 1; i < platform_io.Viewports.Size; i++)
|
||||||
|
if (platform_io.Viewports[i]->RendererUserData)
|
||||||
|
ImGui_ImplDX9_DestroyWindow(platform_io.Viewports[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -4,14 +4,19 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct IDirect3DDevice9;
|
struct IDirect3DDevice9;
|
||||||
|
|
||||||
@@ -23,3 +28,5 @@ IMGUI_IMPL_API void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data);
|
|||||||
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
||||||
IMGUI_IMPL_API bool ImGui_ImplDX9_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplDX9_CreateDeviceObjects();
|
||||||
IMGUI_IMPL_API void ImGui_ImplDX9_InvalidateDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplDX9_InvalidateDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -9,24 +9,37 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
|
||||||
|
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
|
// Issues:
|
||||||
|
// [ ] Platform: Multi-viewport support: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2023-12-19: Emscripten: Added ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback() to register canvas selector and auto-resize GLFW window.
|
||||||
|
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys.
|
||||||
|
// 2023-07-18: Inputs: Revert ignoring mouse data on GLFW_CURSOR_DISABLED as it can be used differently. User may set ImGuiConfigFLags_NoMouse if desired. (#5625, #6609)
|
||||||
|
// 2023-06-12: Accept glfwGetTime() not returning a monotonically increasing value. This seems to happens on some Windows setup when peripherals disconnect, and is likely to also happen on browser + Emscripten. (#6491)
|
||||||
// 2023-04-04: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_TouchScreen/ImGuiMouseSource_Pen on Windows ONLY, using a custom WndProc hook. (#2702)
|
// 2023-04-04: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_TouchScreen/ImGuiMouseSource_Pen on Windows ONLY, using a custom WndProc hook. (#2702)
|
||||||
// 2023-03-16: Inputs: Fixed key modifiers handling on secondary viewports (docking branch). Broken on 2023/01/04. (#6248, #6034)
|
// 2023-03-16: Inputs: Fixed key modifiers handling on secondary viewports (docking branch). Broken on 2023/01/04. (#6248, #6034)
|
||||||
// 2023-03-14: Emscripten: Avoid using glfwGetError() and glfwGetGamepadState() which are not correctly implemented in Emscripten emulation. (#6240)
|
// 2023-03-14: Emscripten: Avoid using glfwGetError() and glfwGetGamepadState() which are not correctly implemented in Emscripten emulation. (#6240)
|
||||||
// 2023-02-03: Emscripten: Registering custom low-level mouse wheel handler to get more accurate scrolling impulses on Emscripten. (#4019, #6096)
|
// 2023-02-03: Emscripten: Registering custom low-level mouse wheel handler to get more accurate scrolling impulses on Emscripten. (#4019, #6096)
|
||||||
|
// 2023-01-18: Handle unsupported glfwGetVideoMode() call on e.g. Emscripten.
|
||||||
// 2023-01-04: Inputs: Fixed mods state on Linux when using Alt-GR text input (e.g. German keyboard layout), could lead to broken text input. Revert a 2022/01/17 change were we resumed using mods provided by GLFW, turns out they were faulty.
|
// 2023-01-04: Inputs: Fixed mods state on Linux when using Alt-GR text input (e.g. German keyboard layout), could lead to broken text input. Revert a 2022/01/17 change were we resumed using mods provided by GLFW, turns out they were faulty.
|
||||||
// 2022-11-22: Perform a dummy glfwGetError() read to cancel missing names with glfwGetKeyName(). (#5908)
|
// 2022-11-22: Perform a dummy glfwGetError() read to cancel missing names with glfwGetKeyName(). (#5908)
|
||||||
// 2022-10-18: Perform a dummy glfwGetError() read to cancel missing mouse cursors errors. Using GLFW_VERSION_COMBINED directly. (#5785)
|
// 2022-10-18: Perform a dummy glfwGetError() read to cancel missing mouse cursors errors. Using GLFW_VERSION_COMBINED directly. (#5785)
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2022-09-26: Inputs: Renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported).
|
// 2022-09-26: Inputs: Renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported).
|
||||||
// 2022-09-01: Inputs: Honor GLFW_CURSOR_DISABLED by not setting mouse position.
|
// 2022-09-01: Inputs: Honor GLFW_CURSOR_DISABLED by not setting mouse position *EDIT* Reverted 2023-07-18.
|
||||||
// 2022-04-30: Inputs: Fixed ImGui_ImplGlfw_TranslateUntranslatedKey() for lower case letters on OSX.
|
// 2022-04-30: Inputs: Fixed ImGui_ImplGlfw_TranslateUntranslatedKey() for lower case letters on OSX.
|
||||||
// 2022-03-23: Inputs: Fixed a regression in 1.87 which resulted in keyboard modifiers events being reported incorrectly on Linux/X11.
|
// 2022-03-23: Inputs: Fixed a regression in 1.87 which resulted in keyboard modifiers events being reported incorrectly on Linux/X11.
|
||||||
// 2022-02-07: Added ImGui_ImplGlfw_InstallCallbacks()/ImGui_ImplGlfw_RestoreCallbacks() helpers to facilitate user installing callbacks after initializing backend.
|
// 2022-02-07: Added ImGui_ImplGlfw_InstallCallbacks()/ImGui_ImplGlfw_RestoreCallbacks() helpers to facilitate user installing callbacks after initializing backend.
|
||||||
@@ -63,6 +76,7 @@
|
|||||||
// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
|
// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_glfw.h"
|
#include "imgui_impl_glfw.h"
|
||||||
|
|
||||||
// Clang warnings with -Weverything
|
// Clang warnings with -Weverything
|
||||||
@@ -92,11 +106,29 @@
|
|||||||
|
|
||||||
// We gather version tests as define in order to easily see which features are version-dependent.
|
// We gather version tests as define in order to easily see which features are version-dependent.
|
||||||
#define GLFW_VERSION_COMBINED (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 + GLFW_VERSION_REVISION)
|
#define GLFW_VERSION_COMBINED (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 + GLFW_VERSION_REVISION)
|
||||||
|
#define GLFW_HAS_WINDOW_TOPMOST (GLFW_VERSION_COMBINED >= 3200) // 3.2+ GLFW_FLOATING
|
||||||
|
#define GLFW_HAS_WINDOW_HOVERED (GLFW_VERSION_COMBINED >= 3300) // 3.3+ GLFW_HOVERED
|
||||||
|
#define GLFW_HAS_WINDOW_ALPHA (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwSetWindowOpacity
|
||||||
|
#define GLFW_HAS_PER_MONITOR_DPI (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetMonitorContentScale
|
||||||
|
#if defined(__EMSCRIPTEN__) || defined(__SWITCH__) // no Vulkan support in GLFW for Emscripten or homebrew Nintendo Switch
|
||||||
|
#define GLFW_HAS_VULKAN (0)
|
||||||
|
#else
|
||||||
|
#define GLFW_HAS_VULKAN (GLFW_VERSION_COMBINED >= 3200) // 3.2+ glfwCreateWindowSurface
|
||||||
|
#endif
|
||||||
|
#define GLFW_HAS_FOCUS_WINDOW (GLFW_VERSION_COMBINED >= 3200) // 3.2+ glfwFocusWindow
|
||||||
|
#define GLFW_HAS_FOCUS_ON_SHOW (GLFW_VERSION_COMBINED >= 3300) // 3.3+ GLFW_FOCUS_ON_SHOW
|
||||||
|
#define GLFW_HAS_MONITOR_WORK_AREA (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetMonitorWorkarea
|
||||||
|
#define GLFW_HAS_OSX_WINDOW_POS_FIX (GLFW_VERSION_COMBINED >= 3301) // 3.3.1+ Fixed: Resizing window repositions it on MacOS #1553
|
||||||
#ifdef GLFW_RESIZE_NESW_CURSOR // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released?
|
#ifdef GLFW_RESIZE_NESW_CURSOR // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released?
|
||||||
#define GLFW_HAS_NEW_CURSORS (GLFW_VERSION_COMBINED >= 3400) // 3.4+ GLFW_RESIZE_ALL_CURSOR, GLFW_RESIZE_NESW_CURSOR, GLFW_RESIZE_NWSE_CURSOR, GLFW_NOT_ALLOWED_CURSOR
|
#define GLFW_HAS_NEW_CURSORS (GLFW_VERSION_COMBINED >= 3400) // 3.4+ GLFW_RESIZE_ALL_CURSOR, GLFW_RESIZE_NESW_CURSOR, GLFW_RESIZE_NWSE_CURSOR, GLFW_NOT_ALLOWED_CURSOR
|
||||||
#else
|
#else
|
||||||
#define GLFW_HAS_NEW_CURSORS (0)
|
#define GLFW_HAS_NEW_CURSORS (0)
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef GLFW_MOUSE_PASSTHROUGH // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2020-07-17 (passthrough)
|
||||||
|
#define GLFW_HAS_MOUSE_PASSTHROUGH (GLFW_VERSION_COMBINED >= 3400) // 3.4+ GLFW_MOUSE_PASSTHROUGH
|
||||||
|
#else
|
||||||
|
#define GLFW_HAS_MOUSE_PASSTHROUGH (0)
|
||||||
|
#endif
|
||||||
#define GLFW_HAS_GAMEPAD_API (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetGamepadState() new api
|
#define GLFW_HAS_GAMEPAD_API (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetGamepadState() new api
|
||||||
#define GLFW_HAS_GETKEYNAME (GLFW_VERSION_COMBINED >= 3200) // 3.2+ glfwGetKeyName()
|
#define GLFW_HAS_GETKEYNAME (GLFW_VERSION_COMBINED >= 3200) // 3.2+ glfwGetKeyName()
|
||||||
#define GLFW_HAS_GETERROR (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetError()
|
#define GLFW_HAS_GETERROR (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetError()
|
||||||
@@ -106,7 +138,7 @@ enum GlfwClientApi
|
|||||||
{
|
{
|
||||||
GlfwClientApi_Unknown,
|
GlfwClientApi_Unknown,
|
||||||
GlfwClientApi_OpenGL,
|
GlfwClientApi_OpenGL,
|
||||||
GlfwClientApi_Vulkan
|
GlfwClientApi_Vulkan,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImGui_ImplGlfw_Data
|
struct ImGui_ImplGlfw_Data
|
||||||
@@ -117,8 +149,13 @@ struct ImGui_ImplGlfw_Data
|
|||||||
GLFWwindow* MouseWindow;
|
GLFWwindow* MouseWindow;
|
||||||
GLFWcursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
GLFWcursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
||||||
ImVec2 LastValidMousePos;
|
ImVec2 LastValidMousePos;
|
||||||
|
GLFWwindow* KeyOwnerWindows[GLFW_KEY_LAST];
|
||||||
bool InstalledCallbacks;
|
bool InstalledCallbacks;
|
||||||
bool CallbacksChainForAllWindows;
|
bool CallbacksChainForAllWindows;
|
||||||
|
bool WantUpdateMonitors;
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
const char* CanvasSelector;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
|
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
|
||||||
GLFWwindowfocusfun PrevUserCallbackWindowFocus;
|
GLFWwindowfocusfun PrevUserCallbackWindowFocus;
|
||||||
@@ -130,7 +167,7 @@ struct ImGui_ImplGlfw_Data
|
|||||||
GLFWcharfun PrevUserCallbackChar;
|
GLFWcharfun PrevUserCallbackChar;
|
||||||
GLFWmonitorfun PrevUserCallbackMonitor;
|
GLFWmonitorfun PrevUserCallbackMonitor;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WNDPROC GlfwWndProc;
|
WNDPROC PrevWndProc;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ImGui_ImplGlfw_Data() { memset((void*)this, 0, sizeof(*this)); }
|
ImGui_ImplGlfw_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
@@ -148,6 +185,11 @@ static ImGui_ImplGlfw_Data* ImGui_ImplGlfw_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplGlfw_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplGlfw_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplGlfw_UpdateMonitors();
|
||||||
|
static void ImGui_ImplGlfw_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplGlfw_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static const char* ImGui_ImplGlfw_GetClipboardText(void* user_data)
|
static const char* ImGui_ImplGlfw_GetClipboardText(void* user_data)
|
||||||
{
|
{
|
||||||
@@ -268,6 +310,18 @@ static ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int key)
|
|||||||
case GLFW_KEY_F10: return ImGuiKey_F10;
|
case GLFW_KEY_F10: return ImGuiKey_F10;
|
||||||
case GLFW_KEY_F11: return ImGuiKey_F11;
|
case GLFW_KEY_F11: return ImGuiKey_F11;
|
||||||
case GLFW_KEY_F12: return ImGuiKey_F12;
|
case GLFW_KEY_F12: return ImGuiKey_F12;
|
||||||
|
case GLFW_KEY_F13: return ImGuiKey_F13;
|
||||||
|
case GLFW_KEY_F14: return ImGuiKey_F14;
|
||||||
|
case GLFW_KEY_F15: return ImGuiKey_F15;
|
||||||
|
case GLFW_KEY_F16: return ImGuiKey_F16;
|
||||||
|
case GLFW_KEY_F17: return ImGuiKey_F17;
|
||||||
|
case GLFW_KEY_F18: return ImGuiKey_F18;
|
||||||
|
case GLFW_KEY_F19: return ImGuiKey_F19;
|
||||||
|
case GLFW_KEY_F20: return ImGuiKey_F20;
|
||||||
|
case GLFW_KEY_F21: return ImGuiKey_F21;
|
||||||
|
case GLFW_KEY_F22: return ImGuiKey_F22;
|
||||||
|
case GLFW_KEY_F23: return ImGuiKey_F23;
|
||||||
|
case GLFW_KEY_F24: return ImGuiKey_F24;
|
||||||
default: return ImGuiKey_None;
|
default: return ImGuiKey_None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -361,6 +415,9 @@ void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int keycode, int scancode, i
|
|||||||
|
|
||||||
ImGui_ImplGlfw_UpdateKeyModifiers(window);
|
ImGui_ImplGlfw_UpdateKeyModifiers(window);
|
||||||
|
|
||||||
|
if (keycode >= 0 && keycode < IM_ARRAYSIZE(bd->KeyOwnerWindows))
|
||||||
|
bd->KeyOwnerWindows[keycode] = (action == GLFW_PRESS) ? window : nullptr;
|
||||||
|
|
||||||
keycode = ImGui_ImplGlfw_TranslateUntranslatedKey(keycode, scancode);
|
keycode = ImGui_ImplGlfw_TranslateUntranslatedKey(keycode, scancode);
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@@ -384,10 +441,15 @@ void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window, double x, double y)
|
|||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
if (bd->PrevUserCallbackCursorPos != nullptr && ImGui_ImplGlfw_ShouldChainCallback(window))
|
if (bd->PrevUserCallbackCursorPos != nullptr && ImGui_ImplGlfw_ShouldChainCallback(window))
|
||||||
bd->PrevUserCallbackCursorPos(window, x, y);
|
bd->PrevUserCallbackCursorPos(window, x, y);
|
||||||
if (glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
int window_x, window_y;
|
||||||
|
glfwGetWindowPos(window, &window_x, &window_y);
|
||||||
|
x += window_x;
|
||||||
|
y += window_y;
|
||||||
|
}
|
||||||
io.AddMousePosEvent((float)x, (float)y);
|
io.AddMousePosEvent((float)x, (float)y);
|
||||||
bd->LastValidMousePos = ImVec2((float)x, (float)y);
|
bd->LastValidMousePos = ImVec2((float)x, (float)y);
|
||||||
}
|
}
|
||||||
@@ -399,8 +461,6 @@ void ImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window, int entered)
|
|||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
if (bd->PrevUserCallbackCursorEnter != nullptr && ImGui_ImplGlfw_ShouldChainCallback(window))
|
if (bd->PrevUserCallbackCursorEnter != nullptr && ImGui_ImplGlfw_ShouldChainCallback(window))
|
||||||
bd->PrevUserCallbackCursorEnter(window, entered);
|
bd->PrevUserCallbackCursorEnter(window, entered);
|
||||||
if (glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
if (entered)
|
if (entered)
|
||||||
@@ -428,7 +488,8 @@ void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c)
|
|||||||
|
|
||||||
void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor*, int)
|
void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor*, int)
|
||||||
{
|
{
|
||||||
// Unused in 'master' branch but 'docking' branch will use this, so we declare it ahead of it so if you have to install callbacks you can install this one too.
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
@@ -450,32 +511,7 @@ static EM_BOOL ImGui_ImplEmscripten_WheelCallback(int, const EmscriptenWheelEven
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// GLFW doesn't allow to distinguish Mouse vs TouchScreen vs Pen.
|
static LRESULT CALLBACK ImGui_ImplGlfw_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
// Add support for Win32 (based on imgui_impl_win32), because we rely on _TouchScreen info to trickle inputs differently.
|
|
||||||
static ImGuiMouseSource GetMouseSourceFromMessageExtraInfo()
|
|
||||||
{
|
|
||||||
LPARAM extra_info = ::GetMessageExtraInfo();
|
|
||||||
if ((extra_info & 0xFFFFFF80) == 0xFF515700)
|
|
||||||
return ImGuiMouseSource_Pen;
|
|
||||||
if ((extra_info & 0xFFFFFF80) == 0xFF515780)
|
|
||||||
return ImGuiMouseSource_TouchScreen;
|
|
||||||
return ImGuiMouseSource_Mouse;
|
|
||||||
}
|
|
||||||
static LRESULT CALLBACK ImGui_ImplGlfw_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
|
||||||
switch (msg)
|
|
||||||
{
|
|
||||||
case WM_MOUSEMOVE: case WM_NCMOUSEMOVE:
|
|
||||||
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: case WM_LBUTTONUP:
|
|
||||||
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK: case WM_RBUTTONUP:
|
|
||||||
case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK: case WM_MBUTTONUP:
|
|
||||||
case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK: case WM_XBUTTONUP:
|
|
||||||
ImGui::GetIO().AddMouseSourceEvent(GetMouseSourceFromMessageExtraInfo());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return ::CallWindowProc(bd->GlfwWndProc, hWnd, msg, wParam, lParam);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window)
|
void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window)
|
||||||
@@ -542,9 +578,16 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
io.BackendPlatformName = "imgui_impl_glfw";
|
io.BackendPlatformName = "imgui_impl_glfw";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||||
|
#ifndef __EMSCRIPTEN__
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
|
||||||
|
#endif
|
||||||
|
#if GLFW_HAS_MOUSE_PASSTHROUGH || GLFW_HAS_WINDOW_HOVERED
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can call io.AddMouseViewportEvent() with correct data (optional)
|
||||||
|
#endif
|
||||||
|
|
||||||
bd->Window = window;
|
bd->Window = window;
|
||||||
bd->Time = 0.0;
|
bd->Time = 0.0;
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
|
|
||||||
io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
|
io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
|
io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
|
||||||
@@ -586,8 +629,13 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
emscripten_set_wheel_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, nullptr, false, ImGui_ImplEmscripten_WheelCallback);
|
emscripten_set_wheel_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, nullptr, false, ImGui_ImplEmscripten_WheelCallback);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Update monitors the first time (note: monitor callback are broken in GLFW 3.2 and earlier, see github.com/glfw/glfw/issues/784)
|
||||||
|
ImGui_ImplGlfw_UpdateMonitors();
|
||||||
|
glfwSetMonitorCallback(ImGui_ImplGlfw_MonitorCallback);
|
||||||
|
|
||||||
// Set platform dependent data in viewport
|
// Set platform dependent data in viewport
|
||||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
main_viewport->PlatformHandle = (void*)bd->Window;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
main_viewport->PlatformHandleRaw = glfwGetWin32Window(bd->Window);
|
main_viewport->PlatformHandleRaw = glfwGetWin32Window(bd->Window);
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
@@ -595,12 +643,14 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
#else
|
#else
|
||||||
IM_UNUSED(main_viewport);
|
IM_UNUSED(main_viewport);
|
||||||
#endif
|
#endif
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplGlfw_InitPlatformInterface();
|
||||||
|
|
||||||
// Windows: register a WndProc hook so we can intercept some messages.
|
// Windows: register a WndProc hook so we can intercept some messages.
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
bd->GlfwWndProc = (WNDPROC)::GetWindowLongPtr((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC);
|
bd->PrevWndProc = (WNDPROC)::GetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC);
|
||||||
IM_ASSERT(bd->GlfwWndProc != nullptr);
|
IM_ASSERT(bd->PrevWndProc != nullptr);
|
||||||
::SetWindowLongPtr((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)ImGui_ImplGlfw_WndProc);
|
::SetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)ImGui_ImplGlfw_WndProc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bd->ClientApi = client_api;
|
bd->ClientApi = client_api;
|
||||||
@@ -628,21 +678,27 @@ void ImGui_ImplGlfw_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplGlfw_ShutdownPlatformInterface();
|
||||||
|
|
||||||
if (bd->InstalledCallbacks)
|
if (bd->InstalledCallbacks)
|
||||||
ImGui_ImplGlfw_RestoreCallbacks(bd->Window);
|
ImGui_ImplGlfw_RestoreCallbacks(bd->Window);
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
emscripten_set_wheel_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, nullptr, false, nullptr);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
||||||
glfwDestroyCursor(bd->MouseCursors[cursor_n]);
|
glfwDestroyCursor(bd->MouseCursors[cursor_n]);
|
||||||
|
|
||||||
// Windows: register a WndProc hook so we can intercept some messages.
|
// Windows: restore our WndProc hook
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
::SetWindowLongPtr((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)bd->GlfwWndProc);
|
::SetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)bd->PrevWndProc);
|
||||||
bd->GlfwWndProc = nullptr;
|
bd->PrevWndProc = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
io.BackendPlatformName = nullptr;
|
io.BackendPlatformName = nullptr;
|
||||||
io.BackendPlatformUserData = nullptr;
|
io.BackendPlatformUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -650,16 +706,14 @@ static void ImGui_ImplGlfw_UpdateMouseData()
|
|||||||
{
|
{
|
||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
|
||||||
if (glfwGetInputMode(bd->Window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED)
|
ImGuiID mouse_viewport_id = 0;
|
||||||
|
const ImVec2 mouse_pos_prev = io.MousePos;
|
||||||
|
for (int n = 0; n < platform_io.Viewports.Size; n++)
|
||||||
{
|
{
|
||||||
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
ImGuiViewport* viewport = platform_io.Viewports[n];
|
||||||
return;
|
GLFWwindow* window = (GLFWwindow*)viewport->PlatformHandle;
|
||||||
}
|
|
||||||
|
|
||||||
// (those braces are here to reduce diff with multi-viewports support in 'docking' branch)
|
|
||||||
{
|
|
||||||
GLFWwindow* window = bd->Window;
|
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
const bool is_window_focused = true;
|
const bool is_window_focused = true;
|
||||||
@@ -669,19 +723,54 @@ static void ImGui_ImplGlfw_UpdateMouseData()
|
|||||||
if (is_window_focused)
|
if (is_window_focused)
|
||||||
{
|
{
|
||||||
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
||||||
|
// When multi-viewports are enabled, all Dear ImGui positions are same as OS positions.
|
||||||
if (io.WantSetMousePos)
|
if (io.WantSetMousePos)
|
||||||
glfwSetCursorPos(window, (double)io.MousePos.x, (double)io.MousePos.y);
|
glfwSetCursorPos(window, (double)(mouse_pos_prev.x - viewport->Pos.x), (double)(mouse_pos_prev.y - viewport->Pos.y));
|
||||||
|
|
||||||
// (Optional) Fallback to provide mouse position when focused (ImGui_ImplGlfw_CursorPosCallback already provides this when hovered or captured)
|
// (Optional) Fallback to provide mouse position when focused (ImGui_ImplGlfw_CursorPosCallback already provides this when hovered or captured)
|
||||||
if (bd->MouseWindow == nullptr)
|
if (bd->MouseWindow == nullptr)
|
||||||
{
|
{
|
||||||
double mouse_x, mouse_y;
|
double mouse_x, mouse_y;
|
||||||
glfwGetCursorPos(window, &mouse_x, &mouse_y);
|
glfwGetCursorPos(window, &mouse_x, &mouse_y);
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
// Single viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
|
||||||
|
// Multi-viewport mode: mouse position in OS absolute coordinates (io.MousePos is (0,0) when the mouse is on the upper-left of the primary monitor)
|
||||||
|
int window_x, window_y;
|
||||||
|
glfwGetWindowPos(window, &window_x, &window_y);
|
||||||
|
mouse_x += window_x;
|
||||||
|
mouse_y += window_y;
|
||||||
|
}
|
||||||
bd->LastValidMousePos = ImVec2((float)mouse_x, (float)mouse_y);
|
bd->LastValidMousePos = ImVec2((float)mouse_x, (float)mouse_y);
|
||||||
io.AddMousePosEvent((float)mouse_x, (float)mouse_y);
|
io.AddMousePosEvent((float)mouse_x, (float)mouse_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// (Optional) When using multiple viewports: call io.AddMouseViewportEvent() with the viewport the OS mouse cursor is hovering.
|
||||||
|
// If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the backend, Dear imGui will ignore this field and infer the information using its flawed heuristic.
|
||||||
|
// - [X] GLFW >= 3.3 backend ON WINDOWS ONLY does correctly ignore viewports with the _NoInputs flag (since we implement hit via our WndProc hook)
|
||||||
|
// On other platforms we rely on the library fallbacking to its own search when reporting a viewport with _NoInputs flag.
|
||||||
|
// - [!] GLFW <= 3.2 backend CANNOT correctly ignore viewports with the _NoInputs flag, and CANNOT reported Hovered Viewport because of mouse capture.
|
||||||
|
// Some backend are not able to handle that correctly. If a backend report an hovered viewport that has the _NoInputs flag (e.g. when dragging a window
|
||||||
|
// for docking, the viewport has the _NoInputs flag in order to allow us to find the viewport under), then Dear ImGui is forced to ignore the value reported
|
||||||
|
// by the backend, and use its flawed heuristic to guess the viewport behind.
|
||||||
|
// - [X] GLFW backend correctly reports this regardless of another viewport behind focused and dragged from (we need this to find a useful drag and drop target).
|
||||||
|
// FIXME: This is currently only correct on Win32. See what we do below with the WM_NCHITTEST, missing an equivalent for other systems.
|
||||||
|
// See https://github.com/glfw/glfw/issues/1236 if you want to help in making this a GLFW feature.
|
||||||
|
#if GLFW_HAS_MOUSE_PASSTHROUGH
|
||||||
|
const bool window_no_input = (viewport->Flags & ImGuiViewportFlags_NoInputs) != 0;
|
||||||
|
glfwSetWindowAttrib(window, GLFW_MOUSE_PASSTHROUGH, window_no_input);
|
||||||
|
#endif
|
||||||
|
#if GLFW_HAS_MOUSE_PASSTHROUGH || GLFW_HAS_WINDOW_HOVERED
|
||||||
|
if (glfwGetWindowAttrib(window, GLFW_HOVERED))
|
||||||
|
mouse_viewport_id = viewport->ID;
|
||||||
|
#else
|
||||||
|
// We cannot use bd->MouseWindow maintained from CursorEnter/Leave callbacks, because it is locked to the window capturing mouse.
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (io.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport)
|
||||||
|
io.AddMouseViewportEvent(mouse_viewport_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplGlfw_UpdateMouseCursor()
|
static void ImGui_ImplGlfw_UpdateMouseCursor()
|
||||||
@@ -692,9 +781,10 @@ static void ImGui_ImplGlfw_UpdateMouseCursor()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
|
ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
|
||||||
// (those braces are here to reduce diff with multi-viewports support in 'docking' branch)
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
for (int n = 0; n < platform_io.Viewports.Size; n++)
|
||||||
{
|
{
|
||||||
GLFWwindow* window = bd->Window;
|
GLFWwindow* window = (GLFWwindow*)platform_io.Viewports[n]->PlatformHandle;
|
||||||
if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor)
|
if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor)
|
||||||
{
|
{
|
||||||
// Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
|
// Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
|
||||||
@@ -763,6 +853,48 @@ static void ImGui_ImplGlfw_UpdateGamepads()
|
|||||||
#undef MAP_ANALOG
|
#undef MAP_ANALOG
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_UpdateMonitors()
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
bd->WantUpdateMonitors = false;
|
||||||
|
|
||||||
|
int monitors_count = 0;
|
||||||
|
GLFWmonitor** glfw_monitors = glfwGetMonitors(&monitors_count);
|
||||||
|
if (monitors_count == 0) // Preserve existing monitor list if there are none. Happens on macOS sleeping (#5683)
|
||||||
|
return;
|
||||||
|
|
||||||
|
platform_io.Monitors.resize(0);
|
||||||
|
for (int n = 0; n < monitors_count; n++)
|
||||||
|
{
|
||||||
|
ImGuiPlatformMonitor monitor;
|
||||||
|
int x, y;
|
||||||
|
glfwGetMonitorPos(glfw_monitors[n], &x, &y);
|
||||||
|
const GLFWvidmode* vid_mode = glfwGetVideoMode(glfw_monitors[n]);
|
||||||
|
if (vid_mode == nullptr)
|
||||||
|
continue; // Failed to get Video mode (e.g. Emscripten does not support this function)
|
||||||
|
monitor.MainPos = monitor.WorkPos = ImVec2((float)x, (float)y);
|
||||||
|
monitor.MainSize = monitor.WorkSize = ImVec2((float)vid_mode->width, (float)vid_mode->height);
|
||||||
|
#if GLFW_HAS_MONITOR_WORK_AREA
|
||||||
|
int w, h;
|
||||||
|
glfwGetMonitorWorkarea(glfw_monitors[n], &x, &y, &w, &h);
|
||||||
|
if (w > 0 && h > 0) // Workaround a small GLFW issue reporting zero on monitor changes: https://github.com/glfw/glfw/pull/1761
|
||||||
|
{
|
||||||
|
monitor.WorkPos = ImVec2((float)x, (float)y);
|
||||||
|
monitor.WorkSize = ImVec2((float)w, (float)h);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if GLFW_HAS_PER_MONITOR_DPI
|
||||||
|
// Warning: the validity of monitor DPI information on Windows depends on the application DPI awareness settings, which generally needs to be set in the manifest or at runtime.
|
||||||
|
float x_scale, y_scale;
|
||||||
|
glfwGetMonitorContentScale(glfw_monitors[n], &x_scale, &y_scale);
|
||||||
|
monitor.DpiScale = x_scale;
|
||||||
|
#endif
|
||||||
|
monitor.PlatformHandle = (void*)glfw_monitors[n]; // [...] GLFW doc states: "guaranteed to be valid only until the monitor configuration changes"
|
||||||
|
platform_io.Monitors.push_back(monitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_NewFrame()
|
void ImGui_ImplGlfw_NewFrame()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@@ -777,9 +909,14 @@ void ImGui_ImplGlfw_NewFrame()
|
|||||||
io.DisplaySize = ImVec2((float)w, (float)h);
|
io.DisplaySize = ImVec2((float)w, (float)h);
|
||||||
if (w > 0 && h > 0)
|
if (w > 0 && h > 0)
|
||||||
io.DisplayFramebufferScale = ImVec2((float)display_w / (float)w, (float)display_h / (float)h);
|
io.DisplayFramebufferScale = ImVec2((float)display_w / (float)w, (float)display_h / (float)h);
|
||||||
|
if (bd->WantUpdateMonitors)
|
||||||
|
ImGui_ImplGlfw_UpdateMonitors();
|
||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
|
// (Accept glfwGetTime() not returning a monotonically increasing value. Seems to happens on disconnecting peripherals and probably on VMs and Emscripten, see #6491, #6189, #6114, #3644)
|
||||||
double current_time = glfwGetTime();
|
double current_time = glfwGetTime();
|
||||||
|
if (current_time <= bd->Time)
|
||||||
|
current_time = bd->Time + 0.00001f;
|
||||||
io.DeltaTime = bd->Time > 0.0 ? (float)(current_time - bd->Time) : (float)(1.0f / 60.0f);
|
io.DeltaTime = bd->Time > 0.0 ? (float)(current_time - bd->Time) : (float)(1.0f / 60.0f);
|
||||||
bd->Time = current_time;
|
bd->Time = current_time;
|
||||||
|
|
||||||
@@ -790,6 +927,439 @@ void ImGui_ImplGlfw_NewFrame()
|
|||||||
ImGui_ImplGlfw_UpdateGamepads();
|
ImGui_ImplGlfw_UpdateGamepads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
static EM_BOOL ImGui_ImplGlfw_OnCanvasSizeChange(int event_type, const EmscriptenUiEvent* event, void* user_data)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = (ImGui_ImplGlfw_Data*)user_data;
|
||||||
|
double canvas_width, canvas_height;
|
||||||
|
emscripten_get_element_css_size(bd->CanvasSelector, &canvas_width, &canvas_height);
|
||||||
|
glfwSetWindowSize(bd->Window, (int)canvas_width, (int)canvas_height);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static EM_BOOL ImGui_ImplEmscripten_FullscreenChangeCallback(int event_type, const EmscriptenFullscreenChangeEvent* event, void* user_data)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = (ImGui_ImplGlfw_Data*)user_data;
|
||||||
|
double canvas_width, canvas_height;
|
||||||
|
emscripten_get_element_css_size(bd->CanvasSelector, &canvas_width, &canvas_height);
|
||||||
|
glfwSetWindowSize(bd->Window, (int)canvas_width, (int)canvas_height);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 'canvas_selector' is a CSS selector. The event listener is applied to the first element that matches the query.
|
||||||
|
// STRING MUST PERSIST FOR THE APPLICATION DURATION. PLEASE USE A STRING LITERAL OR ENSURE POINTER WILL STAY VALID.
|
||||||
|
void ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback(const char* canvas_selector)
|
||||||
|
{
|
||||||
|
IM_ASSERT(canvas_selector != nullptr);
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplGlfw_InitForXXX()?");
|
||||||
|
|
||||||
|
bd->CanvasSelector = canvas_selector;
|
||||||
|
emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, bd, false, ImGui_ImplGlfw_OnCanvasSizeChange);
|
||||||
|
emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, bd, false, ImGui_ImplEmscripten_FullscreenChangeCallback);
|
||||||
|
|
||||||
|
// Change the size of the GLFW window according to the size of the canvas
|
||||||
|
ImGui_ImplGlfw_OnCanvasSizeChange(EMSCRIPTEN_EVENT_RESIZE, {}, bd);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplGlfw_ViewportData
|
||||||
|
{
|
||||||
|
GLFWwindow* Window;
|
||||||
|
bool WindowOwned;
|
||||||
|
int IgnoreWindowPosEventFrame;
|
||||||
|
int IgnoreWindowSizeEventFrame;
|
||||||
|
#ifdef _WIN32
|
||||||
|
WNDPROC PrevWndProc;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ImGui_ImplGlfw_ViewportData() { memset(this, 0, sizeof(*this)); IgnoreWindowSizeEventFrame = IgnoreWindowPosEventFrame = -1; }
|
||||||
|
~ImGui_ImplGlfw_ViewportData() { IM_ASSERT(Window == nullptr); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_WindowCloseCallback(GLFWwindow* window)
|
||||||
|
{
|
||||||
|
if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle(window))
|
||||||
|
viewport->PlatformRequestClose = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GLFW may dispatch window pos/size events after calling glfwSetWindowPos()/glfwSetWindowSize().
|
||||||
|
// However: depending on the platform the callback may be invoked at different time:
|
||||||
|
// - on Windows it appears to be called within the glfwSetWindowPos()/glfwSetWindowSize() call
|
||||||
|
// - on Linux it is queued and invoked during glfwPollEvents()
|
||||||
|
// Because the event doesn't always fire on glfwSetWindowXXX() we use a frame counter tag to only
|
||||||
|
// ignore recent glfwSetWindowXXX() calls.
|
||||||
|
static void ImGui_ImplGlfw_WindowPosCallback(GLFWwindow* window, int, int)
|
||||||
|
{
|
||||||
|
if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle(window))
|
||||||
|
{
|
||||||
|
if (ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData)
|
||||||
|
{
|
||||||
|
bool ignore_event = (ImGui::GetFrameCount() <= vd->IgnoreWindowPosEventFrame + 1);
|
||||||
|
//data->IgnoreWindowPosEventFrame = -1;
|
||||||
|
if (ignore_event)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
viewport->PlatformRequestMove = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_WindowSizeCallback(GLFWwindow* window, int, int)
|
||||||
|
{
|
||||||
|
if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle(window))
|
||||||
|
{
|
||||||
|
if (ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData)
|
||||||
|
{
|
||||||
|
bool ignore_event = (ImGui::GetFrameCount() <= vd->IgnoreWindowSizeEventFrame + 1);
|
||||||
|
//data->IgnoreWindowSizeEventFrame = -1;
|
||||||
|
if (ignore_event)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
viewport->PlatformRequestResize = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = IM_NEW(ImGui_ImplGlfw_ViewportData)();
|
||||||
|
viewport->PlatformUserData = vd;
|
||||||
|
|
||||||
|
// GLFW 3.2 unfortunately always set focus on glfwCreateWindow() if GLFW_VISIBLE is set, regardless of GLFW_FOCUSED
|
||||||
|
// With GLFW 3.3, the hint GLFW_FOCUS_ON_SHOW fixes this problem
|
||||||
|
glfwWindowHint(GLFW_VISIBLE, false);
|
||||||
|
glfwWindowHint(GLFW_FOCUSED, false);
|
||||||
|
#if GLFW_HAS_FOCUS_ON_SHOW
|
||||||
|
glfwWindowHint(GLFW_FOCUS_ON_SHOW, false);
|
||||||
|
#endif
|
||||||
|
glfwWindowHint(GLFW_DECORATED, (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? false : true);
|
||||||
|
#if GLFW_HAS_WINDOW_TOPMOST
|
||||||
|
glfwWindowHint(GLFW_FLOATING, (viewport->Flags & ImGuiViewportFlags_TopMost) ? true : false);
|
||||||
|
#endif
|
||||||
|
GLFWwindow* share_window = (bd->ClientApi == GlfwClientApi_OpenGL) ? bd->Window : nullptr;
|
||||||
|
vd->Window = glfwCreateWindow((int)viewport->Size.x, (int)viewport->Size.y, "No Title Yet", nullptr, share_window);
|
||||||
|
vd->WindowOwned = true;
|
||||||
|
viewport->PlatformHandle = (void*)vd->Window;
|
||||||
|
#ifdef _WIN32
|
||||||
|
viewport->PlatformHandleRaw = glfwGetWin32Window(vd->Window);
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
viewport->PlatformHandleRaw = (void*)glfwGetCocoaWindow(vd->Window);
|
||||||
|
#endif
|
||||||
|
glfwSetWindowPos(vd->Window, (int)viewport->Pos.x, (int)viewport->Pos.y);
|
||||||
|
|
||||||
|
// Install GLFW callbacks for secondary viewports
|
||||||
|
glfwSetWindowFocusCallback(vd->Window, ImGui_ImplGlfw_WindowFocusCallback);
|
||||||
|
glfwSetCursorEnterCallback(vd->Window, ImGui_ImplGlfw_CursorEnterCallback);
|
||||||
|
glfwSetCursorPosCallback(vd->Window, ImGui_ImplGlfw_CursorPosCallback);
|
||||||
|
glfwSetMouseButtonCallback(vd->Window, ImGui_ImplGlfw_MouseButtonCallback);
|
||||||
|
glfwSetScrollCallback(vd->Window, ImGui_ImplGlfw_ScrollCallback);
|
||||||
|
glfwSetKeyCallback(vd->Window, ImGui_ImplGlfw_KeyCallback);
|
||||||
|
glfwSetCharCallback(vd->Window, ImGui_ImplGlfw_CharCallback);
|
||||||
|
glfwSetWindowCloseCallback(vd->Window, ImGui_ImplGlfw_WindowCloseCallback);
|
||||||
|
glfwSetWindowPosCallback(vd->Window, ImGui_ImplGlfw_WindowPosCallback);
|
||||||
|
glfwSetWindowSizeCallback(vd->Window, ImGui_ImplGlfw_WindowSizeCallback);
|
||||||
|
if (bd->ClientApi == GlfwClientApi_OpenGL)
|
||||||
|
{
|
||||||
|
glfwMakeContextCurrent(vd->Window);
|
||||||
|
glfwSwapInterval(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
if (ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData)
|
||||||
|
{
|
||||||
|
if (vd->WindowOwned)
|
||||||
|
{
|
||||||
|
#if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
|
||||||
|
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
|
||||||
|
::RemovePropA(hwnd, "IMGUI_VIEWPORT");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Release any keys that were pressed in the window being destroyed and are still held down,
|
||||||
|
// because we will not receive any release events after window is destroyed.
|
||||||
|
for (int i = 0; i < IM_ARRAYSIZE(bd->KeyOwnerWindows); i++)
|
||||||
|
if (bd->KeyOwnerWindows[i] == vd->Window)
|
||||||
|
ImGui_ImplGlfw_KeyCallback(vd->Window, i, 0, GLFW_RELEASE, 0); // Later params are only used for main viewport, on which this function is never called.
|
||||||
|
|
||||||
|
glfwDestroyWindow(vd->Window);
|
||||||
|
}
|
||||||
|
vd->Window = nullptr;
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->PlatformUserData = viewport->PlatformHandle = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_ShowWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
// GLFW hack: Hide icon from task bar
|
||||||
|
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon)
|
||||||
|
{
|
||||||
|
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||||
|
ex_style &= ~WS_EX_APPWINDOW;
|
||||||
|
ex_style |= WS_EX_TOOLWINDOW;
|
||||||
|
::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GLFW hack: install hook for WM_NCHITTEST message handler
|
||||||
|
#if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
|
||||||
|
::SetPropA(hwnd, "IMGUI_VIEWPORT", viewport);
|
||||||
|
vd->PrevWndProc = (WNDPROC)::GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
|
||||||
|
::SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)ImGui_ImplGlfw_WndProc);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !GLFW_HAS_FOCUS_ON_SHOW
|
||||||
|
// GLFW hack: GLFW 3.2 has a bug where glfwShowWindow() also activates/focus the window.
|
||||||
|
// The fix was pushed to GLFW repository on 2018/01/09 and should be included in GLFW 3.3 via a GLFW_FOCUS_ON_SHOW window attribute.
|
||||||
|
// See https://github.com/glfw/glfw/issues/1189
|
||||||
|
// FIXME-VIEWPORT: Implement same work-around for Linux/OSX in the meanwhile.
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing)
|
||||||
|
{
|
||||||
|
::ShowWindow(hwnd, SW_SHOWNA);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
glfwShowWindow(vd->Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplGlfw_GetWindowPos(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
int x = 0, y = 0;
|
||||||
|
glfwGetWindowPos(vd->Window, &x, &y);
|
||||||
|
return ImVec2((float)x, (float)y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
vd->IgnoreWindowPosEventFrame = ImGui::GetFrameCount();
|
||||||
|
glfwSetWindowPos(vd->Window, (int)pos.x, (int)pos.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplGlfw_GetWindowSize(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
int w = 0, h = 0;
|
||||||
|
glfwGetWindowSize(vd->Window, &w, &h);
|
||||||
|
return ImVec2((float)w, (float)h);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
#if __APPLE__ && !GLFW_HAS_OSX_WINDOW_POS_FIX
|
||||||
|
// Native OS windows are positioned from the bottom-left corner on macOS, whereas on other platforms they are
|
||||||
|
// positioned from the upper-left corner. GLFW makes an effort to convert macOS style coordinates, however it
|
||||||
|
// doesn't handle it when changing size. We are manually moving the window in order for changes of size to be based
|
||||||
|
// on the upper-left corner.
|
||||||
|
int x, y, width, height;
|
||||||
|
glfwGetWindowPos(vd->Window, &x, &y);
|
||||||
|
glfwGetWindowSize(vd->Window, &width, &height);
|
||||||
|
glfwSetWindowPos(vd->Window, x, y - height + size.y);
|
||||||
|
#endif
|
||||||
|
vd->IgnoreWindowSizeEventFrame = ImGui::GetFrameCount();
|
||||||
|
glfwSetWindowSize(vd->Window, (int)size.x, (int)size.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_SetWindowTitle(ImGuiViewport* viewport, const char* title)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
glfwSetWindowTitle(vd->Window, title);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_SetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
#if GLFW_HAS_FOCUS_WINDOW
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
glfwFocusWindow(vd->Window);
|
||||||
|
#else
|
||||||
|
// FIXME: What are the effect of not having this function? At the moment imgui doesn't actually call SetWindowFocus - we set that up ahead, will answer that question later.
|
||||||
|
(void)viewport;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplGlfw_GetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
return glfwGetWindowAttrib(vd->Window, GLFW_FOCUSED) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplGlfw_GetWindowMinimized(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
return glfwGetWindowAttrib(vd->Window, GLFW_ICONIFIED) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if GLFW_HAS_WINDOW_ALPHA
|
||||||
|
static void ImGui_ImplGlfw_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
glfwSetWindowOpacity(vd->Window, alpha);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
if (bd->ClientApi == GlfwClientApi_OpenGL)
|
||||||
|
glfwMakeContextCurrent(vd->Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
if (bd->ClientApi == GlfwClientApi_OpenGL)
|
||||||
|
{
|
||||||
|
glfwMakeContextCurrent(vd->Window);
|
||||||
|
glfwSwapBuffers(vd->Window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// Vulkan support (the Vulkan renderer needs to call a platform-side support function to create the surface)
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Avoid including <vulkan.h> so we can build without it
|
||||||
|
#if GLFW_HAS_VULKAN
|
||||||
|
#ifndef VULKAN_H_
|
||||||
|
#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object;
|
||||||
|
#if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
|
||||||
|
#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object;
|
||||||
|
#else
|
||||||
|
#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object;
|
||||||
|
#endif
|
||||||
|
VK_DEFINE_HANDLE(VkInstance)
|
||||||
|
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR)
|
||||||
|
struct VkAllocationCallbacks;
|
||||||
|
enum VkResult { VK_RESULT_MAX_ENUM = 0x7FFFFFFF };
|
||||||
|
#endif // VULKAN_H_
|
||||||
|
extern "C" { extern GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); }
|
||||||
|
static int ImGui_ImplGlfw_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_instance, const void* vk_allocator, ImU64* out_vk_surface)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_UNUSED(bd);
|
||||||
|
IM_ASSERT(bd->ClientApi == GlfwClientApi_Vulkan);
|
||||||
|
VkResult err = glfwCreateWindowSurface((VkInstance)vk_instance, vd->Window, (const VkAllocationCallbacks*)vk_allocator, (VkSurfaceKHR*)out_vk_surface);
|
||||||
|
return (int)err;
|
||||||
|
}
|
||||||
|
#endif // GLFW_HAS_VULKAN
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
// Register platform interface (will be coupled with a renderer interface)
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Platform_CreateWindow = ImGui_ImplGlfw_CreateWindow;
|
||||||
|
platform_io.Platform_DestroyWindow = ImGui_ImplGlfw_DestroyWindow;
|
||||||
|
platform_io.Platform_ShowWindow = ImGui_ImplGlfw_ShowWindow;
|
||||||
|
platform_io.Platform_SetWindowPos = ImGui_ImplGlfw_SetWindowPos;
|
||||||
|
platform_io.Platform_GetWindowPos = ImGui_ImplGlfw_GetWindowPos;
|
||||||
|
platform_io.Platform_SetWindowSize = ImGui_ImplGlfw_SetWindowSize;
|
||||||
|
platform_io.Platform_GetWindowSize = ImGui_ImplGlfw_GetWindowSize;
|
||||||
|
platform_io.Platform_SetWindowFocus = ImGui_ImplGlfw_SetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowFocus = ImGui_ImplGlfw_GetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowMinimized = ImGui_ImplGlfw_GetWindowMinimized;
|
||||||
|
platform_io.Platform_SetWindowTitle = ImGui_ImplGlfw_SetWindowTitle;
|
||||||
|
platform_io.Platform_RenderWindow = ImGui_ImplGlfw_RenderWindow;
|
||||||
|
platform_io.Platform_SwapBuffers = ImGui_ImplGlfw_SwapBuffers;
|
||||||
|
#if GLFW_HAS_WINDOW_ALPHA
|
||||||
|
platform_io.Platform_SetWindowAlpha = ImGui_ImplGlfw_SetWindowAlpha;
|
||||||
|
#endif
|
||||||
|
#if GLFW_HAS_VULKAN
|
||||||
|
platform_io.Platform_CreateVkSurface = ImGui_ImplGlfw_CreateVkSurface;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Register main window handle (which is owned by the main application, not by us)
|
||||||
|
// This is mostly for simplicity and consistency, so that our code (e.g. mouse handling etc.) can use same logic for main and secondary viewports.
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = IM_NEW(ImGui_ImplGlfw_ViewportData)();
|
||||||
|
vd->Window = bd->Window;
|
||||||
|
vd->WindowOwned = false;
|
||||||
|
main_viewport->PlatformUserData = vd;
|
||||||
|
main_viewport->PlatformHandle = (void*)bd->Window;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// WndProc hook (declared here because we will need access to ImGui_ImplGlfw_ViewportData)
|
||||||
|
#ifdef _WIN32
|
||||||
|
static ImGuiMouseSource GetMouseSourceFromMessageExtraInfo()
|
||||||
|
{
|
||||||
|
LPARAM extra_info = ::GetMessageExtraInfo();
|
||||||
|
if ((extra_info & 0xFFFFFF80) == 0xFF515700)
|
||||||
|
return ImGuiMouseSource_Pen;
|
||||||
|
if ((extra_info & 0xFFFFFF80) == 0xFF515780)
|
||||||
|
return ImGuiMouseSource_TouchScreen;
|
||||||
|
return ImGuiMouseSource_Mouse;
|
||||||
|
}
|
||||||
|
static LRESULT CALLBACK ImGui_ImplGlfw_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
WNDPROC prev_wndproc = bd->PrevWndProc;
|
||||||
|
ImGuiViewport* viewport = (ImGuiViewport*)::GetPropA(hWnd, "IMGUI_VIEWPORT");
|
||||||
|
if (viewport != NULL)
|
||||||
|
if (ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData)
|
||||||
|
prev_wndproc = vd->PrevWndProc;
|
||||||
|
|
||||||
|
switch (msg)
|
||||||
|
{
|
||||||
|
// GLFW doesn't allow to distinguish Mouse vs TouchScreen vs Pen.
|
||||||
|
// Add support for Win32 (based on imgui_impl_win32), because we rely on _TouchScreen info to trickle inputs differently.
|
||||||
|
case WM_MOUSEMOVE: case WM_NCMOUSEMOVE:
|
||||||
|
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: case WM_LBUTTONUP:
|
||||||
|
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK: case WM_RBUTTONUP:
|
||||||
|
case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK: case WM_MBUTTONUP:
|
||||||
|
case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK: case WM_XBUTTONUP:
|
||||||
|
ImGui::GetIO().AddMouseSourceEvent(GetMouseSourceFromMessageExtraInfo());
|
||||||
|
break;
|
||||||
|
|
||||||
|
// We have submitted https://github.com/glfw/glfw/pull/1568 to allow GLFW to support "transparent inputs".
|
||||||
|
// In the meanwhile we implement custom per-platform workarounds here (FIXME-VIEWPORT: Implement same work-around for Linux/OSX!)
|
||||||
|
#if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED
|
||||||
|
case WM_NCHITTEST:
|
||||||
|
{
|
||||||
|
// Let mouse pass-through the window. This will allow the backend to call io.AddMouseViewportEvent() properly (which is OPTIONAL).
|
||||||
|
// The ImGuiViewportFlags_NoInputs flag is set while dragging a viewport, as want to detect the window behind the one we are dragging.
|
||||||
|
// If you cannot easily access those viewport flags from your windowing/event code: you may manually synchronize its state e.g. in
|
||||||
|
// your main loop after calling UpdatePlatformWindows(). Iterate all viewports/platform windows and pass the flag to your windowing system.
|
||||||
|
if (viewport && (viewport->Flags & ImGuiViewportFlags_NoInputs))
|
||||||
|
return HTTRANSPARENT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return ::CallWindowProcW(prev_wndproc, hWnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
|
#endif // #ifdef _WIN32
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -1,21 +1,30 @@
|
|||||||
// dear imgui: Platform Backend for GLFW
|
// dear imgui: Platform Backend for GLFW
|
||||||
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..)
|
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..)
|
||||||
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||||
|
// (Requires: GLFW 3.1+. Prefer GLFW 3.3+ for full feature support.)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Clipboard support.
|
// [X] Platform: Clipboard support.
|
||||||
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen/Pen (Windows only).
|
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen/Pen (Windows only).
|
||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
|
// [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
|
||||||
|
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
|
// Issues:
|
||||||
|
// [ ] Platform: Multi-viewport support: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct GLFWwindow;
|
struct GLFWwindow;
|
||||||
struct GLFWmonitor;
|
struct GLFWmonitor;
|
||||||
@@ -26,6 +35,11 @@ IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool ins
|
|||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();
|
||||||
|
|
||||||
|
// Emscripten related initialization phase methods
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback(const char* canvas_selector);
|
||||||
|
#endif
|
||||||
|
|
||||||
// GLFW callbacks install
|
// GLFW callbacks install
|
||||||
// - When calling Init with 'install_callbacks=true': ImGui_ImplGlfw_InstallCallbacks() is called. GLFW callbacks will be installed for you. They will chain-call user's previously installed callbacks, if any.
|
// - When calling Init with 'install_callbacks=true': ImGui_ImplGlfw_InstallCallbacks() is called. GLFW callbacks will be installed for you. They will chain-call user's previously installed callbacks, if any.
|
||||||
// - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call individual function yourself from your own GLFW callbacks.
|
// - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call individual function yourself from your own GLFW callbacks.
|
||||||
@@ -45,3 +59,5 @@ IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double
|
|||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
|
IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
|
||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor, int event);
|
IMGUI_IMPL_API void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor, int event);
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// Issues:
|
// Missing features:
|
||||||
// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
|
// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
|
||||||
// [ ] Platform: Missing horizontal mouse wheel support.
|
// [ ] Platform: Missing horizontal mouse wheel support.
|
||||||
// [ ] Platform: Missing mouse cursor shape/visibility support.
|
// [ ] Platform: Missing mouse cursor shape/visibility support.
|
||||||
@@ -16,11 +16,15 @@
|
|||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2023-04-17: BREAKING: Removed call to ImGui::NewFrame() from ImGui_ImplGLUT_NewFrame(). Needs to be called from the main application loop, like with every other backends.
|
||||||
// 2022-09-26: Inputs: Renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported).
|
// 2022-09-26: Inputs: Renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported).
|
||||||
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago) with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago) with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
||||||
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
@@ -31,6 +35,7 @@
|
|||||||
// 2018-03-22: Added GLUT Platform binding.
|
// 2018-03-22: Added GLUT Platform binding.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_glut.h"
|
#include "imgui_impl_glut.h"
|
||||||
#define GL_SILENCE_DEPRECATION
|
#define GL_SILENCE_DEPRECATION
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@@ -190,6 +195,8 @@ void ImGui_ImplGLUT_InstallFuncs()
|
|||||||
|
|
||||||
void ImGui_ImplGLUT_Shutdown()
|
void ImGui_ImplGLUT_Shutdown()
|
||||||
{
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.BackendPlatformName = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGLUT_NewFrame()
|
void ImGui_ImplGLUT_NewFrame()
|
||||||
@@ -202,9 +209,6 @@ void ImGui_ImplGLUT_NewFrame()
|
|||||||
delta_time_ms = 1;
|
delta_time_ms = 1;
|
||||||
io.DeltaTime = delta_time_ms / 1000.0f;
|
io.DeltaTime = delta_time_ms / 1000.0f;
|
||||||
g_Time = current_time;
|
g_Time = current_time;
|
||||||
|
|
||||||
// Start the frame
|
|
||||||
ImGui::NewFrame();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplGLUT_UpdateKeyModifiers()
|
static void ImGui_ImplGLUT_UpdateKeyModifiers()
|
||||||
@@ -298,3 +302,7 @@ void ImGui_ImplGLUT_MotionFunc(int x, int y)
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.AddMousePosEvent((float)x, (float)y);
|
io.AddMousePosEvent((float)x, (float)y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// Issues:
|
// Missing features:
|
||||||
// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
|
// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
|
||||||
// [ ] Platform: Missing horizontal mouse wheel support.
|
// [ ] Platform: Missing horizontal mouse wheel support.
|
||||||
// [ ] Platform: Missing mouse cursor shape/visibility support.
|
// [ ] Platform: Missing mouse cursor shape/visibility support.
|
||||||
@@ -16,10 +16,14 @@
|
|||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplGLUT_Init();
|
IMGUI_IMPL_API bool ImGui_ImplGLUT_Init();
|
||||||
@@ -29,7 +33,7 @@ IMGUI_IMPL_API void ImGui_ImplGLUT_NewFrame();
|
|||||||
|
|
||||||
// You can call ImGui_ImplGLUT_InstallFuncs() to get all those functions installed automatically,
|
// You can call ImGui_ImplGLUT_InstallFuncs() to get all those functions installed automatically,
|
||||||
// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
|
// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
|
||||||
//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
|
//------------------------------------ GLUT name ---------------------------------------------- Decent Name ---------
|
||||||
IMGUI_IMPL_API void ImGui_ImplGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
|
IMGUI_IMPL_API void ImGui_ImplGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
|
||||||
IMGUI_IMPL_API void ImGui_ImplGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
|
IMGUI_IMPL_API void ImGui_ImplGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
|
||||||
IMGUI_IMPL_API void ImGui_ImplGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
|
IMGUI_IMPL_API void ImGui_ImplGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
|
||||||
@@ -38,3 +42,5 @@ IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int
|
|||||||
IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
|
IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
|
||||||
IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
|
IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
|
||||||
IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
|
IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -4,13 +4,18 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// ObjC API
|
// ObjC API
|
||||||
@@ -62,3 +67,7 @@ IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -4,14 +4,19 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Metal: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2022-08-23: Metal: Update deprecated property 'sampleCount'->'rasterSampleCount'.
|
// 2022-08-23: Metal: Update deprecated property 'sampleCount'->'rasterSampleCount'.
|
||||||
// 2022-07-05: Metal: Add dispatch synchronization.
|
// 2022-07-05: Metal: Add dispatch synchronization.
|
||||||
// 2022-06-30: Metal: Use __bridge for ARC based systems.
|
// 2022-06-30: Metal: Use __bridge for ARC based systems.
|
||||||
@@ -30,10 +35,17 @@
|
|||||||
// 2018-07-05: Metal: Added new Metal backend implementation.
|
// 2018-07-05: Metal: Added new Metal backend implementation.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_metal.h"
|
#include "imgui_impl_metal.h"
|
||||||
#import <time.h>
|
#import <time.h>
|
||||||
#import <Metal/Metal.h>
|
#import <Metal/Metal.h>
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplMetal_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplMetal_ShutdownPlatformInterface();
|
||||||
|
static void ImGui_ImplMetal_CreateDeviceObjectsForPlatformWindows();
|
||||||
|
static void ImGui_ImplMetal_InvalidateDeviceObjectsForPlatformWindows();
|
||||||
|
|
||||||
#pragma mark - Support classes
|
#pragma mark - Support classes
|
||||||
|
|
||||||
// A wrapper around a MTLBuffer object that knows the last time it was reused
|
// A wrapper around a MTLBuffer object that knows the last time it was reused
|
||||||
@@ -126,17 +138,29 @@ bool ImGui_ImplMetal_Init(id<MTLDevice> device)
|
|||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_metal";
|
io.BackendRendererName = "imgui_impl_metal";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||||
|
|
||||||
bd->SharedMetalContext = [[MetalContext alloc] init];
|
bd->SharedMetalContext = [[MetalContext alloc] init];
|
||||||
bd->SharedMetalContext.device = device;
|
bd->SharedMetalContext.device = device;
|
||||||
|
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplMetal_InitPlatformInterface();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplMetal_Shutdown()
|
void ImGui_ImplMetal_Shutdown()
|
||||||
{
|
{
|
||||||
|
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
|
||||||
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
|
ImGui_ImplMetal_ShutdownPlatformInterface();
|
||||||
ImGui_ImplMetal_DestroyDeviceObjects();
|
ImGui_ImplMetal_DestroyDeviceObjects();
|
||||||
ImGui_ImplMetal_DestroyBackendData();
|
ImGui_ImplMetal_DestroyBackendData();
|
||||||
|
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.BackendRendererName = nullptr;
|
||||||
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor)
|
void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor)
|
||||||
@@ -354,6 +378,7 @@ bool ImGui_ImplMetal_CreateDeviceObjects(id<MTLDevice> device)
|
|||||||
depthStencilDescriptor.depthWriteEnabled = NO;
|
depthStencilDescriptor.depthWriteEnabled = NO;
|
||||||
depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways;
|
depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways;
|
||||||
bd->SharedMetalContext.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor];
|
bd->SharedMetalContext.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor];
|
||||||
|
ImGui_ImplMetal_CreateDeviceObjectsForPlatformWindows();
|
||||||
ImGui_ImplMetal_CreateFontsTexture(device);
|
ImGui_ImplMetal_CreateFontsTexture(device);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -363,9 +388,155 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|||||||
{
|
{
|
||||||
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
|
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
|
||||||
ImGui_ImplMetal_DestroyFontsTexture();
|
ImGui_ImplMetal_DestroyFontsTexture();
|
||||||
|
ImGui_ImplMetal_InvalidateDeviceObjectsForPlatformWindows();
|
||||||
[bd->SharedMetalContext.renderPipelineStateCache removeAllObjects];
|
[bd->SharedMetalContext.renderPipelineStateCache removeAllObjects];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - Multi-viewport support
|
||||||
|
|
||||||
|
#import <QuartzCore/CAMetalLayer.h>
|
||||||
|
|
||||||
|
#if TARGET_OS_OSX
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
struct ImGuiViewportDataMetal
|
||||||
|
{
|
||||||
|
CAMetalLayer* MetalLayer;
|
||||||
|
id<MTLCommandQueue> CommandQueue;
|
||||||
|
MTLRenderPassDescriptor* RenderPassDescriptor;
|
||||||
|
void* Handle = nullptr;
|
||||||
|
bool FirstFrame = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplMetal_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
|
||||||
|
ImGuiViewportDataMetal* data = IM_NEW(ImGuiViewportDataMetal)();
|
||||||
|
viewport->RendererUserData = data;
|
||||||
|
|
||||||
|
// PlatformHandleRaw should always be a NSWindow*, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
|
||||||
|
// Some back-ends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the NSWindow*.
|
||||||
|
void* handle = viewport->PlatformHandleRaw ? viewport->PlatformHandleRaw : viewport->PlatformHandle;
|
||||||
|
IM_ASSERT(handle != nullptr);
|
||||||
|
|
||||||
|
id<MTLDevice> device = bd->SharedMetalContext.device;
|
||||||
|
CAMetalLayer* layer = [CAMetalLayer layer];
|
||||||
|
layer.device = device;
|
||||||
|
layer.framebufferOnly = YES;
|
||||||
|
layer.pixelFormat = bd->SharedMetalContext.framebufferDescriptor.colorPixelFormat;
|
||||||
|
#if TARGET_OS_OSX
|
||||||
|
NSWindow* window = (__bridge NSWindow*)handle;
|
||||||
|
NSView* view = window.contentView;
|
||||||
|
view.layer = layer;
|
||||||
|
view.wantsLayer = YES;
|
||||||
|
#endif
|
||||||
|
data->MetalLayer = layer;
|
||||||
|
data->CommandQueue = [device newCommandQueue];
|
||||||
|
data->RenderPassDescriptor = [[MTLRenderPassDescriptor alloc] init];
|
||||||
|
data->Handle = handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplMetal_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
// The main viewport (owned by the application) will always have RendererUserData == 0 since we didn't create the data for it.
|
||||||
|
if (ImGuiViewportDataMetal* data = (ImGuiViewportDataMetal*)viewport->RendererUserData)
|
||||||
|
IM_DELETE(data);
|
||||||
|
viewport->RendererUserData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static CGSize MakeScaledSize(CGSize size, CGFloat scale)
|
||||||
|
{
|
||||||
|
return CGSizeMake(size.width * scale, size.height * scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplMetal_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataMetal* data = (ImGuiViewportDataMetal*)viewport->RendererUserData;
|
||||||
|
data->MetalLayer.drawableSize = MakeScaledSize(CGSizeMake(size.x, size.y), viewport->DpiScale);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplMetal_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataMetal* data = (ImGuiViewportDataMetal*)viewport->RendererUserData;
|
||||||
|
|
||||||
|
#if TARGET_OS_OSX
|
||||||
|
void* handle = viewport->PlatformHandleRaw ? viewport->PlatformHandleRaw : viewport->PlatformHandle;
|
||||||
|
NSWindow* window = (__bridge NSWindow*)handle;
|
||||||
|
|
||||||
|
// Always render the first frame, regardless of occlusionState, to avoid an initial flicker
|
||||||
|
if ((window.occlusionState & NSWindowOcclusionStateVisible) == 0 && !data->FirstFrame)
|
||||||
|
{
|
||||||
|
// Do not render windows which are completely occluded. Calling -[CAMetalLayer nextDrawable] will hang for
|
||||||
|
// approximately 1 second if the Metal layer is completely occluded.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data->FirstFrame = false;
|
||||||
|
|
||||||
|
viewport->DpiScale = (float)window.backingScaleFactor;
|
||||||
|
if (data->MetalLayer.contentsScale != viewport->DpiScale)
|
||||||
|
{
|
||||||
|
data->MetalLayer.contentsScale = viewport->DpiScale;
|
||||||
|
data->MetalLayer.drawableSize = MakeScaledSize(window.frame.size, viewport->DpiScale);
|
||||||
|
}
|
||||||
|
viewport->DrawData->FramebufferScale = ImVec2(viewport->DpiScale, viewport->DpiScale);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
id <CAMetalDrawable> drawable = [data->MetalLayer nextDrawable];
|
||||||
|
if (drawable == nil)
|
||||||
|
return;
|
||||||
|
|
||||||
|
MTLRenderPassDescriptor* renderPassDescriptor = data->RenderPassDescriptor;
|
||||||
|
renderPassDescriptor.colorAttachments[0].texture = drawable.texture;
|
||||||
|
renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(0, 0, 0, 0);
|
||||||
|
if ((viewport->Flags & ImGuiViewportFlags_NoRendererClear) == 0)
|
||||||
|
renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear;
|
||||||
|
|
||||||
|
id <MTLCommandBuffer> commandBuffer = [data->CommandQueue commandBuffer];
|
||||||
|
id <MTLRenderCommandEncoder> renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];
|
||||||
|
ImGui_ImplMetal_RenderDrawData(viewport->DrawData, commandBuffer, renderEncoder);
|
||||||
|
[renderEncoder endEncoding];
|
||||||
|
|
||||||
|
[commandBuffer presentDrawable:drawable];
|
||||||
|
[commandBuffer commit];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplMetal_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_CreateWindow = ImGui_ImplMetal_CreateWindow;
|
||||||
|
platform_io.Renderer_DestroyWindow = ImGui_ImplMetal_DestroyWindow;
|
||||||
|
platform_io.Renderer_SetWindowSize = ImGui_ImplMetal_SetWindowSize;
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplMetal_RenderWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplMetal_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplMetal_CreateDeviceObjectsForPlatformWindows()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
for (int i = 1; i < platform_io.Viewports.Size; i++)
|
||||||
|
if (!platform_io.Viewports[i]->RendererUserData)
|
||||||
|
ImGui_ImplMetal_CreateWindow(platform_io.Viewports[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplMetal_InvalidateDeviceObjectsForPlatformWindows()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
for (int i = 1; i < platform_io.Viewports.Size; i++)
|
||||||
|
if (platform_io.Viewports[i]->RendererUserData)
|
||||||
|
ImGui_ImplMetal_DestroyWindow(platform_io.Viewports[i]);
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - MetalBuffer implementation
|
#pragma mark - MetalBuffer implementation
|
||||||
|
|
||||||
@implementation MetalBuffer
|
@implementation MetalBuffer
|
||||||
@@ -536,13 +707,13 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|||||||
}
|
}
|
||||||
|
|
||||||
MTLVertexDescriptor* vertexDescriptor = [MTLVertexDescriptor vertexDescriptor];
|
MTLVertexDescriptor* vertexDescriptor = [MTLVertexDescriptor vertexDescriptor];
|
||||||
vertexDescriptor.attributes[0].offset = IM_OFFSETOF(ImDrawVert, pos);
|
vertexDescriptor.attributes[0].offset = offsetof(ImDrawVert, pos);
|
||||||
vertexDescriptor.attributes[0].format = MTLVertexFormatFloat2; // position
|
vertexDescriptor.attributes[0].format = MTLVertexFormatFloat2; // position
|
||||||
vertexDescriptor.attributes[0].bufferIndex = 0;
|
vertexDescriptor.attributes[0].bufferIndex = 0;
|
||||||
vertexDescriptor.attributes[1].offset = IM_OFFSETOF(ImDrawVert, uv);
|
vertexDescriptor.attributes[1].offset = offsetof(ImDrawVert, uv);
|
||||||
vertexDescriptor.attributes[1].format = MTLVertexFormatFloat2; // texCoords
|
vertexDescriptor.attributes[1].format = MTLVertexFormatFloat2; // texCoords
|
||||||
vertexDescriptor.attributes[1].bufferIndex = 0;
|
vertexDescriptor.attributes[1].bufferIndex = 0;
|
||||||
vertexDescriptor.attributes[2].offset = IM_OFFSETOF(ImDrawVert, col);
|
vertexDescriptor.attributes[2].offset = offsetof(ImDrawVert, col);
|
||||||
vertexDescriptor.attributes[2].format = MTLVertexFormatUChar4; // color
|
vertexDescriptor.attributes[2].format = MTLVertexFormatUChar4; // color
|
||||||
vertexDescriptor.attributes[2].bufferIndex = 0;
|
vertexDescriptor.attributes[2].bufferIndex = 0;
|
||||||
vertexDescriptor.layouts[0].stepRate = 1;
|
vertexDescriptor.layouts[0].stepRate = 1;
|
||||||
@@ -573,3 +744,7 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -3,11 +3,15 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
// **Prefer using the code in imgui_impl_opengl3.cpp**
|
// **Prefer using the code in imgui_impl_opengl3.cpp**
|
||||||
@@ -19,8 +23,9 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2021-12-08: OpenGL: Fixed mishandling of the the ImDrawCmd::IdxOffset field! This is an old bug but it never had an effect until some internal rendering changes in 1.86.
|
// 2021-12-08: OpenGL: Fixed mishandling of the ImDrawCmd::IdxOffset field! This is an old bug but it never had an effect until some internal rendering changes in 1.86.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2021-05-19: OpenGL: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
// 2021-05-19: OpenGL: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
||||||
// 2021-01-03: OpenGL: Backup, setup and restore GL_SHADE_MODEL state, disable GL_STENCIL_TEST and disable GL_NORMAL_ARRAY client state to increase compatibility with legacy OpenGL applications.
|
// 2021-01-03: OpenGL: Backup, setup and restore GL_SHADE_MODEL state, disable GL_STENCIL_TEST and disable GL_NORMAL_ARRAY client state to increase compatibility with legacy OpenGL applications.
|
||||||
@@ -37,12 +42,9 @@
|
|||||||
// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
|
// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_opengl2.h"
|
#include "imgui_impl_opengl2.h"
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
|
||||||
#include <stddef.h> // intptr_t
|
|
||||||
#else
|
|
||||||
#include <stdint.h> // intptr_t
|
#include <stdint.h> // intptr_t
|
||||||
#endif
|
|
||||||
|
|
||||||
// Clang/GCC warnings with -Weverything
|
// Clang/GCC warnings with -Weverything
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
@@ -79,6 +81,10 @@ static ImGui_ImplOpenGL2_Data* ImGui_ImplOpenGL2_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL2_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL2_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplOpenGL2_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplOpenGL2_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
bool ImGui_ImplOpenGL2_Init()
|
bool ImGui_ImplOpenGL2_Init()
|
||||||
{
|
{
|
||||||
@@ -89,6 +95,10 @@ bool ImGui_ImplOpenGL2_Init()
|
|||||||
ImGui_ImplOpenGL2_Data* bd = IM_NEW(ImGui_ImplOpenGL2_Data)();
|
ImGui_ImplOpenGL2_Data* bd = IM_NEW(ImGui_ImplOpenGL2_Data)();
|
||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_opengl2";
|
io.BackendRendererName = "imgui_impl_opengl2";
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||||
|
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplOpenGL2_InitPlatformInterface();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -99,9 +109,11 @@ void ImGui_ImplOpenGL2_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplOpenGL2_ShutdownPlatformInterface();
|
||||||
ImGui_ImplOpenGL2_DestroyDeviceObjects();
|
ImGui_ImplOpenGL2_DestroyDeviceObjects();
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasViewports;
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,9 +203,9 @@ void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data)
|
|||||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||||
const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
|
const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
|
||||||
const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
|
const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
|
||||||
glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, pos)));
|
glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + offsetof(ImDrawVert, pos)));
|
||||||
glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, uv)));
|
glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + offsetof(ImDrawVert, uv)));
|
||||||
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, col)));
|
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + offsetof(ImDrawVert, col)));
|
||||||
|
|
||||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
@@ -293,6 +305,39 @@ void ImGui_ImplOpenGL2_DestroyDeviceObjects()
|
|||||||
ImGui_ImplOpenGL2_DestroyFontsTexture();
|
ImGui_ImplOpenGL2_DestroyFontsTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void ImGui_ImplOpenGL2_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
|
{
|
||||||
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
ImGui_ImplOpenGL2_RenderDrawData(viewport->DrawData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOpenGL2_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplOpenGL2_RenderWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOpenGL2_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -3,11 +3,15 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
// **Prefer using the code in imgui_impl_opengl3.cpp**
|
// **Prefer using the code in imgui_impl_opengl3.cpp**
|
||||||
@@ -19,6 +23,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL2_Init();
|
IMGUI_IMPL_API bool ImGui_ImplOpenGL2_Init();
|
||||||
IMGUI_IMPL_API void ImGui_ImplOpenGL2_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplOpenGL2_Shutdown();
|
||||||
@@ -30,3 +35,5 @@ IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateFontsTexture();
|
|||||||
IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyFontsTexture();
|
IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyFontsTexture();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateDeviceObjects();
|
||||||
IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -5,15 +5,31 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [x] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
|
// About WebGL/ES:
|
||||||
|
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
||||||
|
// - This is done automatically on iOS, Android and Emscripten targets.
|
||||||
|
// - For other targets, the define needs to be visible from the imgui_impl_opengl3.cpp compilation unit. If unsure, define globally or in imconfig.h.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2024-01-09: OpenGL: Update GL3W based imgui_impl_opengl3_loader.h to load "libGL.so" and variants, fixing regression on distros missing a symlink.
|
||||||
|
// 2023-11-08: OpenGL: Update GL3W based imgui_impl_opengl3_loader.h to load "libGL.so" instead of "libGL.so.1", accommodating for NetBSD systems having only "libGL.so.3" available. (#6983)
|
||||||
|
// 2023-10-05: OpenGL: Rename symbols in our internal loader so that LTO compilation with another copy of gl3w is possible. (#6875, #6668, #4445)
|
||||||
|
// 2023-06-20: OpenGL: Fixed erroneous use glGetIntegerv(GL_CONTEXT_PROFILE_MASK) on contexts lower than 3.2. (#6539, #6333)
|
||||||
|
// 2023-05-09: OpenGL: Support for glBindSampler() backup/restore on ES3. (#6375)
|
||||||
|
// 2023-04-18: OpenGL: Restore front and back polygon mode separately when supported by context. (#6333)
|
||||||
// 2023-03-23: OpenGL: Properly restoring "no shader program bound" if it was the case prior to running the rendering function. (#6267, #6220, #6224)
|
// 2023-03-23: OpenGL: Properly restoring "no shader program bound" if it was the case prior to running the rendering function. (#6267, #6220, #6224)
|
||||||
// 2023-03-15: OpenGL: Fixed GL loader crash when GL_VERSION returns NULL. (#6154, #4445, #3530)
|
// 2023-03-15: OpenGL: Fixed GL loader crash when GL_VERSION returns NULL. (#6154, #4445, #3530)
|
||||||
// 2023-03-06: OpenGL: Fixed restoration of a potentially deleted OpenGL program, by calling glIsProgram(). (#6220, #6224)
|
// 2023-03-06: OpenGL: Fixed restoration of a potentially deleted OpenGL program, by calling glIsProgram(). (#6220, #6224)
|
||||||
@@ -96,13 +112,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_opengl3.h"
|
#include "imgui_impl_opengl3.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
|
||||||
#include <stddef.h> // intptr_t
|
|
||||||
#else
|
|
||||||
#include <stdint.h> // intptr_t
|
#include <stdint.h> // intptr_t
|
||||||
#endif
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
#include <TargetConditionals.h>
|
#include <TargetConditionals.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -165,19 +178,15 @@
|
|||||||
#define GL_VERTEX_ARRAY_BINDING GL_VERTEX_ARRAY_BINDING_OES
|
#define GL_VERTEX_ARRAY_BINDING GL_VERTEX_ARRAY_BINDING_OES
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Desktop GL 2.0+ has glPolygonMode() which GL ES and WebGL don't have.
|
// Desktop GL 2.0+ has extension and glPolygonMode() which GL ES and WebGL don't have..
|
||||||
#ifdef GL_POLYGON_MODE
|
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3)
|
||||||
#define IMGUI_IMPL_HAS_POLYGON_MODE
|
#define IMGUI_IMPL_OPENGL_HAS_EXTENSIONS // has glGetIntegerv(GL_NUM_EXTENSIONS)
|
||||||
|
#define IMGUI_IMPL_OPENGL_HAS_POLYGON_MODE // has glPolygonMode()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
|
// Desktop GL 2.1+ and GL ES 3.0+ have glBindBuffer() with GL_PIXEL_UNPACK_BUFFER target.
|
||||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_2)
|
#if !defined(IMGUI_IMPL_OPENGL_ES2)
|
||||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_BUFFER_PIXEL_UNPACK
|
||||||
#endif
|
|
||||||
|
|
||||||
// Desktop GL 3.3+ has glBindSampler()
|
|
||||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_3)
|
|
||||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Desktop GL 3.1+ has GL_PRIMITIVE_RESTART state
|
// Desktop GL 3.1+ has GL_PRIMITIVE_RESTART state
|
||||||
@@ -185,9 +194,14 @@
|
|||||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART
|
#define IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Desktop GL use extension detection
|
// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
|
||||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3)
|
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_2)
|
||||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_EXTENSIONS
|
#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Desktop GL 3.3+ and GL ES 3.0+ have glBindSampler()
|
||||||
|
#if !defined(IMGUI_IMPL_OPENGL_ES2) && (defined(IMGUI_IMPL_OPENGL_ES3) || defined(GL_VERSION_3_3))
|
||||||
|
#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// [Debugging]
|
// [Debugging]
|
||||||
@@ -204,6 +218,10 @@ struct ImGui_ImplOpenGL3_Data
|
|||||||
{
|
{
|
||||||
GLuint GlVersion; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries (e.g. 320 for GL 3.2)
|
GLuint GlVersion; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries (e.g. 320 for GL 3.2)
|
||||||
char GlslVersionString[32]; // Specified by user or detected based on compile time GL settings.
|
char GlslVersionString[32]; // Specified by user or detected based on compile time GL settings.
|
||||||
|
bool GlProfileIsES2;
|
||||||
|
bool GlProfileIsES3;
|
||||||
|
bool GlProfileIsCompat;
|
||||||
|
GLint GlProfileMask;
|
||||||
GLuint FontTexture;
|
GLuint FontTexture;
|
||||||
GLuint ShaderHandle;
|
GLuint ShaderHandle;
|
||||||
GLint AttribLocationTex; // Uniforms location
|
GLint AttribLocationTex; // Uniforms location
|
||||||
@@ -227,6 +245,10 @@ static ImGui_ImplOpenGL3_Data* ImGui_ImplOpenGL3_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplOpenGL3_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplOpenGL3_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// OpenGL vertex attribute state (for ES 1.0 and ES 2.0 only)
|
// OpenGL vertex attribute state (for ES 1.0 and ES 2.0 only)
|
||||||
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||||
struct ImGui_ImplOpenGL3_VtxAttribState
|
struct ImGui_ImplOpenGL3_VtxAttribState
|
||||||
@@ -272,7 +294,12 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
io.BackendRendererName = "imgui_impl_opengl3";
|
io.BackendRendererName = "imgui_impl_opengl3";
|
||||||
|
|
||||||
// Query for GL version (e.g. 320 for GL 3.2)
|
// Query for GL version (e.g. 320 for GL 3.2)
|
||||||
#if !defined(IMGUI_IMPL_OPENGL_ES2)
|
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||||
|
// GLES 2
|
||||||
|
bd->GlVersion = 200;
|
||||||
|
bd->GlProfileIsES2 = true;
|
||||||
|
#else
|
||||||
|
// Desktop or GLES 3
|
||||||
GLint major = 0;
|
GLint major = 0;
|
||||||
GLint minor = 0;
|
GLint minor = 0;
|
||||||
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
||||||
@@ -284,6 +311,15 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
sscanf(gl_version, "%d.%d", &major, &minor);
|
sscanf(gl_version, "%d.%d", &major, &minor);
|
||||||
}
|
}
|
||||||
bd->GlVersion = (GLuint)(major * 100 + minor * 10);
|
bd->GlVersion = (GLuint)(major * 100 + minor * 10);
|
||||||
|
#if defined(GL_CONTEXT_PROFILE_MASK)
|
||||||
|
if (bd->GlVersion >= 320)
|
||||||
|
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &bd->GlProfileMask);
|
||||||
|
bd->GlProfileIsCompat = (bd->GlProfileMask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(IMGUI_IMPL_OPENGL_ES3)
|
||||||
|
bd->GlProfileIsES3 = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
bd->UseBufferSubData = false;
|
bd->UseBufferSubData = false;
|
||||||
/*
|
/*
|
||||||
@@ -294,18 +330,17 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
bd->UseBufferSubData = true;
|
bd->UseBufferSubData = true;
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
#else
|
|
||||||
bd->GlVersion = 200; // GLES 2
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_DEBUG
|
#ifdef IMGUI_IMPL_OPENGL_DEBUG
|
||||||
printf("GL_MAJOR_VERSION = %d\nGL_MINOR_VERSION = %d\nGL_VENDOR = '%s'\nGL_RENDERER = '%s'\n", major, minor, (const char*)glGetString(GL_VENDOR), (const char*)glGetString(GL_RENDERER)); // [DEBUG]
|
printf("GlVersion = %d\nGlProfileIsCompat = %d\nGlProfileMask = 0x%X\nGlProfileIsES2 = %d, GlProfileIsES3 = %d\nGL_VENDOR = '%s'\nGL_RENDERER = '%s'\n", bd->GlVersion, bd->GlProfileIsCompat, bd->GlProfileMask, bd->GlProfileIsES2, bd->GlProfileIsES3, (const char*)glGetString(GL_VENDOR), (const char*)glGetString(GL_RENDERER)); // [DEBUG]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||||
if (bd->GlVersion >= 320)
|
if (bd->GlVersion >= 320)
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
#endif
|
#endif
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||||
|
|
||||||
// Store GLSL version string so we can refer to it later in case we recreate shaders.
|
// Store GLSL version string so we can refer to it later in case we recreate shaders.
|
||||||
// Note: GLSL version is NOT the same as GL version. Leave this to nullptr if unsure.
|
// Note: GLSL version is NOT the same as GL version. Leave this to nullptr if unsure.
|
||||||
@@ -332,7 +367,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
|
|
||||||
// Detect extensions we support
|
// Detect extensions we support
|
||||||
bd->HasClipOrigin = (bd->GlVersion >= 450);
|
bd->HasClipOrigin = (bd->GlVersion >= 450);
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_EXTENSIONS
|
#ifdef IMGUI_IMPL_OPENGL_HAS_EXTENSIONS
|
||||||
GLint num_extensions = 0;
|
GLint num_extensions = 0;
|
||||||
glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
|
glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
|
||||||
for (GLint i = 0; i < num_extensions; i++)
|
for (GLint i = 0; i < num_extensions; i++)
|
||||||
@@ -343,6 +378,9 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplOpenGL3_InitPlatformInterface();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,9 +390,11 @@ void ImGui_ImplOpenGL3_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplOpenGL3_ShutdownPlatformInterface();
|
||||||
ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,7 +423,7 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
|
|||||||
if (bd->GlVersion >= 310)
|
if (bd->GlVersion >= 310)
|
||||||
glDisable(GL_PRIMITIVE_RESTART);
|
glDisable(GL_PRIMITIVE_RESTART);
|
||||||
#endif
|
#endif
|
||||||
#ifdef IMGUI_IMPL_HAS_POLYGON_MODE
|
#ifdef IMGUI_IMPL_OPENGL_HAS_POLYGON_MODE
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -420,8 +460,8 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
|
|||||||
glUniformMatrix4fv(bd->AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
glUniformMatrix4fv(bd->AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
if (bd->GlVersion >= 330)
|
if (bd->GlVersion >= 330 || bd->GlProfileIsES3)
|
||||||
glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.
|
glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 and GL ES 3.0 may set that otherwise.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
(void)vertex_array_object;
|
(void)vertex_array_object;
|
||||||
@@ -435,9 +475,9 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
|
|||||||
GL_CALL(glEnableVertexAttribArray(bd->AttribLocationVtxPos));
|
GL_CALL(glEnableVertexAttribArray(bd->AttribLocationVtxPos));
|
||||||
GL_CALL(glEnableVertexAttribArray(bd->AttribLocationVtxUV));
|
GL_CALL(glEnableVertexAttribArray(bd->AttribLocationVtxUV));
|
||||||
GL_CALL(glEnableVertexAttribArray(bd->AttribLocationVtxColor));
|
GL_CALL(glEnableVertexAttribArray(bd->AttribLocationVtxColor));
|
||||||
GL_CALL(glVertexAttribPointer(bd->AttribLocationVtxPos, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, pos)));
|
GL_CALL(glVertexAttribPointer(bd->AttribLocationVtxPos, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)offsetof(ImDrawVert, pos)));
|
||||||
GL_CALL(glVertexAttribPointer(bd->AttribLocationVtxUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv)));
|
GL_CALL(glVertexAttribPointer(bd->AttribLocationVtxUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)offsetof(ImDrawVert, uv)));
|
||||||
GL_CALL(glVertexAttribPointer(bd->AttribLocationVtxColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col)));
|
GL_CALL(glVertexAttribPointer(bd->AttribLocationVtxColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)offsetof(ImDrawVert, col)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenGL3 Render function.
|
// OpenGL3 Render function.
|
||||||
@@ -459,7 +499,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program);
|
GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program);
|
||||||
GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture);
|
GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture);
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
GLuint last_sampler; if (bd->GlVersion >= 330) { glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler); } else { last_sampler = 0; }
|
GLuint last_sampler; if (bd->GlVersion >= 330 || bd->GlProfileIsES3) { glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler); } else { last_sampler = 0; }
|
||||||
#endif
|
#endif
|
||||||
GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer);
|
GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer);
|
||||||
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||||
@@ -472,7 +512,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||||
GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object);
|
GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object);
|
||||||
#endif
|
#endif
|
||||||
#ifdef IMGUI_IMPL_HAS_POLYGON_MODE
|
#ifdef IMGUI_IMPL_OPENGL_HAS_POLYGON_MODE
|
||||||
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
|
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
|
||||||
#endif
|
#endif
|
||||||
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
|
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
|
||||||
@@ -586,7 +626,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
if (last_program == 0 || glIsProgram(last_program)) glUseProgram(last_program);
|
if (last_program == 0 || glIsProgram(last_program)) glUseProgram(last_program);
|
||||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
if (bd->GlVersion >= 330)
|
if (bd->GlVersion >= 330 || bd->GlProfileIsES3)
|
||||||
glBindSampler(0, last_sampler);
|
glBindSampler(0, last_sampler);
|
||||||
#endif
|
#endif
|
||||||
glActiveTexture(last_active_texture);
|
glActiveTexture(last_active_texture);
|
||||||
@@ -611,9 +651,19 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
if (bd->GlVersion >= 310) { if (last_enable_primitive_restart) glEnable(GL_PRIMITIVE_RESTART); else glDisable(GL_PRIMITIVE_RESTART); }
|
if (bd->GlVersion >= 310) { if (last_enable_primitive_restart) glEnable(GL_PRIMITIVE_RESTART); else glDisable(GL_PRIMITIVE_RESTART); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_HAS_POLYGON_MODE
|
#ifdef IMGUI_IMPL_OPENGL_HAS_POLYGON_MODE
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
|
// Desktop OpenGL 3.0 and OpenGL 3.1 had separate polygon draw modes for front-facing and back-facing faces of polygons
|
||||||
#endif
|
if (bd->GlVersion <= 310 || bd->GlProfileIsCompat)
|
||||||
|
{
|
||||||
|
glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]);
|
||||||
|
glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
|
||||||
|
}
|
||||||
|
#endif // IMGUI_IMPL_OPENGL_HAS_POLYGON_MODE
|
||||||
|
|
||||||
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]);
|
||||||
(void)bd; // Not all compilation paths use this
|
(void)bd; // Not all compilation paths use this
|
||||||
@@ -709,6 +759,10 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects()
|
|||||||
GLint last_texture, last_array_buffer;
|
GLint last_texture, last_array_buffer;
|
||||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
||||||
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_BUFFER_PIXEL_UNPACK
|
||||||
|
GLint last_pixel_unpack_buffer;
|
||||||
|
if (bd->GlVersion >= 210) { glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &last_pixel_unpack_buffer); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); }
|
||||||
|
#endif
|
||||||
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||||
GLint last_vertex_array;
|
GLint last_vertex_array;
|
||||||
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
||||||
@@ -882,6 +936,9 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects()
|
|||||||
// Restore modified GL state
|
// Restore modified GL state
|
||||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||||
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_BUFFER_PIXEL_UNPACK
|
||||||
|
if (bd->GlVersion >= 210) { glBindBuffer(GL_PIXEL_UNPACK_BUFFER, last_pixel_unpack_buffer); }
|
||||||
|
#endif
|
||||||
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||||
glBindVertexArray(last_vertex_array);
|
glBindVertexArray(last_vertex_array);
|
||||||
#endif
|
#endif
|
||||||
@@ -898,9 +955,41 @@ void ImGui_ImplOpenGL3_DestroyDeviceObjects()
|
|||||||
ImGui_ImplOpenGL3_DestroyFontsTexture();
|
ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void ImGui_ImplOpenGL3_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
|
{
|
||||||
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
ImGui_ImplOpenGL3_RenderDrawData(viewport->DrawData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOpenGL3_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplOpenGL3_RenderWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOpenGL3_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -5,12 +5,21 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [x] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
|
// About WebGL/ES:
|
||||||
|
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
||||||
|
// - This is done automatically on iOS, Android and Emscripten targets.
|
||||||
|
// - For other targets, the define needs to be visible from the imgui_impl_opengl3.cpp compilation unit. If unsure, define globally or in imconfig.h.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// About GLSL version:
|
// About GLSL version:
|
||||||
// The 'glsl_version' initialization parameter should be nullptr (default) or a "#version XXX" string.
|
// The 'glsl_version' initialization parameter should be nullptr (default) or a "#version XXX" string.
|
||||||
@@ -19,6 +28,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
// Backend API
|
// Backend API
|
||||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = nullptr);
|
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = nullptr);
|
||||||
@@ -53,3 +63,5 @@ IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -154,6 +154,8 @@ typedef khronos_uint8_t GLubyte;
|
|||||||
#define GL_ONE 1
|
#define GL_ONE 1
|
||||||
#define GL_SRC_ALPHA 0x0302
|
#define GL_SRC_ALPHA 0x0302
|
||||||
#define GL_ONE_MINUS_SRC_ALPHA 0x0303
|
#define GL_ONE_MINUS_SRC_ALPHA 0x0303
|
||||||
|
#define GL_FRONT 0x0404
|
||||||
|
#define GL_BACK 0x0405
|
||||||
#define GL_FRONT_AND_BACK 0x0408
|
#define GL_FRONT_AND_BACK 0x0408
|
||||||
#define GL_POLYGON_MODE 0x0B40
|
#define GL_POLYGON_MODE 0x0B40
|
||||||
#define GL_CULL_FACE 0x0B44
|
#define GL_CULL_FACE 0x0B44
|
||||||
@@ -258,6 +260,8 @@ typedef khronos_intptr_t GLintptr;
|
|||||||
#define GL_ARRAY_BUFFER_BINDING 0x8894
|
#define GL_ARRAY_BUFFER_BINDING 0x8894
|
||||||
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
|
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
|
||||||
#define GL_STREAM_DRAW 0x88E0
|
#define GL_STREAM_DRAW 0x88E0
|
||||||
|
#define GL_PIXEL_UNPACK_BUFFER 0x88EC
|
||||||
|
#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
|
||||||
typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
|
typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
|
||||||
typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers);
|
typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers);
|
||||||
typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
|
typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
|
||||||
@@ -373,6 +377,8 @@ GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays);
|
|||||||
typedef struct __GLsync *GLsync;
|
typedef struct __GLsync *GLsync;
|
||||||
typedef khronos_uint64_t GLuint64;
|
typedef khronos_uint64_t GLuint64;
|
||||||
typedef khronos_int64_t GLint64;
|
typedef khronos_int64_t GLint64;
|
||||||
|
#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
|
||||||
|
#define GL_CONTEXT_PROFILE_MASK 0x9126
|
||||||
typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex);
|
typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex);
|
||||||
typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data);
|
typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data);
|
||||||
#ifdef GL_GLEXT_PROTOTYPES
|
#ifdef GL_GLEXT_PROTOTYPES
|
||||||
@@ -463,7 +469,7 @@ GL3W_API int imgl3wIsSupported(int major, int minor);
|
|||||||
GL3W_API GL3WglProc imgl3wGetProcAddress(const char *proc);
|
GL3W_API GL3WglProc imgl3wGetProcAddress(const char *proc);
|
||||||
|
|
||||||
/* gl3w internal state */
|
/* gl3w internal state */
|
||||||
union GL3WProcs {
|
union ImGL3WProcs {
|
||||||
GL3WglProc ptr[59];
|
GL3WglProc ptr[59];
|
||||||
struct {
|
struct {
|
||||||
PFNGLACTIVETEXTUREPROC ActiveTexture;
|
PFNGLACTIVETEXTUREPROC ActiveTexture;
|
||||||
@@ -528,7 +534,7 @@ union GL3WProcs {
|
|||||||
} gl;
|
} gl;
|
||||||
};
|
};
|
||||||
|
|
||||||
GL3W_API extern union GL3WProcs imgl3wProcs;
|
GL3W_API extern union ImGL3WProcs imgl3wProcs;
|
||||||
|
|
||||||
/* OpenGL functions */
|
/* OpenGL functions */
|
||||||
#define glActiveTexture imgl3wProcs.gl.ActiveTexture
|
#define glActiveTexture imgl3wProcs.gl.ActiveTexture
|
||||||
@@ -604,7 +610,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
#define GL3W_ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
@@ -662,7 +668,12 @@ static GL3WglProc (*glx_get_proc_address)(const GLubyte *);
|
|||||||
|
|
||||||
static int open_libgl(void)
|
static int open_libgl(void)
|
||||||
{
|
{
|
||||||
libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL);
|
// While most systems use libGL.so.1, NetBSD seems to use that libGL.so.3. See https://github.com/ocornut/imgui/issues/6983
|
||||||
|
libgl = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL);
|
||||||
|
if (!libgl)
|
||||||
|
libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL);
|
||||||
|
if (!libgl)
|
||||||
|
libgl = dlopen("libGL.so.3", RTLD_LAZY | RTLD_LOCAL);
|
||||||
if (!libgl)
|
if (!libgl)
|
||||||
return GL3W_ERROR_LIBRARY_OPEN;
|
return GL3W_ERROR_LIBRARY_OPEN;
|
||||||
*(void **)(&glx_get_proc_address) = dlsym(libgl, "glXGetProcAddressARB");
|
*(void **)(&glx_get_proc_address) = dlsym(libgl, "glXGetProcAddressARB");
|
||||||
@@ -790,12 +801,12 @@ static const char *proc_names[] = {
|
|||||||
"glViewport",
|
"glViewport",
|
||||||
};
|
};
|
||||||
|
|
||||||
GL3W_API union GL3WProcs imgl3wProcs;
|
GL3W_API union ImGL3WProcs imgl3wProcs;
|
||||||
|
|
||||||
static void load_procs(GL3WGetProcAddressProc proc)
|
static void load_procs(GL3WGetProcAddressProc proc)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < ARRAY_SIZE(proc_names); i++)
|
for (i = 0; i < GL3W_ARRAY_SIZE(proc_names); i++)
|
||||||
imgl3wProcs.ptr[i] = proc(proc_names[i]);
|
imgl3wProcs.ptr[i] = proc(proc_names[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,19 @@
|
|||||||
// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend).
|
// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend).
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: IME support.
|
// [X] Platform: IME support.
|
||||||
|
// [x] Platform: Multi-viewport / platform windows.
|
||||||
|
// - [ ] Window size not correctly reported when enabling io.ConfigViewportsNoDecoration
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
#ifdef __OBJC__
|
#ifdef __OBJC__
|
||||||
|
|
||||||
@@ -43,3 +49,5 @@ IMGUI_IMPL_API void ImGui_ImplOSX_NewFrame(void* _Nullable view);
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -10,13 +10,19 @@
|
|||||||
// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend).
|
// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend).
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: IME support.
|
// [X] Platform: IME support.
|
||||||
|
// [x] Platform: Multi-viewport / platform windows.
|
||||||
|
// - [ ] Window size not correctly reported when enabling io.ConfigViewportsNoDecoration
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#import "imgui.h"
|
#import "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#import "imgui_impl_osx.h"
|
#import "imgui_impl_osx.h"
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#import <Carbon/Carbon.h>
|
#import <Carbon/Carbon.h>
|
||||||
@@ -25,6 +31,8 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F20 function keys. Stopped mapping F13 into PrintScreen.
|
||||||
// 2023-04-09: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_Pen.
|
// 2023-04-09: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_Pen.
|
||||||
// 2023-02-01: Fixed scroll wheel scaling for devices emitting events with hasPreciseScrollingDeltas==false (e.g. non-Apple mices).
|
// 2023-02-01: Fixed scroll wheel scaling for devices emitting events with hasPreciseScrollingDeltas==false (e.g. non-Apple mices).
|
||||||
// 2022-11-02: Fixed mouse coordinates before clicking the host window.
|
// 2022-11-02: Fixed mouse coordinates before clicking the host window.
|
||||||
@@ -75,6 +83,7 @@ struct ImGui_ImplOSX_Data
|
|||||||
KeyEventResponder* KeyEventResponder;
|
KeyEventResponder* KeyEventResponder;
|
||||||
NSTextInputContext* InputContext;
|
NSTextInputContext* InputContext;
|
||||||
id Monitor;
|
id Monitor;
|
||||||
|
NSWindow* Window;
|
||||||
|
|
||||||
ImGui_ImplOSX_Data() { memset(this, 0, sizeof(*this)); }
|
ImGui_ImplOSX_Data() { memset(this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
@@ -86,6 +95,9 @@ static void ImGui_ImplOSX_DestroyBackendData() { IM_DELETE(
|
|||||||
static inline CFTimeInterval GetMachAbsoluteTimeInSeconds() { return (CFTimeInterval)(double)(clock_gettime_nsec_np(CLOCK_UPTIME_RAW) / 1e9); }
|
static inline CFTimeInterval GetMachAbsoluteTimeInSeconds() { return (CFTimeInterval)(double)(clock_gettime_nsec_np(CLOCK_UPTIME_RAW) / 1e9); }
|
||||||
|
|
||||||
// Forward Declarations
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplOSX_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplOSX_ShutdownPlatformInterface();
|
||||||
|
static void ImGui_ImplOSX_UpdateMonitors();
|
||||||
static void ImGui_ImplOSX_AddTrackingArea(NSView* _Nonnull view);
|
static void ImGui_ImplOSX_AddTrackingArea(NSView* _Nonnull view);
|
||||||
static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view);
|
static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view);
|
||||||
|
|
||||||
@@ -129,12 +141,28 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view);
|
|||||||
|
|
||||||
- (void)updateImePosWithView:(NSView *)view
|
- (void)updateImePosWithView:(NSView *)view
|
||||||
{
|
{
|
||||||
NSWindow *window = view.window;
|
NSWindow* window = view.window;
|
||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
NSRect contentRect = [window contentRectForFrameRect:window.frame];
|
|
||||||
NSRect rect = NSMakeRect(_posX, contentRect.size.height - _posY, 0, 0);
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
_imeRect = [window convertRectToScreen:rect];
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
NSRect frame = window.frame;
|
||||||
|
NSRect contentRect = window.contentLayoutRect;
|
||||||
|
if (window.styleMask & NSWindowStyleMaskFullSizeContentView) // No title bar windows should be considered.
|
||||||
|
contentRect = frame;
|
||||||
|
|
||||||
|
NSRect firstScreenFrame = NSScreen.screens[0].frame;
|
||||||
|
_imeRect = NSMakeRect(_posX, _posY, 0, 0);
|
||||||
|
_imeRect.origin.y = firstScreenFrame.size.height - _imeRect.size.height - _imeRect.origin.y; // Opposite of ConvertNSRect()
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSRect contentRect = [window contentRectForFrameRect:window.frame];
|
||||||
|
NSRect rect = NSMakeRect(_posX, contentRect.size.height - _posY, 0, 0);
|
||||||
|
_imeRect = [window convertRectToScreen:rect];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidMoveToWindow
|
- (void)viewDidMoveToWindow
|
||||||
@@ -229,6 +257,7 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view);
|
|||||||
|
|
||||||
- (void)onApplicationBecomeActive:(NSNotification*)aNotification;
|
- (void)onApplicationBecomeActive:(NSNotification*)aNotification;
|
||||||
- (void)onApplicationBecomeInactive:(NSNotification*)aNotification;
|
- (void)onApplicationBecomeInactive:(NSNotification*)aNotification;
|
||||||
|
- (void)displaysDidChange:(NSNotification*)aNotification;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -246,6 +275,11 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view);
|
|||||||
io.AddFocusEvent(false);
|
io.AddFocusEvent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)displaysDidChange:(NSNotification*)aNotification
|
||||||
|
{
|
||||||
|
ImGui_ImplOSX_UpdateMonitors();
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
@@ -333,36 +367,36 @@ static ImGuiKey ImGui_ImplOSX_KeyCodeToImGuiKey(int key_code)
|
|||||||
case kVK_RightOption: return ImGuiKey_RightAlt;
|
case kVK_RightOption: return ImGuiKey_RightAlt;
|
||||||
case kVK_RightCommand: return ImGuiKey_RightSuper;
|
case kVK_RightCommand: return ImGuiKey_RightSuper;
|
||||||
// case kVK_Function: return ImGuiKey_;
|
// case kVK_Function: return ImGuiKey_;
|
||||||
// case kVK_F17: return ImGuiKey_;
|
|
||||||
// case kVK_VolumeUp: return ImGuiKey_;
|
// case kVK_VolumeUp: return ImGuiKey_;
|
||||||
// case kVK_VolumeDown: return ImGuiKey_;
|
// case kVK_VolumeDown: return ImGuiKey_;
|
||||||
// case kVK_Mute: return ImGuiKey_;
|
// case kVK_Mute: return ImGuiKey_;
|
||||||
// case kVK_F18: return ImGuiKey_;
|
case kVK_F1: return ImGuiKey_F1;
|
||||||
// case kVK_F19: return ImGuiKey_;
|
case kVK_F2: return ImGuiKey_F2;
|
||||||
// case kVK_F20: return ImGuiKey_;
|
case kVK_F3: return ImGuiKey_F3;
|
||||||
|
case kVK_F4: return ImGuiKey_F4;
|
||||||
case kVK_F5: return ImGuiKey_F5;
|
case kVK_F5: return ImGuiKey_F5;
|
||||||
case kVK_F6: return ImGuiKey_F6;
|
case kVK_F6: return ImGuiKey_F6;
|
||||||
case kVK_F7: return ImGuiKey_F7;
|
case kVK_F7: return ImGuiKey_F7;
|
||||||
case kVK_F3: return ImGuiKey_F3;
|
|
||||||
case kVK_F8: return ImGuiKey_F8;
|
case kVK_F8: return ImGuiKey_F8;
|
||||||
case kVK_F9: return ImGuiKey_F9;
|
case kVK_F9: return ImGuiKey_F9;
|
||||||
case kVK_F11: return ImGuiKey_F11;
|
|
||||||
case kVK_F13: return ImGuiKey_PrintScreen;
|
|
||||||
// case kVK_F16: return ImGuiKey_;
|
|
||||||
// case kVK_F14: return ImGuiKey_;
|
|
||||||
case kVK_F10: return ImGuiKey_F10;
|
case kVK_F10: return ImGuiKey_F10;
|
||||||
case 0x6E: return ImGuiKey_Menu;
|
case kVK_F11: return ImGuiKey_F11;
|
||||||
case kVK_F12: return ImGuiKey_F12;
|
case kVK_F12: return ImGuiKey_F12;
|
||||||
// case kVK_F15: return ImGuiKey_;
|
case kVK_F13: return ImGuiKey_F13;
|
||||||
|
case kVK_F14: return ImGuiKey_F14;
|
||||||
|
case kVK_F15: return ImGuiKey_F15;
|
||||||
|
case kVK_F16: return ImGuiKey_F16;
|
||||||
|
case kVK_F17: return ImGuiKey_F17;
|
||||||
|
case kVK_F18: return ImGuiKey_F18;
|
||||||
|
case kVK_F19: return ImGuiKey_F19;
|
||||||
|
case kVK_F20: return ImGuiKey_F20;
|
||||||
|
case 0x6E: return ImGuiKey_Menu;
|
||||||
case kVK_Help: return ImGuiKey_Insert;
|
case kVK_Help: return ImGuiKey_Insert;
|
||||||
case kVK_Home: return ImGuiKey_Home;
|
case kVK_Home: return ImGuiKey_Home;
|
||||||
case kVK_PageUp: return ImGuiKey_PageUp;
|
case kVK_PageUp: return ImGuiKey_PageUp;
|
||||||
case kVK_ForwardDelete: return ImGuiKey_Delete;
|
case kVK_ForwardDelete: return ImGuiKey_Delete;
|
||||||
case kVK_F4: return ImGuiKey_F4;
|
|
||||||
case kVK_End: return ImGuiKey_End;
|
case kVK_End: return ImGuiKey_End;
|
||||||
case kVK_F2: return ImGuiKey_F2;
|
|
||||||
case kVK_PageDown: return ImGuiKey_PageDown;
|
case kVK_PageDown: return ImGuiKey_PageDown;
|
||||||
case kVK_F1: return ImGuiKey_F1;
|
|
||||||
case kVK_LeftArrow: return ImGuiKey_LeftArrow;
|
case kVK_LeftArrow: return ImGuiKey_LeftArrow;
|
||||||
case kVK_RightArrow: return ImGuiKey_RightArrow;
|
case kVK_RightArrow: return ImGuiKey_RightArrow;
|
||||||
case kVK_DownArrow: return ImGuiKey_DownArrow;
|
case kVK_DownArrow: return ImGuiKey_DownArrow;
|
||||||
@@ -393,9 +427,17 @@ bool ImGui_ImplOSX_Init(NSView* view)
|
|||||||
// Setup backend capabilities flags
|
// Setup backend capabilities flags
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
//io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
//io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
|
||||||
|
//io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can call io.AddMouseViewportEvent() with correct data (optional)
|
||||||
io.BackendPlatformName = "imgui_impl_osx";
|
io.BackendPlatformName = "imgui_impl_osx";
|
||||||
|
|
||||||
bd->Observer = [ImGuiObserver new];
|
bd->Observer = [ImGuiObserver new];
|
||||||
|
bd->Window = view.window ?: NSApp.orderedWindows.firstObject;
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
main_viewport->PlatformHandle = main_viewport->PlatformHandleRaw = (__bridge_retained void*)bd->Window;
|
||||||
|
ImGui_ImplOSX_UpdateMonitors();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplOSX_InitPlatformInterface();
|
||||||
|
|
||||||
// Load cursors. Some of them are undocumented.
|
// Load cursors. Some of them are undocumented.
|
||||||
bd->MouseCursorHidden = false;
|
bd->MouseCursorHidden = false;
|
||||||
@@ -476,13 +518,21 @@ bool ImGui_ImplOSX_Init(NSView* view)
|
|||||||
void ImGui_ImplOSX_Shutdown()
|
void ImGui_ImplOSX_Shutdown()
|
||||||
{
|
{
|
||||||
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
|
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
|
||||||
|
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
||||||
|
|
||||||
bd->Observer = nullptr;
|
bd->Observer = nullptr;
|
||||||
if (bd->Monitor != nullptr)
|
if (bd->Monitor != nullptr)
|
||||||
{
|
{
|
||||||
[NSEvent removeMonitor:bd->Monitor];
|
[NSEvent removeMonitor:bd->Monitor];
|
||||||
bd->Monitor = nullptr;
|
bd->Monitor = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui_ImplOSX_ShutdownPlatformInterface();
|
||||||
ImGui_ImplOSX_DestroyBackendData();
|
ImGui_ImplOSX_DestroyBackendData();
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.BackendPlatformName = nullptr;
|
||||||
|
io.BackendPlatformUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplOSX_UpdateMouseCursor()
|
static void ImGui_ImplOSX_UpdateMouseCursor()
|
||||||
@@ -521,7 +571,6 @@ static void ImGui_ImplOSX_UpdateMouseCursor()
|
|||||||
static void ImGui_ImplOSX_UpdateGamepads()
|
static void ImGui_ImplOSX_UpdateGamepads()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
memset(io.NavInputs, 0, sizeof(io.NavInputs));
|
|
||||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) // FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.
|
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) // FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -659,14 +708,23 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
|||||||
|
|
||||||
if (event.type == NSEventTypeMouseMoved || event.type == NSEventTypeLeftMouseDragged || event.type == NSEventTypeRightMouseDragged || event.type == NSEventTypeOtherMouseDragged)
|
if (event.type == NSEventTypeMouseMoved || event.type == NSEventTypeLeftMouseDragged || event.type == NSEventTypeRightMouseDragged || event.type == NSEventTypeOtherMouseDragged)
|
||||||
{
|
{
|
||||||
NSPoint mousePoint = event.locationInWindow;
|
NSPoint mousePoint;
|
||||||
if (event.window == nil)
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
mousePoint = [[view window] convertPointFromScreen:mousePoint];
|
{
|
||||||
mousePoint = [view convertPoint:mousePoint fromView:nil];
|
mousePoint = NSEvent.mouseLocation;
|
||||||
if ([view isFlipped])
|
mousePoint.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - mousePoint.y; // Normalize y coordinate to top-left of main display.
|
||||||
mousePoint = NSMakePoint(mousePoint.x, mousePoint.y);
|
}
|
||||||
else
|
else
|
||||||
mousePoint = NSMakePoint(mousePoint.x, view.bounds.size.height - mousePoint.y);
|
{
|
||||||
|
mousePoint = event.locationInWindow;
|
||||||
|
if (event.window == nil)
|
||||||
|
mousePoint = [[view window] convertPointFromScreen:mousePoint];
|
||||||
|
mousePoint = [view convertPoint:mousePoint fromView:nil]; // Convert to local coordinates of view
|
||||||
|
if ([view isFlipped])
|
||||||
|
mousePoint = NSMakePoint(mousePoint.x, mousePoint.y);
|
||||||
|
else
|
||||||
|
mousePoint = NSMakePoint(mousePoint.x, view.bounds.size.height - mousePoint.y);
|
||||||
|
}
|
||||||
io.AddMouseSourceEvent(GetMouseSource(event));
|
io.AddMouseSourceEvent(GetMouseSource(event));
|
||||||
io.AddMousePosEvent((float)mousePoint.x, (float)mousePoint.y);
|
io.AddMousePosEvent((float)mousePoint.x, (float)mousePoint.y);
|
||||||
return io.WantCaptureMouse;
|
return io.WantCaptureMouse;
|
||||||
@@ -793,3 +851,295 @@ static void ImGui_ImplOSX_AddTrackingArea(NSView* _Nonnull view)
|
|||||||
return event;
|
return event;
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
struct ImGuiViewportDataOSX
|
||||||
|
{
|
||||||
|
NSWindow* Window;
|
||||||
|
bool WindowOwned;
|
||||||
|
|
||||||
|
ImGuiViewportDataOSX() { WindowOwned = false; }
|
||||||
|
~ImGuiViewportDataOSX() { IM_ASSERT(Window == nil); }
|
||||||
|
};
|
||||||
|
|
||||||
|
@interface ImGui_ImplOSX_Window: NSWindow
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation ImGui_ImplOSX_Window
|
||||||
|
|
||||||
|
- (BOOL)canBecomeKeyWindow
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
static void ConvertNSRect(NSRect* r)
|
||||||
|
{
|
||||||
|
NSRect firstScreenFrame = NSScreen.screens[0].frame;
|
||||||
|
IM_ASSERT(firstScreenFrame.origin.x == 0 && firstScreenFrame.origin.y == 0);
|
||||||
|
r->origin.y = firstScreenFrame.size.height - r->origin.y - r->size.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
|
||||||
|
ImGuiViewportDataOSX* data = IM_NEW(ImGuiViewportDataOSX)();
|
||||||
|
viewport->PlatformUserData = data;
|
||||||
|
|
||||||
|
NSScreen* screen = bd->Window.screen;
|
||||||
|
NSRect rect = NSMakeRect(viewport->Pos.x, viewport->Pos.y, viewport->Size.x, viewport->Size.y);
|
||||||
|
ConvertNSRect(&rect);
|
||||||
|
|
||||||
|
NSWindowStyleMask styleMask = 0;
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoDecoration)
|
||||||
|
styleMask |= NSWindowStyleMaskBorderless;
|
||||||
|
else
|
||||||
|
styleMask |= NSWindowStyleMaskTitled | NSWindowStyleMaskResizable | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable;
|
||||||
|
|
||||||
|
NSWindow* window = [[ImGui_ImplOSX_Window alloc] initWithContentRect:rect
|
||||||
|
styleMask:styleMask
|
||||||
|
backing:NSBackingStoreBuffered
|
||||||
|
defer:YES
|
||||||
|
screen:screen];
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_TopMost)
|
||||||
|
[window setLevel:NSFloatingWindowLevel];
|
||||||
|
|
||||||
|
window.title = @"Untitled";
|
||||||
|
window.opaque = YES;
|
||||||
|
|
||||||
|
KeyEventResponder* view = [[KeyEventResponder alloc] initWithFrame:rect];
|
||||||
|
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
|
||||||
|
[view setWantsBestResolutionOpenGLSurface:YES];
|
||||||
|
|
||||||
|
window.contentView = view;
|
||||||
|
|
||||||
|
data->Window = window;
|
||||||
|
data->WindowOwned = true;
|
||||||
|
viewport->PlatformRequestResize = false;
|
||||||
|
viewport->PlatformHandle = viewport->PlatformHandleRaw = (__bridge_retained void*)window;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
NSWindow* window = (__bridge_transfer NSWindow*)viewport->PlatformHandleRaw;
|
||||||
|
window = nil;
|
||||||
|
|
||||||
|
if (ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData)
|
||||||
|
{
|
||||||
|
NSWindow* window = data->Window;
|
||||||
|
if (window != nil && data->WindowOwned)
|
||||||
|
{
|
||||||
|
window.contentView = nil;
|
||||||
|
window.contentViewController = nil;
|
||||||
|
[window orderOut:nil];
|
||||||
|
}
|
||||||
|
data->Window = nil;
|
||||||
|
IM_DELETE(data);
|
||||||
|
}
|
||||||
|
viewport->PlatformUserData = viewport->PlatformHandle = viewport->PlatformHandleRaw = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_ShowWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing)
|
||||||
|
[data->Window orderFront:nil];
|
||||||
|
else
|
||||||
|
[data->Window makeKeyAndOrderFront:nil];
|
||||||
|
|
||||||
|
[data->Window setIsVisible:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplOSX_GetWindowPos(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
NSWindow* window = data->Window;
|
||||||
|
NSRect frame = window.frame;
|
||||||
|
NSRect contentRect = window.contentLayoutRect;
|
||||||
|
if (window.styleMask & NSWindowStyleMaskFullSizeContentView) // No title bar windows should be considered.
|
||||||
|
contentRect = frame;
|
||||||
|
|
||||||
|
NSRect firstScreenFrame = NSScreen.screens[0].frame;
|
||||||
|
return ImVec2(frame.origin.x, firstScreenFrame.size.height - frame.origin.y - contentRect.size.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
NSWindow* window = data->Window;
|
||||||
|
NSSize size = window.frame.size;
|
||||||
|
|
||||||
|
NSRect r = NSMakeRect(pos.x, pos.y, size.width, size.height);
|
||||||
|
ConvertNSRect(&r);
|
||||||
|
[window setFrameOrigin:r.origin];
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplOSX_GetWindowSize(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
NSWindow* window = data->Window;
|
||||||
|
NSSize size = window.contentLayoutRect.size;
|
||||||
|
return ImVec2(size.width, size.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
NSWindow* window = data->Window;
|
||||||
|
NSRect rect = window.frame;
|
||||||
|
rect.origin.y -= (size.y - rect.size.height);
|
||||||
|
rect.size.width = size.x;
|
||||||
|
rect.size.height = size.y;
|
||||||
|
[window setFrame:rect display:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_SetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
[data->Window makeKeyAndOrderFront:bd->Window];
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplOSX_GetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
return data->Window.isKeyWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplOSX_GetWindowMinimized(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
return data->Window.isMiniaturized;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_SetWindowTitle(ImGuiViewport* viewport, const char* title)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
data->Window.title = [NSString stringWithUTF8String:title];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
IM_ASSERT(alpha >= 0.0f && alpha <= 1.0f);
|
||||||
|
|
||||||
|
data->Window.alphaValue = alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
static float ImGui_ImplOSX_GetWindowDpiScale(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
return data->Window.backingScaleFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_UpdateMonitors()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Monitors.resize(0);
|
||||||
|
|
||||||
|
NSRect firstScreenFrame = NSScreen.screens[0].frame;
|
||||||
|
IM_ASSERT(firstScreenFrame.origin.x == 0 && firstScreenFrame.origin.y == 0);
|
||||||
|
|
||||||
|
for (NSScreen* screen in NSScreen.screens)
|
||||||
|
{
|
||||||
|
NSRect frame = screen.frame;
|
||||||
|
NSRect visibleFrame = screen.visibleFrame;
|
||||||
|
ConvertNSRect(&frame);
|
||||||
|
ConvertNSRect(&visibleFrame);
|
||||||
|
|
||||||
|
ImGuiPlatformMonitor imgui_monitor;
|
||||||
|
imgui_monitor.MainPos = ImVec2(frame.origin.x, frame.origin.y);
|
||||||
|
imgui_monitor.MainSize = ImVec2(frame.size.width, frame.size.height);
|
||||||
|
imgui_monitor.WorkPos = ImVec2(visibleFrame.origin.x, visibleFrame.origin.y);
|
||||||
|
imgui_monitor.WorkSize = ImVec2(visibleFrame.size.width, visibleFrame.size.height);
|
||||||
|
imgui_monitor.DpiScale = screen.backingScaleFactor;
|
||||||
|
imgui_monitor.PlatformHandle = (__bridge_retained void*)screen;
|
||||||
|
|
||||||
|
platform_io.Monitors.push_back(imgui_monitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
|
||||||
|
|
||||||
|
// Register platform interface (will be coupled with a renderer interface)
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Platform_CreateWindow = ImGui_ImplOSX_CreateWindow;
|
||||||
|
platform_io.Platform_DestroyWindow = ImGui_ImplOSX_DestroyWindow;
|
||||||
|
platform_io.Platform_ShowWindow = ImGui_ImplOSX_ShowWindow;
|
||||||
|
platform_io.Platform_SetWindowPos = ImGui_ImplOSX_SetWindowPos;
|
||||||
|
platform_io.Platform_GetWindowPos = ImGui_ImplOSX_GetWindowPos;
|
||||||
|
platform_io.Platform_SetWindowSize = ImGui_ImplOSX_SetWindowSize;
|
||||||
|
platform_io.Platform_GetWindowSize = ImGui_ImplOSX_GetWindowSize;
|
||||||
|
platform_io.Platform_SetWindowFocus = ImGui_ImplOSX_SetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowFocus = ImGui_ImplOSX_GetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowMinimized = ImGui_ImplOSX_GetWindowMinimized;
|
||||||
|
platform_io.Platform_SetWindowTitle = ImGui_ImplOSX_SetWindowTitle;
|
||||||
|
platform_io.Platform_SetWindowAlpha = ImGui_ImplOSX_SetWindowAlpha;
|
||||||
|
platform_io.Platform_GetWindowDpiScale = ImGui_ImplOSX_GetWindowDpiScale; // FIXME-DPI
|
||||||
|
|
||||||
|
// Register main window handle (which is owned by the main application, not by us)
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
ImGuiViewportDataOSX* data = IM_NEW(ImGuiViewportDataOSX)();
|
||||||
|
data->Window = bd->Window;
|
||||||
|
data->WindowOwned = false;
|
||||||
|
main_viewport->PlatformUserData = data;
|
||||||
|
main_viewport->PlatformHandle = (__bridge void*)bd->Window;
|
||||||
|
|
||||||
|
[NSNotificationCenter.defaultCenter addObserver:bd->Observer
|
||||||
|
selector:@selector(displaysDidChange:)
|
||||||
|
name:NSApplicationDidChangeScreenParametersNotification
|
||||||
|
object:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
|
||||||
|
[NSNotificationCenter.defaultCenter removeObserver:bd->Observer
|
||||||
|
name:NSApplicationDidChangeScreenParametersNotification
|
||||||
|
object:nil];
|
||||||
|
bd->Observer = nullptr;
|
||||||
|
bd->Window = nullptr;
|
||||||
|
if (bd->Monitor != nullptr)
|
||||||
|
{
|
||||||
|
[NSEvent removeMonitor:bd->Monitor];
|
||||||
|
bd->Monitor = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)main_viewport->PlatformUserData;
|
||||||
|
IM_DELETE(data);
|
||||||
|
main_viewport->PlatformUserData = nullptr;
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -9,15 +9,24 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// [X] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
// Missing features:
|
||||||
|
// [ ] Platform: Multi-viewport + Minimized windows seems to break mouse wheel events (at least under Windows).
|
||||||
|
// [x] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2024-02-14: Inputs: Handle gamepad disconnection. Added ImGui_ImplSDL2_SetGamepadMode().
|
||||||
|
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
||||||
// 2023-04-06: Inputs: Avoid calling SDL_StartTextInput()/SDL_StopTextInput() as they don't only pertain to IME. It's unclear exactly what their relation is to IME. (#6306)
|
// 2023-04-06: Inputs: Avoid calling SDL_StartTextInput()/SDL_StopTextInput() as they don't only pertain to IME. It's unclear exactly what their relation is to IME. (#6306)
|
||||||
// 2023-04-04: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_TouchScreen. (#2702)
|
// 2023-04-04: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_TouchScreen. (#2702)
|
||||||
// 2023-02-23: Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. (#6189, #6114, #3644)
|
// 2023-02-23: Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. (#6189, #6114, #3644)
|
||||||
@@ -42,7 +51,7 @@
|
|||||||
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
// 2021-08-17: Calling io.AddFocusEvent() on SDL_WINDOWEVENT_FOCUS_GAINED/SDL_WINDOWEVENT_FOCUS_LOST.
|
// 2021-08-17: Calling io.AddFocusEvent() on SDL_WINDOWEVENT_FOCUS_GAINED/SDL_WINDOWEVENT_FOCUS_LOST.
|
||||||
// 2021-07-29: Inputs: MousePos is correctly reported when the host platform window is hovered but not focused (using SDL_GetMouseFocus() + SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, requires SDL 2.0.5+)
|
// 2021-07-29: Inputs: MousePos is correctly reported when the host platform window is hovered but not focused (using SDL_GetMouseFocus() + SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, requires SDL 2.0.5+)
|
||||||
// 2021-06-29: *BREAKING CHANGE* Removed 'SDL_Window* window' parameter to ImGui_ImplSDL2_NewFrame() which was unnecessary.
|
// 2021-06:29: *BREAKING CHANGE* Removed 'SDL_Window* window' parameter to ImGui_ImplSDL2_NewFrame() which was unnecessary.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2021-03-22: Rework global mouse pos availability check listing supported platforms explicitly, effectively fixing mouse access on Raspberry Pi. (#2837, #3950)
|
// 2021-03-22: Rework global mouse pos availability check listing supported platforms explicitly, effectively fixing mouse access on Raspberry Pi. (#2837, #3950)
|
||||||
// 2020-05-25: Misc: Report a zero display-size when window is minimized, to be consistent with other backends.
|
// 2020-05-25: Misc: Report a zero display-size when window is minimized, to be consistent with other backends.
|
||||||
@@ -73,6 +82,7 @@
|
|||||||
// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
|
// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_sdl2.h"
|
#include "imgui_impl_sdl2.h"
|
||||||
|
|
||||||
// Clang warnings with -Weverything
|
// Clang warnings with -Weverything
|
||||||
@@ -82,6 +92,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// SDL
|
// SDL
|
||||||
|
// (the multi-viewports feature requires SDL features supported from SDL 2.0.4+. SDL 2.0.5+ is highly recommended)
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
@@ -93,21 +104,39 @@
|
|||||||
#else
|
#else
|
||||||
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 0
|
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 0
|
||||||
#endif
|
#endif
|
||||||
|
#define SDL_HAS_WINDOW_ALPHA SDL_VERSION_ATLEAST(2,0,5)
|
||||||
|
#define SDL_HAS_ALWAYS_ON_TOP SDL_VERSION_ATLEAST(2,0,5)
|
||||||
|
#define SDL_HAS_USABLE_DISPLAY_BOUNDS SDL_VERSION_ATLEAST(2,0,5)
|
||||||
|
#define SDL_HAS_PER_MONITOR_DPI SDL_VERSION_ATLEAST(2,0,4)
|
||||||
#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
|
#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
|
||||||
|
#define SDL_HAS_DISPLAY_EVENT SDL_VERSION_ATLEAST(2,0,9)
|
||||||
|
#if !SDL_HAS_VULKAN
|
||||||
|
static const Uint32 SDL_WINDOW_VULKAN = 0x10000000;
|
||||||
|
#endif
|
||||||
|
|
||||||
// SDL Data
|
// SDL Data
|
||||||
struct ImGui_ImplSDL2_Data
|
struct ImGui_ImplSDL2_Data
|
||||||
{
|
{
|
||||||
SDL_Window* Window;
|
SDL_Window* Window;
|
||||||
SDL_Renderer* Renderer;
|
SDL_Renderer* Renderer;
|
||||||
Uint64 Time;
|
Uint64 Time;
|
||||||
Uint32 MouseWindowID;
|
char* ClipboardTextData;
|
||||||
int MouseButtonsDown;
|
bool UseVulkan;
|
||||||
SDL_Cursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
bool WantUpdateMonitors;
|
||||||
SDL_Cursor* LastMouseCursor;
|
|
||||||
int PendingMouseLeaveFrame;
|
// Mouse handling
|
||||||
char* ClipboardTextData;
|
Uint32 MouseWindowID;
|
||||||
bool MouseCanUseGlobalState;
|
int MouseButtonsDown;
|
||||||
|
SDL_Cursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
||||||
|
SDL_Cursor* MouseLastCursor;
|
||||||
|
int MouseLastLeaveFrame;
|
||||||
|
bool MouseCanUseGlobalState;
|
||||||
|
bool MouseCanReportHoveredViewport; // This is hard to use/unreliable on SDL so we'll set ImGuiBackendFlags_HasMouseHoveredViewport dynamically based on state.
|
||||||
|
|
||||||
|
// Gamepad handling
|
||||||
|
ImVector<SDL_GameController*> Gamepads;
|
||||||
|
ImGui_ImplSDL2_GamepadMode GamepadMode;
|
||||||
|
bool WantUpdateGamepadsList;
|
||||||
|
|
||||||
ImGui_ImplSDL2_Data() { memset((void*)this, 0, sizeof(*this)); }
|
ImGui_ImplSDL2_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
@@ -121,6 +150,11 @@ static ImGui_ImplSDL2_Data* ImGui_ImplSDL2_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplSDL2_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplSDL2_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplSDL2_UpdateMonitors();
|
||||||
|
static void ImGui_ImplSDL2_InitPlatformInterface(SDL_Window* window, void* sdl_gl_context);
|
||||||
|
static void ImGui_ImplSDL2_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static const char* ImGui_ImplSDL2_GetClipboardText(void*)
|
static const char* ImGui_ImplSDL2_GetClipboardText(void*)
|
||||||
{
|
{
|
||||||
@@ -137,13 +171,13 @@ static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Note: native IME will only display if user calls SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1") _before_ SDL_CreateWindow().
|
// Note: native IME will only display if user calls SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1") _before_ SDL_CreateWindow().
|
||||||
static void ImGui_ImplSDL2_SetPlatformImeData(ImGuiViewport*, ImGuiPlatformImeData* data)
|
static void ImGui_ImplSDL2_SetPlatformImeData(ImGuiViewport* viewport, ImGuiPlatformImeData* data)
|
||||||
{
|
{
|
||||||
if (data->WantVisible)
|
if (data->WantVisible)
|
||||||
{
|
{
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
r.x = (int)data->InputPos.x;
|
r.x = (int)(data->InputPos.x - viewport->Pos.x);
|
||||||
r.y = (int)data->InputPos.y;
|
r.y = (int)(data->InputPos.y - viewport->Pos.y + data->InputLineHeight);
|
||||||
r.w = 1;
|
r.w = 1;
|
||||||
r.h = (int)data->InputLineHeight;
|
r.h = (int)data->InputLineHeight;
|
||||||
SDL_SetTextInputRect(&r);
|
SDL_SetTextInputRect(&r);
|
||||||
@@ -259,6 +293,20 @@ static ImGuiKey ImGui_ImplSDL2_KeycodeToImGuiKey(int keycode)
|
|||||||
case SDLK_F10: return ImGuiKey_F10;
|
case SDLK_F10: return ImGuiKey_F10;
|
||||||
case SDLK_F11: return ImGuiKey_F11;
|
case SDLK_F11: return ImGuiKey_F11;
|
||||||
case SDLK_F12: return ImGuiKey_F12;
|
case SDLK_F12: return ImGuiKey_F12;
|
||||||
|
case SDLK_F13: return ImGuiKey_F13;
|
||||||
|
case SDLK_F14: return ImGuiKey_F14;
|
||||||
|
case SDLK_F15: return ImGuiKey_F15;
|
||||||
|
case SDLK_F16: return ImGuiKey_F16;
|
||||||
|
case SDLK_F17: return ImGuiKey_F17;
|
||||||
|
case SDLK_F18: return ImGuiKey_F18;
|
||||||
|
case SDLK_F19: return ImGuiKey_F19;
|
||||||
|
case SDLK_F20: return ImGuiKey_F20;
|
||||||
|
case SDLK_F21: return ImGuiKey_F21;
|
||||||
|
case SDLK_F22: return ImGuiKey_F22;
|
||||||
|
case SDLK_F23: return ImGuiKey_F23;
|
||||||
|
case SDLK_F24: return ImGuiKey_F24;
|
||||||
|
case SDLK_AC_BACK: return ImGuiKey_AppBack;
|
||||||
|
case SDLK_AC_FORWARD: return ImGuiKey_AppForward;
|
||||||
}
|
}
|
||||||
return ImGuiKey_None;
|
return ImGuiKey_None;
|
||||||
}
|
}
|
||||||
@@ -287,6 +335,13 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
|||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
{
|
{
|
||||||
ImVec2 mouse_pos((float)event->motion.x, (float)event->motion.y);
|
ImVec2 mouse_pos((float)event->motion.x, (float)event->motion.y);
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
int window_x, window_y;
|
||||||
|
SDL_GetWindowPosition(SDL_GetWindowFromID(event->motion.windowID), &window_x, &window_y);
|
||||||
|
mouse_pos.x += window_x;
|
||||||
|
mouse_pos.y += window_y;
|
||||||
|
}
|
||||||
io.AddMouseSourceEvent(event->motion.which == SDL_TOUCH_MOUSEID ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse);
|
io.AddMouseSourceEvent(event->motion.which == SDL_TOUCH_MOUSEID ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse);
|
||||||
io.AddMousePosEvent(mouse_pos.x, mouse_pos.y);
|
io.AddMousePosEvent(mouse_pos.x, mouse_pos.y);
|
||||||
return true;
|
return true;
|
||||||
@@ -338,6 +393,15 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
|||||||
io.SetKeyEventNativeData(key, event->key.keysym.sym, event->key.keysym.scancode, event->key.keysym.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions.
|
io.SetKeyEventNativeData(key, event->key.keysym.sym, event->key.keysym.scancode, event->key.keysym.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#if SDL_HAS_DISPLAY_EVENT
|
||||||
|
case SDL_DISPLAYEVENT:
|
||||||
|
{
|
||||||
|
// 2.0.26 has SDL_DISPLAYEVENT_CONNECTED/SDL_DISPLAYEVENT_DISCONNECTED/SDL_DISPLAYEVENT_ORIENTATION,
|
||||||
|
// so change of DPI/Scaling are not reflected in this event. (SDL3 has it)
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
{
|
{
|
||||||
// - When capturing mouse, SDL will send a bunch of conflicting LEAVE/ENTER event on every mouse move, but the final ENTER tends to be right.
|
// - When capturing mouse, SDL will send a bunch of conflicting LEAVE/ENTER event on every mouse move, but the final ENTER tends to be right.
|
||||||
@@ -349,21 +413,38 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
|||||||
if (window_event == SDL_WINDOWEVENT_ENTER)
|
if (window_event == SDL_WINDOWEVENT_ENTER)
|
||||||
{
|
{
|
||||||
bd->MouseWindowID = event->window.windowID;
|
bd->MouseWindowID = event->window.windowID;
|
||||||
bd->PendingMouseLeaveFrame = 0;
|
bd->MouseLastLeaveFrame = 0;
|
||||||
}
|
}
|
||||||
if (window_event == SDL_WINDOWEVENT_LEAVE)
|
if (window_event == SDL_WINDOWEVENT_LEAVE)
|
||||||
bd->PendingMouseLeaveFrame = ImGui::GetFrameCount() + 1;
|
bd->MouseLastLeaveFrame = ImGui::GetFrameCount() + 1;
|
||||||
if (window_event == SDL_WINDOWEVENT_FOCUS_GAINED)
|
if (window_event == SDL_WINDOWEVENT_FOCUS_GAINED)
|
||||||
io.AddFocusEvent(true);
|
io.AddFocusEvent(true);
|
||||||
else if (event->window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
else if (window_event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||||
io.AddFocusEvent(false);
|
io.AddFocusEvent(false);
|
||||||
|
if (window_event == SDL_WINDOWEVENT_CLOSE || window_event == SDL_WINDOWEVENT_MOVED || window_event == SDL_WINDOWEVENT_RESIZED)
|
||||||
|
if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle((void*)SDL_GetWindowFromID(event->window.windowID)))
|
||||||
|
{
|
||||||
|
if (window_event == SDL_WINDOWEVENT_CLOSE)
|
||||||
|
viewport->PlatformRequestClose = true;
|
||||||
|
if (window_event == SDL_WINDOWEVENT_MOVED)
|
||||||
|
viewport->PlatformRequestMove = true;
|
||||||
|
if (window_event == SDL_WINDOWEVENT_RESIZED)
|
||||||
|
viewport->PlatformRequestResize = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case SDL_CONTROLLERDEVICEADDED:
|
||||||
|
case SDL_CONTROLLERDEVICEREMOVED:
|
||||||
|
{
|
||||||
|
bd->WantUpdateGamepadsList = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer)
|
static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void* sdl_gl_context)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
||||||
@@ -383,18 +464,33 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer)
|
|||||||
ImGui_ImplSDL2_Data* bd = IM_NEW(ImGui_ImplSDL2_Data)();
|
ImGui_ImplSDL2_Data* bd = IM_NEW(ImGui_ImplSDL2_Data)();
|
||||||
io.BackendPlatformUserData = (void*)bd;
|
io.BackendPlatformUserData = (void*)bd;
|
||||||
io.BackendPlatformName = "imgui_impl_sdl2";
|
io.BackendPlatformName = "imgui_impl_sdl2";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||||
|
if (mouse_can_use_global_state)
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
|
||||||
|
|
||||||
bd->Window = window;
|
bd->Window = window;
|
||||||
bd->Renderer = renderer;
|
bd->Renderer = renderer;
|
||||||
|
|
||||||
|
// SDL on Linux/OSX doesn't report events for unfocused windows (see https://github.com/ocornut/imgui/issues/4960)
|
||||||
|
// We will use 'MouseCanReportHoveredViewport' to set 'ImGuiBackendFlags_HasMouseHoveredViewport' dynamically each frame.
|
||||||
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
|
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
|
||||||
|
#ifndef __APPLE__
|
||||||
|
bd->MouseCanReportHoveredViewport = bd->MouseCanUseGlobalState;
|
||||||
|
#else
|
||||||
|
bd->MouseCanReportHoveredViewport = false;
|
||||||
|
#endif
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
|
|
||||||
io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
|
io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
|
io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
|
||||||
io.ClipboardUserData = nullptr;
|
io.ClipboardUserData = nullptr;
|
||||||
io.SetPlatformImeDataFn = ImGui_ImplSDL2_SetPlatformImeData;
|
io.SetPlatformImeDataFn = ImGui_ImplSDL2_SetPlatformImeData;
|
||||||
|
|
||||||
|
// Gamepad handling
|
||||||
|
bd->GamepadMode = ImGui_ImplSDL2_GamepadMode_AutoFirst;
|
||||||
|
bd->WantUpdateGamepadsList = true;
|
||||||
|
|
||||||
// Load mouse cursors
|
// Load mouse cursors
|
||||||
bd->MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
|
bd->MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
|
||||||
bd->MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
|
bd->MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
|
||||||
@@ -409,6 +505,7 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer)
|
|||||||
// Set platform dependent data in viewport
|
// Set platform dependent data in viewport
|
||||||
// Our mouse update function expect PlatformHandle to be filled for the main viewport
|
// Our mouse update function expect PlatformHandle to be filled for the main viewport
|
||||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
main_viewport->PlatformHandle = (void*)window;
|
||||||
main_viewport->PlatformHandleRaw = nullptr;
|
main_viewport->PlatformHandleRaw = nullptr;
|
||||||
SDL_SysWMinfo info;
|
SDL_SysWMinfo info;
|
||||||
SDL_VERSION(&info.version);
|
SDL_VERSION(&info.version);
|
||||||
@@ -442,13 +539,17 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer)
|
|||||||
SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0");
|
SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// We need SDL_CaptureMouse(), SDL_GetGlobalMouseState() from SDL 2.0.4+ to support multiple viewports.
|
||||||
|
// We left the call to ImGui_ImplSDL2_InitPlatformInterface() outside of #ifdef to avoid unused-function warnings.
|
||||||
|
if ((io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) && (io.BackendFlags & ImGuiBackendFlags_PlatformHasViewports))
|
||||||
|
ImGui_ImplSDL2_InitPlatformInterface(window, sdl_gl_context);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
|
bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
|
||||||
{
|
{
|
||||||
IM_UNUSED(sdl_gl_context); // Viewport branch will need this.
|
return ImGui_ImplSDL2_Init(window, nullptr, sdl_gl_context);
|
||||||
return ImGui_ImplSDL2_Init(window, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
|
bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
|
||||||
@@ -456,7 +557,11 @@ bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
|
|||||||
#if !SDL_HAS_VULKAN
|
#if !SDL_HAS_VULKAN
|
||||||
IM_ASSERT(0 && "Unsupported");
|
IM_ASSERT(0 && "Unsupported");
|
||||||
#endif
|
#endif
|
||||||
return ImGui_ImplSDL2_Init(window, nullptr);
|
if (!ImGui_ImplSDL2_Init(window, nullptr, nullptr))
|
||||||
|
return false;
|
||||||
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
|
bd->UseVulkan = true;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window)
|
bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window)
|
||||||
@@ -464,36 +569,47 @@ bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window)
|
|||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
IM_ASSERT(0 && "Unsupported");
|
IM_ASSERT(0 && "Unsupported");
|
||||||
#endif
|
#endif
|
||||||
return ImGui_ImplSDL2_Init(window, nullptr);
|
return ImGui_ImplSDL2_Init(window, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window)
|
bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window)
|
||||||
{
|
{
|
||||||
return ImGui_ImplSDL2_Init(window, nullptr);
|
return ImGui_ImplSDL2_Init(window, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer)
|
bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer)
|
||||||
{
|
{
|
||||||
return ImGui_ImplSDL2_Init(window, renderer);
|
return ImGui_ImplSDL2_Init(window, renderer, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ImGui_ImplSDL2_InitForOther(SDL_Window* window)
|
||||||
|
{
|
||||||
|
return ImGui_ImplSDL2_Init(window, nullptr, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_CloseGamepads();
|
||||||
|
|
||||||
void ImGui_ImplSDL2_Shutdown()
|
void ImGui_ImplSDL2_Shutdown()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplSDL2_ShutdownPlatformInterface();
|
||||||
|
|
||||||
if (bd->ClipboardTextData)
|
if (bd->ClipboardTextData)
|
||||||
SDL_free(bd->ClipboardTextData);
|
SDL_free(bd->ClipboardTextData);
|
||||||
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
||||||
SDL_FreeCursor(bd->MouseCursors[cursor_n]);
|
SDL_FreeCursor(bd->MouseCursors[cursor_n]);
|
||||||
bd->LastMouseCursor = nullptr;
|
ImGui_ImplSDL2_CloseGamepads();
|
||||||
|
|
||||||
io.BackendPlatformName = nullptr;
|
io.BackendPlatformName = nullptr;
|
||||||
io.BackendPlatformUserData = nullptr;
|
io.BackendPlatformUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This code is incredibly messy because some of the functions we need for full viewport support are not available in SDL < 2.0.4.
|
||||||
static void ImGui_ImplSDL2_UpdateMouseData()
|
static void ImGui_ImplSDL2_UpdateMouseData()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
@@ -504,25 +620,57 @@ static void ImGui_ImplSDL2_UpdateMouseData()
|
|||||||
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
|
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
|
||||||
SDL_CaptureMouse((bd->MouseButtonsDown != 0) ? SDL_TRUE : SDL_FALSE);
|
SDL_CaptureMouse((bd->MouseButtonsDown != 0) ? SDL_TRUE : SDL_FALSE);
|
||||||
SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
||||||
const bool is_app_focused = (bd->Window == focused_window);
|
const bool is_app_focused = (focused_window && (bd->Window == focused_window || ImGui::FindViewportByPlatformHandle((void*)focused_window)));
|
||||||
#else
|
#else
|
||||||
|
SDL_Window* focused_window = bd->Window;
|
||||||
const bool is_app_focused = (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0; // SDL 2.0.3 and non-windowed systems: single-viewport only
|
const bool is_app_focused = (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0; // SDL 2.0.3 and non-windowed systems: single-viewport only
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (is_app_focused)
|
if (is_app_focused)
|
||||||
{
|
{
|
||||||
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
||||||
if (io.WantSetMousePos)
|
if (io.WantSetMousePos)
|
||||||
SDL_WarpMouseInWindow(bd->Window, (int)io.MousePos.x, (int)io.MousePos.y);
|
{
|
||||||
|
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
SDL_WarpMouseGlobal((int)io.MousePos.x, (int)io.MousePos.y);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
SDL_WarpMouseInWindow(bd->Window, (int)io.MousePos.x, (int)io.MousePos.y);
|
||||||
|
}
|
||||||
|
|
||||||
// (Optional) Fallback to provide mouse position when focused (SDL_MOUSEMOTION already provides this when hovered or captured)
|
// (Optional) Fallback to provide mouse position when focused (SDL_MOUSEMOTION already provides this when hovered or captured)
|
||||||
if (bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0)
|
if (bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0)
|
||||||
{
|
{
|
||||||
int window_x, window_y, mouse_x_global, mouse_y_global;
|
// Single-viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
|
||||||
SDL_GetGlobalMouseState(&mouse_x_global, &mouse_y_global);
|
// Multi-viewport mode: mouse position in OS absolute coordinates (io.MousePos is (0,0) when the mouse is on the upper-left of the primary monitor)
|
||||||
SDL_GetWindowPosition(bd->Window, &window_x, &window_y);
|
int mouse_x, mouse_y, window_x, window_y;
|
||||||
io.AddMousePosEvent((float)(mouse_x_global - window_x), (float)(mouse_y_global - window_y));
|
SDL_GetGlobalMouseState(&mouse_x, &mouse_y);
|
||||||
|
if (!(io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable))
|
||||||
|
{
|
||||||
|
SDL_GetWindowPosition(focused_window, &window_x, &window_y);
|
||||||
|
mouse_x -= window_x;
|
||||||
|
mouse_y -= window_y;
|
||||||
|
}
|
||||||
|
io.AddMousePosEvent((float)mouse_x, (float)mouse_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// (Optional) When using multiple viewports: call io.AddMouseViewportEvent() with the viewport the OS mouse cursor is hovering.
|
||||||
|
// If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the backend, Dear imGui will ignore this field and infer the information using its flawed heuristic.
|
||||||
|
// - [!] SDL backend does NOT correctly ignore viewports with the _NoInputs flag.
|
||||||
|
// Some backend are not able to handle that correctly. If a backend report an hovered viewport that has the _NoInputs flag (e.g. when dragging a window
|
||||||
|
// for docking, the viewport has the _NoInputs flag in order to allow us to find the viewport under), then Dear ImGui is forced to ignore the value reported
|
||||||
|
// by the backend, and use its flawed heuristic to guess the viewport behind.
|
||||||
|
// - [X] SDL backend correctly reports this regardless of another viewport behind focused and dragged from (we need this to find a useful drag and drop target).
|
||||||
|
if (io.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport)
|
||||||
|
{
|
||||||
|
ImGuiID mouse_viewport_id = 0;
|
||||||
|
if (SDL_Window* sdl_mouse_window = SDL_GetWindowFromID(bd->MouseWindowID))
|
||||||
|
if (ImGuiViewport* mouse_viewport = ImGui::FindViewportByPlatformHandle((void*)sdl_mouse_window))
|
||||||
|
mouse_viewport_id = mouse_viewport->ID;
|
||||||
|
io.AddMouseViewportEvent(mouse_viewport_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDL2_UpdateMouseCursor()
|
static void ImGui_ImplSDL2_UpdateMouseCursor()
|
||||||
@@ -542,59 +690,151 @@ static void ImGui_ImplSDL2_UpdateMouseCursor()
|
|||||||
{
|
{
|
||||||
// Show OS mouse cursor
|
// Show OS mouse cursor
|
||||||
SDL_Cursor* expected_cursor = bd->MouseCursors[imgui_cursor] ? bd->MouseCursors[imgui_cursor] : bd->MouseCursors[ImGuiMouseCursor_Arrow];
|
SDL_Cursor* expected_cursor = bd->MouseCursors[imgui_cursor] ? bd->MouseCursors[imgui_cursor] : bd->MouseCursors[ImGuiMouseCursor_Arrow];
|
||||||
if (bd->LastMouseCursor != expected_cursor)
|
if (bd->MouseLastCursor != expected_cursor)
|
||||||
{
|
{
|
||||||
SDL_SetCursor(expected_cursor); // SDL function doesn't have an early out (see #6113)
|
SDL_SetCursor(expected_cursor); // SDL function doesn't have an early out (see #6113)
|
||||||
bd->LastMouseCursor = expected_cursor;
|
bd->MouseLastCursor = expected_cursor;
|
||||||
}
|
}
|
||||||
SDL_ShowCursor(SDL_TRUE);
|
SDL_ShowCursor(SDL_TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_CloseGamepads()
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
|
if (bd->GamepadMode != ImGui_ImplSDL2_GamepadMode_Manual)
|
||||||
|
for (SDL_GameController* gamepad : bd->Gamepads)
|
||||||
|
SDL_GameControllerClose(gamepad);
|
||||||
|
bd->Gamepads.resize(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode mode, struct _SDL_GameController** manual_gamepads_array, int manual_gamepads_count)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
|
ImGui_ImplSDL2_CloseGamepads();
|
||||||
|
if (mode == ImGui_ImplSDL2_GamepadMode_Manual)
|
||||||
|
{
|
||||||
|
IM_ASSERT(manual_gamepads_array != nullptr && manual_gamepads_count > 0);
|
||||||
|
for (int n = 0; n < manual_gamepads_count; n++)
|
||||||
|
bd->Gamepads.push_back(manual_gamepads_array[n]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IM_ASSERT(manual_gamepads_array == nullptr && manual_gamepads_count <= 0);
|
||||||
|
bd->WantUpdateGamepadsList = true;
|
||||||
|
}
|
||||||
|
bd->GamepadMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_UpdateGamepadButton(ImGui_ImplSDL2_Data* bd, ImGuiIO& io, ImGuiKey key, SDL_GameControllerButton button_no)
|
||||||
|
{
|
||||||
|
bool merged_value = false;
|
||||||
|
for (SDL_GameController* gamepad : bd->Gamepads)
|
||||||
|
merged_value |= SDL_GameControllerGetButton(gamepad, button_no) != 0;
|
||||||
|
io.AddKeyEvent(key, merged_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline float Saturate(float v) { return v < 0.0f ? 0.0f : v > 1.0f ? 1.0f : v; }
|
||||||
|
static void ImGui_ImplSDL2_UpdateGamepadAnalog(ImGui_ImplSDL2_Data* bd, ImGuiIO& io, ImGuiKey key, SDL_GameControllerAxis axis_no, float v0, float v1)
|
||||||
|
{
|
||||||
|
float merged_value = 0.0f;
|
||||||
|
for (SDL_GameController* gamepad : bd->Gamepads)
|
||||||
|
{
|
||||||
|
float vn = Saturate((float)(SDL_GameControllerGetAxis(gamepad, axis_no) - v0) / (float)(v1 - v0));
|
||||||
|
if (merged_value < vn)
|
||||||
|
merged_value = vn;
|
||||||
|
}
|
||||||
|
io.AddKeyAnalogEvent(key, merged_value > 0.1f, merged_value);
|
||||||
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDL2_UpdateGamepads()
|
static void ImGui_ImplSDL2_UpdateGamepads()
|
||||||
{
|
{
|
||||||
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) // FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Get gamepad
|
// Update list of controller(s) to use
|
||||||
|
if (bd->WantUpdateGamepadsList && bd->GamepadMode != ImGui_ImplSDL2_GamepadMode_Manual)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_CloseGamepads();
|
||||||
|
int joystick_count = SDL_NumJoysticks();
|
||||||
|
for (int n = 0; n < joystick_count; n++)
|
||||||
|
if (SDL_IsGameController(n))
|
||||||
|
if (SDL_GameController* gamepad = SDL_GameControllerOpen(n))
|
||||||
|
{
|
||||||
|
bd->Gamepads.push_back(gamepad);
|
||||||
|
if (bd->GamepadMode == ImGui_ImplSDL2_GamepadMode_AutoFirst)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bd->WantUpdateGamepadsList = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.
|
||||||
|
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
||||||
|
return;
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
||||||
SDL_GameController* game_controller = SDL_GameControllerOpen(0);
|
if (bd->Gamepads.Size == 0)
|
||||||
if (!game_controller)
|
|
||||||
return;
|
return;
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
||||||
|
|
||||||
// Update gamepad inputs
|
// Update gamepad inputs
|
||||||
#define IM_SATURATE(V) (V < 0.0f ? 0.0f : V > 1.0f ? 1.0f : V)
|
const int thumb_dead_zone = 8000; // SDL_gamecontroller.h suggests using this value.
|
||||||
#define MAP_BUTTON(KEY_NO, BUTTON_NO) { io.AddKeyEvent(KEY_NO, SDL_GameControllerGetButton(game_controller, BUTTON_NO) != 0); }
|
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadStart, SDL_CONTROLLER_BUTTON_START);
|
||||||
#define MAP_ANALOG(KEY_NO, AXIS_NO, V0, V1) { float vn = (float)(SDL_GameControllerGetAxis(game_controller, AXIS_NO) - V0) / (float)(V1 - V0); vn = IM_SATURATE(vn); io.AddKeyAnalogEvent(KEY_NO, vn > 0.1f, vn); }
|
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadBack, SDL_CONTROLLER_BUTTON_BACK);
|
||||||
const int thumb_dead_zone = 8000; // SDL_gamecontroller.h suggests using this value.
|
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceLeft, SDL_CONTROLLER_BUTTON_X); // Xbox X, PS Square
|
||||||
MAP_BUTTON(ImGuiKey_GamepadStart, SDL_CONTROLLER_BUTTON_START);
|
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceRight, SDL_CONTROLLER_BUTTON_B); // Xbox B, PS Circle
|
||||||
MAP_BUTTON(ImGuiKey_GamepadBack, SDL_CONTROLLER_BUTTON_BACK);
|
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceUp, SDL_CONTROLLER_BUTTON_Y); // Xbox Y, PS Triangle
|
||||||
MAP_BUTTON(ImGuiKey_GamepadFaceLeft, SDL_CONTROLLER_BUTTON_X); // Xbox X, PS Square
|
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceDown, SDL_CONTROLLER_BUTTON_A); // Xbox A, PS Cross
|
||||||
MAP_BUTTON(ImGuiKey_GamepadFaceRight, SDL_CONTROLLER_BUTTON_B); // Xbox B, PS Circle
|
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadLeft, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadFaceUp, SDL_CONTROLLER_BUTTON_Y); // Xbox Y, PS Triangle
|
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadRight, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadFaceDown, SDL_CONTROLLER_BUTTON_A); // Xbox A, PS Cross
|
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadUp, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadDpadLeft, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadDown, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadDpadRight, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadL1, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadDpadUp, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadR1, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadDpadDown, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadL2, SDL_CONTROLLER_AXIS_TRIGGERLEFT, 0.0f, 32767);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadL1, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
|
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadR2, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, 0.0f, 32767);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadR1, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadL3, SDL_CONTROLLER_BUTTON_LEFTSTICK);
|
||||||
MAP_ANALOG(ImGuiKey_GamepadL2, SDL_CONTROLLER_AXIS_TRIGGERLEFT, 0.0f, 32767);
|
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadR3, SDL_CONTROLLER_BUTTON_RIGHTSTICK);
|
||||||
MAP_ANALOG(ImGuiKey_GamepadR2, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, 0.0f, 32767);
|
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickLeft, SDL_CONTROLLER_AXIS_LEFTX, -thumb_dead_zone, -32768);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadL3, SDL_CONTROLLER_BUTTON_LEFTSTICK);
|
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickRight, SDL_CONTROLLER_AXIS_LEFTX, +thumb_dead_zone, +32767);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadR3, SDL_CONTROLLER_BUTTON_RIGHTSTICK);
|
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickUp, SDL_CONTROLLER_AXIS_LEFTY, -thumb_dead_zone, -32768);
|
||||||
MAP_ANALOG(ImGuiKey_GamepadLStickLeft, SDL_CONTROLLER_AXIS_LEFTX, -thumb_dead_zone, -32768);
|
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickDown, SDL_CONTROLLER_AXIS_LEFTY, +thumb_dead_zone, +32767);
|
||||||
MAP_ANALOG(ImGuiKey_GamepadLStickRight, SDL_CONTROLLER_AXIS_LEFTX, +thumb_dead_zone, +32767);
|
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickLeft, SDL_CONTROLLER_AXIS_RIGHTX, -thumb_dead_zone, -32768);
|
||||||
MAP_ANALOG(ImGuiKey_GamepadLStickUp, SDL_CONTROLLER_AXIS_LEFTY, -thumb_dead_zone, -32768);
|
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickRight, SDL_CONTROLLER_AXIS_RIGHTX, +thumb_dead_zone, +32767);
|
||||||
MAP_ANALOG(ImGuiKey_GamepadLStickDown, SDL_CONTROLLER_AXIS_LEFTY, +thumb_dead_zone, +32767);
|
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickUp, SDL_CONTROLLER_AXIS_RIGHTY, -thumb_dead_zone, -32768);
|
||||||
MAP_ANALOG(ImGuiKey_GamepadRStickLeft, SDL_CONTROLLER_AXIS_RIGHTX, -thumb_dead_zone, -32768);
|
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickDown, SDL_CONTROLLER_AXIS_RIGHTY, +thumb_dead_zone, +32767);
|
||||||
MAP_ANALOG(ImGuiKey_GamepadRStickRight, SDL_CONTROLLER_AXIS_RIGHTX, +thumb_dead_zone, +32767);
|
}
|
||||||
MAP_ANALOG(ImGuiKey_GamepadRStickUp, SDL_CONTROLLER_AXIS_RIGHTY, -thumb_dead_zone, -32768);
|
|
||||||
MAP_ANALOG(ImGuiKey_GamepadRStickDown, SDL_CONTROLLER_AXIS_RIGHTY, +thumb_dead_zone, +32767);
|
// FIXME: Note that doesn't update with DPI/Scaling change only as SDL2 doesn't have an event for it (SDL3 has).
|
||||||
#undef MAP_BUTTON
|
static void ImGui_ImplSDL2_UpdateMonitors()
|
||||||
#undef MAP_ANALOG
|
{
|
||||||
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Monitors.resize(0);
|
||||||
|
bd->WantUpdateMonitors = false;
|
||||||
|
int display_count = SDL_GetNumVideoDisplays();
|
||||||
|
for (int n = 0; n < display_count; n++)
|
||||||
|
{
|
||||||
|
// Warning: the validity of monitor DPI information on Windows depends on the application DPI awareness settings, which generally needs to be set in the manifest or at runtime.
|
||||||
|
ImGuiPlatformMonitor monitor;
|
||||||
|
SDL_Rect r;
|
||||||
|
SDL_GetDisplayBounds(n, &r);
|
||||||
|
monitor.MainPos = monitor.WorkPos = ImVec2((float)r.x, (float)r.y);
|
||||||
|
monitor.MainSize = monitor.WorkSize = ImVec2((float)r.w, (float)r.h);
|
||||||
|
#if SDL_HAS_USABLE_DISPLAY_BOUNDS
|
||||||
|
SDL_GetDisplayUsableBounds(n, &r);
|
||||||
|
monitor.WorkPos = ImVec2((float)r.x, (float)r.y);
|
||||||
|
monitor.WorkSize = ImVec2((float)r.w, (float)r.h);
|
||||||
|
#endif
|
||||||
|
#if SDL_HAS_PER_MONITOR_DPI
|
||||||
|
// FIXME-VIEWPORT: On MacOS SDL reports actual monitor DPI scale, ignoring OS configuration. We may want to set
|
||||||
|
// DpiScale to cocoa_window.backingScaleFactor here.
|
||||||
|
float dpi = 0.0f;
|
||||||
|
if (!SDL_GetDisplayDPI(n, &dpi, nullptr, nullptr))
|
||||||
|
monitor.DpiScale = dpi / 96.0f;
|
||||||
|
#endif
|
||||||
|
monitor.PlatformHandle = (void*)(intptr_t)n;
|
||||||
|
platform_io.Monitors.push_back(monitor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDL2_NewFrame()
|
void ImGui_ImplSDL2_NewFrame()
|
||||||
@@ -617,6 +857,10 @@ void ImGui_ImplSDL2_NewFrame()
|
|||||||
if (w > 0 && h > 0)
|
if (w > 0 && h > 0)
|
||||||
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
||||||
|
|
||||||
|
// Update monitors
|
||||||
|
if (bd->WantUpdateMonitors)
|
||||||
|
ImGui_ImplSDL2_UpdateMonitors();
|
||||||
|
|
||||||
// Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
|
// Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
|
||||||
// (Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. Happens in VMs and Emscripten, see #6189, #6114, #3644)
|
// (Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. Happens in VMs and Emscripten, see #6189, #6114, #3644)
|
||||||
static Uint64 frequency = SDL_GetPerformanceFrequency();
|
static Uint64 frequency = SDL_GetPerformanceFrequency();
|
||||||
@@ -626,13 +870,20 @@ void ImGui_ImplSDL2_NewFrame()
|
|||||||
io.DeltaTime = bd->Time > 0 ? (float)((double)(current_time - bd->Time) / frequency) : (float)(1.0f / 60.0f);
|
io.DeltaTime = bd->Time > 0 ? (float)((double)(current_time - bd->Time) / frequency) : (float)(1.0f / 60.0f);
|
||||||
bd->Time = current_time;
|
bd->Time = current_time;
|
||||||
|
|
||||||
if (bd->PendingMouseLeaveFrame && bd->PendingMouseLeaveFrame >= ImGui::GetFrameCount() && bd->MouseButtonsDown == 0)
|
if (bd->MouseLastLeaveFrame && bd->MouseLastLeaveFrame >= ImGui::GetFrameCount() && bd->MouseButtonsDown == 0)
|
||||||
{
|
{
|
||||||
bd->MouseWindowID = 0;
|
bd->MouseWindowID = 0;
|
||||||
bd->PendingMouseLeaveFrame = 0;
|
bd->MouseLastLeaveFrame = 0;
|
||||||
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Our io.AddMouseViewportEvent() calls will only be valid when not capturing.
|
||||||
|
// Technically speaking testing for 'bd->MouseButtonsDown == 0' would be more rygorous, but testing for payload reduces noise and potential side-effects.
|
||||||
|
if (bd->MouseCanReportHoveredViewport && ImGui::GetDragDropPayload() == nullptr)
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport;
|
||||||
|
else
|
||||||
|
io.BackendFlags &= ~ImGuiBackendFlags_HasMouseHoveredViewport;
|
||||||
|
|
||||||
ImGui_ImplSDL2_UpdateMouseData();
|
ImGui_ImplSDL2_UpdateMouseData();
|
||||||
ImGui_ImplSDL2_UpdateMouseCursor();
|
ImGui_ImplSDL2_UpdateMouseCursor();
|
||||||
|
|
||||||
@@ -640,6 +891,257 @@ void ImGui_ImplSDL2_NewFrame()
|
|||||||
ImGui_ImplSDL2_UpdateGamepads();
|
ImGui_ImplSDL2_UpdateGamepads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplSDL2_ViewportData
|
||||||
|
{
|
||||||
|
SDL_Window* Window;
|
||||||
|
Uint32 WindowID;
|
||||||
|
bool WindowOwned;
|
||||||
|
SDL_GLContext GLContext;
|
||||||
|
|
||||||
|
ImGui_ImplSDL2_ViewportData() { Window = nullptr; WindowID = 0; WindowOwned = false; GLContext = nullptr; }
|
||||||
|
~ImGui_ImplSDL2_ViewportData() { IM_ASSERT(Window == nullptr && GLContext == nullptr); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = IM_NEW(ImGui_ImplSDL2_ViewportData)();
|
||||||
|
viewport->PlatformUserData = vd;
|
||||||
|
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
ImGui_ImplSDL2_ViewportData* main_viewport_data = (ImGui_ImplSDL2_ViewportData*)main_viewport->PlatformUserData;
|
||||||
|
|
||||||
|
// Share GL resources with main context
|
||||||
|
bool use_opengl = (main_viewport_data->GLContext != nullptr);
|
||||||
|
SDL_GLContext backup_context = nullptr;
|
||||||
|
if (use_opengl)
|
||||||
|
{
|
||||||
|
backup_context = SDL_GL_GetCurrentContext();
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
|
||||||
|
SDL_GL_MakeCurrent(main_viewport_data->Window, main_viewport_data->GLContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint32 sdl_flags = 0;
|
||||||
|
sdl_flags |= use_opengl ? SDL_WINDOW_OPENGL : (bd->UseVulkan ? SDL_WINDOW_VULKAN : 0);
|
||||||
|
sdl_flags |= SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_ALLOW_HIGHDPI;
|
||||||
|
sdl_flags |= SDL_WINDOW_HIDDEN;
|
||||||
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? SDL_WINDOW_BORDERLESS : 0;
|
||||||
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? 0 : SDL_WINDOW_RESIZABLE;
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
// See SDL hack in ImGui_ImplSDL2_ShowWindow().
|
||||||
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon) ? SDL_WINDOW_SKIP_TASKBAR : 0;
|
||||||
|
#endif
|
||||||
|
#if SDL_HAS_ALWAYS_ON_TOP
|
||||||
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_TopMost) ? SDL_WINDOW_ALWAYS_ON_TOP : 0;
|
||||||
|
#endif
|
||||||
|
vd->Window = SDL_CreateWindow("No Title Yet", (int)viewport->Pos.x, (int)viewport->Pos.y, (int)viewport->Size.x, (int)viewport->Size.y, sdl_flags);
|
||||||
|
vd->WindowOwned = true;
|
||||||
|
if (use_opengl)
|
||||||
|
{
|
||||||
|
vd->GLContext = SDL_GL_CreateContext(vd->Window);
|
||||||
|
SDL_GL_SetSwapInterval(0);
|
||||||
|
}
|
||||||
|
if (use_opengl && backup_context)
|
||||||
|
SDL_GL_MakeCurrent(vd->Window, backup_context);
|
||||||
|
|
||||||
|
viewport->PlatformHandle = (void*)vd->Window;
|
||||||
|
viewport->PlatformHandleRaw = nullptr;
|
||||||
|
SDL_SysWMinfo info;
|
||||||
|
SDL_VERSION(&info.version);
|
||||||
|
if (SDL_GetWindowWMInfo(vd->Window, &info))
|
||||||
|
{
|
||||||
|
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
|
||||||
|
viewport->PlatformHandleRaw = info.info.win.window;
|
||||||
|
#elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA)
|
||||||
|
viewport->PlatformHandleRaw = (void*)info.info.cocoa.window;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
if (ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData)
|
||||||
|
{
|
||||||
|
if (vd->GLContext && vd->WindowOwned)
|
||||||
|
SDL_GL_DeleteContext(vd->GLContext);
|
||||||
|
if (vd->Window && vd->WindowOwned)
|
||||||
|
SDL_DestroyWindow(vd->Window);
|
||||||
|
vd->GLContext = nullptr;
|
||||||
|
vd->Window = nullptr;
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->PlatformUserData = viewport->PlatformHandle = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_ShowWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
#if defined(_WIN32)
|
||||||
|
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
|
||||||
|
|
||||||
|
// SDL hack: Hide icon from task bar
|
||||||
|
// Note: SDL 2.0.6+ has a SDL_WINDOW_SKIP_TASKBAR flag which is supported under Windows but the way it create the window breaks our seamless transition.
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon)
|
||||||
|
{
|
||||||
|
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||||
|
ex_style &= ~WS_EX_APPWINDOW;
|
||||||
|
ex_style |= WS_EX_TOOLWINDOW;
|
||||||
|
::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SDL hack: SDL always activate/focus windows :/
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing)
|
||||||
|
{
|
||||||
|
::ShowWindow(hwnd, SW_SHOWNA);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SDL_ShowWindow(vd->Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplSDL2_GetWindowPos(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
int x = 0, y = 0;
|
||||||
|
SDL_GetWindowPosition(vd->Window, &x, &y);
|
||||||
|
return ImVec2((float)x, (float)y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_SetWindowPosition(vd->Window, (int)pos.x, (int)pos.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplSDL2_GetWindowSize(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
int w = 0, h = 0;
|
||||||
|
SDL_GetWindowSize(vd->Window, &w, &h);
|
||||||
|
return ImVec2((float)w, (float)h);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_SetWindowSize(vd->Window, (int)size.x, (int)size.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_SetWindowTitle(ImGuiViewport* viewport, const char* title)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_SetWindowTitle(vd->Window, title);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SDL_HAS_WINDOW_ALPHA
|
||||||
|
static void ImGui_ImplSDL2_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_SetWindowOpacity(vd->Window, alpha);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_SetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_RaiseWindow(vd->Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplSDL2_GetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
return (SDL_GetWindowFlags(vd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplSDL2_GetWindowMinimized(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
return (SDL_GetWindowFlags(vd->Window) & SDL_WINDOW_MINIMIZED) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
if (vd->GLContext)
|
||||||
|
SDL_GL_MakeCurrent(vd->Window, vd->GLContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
if (vd->GLContext)
|
||||||
|
{
|
||||||
|
SDL_GL_MakeCurrent(vd->Window, vd->GLContext);
|
||||||
|
SDL_GL_SwapWindow(vd->Window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vulkan support (the Vulkan renderer needs to call a platform-side support function to create the surface)
|
||||||
|
// SDL is graceful enough to _not_ need <vulkan/vulkan.h> so we can safely include this.
|
||||||
|
#if SDL_HAS_VULKAN
|
||||||
|
#include <SDL_vulkan.h>
|
||||||
|
static int ImGui_ImplSDL2_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_instance, const void* vk_allocator, ImU64* out_vk_surface)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
(void)vk_allocator;
|
||||||
|
SDL_bool ret = SDL_Vulkan_CreateSurface(vd->Window, (VkInstance)vk_instance, (VkSurfaceKHR*)out_vk_surface);
|
||||||
|
return ret ? 0 : 1; // ret ? VK_SUCCESS : VK_NOT_READY
|
||||||
|
}
|
||||||
|
#endif // SDL_HAS_VULKAN
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_InitPlatformInterface(SDL_Window* window, void* sdl_gl_context)
|
||||||
|
{
|
||||||
|
// Register platform interface (will be coupled with a renderer interface)
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Platform_CreateWindow = ImGui_ImplSDL2_CreateWindow;
|
||||||
|
platform_io.Platform_DestroyWindow = ImGui_ImplSDL2_DestroyWindow;
|
||||||
|
platform_io.Platform_ShowWindow = ImGui_ImplSDL2_ShowWindow;
|
||||||
|
platform_io.Platform_SetWindowPos = ImGui_ImplSDL2_SetWindowPos;
|
||||||
|
platform_io.Platform_GetWindowPos = ImGui_ImplSDL2_GetWindowPos;
|
||||||
|
platform_io.Platform_SetWindowSize = ImGui_ImplSDL2_SetWindowSize;
|
||||||
|
platform_io.Platform_GetWindowSize = ImGui_ImplSDL2_GetWindowSize;
|
||||||
|
platform_io.Platform_SetWindowFocus = ImGui_ImplSDL2_SetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowFocus = ImGui_ImplSDL2_GetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowMinimized = ImGui_ImplSDL2_GetWindowMinimized;
|
||||||
|
platform_io.Platform_SetWindowTitle = ImGui_ImplSDL2_SetWindowTitle;
|
||||||
|
platform_io.Platform_RenderWindow = ImGui_ImplSDL2_RenderWindow;
|
||||||
|
platform_io.Platform_SwapBuffers = ImGui_ImplSDL2_SwapBuffers;
|
||||||
|
#if SDL_HAS_WINDOW_ALPHA
|
||||||
|
platform_io.Platform_SetWindowAlpha = ImGui_ImplSDL2_SetWindowAlpha;
|
||||||
|
#endif
|
||||||
|
#if SDL_HAS_VULKAN
|
||||||
|
platform_io.Platform_CreateVkSurface = ImGui_ImplSDL2_CreateVkSurface;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Register main window handle (which is owned by the main application, not by us)
|
||||||
|
// This is mostly for simplicity and consistency, so that our code (e.g. mouse handling etc.) can use same logic for main and secondary viewports.
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = IM_NEW(ImGui_ImplSDL2_ViewportData)();
|
||||||
|
vd->Window = window;
|
||||||
|
vd->WindowID = SDL_GetWindowID(window);
|
||||||
|
vd->WindowOwned = false;
|
||||||
|
vd->GLContext = sdl_gl_context;
|
||||||
|
main_viewport->PlatformUserData = vd;
|
||||||
|
main_viewport->PlatformHandle = vd->Window;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -8,18 +8,26 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// [X] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
// Missing features:
|
||||||
|
// [ ] Platform: Multi-viewport + Minimized windows seems to break mouse wheel events (at least under Windows).
|
||||||
|
// [x] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
struct SDL_Renderer;
|
struct SDL_Renderer;
|
||||||
|
struct _SDL_GameController;
|
||||||
typedef union SDL_Event SDL_Event;
|
typedef union SDL_Event SDL_Event;
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
||||||
@@ -27,10 +35,14 @@ IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
|
|||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer);
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOther(SDL_Window* window);
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
// Gamepad selection automatically starts in AutoFirst mode, picking first available SDL_Gamepad. You may override this.
|
||||||
static inline void ImGui_ImplSDL2_NewFrame(SDL_Window*) { ImGui_ImplSDL2_NewFrame(); } // 1.84: removed unnecessary parameter
|
// When using manual mode, caller is responsible for opening/closing gamepad.
|
||||||
#endif
|
enum ImGui_ImplSDL2_GamepadMode { ImGui_ImplSDL2_GamepadMode_AutoFirst, ImGui_ImplSDL2_GamepadMode_AutoAll, ImGui_ImplSDL2_GamepadMode_Manual };
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode mode, struct _SDL_GameController** manual_gamepads_array = NULL, int manual_gamepads_count = -1);
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -9,22 +9,33 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
|
// [x] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable' -> the OS animation effect when window gets created/destroyed is problematic. SDL2 backend doesn't have issue.
|
||||||
// Missing features:
|
// Missing features:
|
||||||
|
// [ ] Platform: Multi-viewport + Minimized windows seems to break mouse wheel events (at least under Windows).
|
||||||
// [x] Platform: Basic IME support. Position somehow broken in SDL3 + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
// [x] Platform: Basic IME support. Position somehow broken in SDL3 + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2024-02-13: Inputs: Fixed gamepad support. Handle gamepad disconnection. Added ImGui_ImplSDL3_SetGamepadMode().
|
||||||
|
// 2023-11-13: Updated for recent SDL3 API changes.
|
||||||
|
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
||||||
|
// 2023-05-04: Fixed build on Emscripten/iOS/Android. (#6391)
|
||||||
// 2023-04-06: Inputs: Avoid calling SDL_StartTextInput()/SDL_StopTextInput() as they don't only pertain to IME. It's unclear exactly what their relation is to IME. (#6306)
|
// 2023-04-06: Inputs: Avoid calling SDL_StartTextInput()/SDL_StopTextInput() as they don't only pertain to IME. It's unclear exactly what their relation is to IME. (#6306)
|
||||||
// 2023-04-04: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_TouchScreen. (#2702)
|
// 2023-04-04: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_TouchScreen. (#2702)
|
||||||
// 2023-02-23: Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. (#6189, #6114, #3644)
|
// 2023-02-23: Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. (#6189, #6114, #3644)
|
||||||
// 2023-02-07: Forked "imgui_impl_sdl2" into "imgui_impl_sdl3". Removed version checks for old feature. Refer to imgui_impl_sdl2.cpp for older changelog.
|
// 2023-02-07: Forked "imgui_impl_sdl2" into "imgui_impl_sdl3". Removed version checks for old feature. Refer to imgui_impl_sdl2.cpp for older changelog.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_sdl3.h"
|
#include "imgui_impl_sdl3.h"
|
||||||
|
|
||||||
// Clang warnings with -Weverything
|
// Clang warnings with -Weverything
|
||||||
@@ -35,10 +46,15 @@
|
|||||||
|
|
||||||
// SDL
|
// SDL
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <SDL3/SDL_syswm.h>
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
#include <TargetConditionals.h>
|
#include <TargetConditionals.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _WIN32
|
||||||
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#endif
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS) && !defined(__amigaos4__)
|
#if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS) && !defined(__amigaos4__)
|
||||||
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 1
|
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 1
|
||||||
@@ -49,16 +65,26 @@
|
|||||||
// SDL Data
|
// SDL Data
|
||||||
struct ImGui_ImplSDL3_Data
|
struct ImGui_ImplSDL3_Data
|
||||||
{
|
{
|
||||||
SDL_Window* Window;
|
SDL_Window* Window;
|
||||||
SDL_Renderer* Renderer;
|
SDL_Renderer* Renderer;
|
||||||
Uint64 Time;
|
Uint64 Time;
|
||||||
Uint32 MouseWindowID;
|
char* ClipboardTextData;
|
||||||
int MouseButtonsDown;
|
bool UseVulkan;
|
||||||
SDL_Cursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
bool WantUpdateMonitors;
|
||||||
SDL_Cursor* LastMouseCursor;
|
|
||||||
int PendingMouseLeaveFrame;
|
// Mouse handling
|
||||||
char* ClipboardTextData;
|
Uint32 MouseWindowID;
|
||||||
bool MouseCanUseGlobalState;
|
int MouseButtonsDown;
|
||||||
|
SDL_Cursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
||||||
|
SDL_Cursor* MouseLastCursor;
|
||||||
|
int MousePendingLeaveFrame;
|
||||||
|
bool MouseCanUseGlobalState;
|
||||||
|
bool MouseCanReportHoveredViewport; // This is hard to use/unreliable on SDL so we'll set ImGuiBackendFlags_HasMouseHoveredViewport dynamically based on state.
|
||||||
|
|
||||||
|
// Gamepad handling
|
||||||
|
ImVector<SDL_Gamepad*> Gamepads;
|
||||||
|
ImGui_ImplSDL3_GamepadMode GamepadMode;
|
||||||
|
bool WantUpdateGamepadsList;
|
||||||
|
|
||||||
ImGui_ImplSDL3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
ImGui_ImplSDL3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
@@ -72,6 +98,11 @@ static ImGui_ImplSDL3_Data* ImGui_ImplSDL3_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplSDL3_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplSDL3_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplSDL3_UpdateMonitors();
|
||||||
|
static void ImGui_ImplSDL3_InitPlatformInterface(SDL_Window* window, void* sdl_gl_context);
|
||||||
|
static void ImGui_ImplSDL3_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static const char* ImGui_ImplSDL3_GetClipboardText(void*)
|
static const char* ImGui_ImplSDL3_GetClipboardText(void*)
|
||||||
{
|
{
|
||||||
@@ -87,13 +118,13 @@ static void ImGui_ImplSDL3_SetClipboardText(void*, const char* text)
|
|||||||
SDL_SetClipboardText(text);
|
SDL_SetClipboardText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDL3_SetPlatformImeData(ImGuiViewport*, ImGuiPlatformImeData* data)
|
static void ImGui_ImplSDL3_SetPlatformImeData(ImGuiViewport* viewport, ImGuiPlatformImeData* data)
|
||||||
{
|
{
|
||||||
if (data->WantVisible)
|
if (data->WantVisible)
|
||||||
{
|
{
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
r.x = (int)data->InputPos.x;
|
r.x = (int)(data->InputPos.x - viewport->Pos.x);
|
||||||
r.y = (int)data->InputPos.y;
|
r.y = (int)(data->InputPos.y - viewport->Pos.y + data->InputLineHeight);
|
||||||
r.w = 1;
|
r.w = 1;
|
||||||
r.h = (int)data->InputLineHeight;
|
r.h = (int)data->InputLineHeight;
|
||||||
SDL_SetTextInputRect(&r);
|
SDL_SetTextInputRect(&r);
|
||||||
@@ -209,6 +240,20 @@ static ImGuiKey ImGui_ImplSDL3_KeycodeToImGuiKey(int keycode)
|
|||||||
case SDLK_F10: return ImGuiKey_F10;
|
case SDLK_F10: return ImGuiKey_F10;
|
||||||
case SDLK_F11: return ImGuiKey_F11;
|
case SDLK_F11: return ImGuiKey_F11;
|
||||||
case SDLK_F12: return ImGuiKey_F12;
|
case SDLK_F12: return ImGuiKey_F12;
|
||||||
|
case SDLK_F13: return ImGuiKey_F13;
|
||||||
|
case SDLK_F14: return ImGuiKey_F14;
|
||||||
|
case SDLK_F15: return ImGuiKey_F15;
|
||||||
|
case SDLK_F16: return ImGuiKey_F16;
|
||||||
|
case SDLK_F17: return ImGuiKey_F17;
|
||||||
|
case SDLK_F18: return ImGuiKey_F18;
|
||||||
|
case SDLK_F19: return ImGuiKey_F19;
|
||||||
|
case SDLK_F20: return ImGuiKey_F20;
|
||||||
|
case SDLK_F21: return ImGuiKey_F21;
|
||||||
|
case SDLK_F22: return ImGuiKey_F22;
|
||||||
|
case SDLK_F23: return ImGuiKey_F23;
|
||||||
|
case SDLK_F24: return ImGuiKey_F24;
|
||||||
|
case SDLK_AC_BACK: return ImGuiKey_AppBack;
|
||||||
|
case SDLK_AC_FORWARD: return ImGuiKey_AppForward;
|
||||||
}
|
}
|
||||||
return ImGuiKey_None;
|
return ImGuiKey_None;
|
||||||
}
|
}
|
||||||
@@ -237,6 +282,13 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
|||||||
case SDL_EVENT_MOUSE_MOTION:
|
case SDL_EVENT_MOUSE_MOTION:
|
||||||
{
|
{
|
||||||
ImVec2 mouse_pos((float)event->motion.x, (float)event->motion.y);
|
ImVec2 mouse_pos((float)event->motion.x, (float)event->motion.y);
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
int window_x, window_y;
|
||||||
|
SDL_GetWindowPosition(SDL_GetWindowFromID(event->motion.windowID), &window_x, &window_y);
|
||||||
|
mouse_pos.x += window_x;
|
||||||
|
mouse_pos.y += window_y;
|
||||||
|
}
|
||||||
io.AddMouseSourceEvent(event->motion.which == SDL_TOUCH_MOUSEID ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse);
|
io.AddMouseSourceEvent(event->motion.which == SDL_TOUCH_MOUSEID ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse);
|
||||||
io.AddMousePosEvent(mouse_pos.x, mouse_pos.y);
|
io.AddMousePosEvent(mouse_pos.x, mouse_pos.y);
|
||||||
return true;
|
return true;
|
||||||
@@ -283,10 +335,19 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
|||||||
io.SetKeyEventNativeData(key, event->key.keysym.sym, event->key.keysym.scancode, event->key.keysym.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions.
|
io.SetKeyEventNativeData(key, event->key.keysym.sym, event->key.keysym.scancode, event->key.keysym.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case SDL_EVENT_DISPLAY_ORIENTATION:
|
||||||
|
case SDL_EVENT_DISPLAY_ADDED:
|
||||||
|
case SDL_EVENT_DISPLAY_REMOVED:
|
||||||
|
case SDL_EVENT_DISPLAY_MOVED:
|
||||||
|
case SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED:
|
||||||
|
{
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
case SDL_EVENT_WINDOW_MOUSE_ENTER:
|
case SDL_EVENT_WINDOW_MOUSE_ENTER:
|
||||||
{
|
{
|
||||||
bd->MouseWindowID = event->window.windowID;
|
bd->MouseWindowID = event->window.windowID;
|
||||||
bd->PendingMouseLeaveFrame = 0;
|
bd->MousePendingLeaveFrame = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// - In some cases, when detaching a window from main viewport SDL may send SDL_WINDOWEVENT_ENTER one frame too late,
|
// - In some cases, when detaching a window from main viewport SDL may send SDL_WINDOWEVENT_ENTER one frame too late,
|
||||||
@@ -295,7 +356,7 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
|||||||
// FIXME: Unconfirmed whether this is still needed with SDL3.
|
// FIXME: Unconfirmed whether this is still needed with SDL3.
|
||||||
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
|
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
|
||||||
{
|
{
|
||||||
bd->PendingMouseLeaveFrame = ImGui::GetFrameCount() + 1;
|
bd->MousePendingLeaveFrame = ImGui::GetFrameCount() + 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case SDL_EVENT_WINDOW_FOCUS_GAINED:
|
case SDL_EVENT_WINDOW_FOCUS_GAINED:
|
||||||
@@ -304,14 +365,46 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
|||||||
case SDL_EVENT_WINDOW_FOCUS_LOST:
|
case SDL_EVENT_WINDOW_FOCUS_LOST:
|
||||||
io.AddFocusEvent(false);
|
io.AddFocusEvent(false);
|
||||||
return true;
|
return true;
|
||||||
|
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
|
||||||
|
case SDL_EVENT_WINDOW_MOVED:
|
||||||
|
case SDL_EVENT_WINDOW_RESIZED:
|
||||||
|
if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle((void*)SDL_GetWindowFromID(event->window.windowID)))
|
||||||
|
{
|
||||||
|
if (event->type == SDL_EVENT_WINDOW_CLOSE_REQUESTED)
|
||||||
|
viewport->PlatformRequestClose = true;
|
||||||
|
if (event->type == SDL_EVENT_WINDOW_MOVED)
|
||||||
|
viewport->PlatformRequestMove = true;
|
||||||
|
if (event->type == SDL_EVENT_WINDOW_RESIZED)
|
||||||
|
viewport->PlatformRequestResize = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case SDL_EVENT_GAMEPAD_ADDED:
|
||||||
|
case SDL_EVENT_GAMEPAD_REMOVED:
|
||||||
|
{
|
||||||
|
bd->WantUpdateGamepadsList = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer)
|
static void ImGui_ImplSDL3_SetupPlatformHandles(ImGuiViewport* viewport, SDL_Window* window)
|
||||||
|
{
|
||||||
|
viewport->PlatformHandle = window;
|
||||||
|
viewport->PlatformHandleRaw = nullptr;
|
||||||
|
#if defined(__WIN32__) && !defined(__WINRT__)
|
||||||
|
viewport->PlatformHandleRaw = (HWND)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.win32.hwnd", nullptr);
|
||||||
|
#elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA)
|
||||||
|
viewport->PlatformHandleRaw = (void*)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.cocoa.window", nullptr);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void* sdl_gl_context)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
||||||
|
IM_UNUSED(sdl_gl_context); // Unused in this branch
|
||||||
|
|
||||||
// Check and store if we are on a SDL backend that supports global mouse position
|
// Check and store if we are on a SDL backend that supports global mouse position
|
||||||
// ("wayland" and "rpi" don't support it, but we chose to use a white-list instead of a black-list)
|
// ("wayland" and "rpi" don't support it, but we chose to use a white-list instead of a black-list)
|
||||||
@@ -330,16 +423,31 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer)
|
|||||||
io.BackendPlatformName = "imgui_impl_sdl3";
|
io.BackendPlatformName = "imgui_impl_sdl3";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||||
|
if (mouse_can_use_global_state)
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
|
||||||
|
|
||||||
bd->Window = window;
|
bd->Window = window;
|
||||||
bd->Renderer = renderer;
|
bd->Renderer = renderer;
|
||||||
|
|
||||||
|
// SDL on Linux/OSX doesn't report events for unfocused windows (see https://github.com/ocornut/imgui/issues/4960)
|
||||||
|
// We will use 'MouseCanReportHoveredViewport' to set 'ImGuiBackendFlags_HasMouseHoveredViewport' dynamically each frame.
|
||||||
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
|
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
|
||||||
|
#ifndef __APPLE__
|
||||||
|
bd->MouseCanReportHoveredViewport = bd->MouseCanUseGlobalState;
|
||||||
|
#else
|
||||||
|
bd->MouseCanReportHoveredViewport = false;
|
||||||
|
#endif
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
|
|
||||||
io.SetClipboardTextFn = ImGui_ImplSDL3_SetClipboardText;
|
io.SetClipboardTextFn = ImGui_ImplSDL3_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplSDL3_GetClipboardText;
|
io.GetClipboardTextFn = ImGui_ImplSDL3_GetClipboardText;
|
||||||
io.ClipboardUserData = nullptr;
|
io.ClipboardUserData = nullptr;
|
||||||
io.SetPlatformImeDataFn = ImGui_ImplSDL3_SetPlatformImeData;
|
io.SetPlatformImeDataFn = ImGui_ImplSDL3_SetPlatformImeData;
|
||||||
|
|
||||||
|
// Gamepad handling
|
||||||
|
bd->GamepadMode = ImGui_ImplSDL3_GamepadMode_AutoFirst;
|
||||||
|
bd->WantUpdateGamepadsList = true;
|
||||||
|
|
||||||
// Load mouse cursors
|
// Load mouse cursors
|
||||||
bd->MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
|
bd->MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
|
||||||
bd->MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
|
bd->MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
|
||||||
@@ -354,43 +462,41 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer)
|
|||||||
// Set platform dependent data in viewport
|
// Set platform dependent data in viewport
|
||||||
// Our mouse update function expect PlatformHandle to be filled for the main viewport
|
// Our mouse update function expect PlatformHandle to be filled for the main viewport
|
||||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
main_viewport->PlatformHandleRaw = nullptr;
|
ImGui_ImplSDL3_SetupPlatformHandles(main_viewport, window);
|
||||||
SDL_SysWMinfo info;
|
|
||||||
if (SDL_GetWindowWMInfo(window, &info, SDL_SYSWM_CURRENT_VERSION) == 0)
|
|
||||||
{
|
|
||||||
#if defined(SDL_ENABLE_SYSWM_WINDOWS)
|
|
||||||
main_viewport->PlatformHandleRaw = (void*)info.info.win.window;
|
|
||||||
#elif defined(__APPLE__) && defined(SDL_ENABLE_SYSWM_COCOA)
|
|
||||||
main_viewport->PlatformHandleRaw = (void*)info.info.cocoa.window;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// From 2.0.5: Set SDL hint to receive mouse click events on window focus, otherwise SDL doesn't emit the event.
|
// From 2.0.5: Set SDL hint to receive mouse click events on window focus, otherwise SDL doesn't emit the event.
|
||||||
// Without this, when clicking to gain focus, our widgets wouldn't activate even though they showed as hovered.
|
// Without this, when clicking to gain focus, our widgets wouldn't activate even though they showed as hovered.
|
||||||
// (This is unfortunately a global SDL setting, so enabling it might have a side-effect on your application.
|
// (This is unfortunately a global SDL setting, so enabling it might have a side-effect on your application.
|
||||||
// It is unlikely to make a difference, but if your app absolutely needs to ignore the initial on-focus click:
|
// It is unlikely to make a difference, but if your app absolutely needs to ignore the initial on-focus click:
|
||||||
// you can ignore SDL_EVENT_MOUSE_BUTTON_DOWN events coming right after a SDL_WINDOWEVENT_FOCUS_GAINED)
|
// you can ignore SDL_EVENT_MOUSE_BUTTON_DOWN events coming right after a SDL_WINDOWEVENT_FOCUS_GAINED)
|
||||||
#ifdef SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH
|
|
||||||
SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
|
SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
|
||||||
#endif
|
|
||||||
|
|
||||||
// From 2.0.22: Disable auto-capture, this is preventing drag and drop across multiple windows (see #5710)
|
// From 2.0.22: Disable auto-capture, this is preventing drag and drop across multiple windows (see #5710)
|
||||||
#ifdef SDL_HINT_MOUSE_AUTO_CAPTURE
|
|
||||||
SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0");
|
SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0");
|
||||||
#endif
|
|
||||||
|
// SDL 3.x : see https://github.com/libsdl-org/SDL/issues/6659
|
||||||
|
SDL_SetHint("SDL_BORDERLESS_WINDOWED_STYLE", "0");
|
||||||
|
|
||||||
|
// We need SDL_CaptureMouse(), SDL_GetGlobalMouseState() from SDL 2.0.4+ to support multiple viewports.
|
||||||
|
// We left the call to ImGui_ImplSDL3_InitPlatformInterface() outside of #ifdef to avoid unused-function warnings.
|
||||||
|
if ((io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) && (io.BackendFlags & ImGuiBackendFlags_PlatformHasViewports))
|
||||||
|
ImGui_ImplSDL3_InitPlatformInterface(window, sdl_gl_context);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL3_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
|
bool ImGui_ImplSDL3_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
|
||||||
{
|
{
|
||||||
IM_UNUSED(sdl_gl_context); // Viewport branch will need this.
|
return ImGui_ImplSDL3_Init(window, nullptr, sdl_gl_context);
|
||||||
return ImGui_ImplSDL3_Init(window, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL3_InitForVulkan(SDL_Window* window)
|
bool ImGui_ImplSDL3_InitForVulkan(SDL_Window* window)
|
||||||
{
|
{
|
||||||
return ImGui_ImplSDL3_Init(window, nullptr);
|
if (!ImGui_ImplSDL3_Init(window, nullptr, nullptr))
|
||||||
|
return false;
|
||||||
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
|
bd->UseVulkan = true;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL3_InitForD3D(SDL_Window* window)
|
bool ImGui_ImplSDL3_InitForD3D(SDL_Window* window)
|
||||||
@@ -398,36 +504,47 @@ bool ImGui_ImplSDL3_InitForD3D(SDL_Window* window)
|
|||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
IM_ASSERT(0 && "Unsupported");
|
IM_ASSERT(0 && "Unsupported");
|
||||||
#endif
|
#endif
|
||||||
return ImGui_ImplSDL3_Init(window, nullptr);
|
return ImGui_ImplSDL3_Init(window, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL3_InitForMetal(SDL_Window* window)
|
bool ImGui_ImplSDL3_InitForMetal(SDL_Window* window)
|
||||||
{
|
{
|
||||||
return ImGui_ImplSDL3_Init(window, nullptr);
|
return ImGui_ImplSDL3_Init(window, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL3_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer)
|
bool ImGui_ImplSDL3_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer)
|
||||||
{
|
{
|
||||||
return ImGui_ImplSDL3_Init(window, renderer);
|
return ImGui_ImplSDL3_Init(window, renderer, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ImGui_ImplSDL3_InitForOther(SDL_Window* window)
|
||||||
|
{
|
||||||
|
return ImGui_ImplSDL3_Init(window, nullptr, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_CloseGamepads();
|
||||||
|
|
||||||
void ImGui_ImplSDL3_Shutdown()
|
void ImGui_ImplSDL3_Shutdown()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplSDL3_ShutdownPlatformInterface();
|
||||||
|
|
||||||
if (bd->ClipboardTextData)
|
if (bd->ClipboardTextData)
|
||||||
SDL_free(bd->ClipboardTextData);
|
SDL_free(bd->ClipboardTextData);
|
||||||
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
||||||
SDL_DestroyCursor(bd->MouseCursors[cursor_n]);
|
SDL_DestroyCursor(bd->MouseCursors[cursor_n]);
|
||||||
bd->LastMouseCursor = nullptr;
|
ImGui_ImplSDL3_CloseGamepads();
|
||||||
|
|
||||||
io.BackendPlatformName = nullptr;
|
io.BackendPlatformName = nullptr;
|
||||||
io.BackendPlatformUserData = nullptr;
|
io.BackendPlatformUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This code is incredibly messy because some of the functions we need for full viewport support are not available in SDL < 2.0.4.
|
||||||
static void ImGui_ImplSDL3_UpdateMouseData()
|
static void ImGui_ImplSDL3_UpdateMouseData()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
@@ -438,27 +555,57 @@ static void ImGui_ImplSDL3_UpdateMouseData()
|
|||||||
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
|
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
|
||||||
SDL_CaptureMouse((bd->MouseButtonsDown != 0) ? SDL_TRUE : SDL_FALSE);
|
SDL_CaptureMouse((bd->MouseButtonsDown != 0) ? SDL_TRUE : SDL_FALSE);
|
||||||
SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
||||||
const bool is_app_focused = (bd->Window == focused_window);
|
const bool is_app_focused = (focused_window && (bd->Window == focused_window || ImGui::FindViewportByPlatformHandle((void*)focused_window)));
|
||||||
#else
|
#else
|
||||||
|
SDL_Window* focused_window = bd->Window;
|
||||||
const bool is_app_focused = (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0; // SDL 2.0.3 and non-windowed systems: single-viewport only
|
const bool is_app_focused = (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0; // SDL 2.0.3 and non-windowed systems: single-viewport only
|
||||||
#endif
|
#endif
|
||||||
if (is_app_focused)
|
if (is_app_focused)
|
||||||
{
|
{
|
||||||
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
||||||
if (io.WantSetMousePos)
|
if (io.WantSetMousePos)
|
||||||
SDL_WarpMouseInWindow(bd->Window, io.MousePos.x, io.MousePos.y);
|
{
|
||||||
|
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
SDL_WarpMouseGlobal(io.MousePos.x, io.MousePos.y);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
SDL_WarpMouseInWindow(bd->Window, io.MousePos.x, io.MousePos.y);
|
||||||
|
}
|
||||||
|
|
||||||
// (Optional) Fallback to provide mouse position when focused (SDL_EVENT_MOUSE_MOTION already provides this when hovered or captured)
|
// (Optional) Fallback to provide mouse position when focused (SDL_EVENT_MOUSE_MOTION already provides this when hovered or captured)
|
||||||
if (bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0)
|
if (bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0)
|
||||||
{
|
{
|
||||||
// Single-viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
|
// Single-viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
|
||||||
float mouse_x_global, mouse_y_global;
|
// Multi-viewport mode: mouse position in OS absolute coordinates (io.MousePos is (0,0) when the mouse is on the upper-left of the primary monitor)
|
||||||
|
float mouse_x, mouse_y;
|
||||||
int window_x, window_y;
|
int window_x, window_y;
|
||||||
SDL_GetGlobalMouseState(&mouse_x_global, &mouse_y_global);
|
SDL_GetGlobalMouseState(&mouse_x, &mouse_y);
|
||||||
SDL_GetWindowPosition(focused_window, &window_x, &window_y);
|
if (!(io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable))
|
||||||
io.AddMousePosEvent(mouse_x_global - window_x, mouse_y_global - window_y);
|
{
|
||||||
|
SDL_GetWindowPosition(focused_window, &window_x, &window_y);
|
||||||
|
mouse_x -= window_x;
|
||||||
|
mouse_y -= window_y;
|
||||||
|
}
|
||||||
|
io.AddMousePosEvent((float)mouse_x, (float)mouse_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// (Optional) When using multiple viewports: call io.AddMouseViewportEvent() with the viewport the OS mouse cursor is hovering.
|
||||||
|
// If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the backend, Dear imGui will ignore this field and infer the information using its flawed heuristic.
|
||||||
|
// - [!] SDL backend does NOT correctly ignore viewports with the _NoInputs flag.
|
||||||
|
// Some backend are not able to handle that correctly. If a backend report an hovered viewport that has the _NoInputs flag (e.g. when dragging a window
|
||||||
|
// for docking, the viewport has the _NoInputs flag in order to allow us to find the viewport under), then Dear ImGui is forced to ignore the value reported
|
||||||
|
// by the backend, and use its flawed heuristic to guess the viewport behind.
|
||||||
|
// - [X] SDL backend correctly reports this regardless of another viewport behind focused and dragged from (we need this to find a useful drag and drop target).
|
||||||
|
if (io.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport)
|
||||||
|
{
|
||||||
|
ImGuiID mouse_viewport_id = 0;
|
||||||
|
if (SDL_Window* sdl_mouse_window = SDL_GetWindowFromID(bd->MouseWindowID))
|
||||||
|
if (ImGuiViewport* mouse_viewport = ImGui::FindViewportByPlatformHandle((void*)sdl_mouse_window))
|
||||||
|
mouse_viewport_id = mouse_viewport->ID;
|
||||||
|
io.AddMouseViewportEvent(mouse_viewport_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDL3_UpdateMouseCursor()
|
static void ImGui_ImplSDL3_UpdateMouseCursor()
|
||||||
@@ -478,59 +625,147 @@ static void ImGui_ImplSDL3_UpdateMouseCursor()
|
|||||||
{
|
{
|
||||||
// Show OS mouse cursor
|
// Show OS mouse cursor
|
||||||
SDL_Cursor* expected_cursor = bd->MouseCursors[imgui_cursor] ? bd->MouseCursors[imgui_cursor] : bd->MouseCursors[ImGuiMouseCursor_Arrow];
|
SDL_Cursor* expected_cursor = bd->MouseCursors[imgui_cursor] ? bd->MouseCursors[imgui_cursor] : bd->MouseCursors[ImGuiMouseCursor_Arrow];
|
||||||
if (bd->LastMouseCursor != expected_cursor)
|
if (bd->MouseLastCursor != expected_cursor)
|
||||||
{
|
{
|
||||||
SDL_SetCursor(expected_cursor); // SDL function doesn't have an early out (see #6113)
|
SDL_SetCursor(expected_cursor); // SDL function doesn't have an early out (see #6113)
|
||||||
bd->LastMouseCursor = expected_cursor;
|
bd->MouseLastCursor = expected_cursor;
|
||||||
}
|
}
|
||||||
SDL_ShowCursor();
|
SDL_ShowCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_CloseGamepads()
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
|
if (bd->GamepadMode != ImGui_ImplSDL3_GamepadMode_Manual)
|
||||||
|
for (SDL_Gamepad* gamepad : bd->Gamepads)
|
||||||
|
SDL_CloseGamepad(gamepad);
|
||||||
|
bd->Gamepads.resize(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplSDL3_SetGamepadMode(ImGui_ImplSDL3_GamepadMode mode, SDL_Gamepad** manual_gamepads_array, int manual_gamepads_count)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
|
ImGui_ImplSDL3_CloseGamepads();
|
||||||
|
if (mode == ImGui_ImplSDL3_GamepadMode_Manual)
|
||||||
|
{
|
||||||
|
IM_ASSERT(manual_gamepads_array != nullptr && manual_gamepads_count > 0);
|
||||||
|
for (int n = 0; n < manual_gamepads_count; n++)
|
||||||
|
bd->Gamepads.push_back(manual_gamepads_array[n]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IM_ASSERT(manual_gamepads_array == nullptr && manual_gamepads_count <= 0);
|
||||||
|
bd->WantUpdateGamepadsList = true;
|
||||||
|
}
|
||||||
|
bd->GamepadMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_UpdateGamepadButton(ImGui_ImplSDL3_Data* bd, ImGuiIO& io, ImGuiKey key, SDL_GamepadButton button_no)
|
||||||
|
{
|
||||||
|
bool merged_value = false;
|
||||||
|
for (SDL_Gamepad* gamepad : bd->Gamepads)
|
||||||
|
merged_value |= SDL_GetGamepadButton(gamepad, button_no) != 0;
|
||||||
|
io.AddKeyEvent(key, merged_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline float Saturate(float v) { return v < 0.0f ? 0.0f : v > 1.0f ? 1.0f : v; }
|
||||||
|
static void ImGui_ImplSDL3_UpdateGamepadAnalog(ImGui_ImplSDL3_Data* bd, ImGuiIO& io, ImGuiKey key, SDL_GamepadAxis axis_no, float v0, float v1)
|
||||||
|
{
|
||||||
|
float merged_value = 0.0f;
|
||||||
|
for (SDL_Gamepad* gamepad : bd->Gamepads)
|
||||||
|
{
|
||||||
|
float vn = Saturate((float)(SDL_GetGamepadAxis(gamepad, axis_no) - v0) / (float)(v1 - v0));
|
||||||
|
if (merged_value < vn)
|
||||||
|
merged_value = vn;
|
||||||
|
}
|
||||||
|
io.AddKeyAnalogEvent(key, merged_value > 0.1f, merged_value);
|
||||||
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDL3_UpdateGamepads()
|
static void ImGui_ImplSDL3_UpdateGamepads()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) // FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
return;
|
|
||||||
|
|
||||||
// Get gamepad
|
// Update list of gamepads to use
|
||||||
|
if (bd->WantUpdateGamepadsList && bd->GamepadMode != ImGui_ImplSDL3_GamepadMode_Manual)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_CloseGamepads();
|
||||||
|
int sdl_gamepads_count = 0;
|
||||||
|
SDL_JoystickID* sdl_gamepads = SDL_GetGamepads(&sdl_gamepads_count);
|
||||||
|
for (int n = 0; n < sdl_gamepads_count; n++)
|
||||||
|
if (SDL_Gamepad* gamepad = SDL_OpenGamepad(sdl_gamepads[n]))
|
||||||
|
{
|
||||||
|
bd->Gamepads.push_back(gamepad);
|
||||||
|
if (bd->GamepadMode == ImGui_ImplSDL3_GamepadMode_AutoFirst)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bd->WantUpdateGamepadsList = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.
|
||||||
|
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
||||||
|
return;
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
||||||
SDL_Gamepad* gamepad = SDL_OpenGamepad(0);
|
if (bd->Gamepads.Size == 0)
|
||||||
if (!gamepad)
|
|
||||||
return;
|
return;
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
||||||
|
|
||||||
// Update gamepad inputs
|
// Update gamepad inputs
|
||||||
#define IM_SATURATE(V) (V < 0.0f ? 0.0f : V > 1.0f ? 1.0f : V)
|
const int thumb_dead_zone = 8000; // SDL_gamepad.h suggests using this value.
|
||||||
#define MAP_BUTTON(KEY_NO, BUTTON_NO) { io.AddKeyEvent(KEY_NO, SDL_GetGamepadButton(gamepad, BUTTON_NO) != 0); }
|
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadStart, SDL_GAMEPAD_BUTTON_START);
|
||||||
#define MAP_ANALOG(KEY_NO, AXIS_NO, V0, V1) { float vn = (float)(SDL_GetGamepadAxis(gamepad, AXIS_NO) - V0) / (float)(V1 - V0); vn = IM_SATURATE(vn); io.AddKeyAnalogEvent(KEY_NO, vn > 0.1f, vn); }
|
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadBack, SDL_GAMEPAD_BUTTON_BACK);
|
||||||
const int thumb_dead_zone = 8000; // SDL_gamecontroller.h suggests using this value.
|
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceLeft, SDL_GAMEPAD_BUTTON_WEST); // Xbox X, PS Square
|
||||||
MAP_BUTTON(ImGuiKey_GamepadStart, SDL_GAMEPAD_BUTTON_START);
|
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceRight, SDL_GAMEPAD_BUTTON_EAST); // Xbox B, PS Circle
|
||||||
MAP_BUTTON(ImGuiKey_GamepadBack, SDL_GAMEPAD_BUTTON_BACK);
|
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceUp, SDL_GAMEPAD_BUTTON_NORTH); // Xbox Y, PS Triangle
|
||||||
MAP_BUTTON(ImGuiKey_GamepadFaceLeft, SDL_GAMEPAD_BUTTON_X); // Xbox X, PS Square
|
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceDown, SDL_GAMEPAD_BUTTON_SOUTH); // Xbox A, PS Cross
|
||||||
MAP_BUTTON(ImGuiKey_GamepadFaceRight, SDL_GAMEPAD_BUTTON_B); // Xbox B, PS Circle
|
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadLeft, SDL_GAMEPAD_BUTTON_DPAD_LEFT);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadFaceUp, SDL_GAMEPAD_BUTTON_Y); // Xbox Y, PS Triangle
|
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadRight, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadFaceDown, SDL_GAMEPAD_BUTTON_A); // Xbox A, PS Cross
|
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadUp, SDL_GAMEPAD_BUTTON_DPAD_UP);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadDpadLeft, SDL_GAMEPAD_BUTTON_DPAD_LEFT);
|
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadDown, SDL_GAMEPAD_BUTTON_DPAD_DOWN);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadDpadRight, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
|
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadL1, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadDpadUp, SDL_GAMEPAD_BUTTON_DPAD_UP);
|
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadR1, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadDpadDown, SDL_GAMEPAD_BUTTON_DPAD_DOWN);
|
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadL2, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, 0.0f, 32767);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadL1, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER);
|
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadR2, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, 0.0f, 32767);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadR1, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER);
|
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadL3, SDL_GAMEPAD_BUTTON_LEFT_STICK);
|
||||||
MAP_ANALOG(ImGuiKey_GamepadL2, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, 0.0f, 32767);
|
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadR3, SDL_GAMEPAD_BUTTON_RIGHT_STICK);
|
||||||
MAP_ANALOG(ImGuiKey_GamepadR2, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, 0.0f, 32767);
|
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickLeft, SDL_GAMEPAD_AXIS_LEFTX, -thumb_dead_zone, -32768);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadL3, SDL_GAMEPAD_BUTTON_LEFT_STICK);
|
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickRight, SDL_GAMEPAD_AXIS_LEFTX, +thumb_dead_zone, +32767);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadR3, SDL_GAMEPAD_BUTTON_RIGHT_STICK);
|
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickUp, SDL_GAMEPAD_AXIS_LEFTY, -thumb_dead_zone, -32768);
|
||||||
MAP_ANALOG(ImGuiKey_GamepadLStickLeft, SDL_GAMEPAD_AXIS_LEFTX, -thumb_dead_zone, -32768);
|
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickDown, SDL_GAMEPAD_AXIS_LEFTY, +thumb_dead_zone, +32767);
|
||||||
MAP_ANALOG(ImGuiKey_GamepadLStickRight, SDL_GAMEPAD_AXIS_LEFTX, +thumb_dead_zone, +32767);
|
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickLeft, SDL_GAMEPAD_AXIS_RIGHTX, -thumb_dead_zone, -32768);
|
||||||
MAP_ANALOG(ImGuiKey_GamepadLStickUp, SDL_GAMEPAD_AXIS_LEFTY, -thumb_dead_zone, -32768);
|
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickRight, SDL_GAMEPAD_AXIS_RIGHTX, +thumb_dead_zone, +32767);
|
||||||
MAP_ANALOG(ImGuiKey_GamepadLStickDown, SDL_GAMEPAD_AXIS_LEFTY, +thumb_dead_zone, +32767);
|
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickUp, SDL_GAMEPAD_AXIS_RIGHTY, -thumb_dead_zone, -32768);
|
||||||
MAP_ANALOG(ImGuiKey_GamepadRStickLeft, SDL_GAMEPAD_AXIS_RIGHTX, -thumb_dead_zone, -32768);
|
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickDown, SDL_GAMEPAD_AXIS_RIGHTY, +thumb_dead_zone, +32767);
|
||||||
MAP_ANALOG(ImGuiKey_GamepadRStickRight, SDL_GAMEPAD_AXIS_RIGHTX, +thumb_dead_zone, +32767);
|
}
|
||||||
MAP_ANALOG(ImGuiKey_GamepadRStickUp, SDL_GAMEPAD_AXIS_RIGHTY, -thumb_dead_zone, -32768);
|
|
||||||
MAP_ANALOG(ImGuiKey_GamepadRStickDown, SDL_GAMEPAD_AXIS_RIGHTY, +thumb_dead_zone, +32767);
|
static void ImGui_ImplSDL3_UpdateMonitors()
|
||||||
#undef MAP_BUTTON
|
{
|
||||||
#undef MAP_ANALOG
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Monitors.resize(0);
|
||||||
|
bd->WantUpdateMonitors = false;
|
||||||
|
|
||||||
|
int display_count;
|
||||||
|
SDL_DisplayID* displays = SDL_GetDisplays(&display_count);
|
||||||
|
for (int n = 0; n < display_count; n++)
|
||||||
|
{
|
||||||
|
// Warning: the validity of monitor DPI information on Windows depends on the application DPI awareness settings, which generally needs to be set in the manifest or at runtime.
|
||||||
|
SDL_DisplayID display_id = displays[n];
|
||||||
|
ImGuiPlatformMonitor monitor;
|
||||||
|
SDL_Rect r;
|
||||||
|
SDL_GetDisplayBounds(display_id, &r);
|
||||||
|
monitor.MainPos = monitor.WorkPos = ImVec2((float)r.x, (float)r.y);
|
||||||
|
monitor.MainSize = monitor.WorkSize = ImVec2((float)r.w, (float)r.h);
|
||||||
|
SDL_GetDisplayUsableBounds(display_id, &r);
|
||||||
|
monitor.WorkPos = ImVec2((float)r.x, (float)r.y);
|
||||||
|
monitor.WorkSize = ImVec2((float)r.w, (float)r.h);
|
||||||
|
// FIXME-VIEWPORT: On MacOS SDL reports actual monitor DPI scale, ignoring OS configuration. We may want to set
|
||||||
|
// DpiScale to cocoa_window.backingScaleFactor here.
|
||||||
|
monitor.DpiScale = SDL_GetDisplayContentScale(display_id);
|
||||||
|
monitor.PlatformHandle = (void*)(intptr_t)n;
|
||||||
|
platform_io.Monitors.push_back(monitor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDL3_NewFrame()
|
void ImGui_ImplSDL3_NewFrame()
|
||||||
@@ -550,6 +785,10 @@ void ImGui_ImplSDL3_NewFrame()
|
|||||||
if (w > 0 && h > 0)
|
if (w > 0 && h > 0)
|
||||||
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
||||||
|
|
||||||
|
// Update monitors
|
||||||
|
if (bd->WantUpdateMonitors)
|
||||||
|
ImGui_ImplSDL3_UpdateMonitors();
|
||||||
|
|
||||||
// Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
|
// Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
|
||||||
// (Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. Happens in VMs and Emscripten, see #6189, #6114, #3644)
|
// (Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. Happens in VMs and Emscripten, see #6189, #6114, #3644)
|
||||||
static Uint64 frequency = SDL_GetPerformanceFrequency();
|
static Uint64 frequency = SDL_GetPerformanceFrequency();
|
||||||
@@ -559,13 +798,20 @@ void ImGui_ImplSDL3_NewFrame()
|
|||||||
io.DeltaTime = bd->Time > 0 ? (float)((double)(current_time - bd->Time) / frequency) : (float)(1.0f / 60.0f);
|
io.DeltaTime = bd->Time > 0 ? (float)((double)(current_time - bd->Time) / frequency) : (float)(1.0f / 60.0f);
|
||||||
bd->Time = current_time;
|
bd->Time = current_time;
|
||||||
|
|
||||||
if (bd->PendingMouseLeaveFrame && bd->PendingMouseLeaveFrame >= ImGui::GetFrameCount() && bd->MouseButtonsDown == 0)
|
if (bd->MousePendingLeaveFrame && bd->MousePendingLeaveFrame >= ImGui::GetFrameCount() && bd->MouseButtonsDown == 0)
|
||||||
{
|
{
|
||||||
bd->MouseWindowID = 0;
|
bd->MouseWindowID = 0;
|
||||||
bd->PendingMouseLeaveFrame = 0;
|
bd->MousePendingLeaveFrame = 0;
|
||||||
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Our io.AddMouseViewportEvent() calls will only be valid when not capturing.
|
||||||
|
// Technically speaking testing for 'bd->MouseButtonsDown == 0' would be more rygorous, but testing for payload reduces noise and potential side-effects.
|
||||||
|
if (bd->MouseCanReportHoveredViewport && ImGui::GetDragDropPayload() == nullptr)
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport;
|
||||||
|
else
|
||||||
|
io.BackendFlags &= ~ImGuiBackendFlags_HasMouseHoveredViewport;
|
||||||
|
|
||||||
ImGui_ImplSDL3_UpdateMouseData();
|
ImGui_ImplSDL3_UpdateMouseData();
|
||||||
ImGui_ImplSDL3_UpdateMouseCursor();
|
ImGui_ImplSDL3_UpdateMouseCursor();
|
||||||
|
|
||||||
@@ -573,7 +819,236 @@ void ImGui_ImplSDL3_NewFrame()
|
|||||||
ImGui_ImplSDL3_UpdateGamepads();
|
ImGui_ImplSDL3_UpdateGamepads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplSDL3_ViewportData
|
||||||
|
{
|
||||||
|
SDL_Window* Window;
|
||||||
|
Uint32 WindowID;
|
||||||
|
bool WindowOwned;
|
||||||
|
SDL_GLContext GLContext;
|
||||||
|
|
||||||
|
ImGui_ImplSDL3_ViewportData() { Window = nullptr; WindowID = 0; WindowOwned = false; GLContext = nullptr; }
|
||||||
|
~ImGui_ImplSDL3_ViewportData() { IM_ASSERT(Window == nullptr && GLContext == nullptr); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = IM_NEW(ImGui_ImplSDL3_ViewportData)();
|
||||||
|
viewport->PlatformUserData = vd;
|
||||||
|
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
ImGui_ImplSDL3_ViewportData* main_viewport_data = (ImGui_ImplSDL3_ViewportData*)main_viewport->PlatformUserData;
|
||||||
|
|
||||||
|
// Share GL resources with main context
|
||||||
|
bool use_opengl = (main_viewport_data->GLContext != nullptr);
|
||||||
|
SDL_GLContext backup_context = nullptr;
|
||||||
|
if (use_opengl)
|
||||||
|
{
|
||||||
|
backup_context = SDL_GL_GetCurrentContext();
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
|
||||||
|
SDL_GL_MakeCurrent(main_viewport_data->Window, main_viewport_data->GLContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint32 sdl_flags = 0;
|
||||||
|
sdl_flags |= use_opengl ? SDL_WINDOW_OPENGL : (bd->UseVulkan ? SDL_WINDOW_VULKAN : 0);
|
||||||
|
sdl_flags |= SDL_GetWindowFlags(bd->Window);
|
||||||
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? SDL_WINDOW_BORDERLESS : 0;
|
||||||
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? 0 : SDL_WINDOW_RESIZABLE;
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
// See SDL hack in ImGui_ImplSDL3_ShowWindow().
|
||||||
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon) ? SDL_WINDOW_UTILITY : 0;
|
||||||
|
#endif
|
||||||
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_TopMost) ? SDL_WINDOW_ALWAYS_ON_TOP : 0;
|
||||||
|
vd->Window = SDL_CreateWindow("No Title Yet", (int)viewport->Size.x, (int)viewport->Size.y, sdl_flags);
|
||||||
|
SDL_SetWindowPosition(vd->Window, (int)viewport->Pos.x, (int)viewport->Pos.y);
|
||||||
|
vd->WindowOwned = true;
|
||||||
|
if (use_opengl)
|
||||||
|
{
|
||||||
|
vd->GLContext = SDL_GL_CreateContext(vd->Window);
|
||||||
|
SDL_GL_SetSwapInterval(0);
|
||||||
|
}
|
||||||
|
if (use_opengl && backup_context)
|
||||||
|
SDL_GL_MakeCurrent(vd->Window, backup_context);
|
||||||
|
|
||||||
|
ImGui_ImplSDL3_SetupPlatformHandles(viewport, vd->Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
if (ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData)
|
||||||
|
{
|
||||||
|
if (vd->GLContext && vd->WindowOwned)
|
||||||
|
SDL_GL_DeleteContext(vd->GLContext);
|
||||||
|
if (vd->Window && vd->WindowOwned)
|
||||||
|
SDL_DestroyWindow(vd->Window);
|
||||||
|
vd->GLContext = nullptr;
|
||||||
|
vd->Window = nullptr;
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->PlatformUserData = viewport->PlatformHandle = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_ShowWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
#if defined(_WIN32)
|
||||||
|
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
|
||||||
|
|
||||||
|
// SDL hack: Hide icon from task bar
|
||||||
|
// Note: SDL 3.0.0+ has a SDL_WINDOW_UTILITY flag which is supported under Windows but the way it create the window breaks our seamless transition.
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon)
|
||||||
|
{
|
||||||
|
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||||
|
ex_style &= ~WS_EX_APPWINDOW;
|
||||||
|
ex_style |= WS_EX_TOOLWINDOW;
|
||||||
|
::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SDL hack: SDL always activate/focus windows :/
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing)
|
||||||
|
{
|
||||||
|
::ShowWindow(hwnd, SW_SHOWNA);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SDL_ShowWindow(vd->Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplSDL3_GetWindowPos(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
int x = 0, y = 0;
|
||||||
|
SDL_GetWindowPosition(vd->Window, &x, &y);
|
||||||
|
return ImVec2((float)x, (float)y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_SetWindowPosition(vd->Window, (int)pos.x, (int)pos.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplSDL3_GetWindowSize(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
int w = 0, h = 0;
|
||||||
|
SDL_GetWindowSize(vd->Window, &w, &h);
|
||||||
|
return ImVec2((float)w, (float)h);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_SetWindowSize(vd->Window, (int)size.x, (int)size.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_SetWindowTitle(ImGuiViewport* viewport, const char* title)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_SetWindowTitle(vd->Window, title);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_SetWindowOpacity(vd->Window, alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_SetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_RaiseWindow(vd->Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplSDL3_GetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
return (SDL_GetWindowFlags(vd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplSDL3_GetWindowMinimized(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
return (SDL_GetWindowFlags(vd->Window) & SDL_WINDOW_MINIMIZED) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
if (vd->GLContext)
|
||||||
|
SDL_GL_MakeCurrent(vd->Window, vd->GLContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
if (vd->GLContext)
|
||||||
|
{
|
||||||
|
SDL_GL_MakeCurrent(vd->Window, vd->GLContext);
|
||||||
|
SDL_GL_SwapWindow(vd->Window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vulkan support (the Vulkan renderer needs to call a platform-side support function to create the surface)
|
||||||
|
// SDL is graceful enough to _not_ need <vulkan/vulkan.h> so we can safely include this.
|
||||||
|
#include <SDL3/SDL_vulkan.h>
|
||||||
|
static int ImGui_ImplSDL3_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_instance, const void* vk_allocator, ImU64* out_vk_surface)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
(void)vk_allocator;
|
||||||
|
SDL_bool ret = SDL_Vulkan_CreateSurface(vd->Window, (VkInstance)vk_instance, (VkAllocationCallbacks*)vk_allocator, (VkSurfaceKHR*)out_vk_surface);
|
||||||
|
return ret ? 0 : 1; // ret ? VK_SUCCESS : VK_NOT_READY
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_InitPlatformInterface(SDL_Window* window, void* sdl_gl_context)
|
||||||
|
{
|
||||||
|
// Register platform interface (will be coupled with a renderer interface)
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Platform_CreateWindow = ImGui_ImplSDL3_CreateWindow;
|
||||||
|
platform_io.Platform_DestroyWindow = ImGui_ImplSDL3_DestroyWindow;
|
||||||
|
platform_io.Platform_ShowWindow = ImGui_ImplSDL3_ShowWindow;
|
||||||
|
platform_io.Platform_SetWindowPos = ImGui_ImplSDL3_SetWindowPos;
|
||||||
|
platform_io.Platform_GetWindowPos = ImGui_ImplSDL3_GetWindowPos;
|
||||||
|
platform_io.Platform_SetWindowSize = ImGui_ImplSDL3_SetWindowSize;
|
||||||
|
platform_io.Platform_GetWindowSize = ImGui_ImplSDL3_GetWindowSize;
|
||||||
|
platform_io.Platform_SetWindowFocus = ImGui_ImplSDL3_SetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowFocus = ImGui_ImplSDL3_GetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowMinimized = ImGui_ImplSDL3_GetWindowMinimized;
|
||||||
|
platform_io.Platform_SetWindowTitle = ImGui_ImplSDL3_SetWindowTitle;
|
||||||
|
platform_io.Platform_RenderWindow = ImGui_ImplSDL3_RenderWindow;
|
||||||
|
platform_io.Platform_SwapBuffers = ImGui_ImplSDL3_SwapBuffers;
|
||||||
|
platform_io.Platform_SetWindowAlpha = ImGui_ImplSDL3_SetWindowAlpha;
|
||||||
|
platform_io.Platform_CreateVkSurface = ImGui_ImplSDL3_CreateVkSurface;
|
||||||
|
|
||||||
|
// Register main window handle (which is owned by the main application, not by us)
|
||||||
|
// This is mostly for simplicity and consistency, so that our code (e.g. mouse handling etc.) can use same logic for main and secondary viewports.
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = IM_NEW(ImGui_ImplSDL3_ViewportData)();
|
||||||
|
vd->Window = window;
|
||||||
|
vd->WindowID = SDL_GetWindowID(window);
|
||||||
|
vd->WindowOwned = false;
|
||||||
|
vd->GLContext = sdl_gl_context;
|
||||||
|
main_viewport->PlatformUserData = vd;
|
||||||
|
main_viewport->PlatformHandle = vd->Window;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -9,19 +9,26 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
|
// [x] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable' -> the OS animation effect when window gets created/destroyed is problematic. SDL2 backend doesn't have issue.
|
||||||
// Missing features:
|
// Missing features:
|
||||||
|
// [ ] Platform: Multi-viewport + Minimized windows seems to break mouse wheel events (at least under Windows).
|
||||||
// [x] Platform: Basic IME support. Position somehow broken in SDL3 + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
// [x] Platform: Basic IME support. Position somehow broken in SDL3 + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
struct SDL_Renderer;
|
struct SDL_Renderer;
|
||||||
|
struct SDL_Gamepad;
|
||||||
typedef union SDL_Event SDL_Event;
|
typedef union SDL_Event SDL_Event;
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
||||||
@@ -29,6 +36,14 @@ IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForVulkan(SDL_Window* window);
|
|||||||
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForD3D(SDL_Window* window);
|
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForD3D(SDL_Window* window);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForMetal(SDL_Window* window);
|
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForMetal(SDL_Window* window);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer);
|
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer);
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForOther(SDL_Window* window);
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDL3_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplSDL3_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDL3_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplSDL3_NewFrame();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event);
|
IMGUI_IMPL_API bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event);
|
||||||
|
|
||||||
|
// Gamepad selection automatically starts in AutoFirst mode, picking first available SDL_Gamepad. You may override this.
|
||||||
|
// When using manual mode, caller is responsible for opening/closing gamepad.
|
||||||
|
enum ImGui_ImplSDL3_GamepadMode { ImGui_ImplSDL3_GamepadMode_AutoFirst, ImGui_ImplSDL3_GamepadMode_AutoAll, ImGui_ImplSDL3_GamepadMode_Manual };
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplSDL3_SetGamepadMode(ImGui_ImplSDL3_GamepadMode mode, SDL_Gamepad** manual_gamepads_array = NULL, int manual_gamepads_count = -1);
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
// dear imgui: Renderer Backend for SDL_Renderer
|
|
||||||
// (Requires: SDL 2.0.17+)
|
|
||||||
|
|
||||||
// Important to understand: SDL_Renderer is an _optional_ component of SDL.
|
|
||||||
// For a multi-platform app consider using e.g. SDL+DirectX on Windows and SDL+OpenGL on Linux/OSX.
|
|
||||||
// If your application will want to render any non trivial amount of graphics other than UI,
|
|
||||||
// please be aware that SDL_Renderer offers a limited graphic API to the end-user and it might
|
|
||||||
// be difficult to step out of those boundaries.
|
|
||||||
// However, we understand it is a convenient choice to get an app started easily.
|
|
||||||
|
|
||||||
// Implemented features:
|
|
||||||
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
|
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
|
||||||
|
|
||||||
struct SDL_Renderer;
|
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer_Init(SDL_Renderer* renderer);
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer_Shutdown();
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer_NewFrame();
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data);
|
|
||||||
|
|
||||||
// Called by Init/NewFrame/Shutdown
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer_CreateFontsTexture();
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer_DestroyFontsTexture();
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer_CreateDeviceObjects();
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer_DestroyDeviceObjects();
|
|
||||||
@@ -1,22 +1,28 @@
|
|||||||
// dear imgui: Renderer Backend for SDL_Renderer
|
// dear imgui: Renderer Backend for SDL_Renderer for SDL2
|
||||||
// (Requires: SDL 2.0.17+)
|
// (Requires: SDL 2.0.17+)
|
||||||
|
|
||||||
// Important to understand: SDL_Renderer is an _optional_ component of SDL.
|
// Note how SDL_Renderer is an _optional_ component of SDL2.
|
||||||
// For a multi-platform app consider using e.g. SDL+DirectX on Windows and SDL+OpenGL on Linux/OSX.
|
// For a multi-platform app consider using e.g. SDL+DirectX on Windows and SDL+OpenGL on Linux/OSX.
|
||||||
// If your application will want to render any non trivial amount of graphics other than UI,
|
// If your application will want to render any non trivial amount of graphics other than UI,
|
||||||
// please be aware that SDL_Renderer offers a limited graphic API to the end-user and it might
|
// please be aware that SDL_Renderer currently offers a limited graphic API to the end-user and
|
||||||
// be difficult to step out of those boundaries.
|
// it might be difficult to step out of those boundaries.
|
||||||
// However, we understand it is a convenient choice to get an app started easily.
|
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// Missing features:
|
||||||
|
// [ ] Renderer: Multi-viewport support (multiple windows).
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
|
// 2023-05-30: Renamed imgui_impl_sdlrenderer.h/.cpp to imgui_impl_sdlrenderer2.h/.cpp to accommodate for upcoming SDL3.
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2021-12-21: Update SDL_RenderGeometryRaw() format to work with SDL 2.0.19.
|
// 2021-12-21: Update SDL_RenderGeometryRaw() format to work with SDL 2.0.19.
|
||||||
// 2021-12-03: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
// 2021-12-03: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
||||||
@@ -24,12 +30,9 @@
|
|||||||
// 2021-09-21: Initial version.
|
// 2021-09-21: Initial version.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_sdlrenderer.h"
|
#ifndef IMGUI_DISABLE
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
#include "imgui_impl_sdlrenderer2.h"
|
||||||
#include <stddef.h> // intptr_t
|
|
||||||
#else
|
|
||||||
#include <stdint.h> // intptr_t
|
#include <stdint.h> // intptr_t
|
||||||
#endif
|
|
||||||
|
|
||||||
// Clang warnings with -Weverything
|
// Clang warnings with -Weverything
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
@@ -44,31 +47,31 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// SDL_Renderer data
|
// SDL_Renderer data
|
||||||
struct ImGui_ImplSDLRenderer_Data
|
struct ImGui_ImplSDLRenderer2_Data
|
||||||
{
|
{
|
||||||
SDL_Renderer* SDLRenderer;
|
SDL_Renderer* SDLRenderer;
|
||||||
SDL_Texture* FontTexture;
|
SDL_Texture* FontTexture;
|
||||||
ImGui_ImplSDLRenderer_Data() { memset((void*)this, 0, sizeof(*this)); }
|
ImGui_ImplSDLRenderer2_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
|
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
|
||||||
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
|
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
|
||||||
static ImGui_ImplSDLRenderer_Data* ImGui_ImplSDLRenderer_GetBackendData()
|
static ImGui_ImplSDLRenderer2_Data* ImGui_ImplSDLRenderer2_GetBackendData()
|
||||||
{
|
{
|
||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplSDLRenderer_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplSDLRenderer2_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
bool ImGui_ImplSDLRenderer_Init(SDL_Renderer* renderer)
|
bool ImGui_ImplSDLRenderer2_Init(SDL_Renderer* renderer)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
IM_ASSERT(renderer != nullptr && "SDL_Renderer not initialized!");
|
IM_ASSERT(renderer != nullptr && "SDL_Renderer not initialized!");
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
// Setup backend capabilities flags
|
||||||
ImGui_ImplSDLRenderer_Data* bd = IM_NEW(ImGui_ImplSDLRenderer_Data)();
|
ImGui_ImplSDLRenderer2_Data* bd = IM_NEW(ImGui_ImplSDLRenderer2_Data)();
|
||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_sdlrenderer";
|
io.BackendRendererName = "imgui_impl_sdlrenderer2";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
|
||||||
bd->SDLRenderer = renderer;
|
bd->SDLRenderer = renderer;
|
||||||
@@ -76,22 +79,23 @@ bool ImGui_ImplSDLRenderer_Init(SDL_Renderer* renderer)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDLRenderer_Shutdown()
|
void ImGui_ImplSDLRenderer2_Shutdown()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDLRenderer_Data* bd = ImGui_ImplSDLRenderer_GetBackendData();
|
ImGui_ImplSDLRenderer2_Data* bd = ImGui_ImplSDLRenderer2_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
ImGui_ImplSDLRenderer_DestroyDeviceObjects();
|
ImGui_ImplSDLRenderer2_DestroyDeviceObjects();
|
||||||
|
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDLRenderer_SetupRenderState()
|
static void ImGui_ImplSDLRenderer2_SetupRenderState()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDLRenderer_Data* bd = ImGui_ImplSDLRenderer_GetBackendData();
|
ImGui_ImplSDLRenderer2_Data* bd = ImGui_ImplSDLRenderer2_GetBackendData();
|
||||||
|
|
||||||
// Clear out any viewports and cliprect set by the user
|
// Clear out any viewports and cliprect set by the user
|
||||||
// FIXME: Technically speaking there are lots of other things we could backup/setup/restore during our render process.
|
// FIXME: Technically speaking there are lots of other things we could backup/setup/restore during our render process.
|
||||||
@@ -99,18 +103,18 @@ static void ImGui_ImplSDLRenderer_SetupRenderState()
|
|||||||
SDL_RenderSetClipRect(bd->SDLRenderer, nullptr);
|
SDL_RenderSetClipRect(bd->SDLRenderer, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDLRenderer_NewFrame()
|
void ImGui_ImplSDLRenderer2_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDLRenderer_Data* bd = ImGui_ImplSDLRenderer_GetBackendData();
|
ImGui_ImplSDLRenderer2_Data* bd = ImGui_ImplSDLRenderer2_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplSDLRenderer_Init()?");
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplSDLRenderer2_Init()?");
|
||||||
|
|
||||||
if (!bd->FontTexture)
|
if (!bd->FontTexture)
|
||||||
ImGui_ImplSDLRenderer_CreateDeviceObjects();
|
ImGui_ImplSDLRenderer2_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data)
|
void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
ImGui_ImplSDLRenderer_Data* bd = ImGui_ImplSDLRenderer_GetBackendData();
|
ImGui_ImplSDLRenderer2_Data* bd = ImGui_ImplSDLRenderer2_GetBackendData();
|
||||||
|
|
||||||
// If there's a scale factor set by the user, use that instead
|
// If there's a scale factor set by the user, use that instead
|
||||||
// If the user has specified a scale factor to SDL_Renderer already via SDL_RenderSetScale(), SDL will scale whatever we pass
|
// If the user has specified a scale factor to SDL_Renderer already via SDL_RenderSetScale(), SDL will scale whatever we pass
|
||||||
@@ -145,7 +149,7 @@ void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ImVec2 clip_scale = render_scale;
|
ImVec2 clip_scale = render_scale;
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
ImGui_ImplSDLRenderer_SetupRenderState();
|
ImGui_ImplSDLRenderer2_SetupRenderState();
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||||
@@ -160,7 +164,7 @@ void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data)
|
|||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||||
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||||
ImGui_ImplSDLRenderer_SetupRenderState();
|
ImGui_ImplSDLRenderer2_SetupRenderState();
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(cmd_list, pcmd);
|
pcmd->UserCallback(cmd_list, pcmd);
|
||||||
}
|
}
|
||||||
@@ -179,12 +183,12 @@ void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data)
|
|||||||
SDL_Rect r = { (int)(clip_min.x), (int)(clip_min.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y) };
|
SDL_Rect r = { (int)(clip_min.x), (int)(clip_min.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y) };
|
||||||
SDL_RenderSetClipRect(bd->SDLRenderer, &r);
|
SDL_RenderSetClipRect(bd->SDLRenderer, &r);
|
||||||
|
|
||||||
const float* xy = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + IM_OFFSETOF(ImDrawVert, pos));
|
const float* xy = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, pos));
|
||||||
const float* uv = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + IM_OFFSETOF(ImDrawVert, uv));
|
const float* uv = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, uv));
|
||||||
#if SDL_VERSION_ATLEAST(2,0,19)
|
#if SDL_VERSION_ATLEAST(2,0,19)
|
||||||
const SDL_Color* color = (const SDL_Color*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + IM_OFFSETOF(ImDrawVert, col)); // SDL 2.0.19+
|
const SDL_Color* color = (const SDL_Color*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, col)); // SDL 2.0.19+
|
||||||
#else
|
#else
|
||||||
const int* color = (const int*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + IM_OFFSETOF(ImDrawVert, col)); // SDL 2.0.17 and 2.0.18
|
const int* color = (const int*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, col)); // SDL 2.0.17 and 2.0.18
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Bind texture, Draw
|
// Bind texture, Draw
|
||||||
@@ -205,10 +209,10 @@ void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Called by Init/NewFrame/Shutdown
|
// Called by Init/NewFrame/Shutdown
|
||||||
bool ImGui_ImplSDLRenderer_CreateFontsTexture()
|
bool ImGui_ImplSDLRenderer2_CreateFontsTexture()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGui_ImplSDLRenderer_Data* bd = ImGui_ImplSDLRenderer_GetBackendData();
|
ImGui_ImplSDLRenderer2_Data* bd = ImGui_ImplSDLRenderer2_GetBackendData();
|
||||||
|
|
||||||
// Build texture atlas
|
// Build texture atlas
|
||||||
unsigned char* pixels;
|
unsigned char* pixels;
|
||||||
@@ -233,10 +237,10 @@ bool ImGui_ImplSDLRenderer_CreateFontsTexture()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDLRenderer_DestroyFontsTexture()
|
void ImGui_ImplSDLRenderer2_DestroyFontsTexture()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGui_ImplSDLRenderer_Data* bd = ImGui_ImplSDLRenderer_GetBackendData();
|
ImGui_ImplSDLRenderer2_Data* bd = ImGui_ImplSDLRenderer2_GetBackendData();
|
||||||
if (bd->FontTexture)
|
if (bd->FontTexture)
|
||||||
{
|
{
|
||||||
io.Fonts->SetTexID(0);
|
io.Fonts->SetTexID(0);
|
||||||
@@ -245,16 +249,20 @@ void ImGui_ImplSDLRenderer_DestroyFontsTexture()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDLRenderer_CreateDeviceObjects()
|
bool ImGui_ImplSDLRenderer2_CreateDeviceObjects()
|
||||||
{
|
{
|
||||||
return ImGui_ImplSDLRenderer_CreateFontsTexture();
|
return ImGui_ImplSDLRenderer2_CreateFontsTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDLRenderer_DestroyDeviceObjects()
|
void ImGui_ImplSDLRenderer2_DestroyDeviceObjects()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDLRenderer_DestroyFontsTexture();
|
ImGui_ImplSDLRenderer2_DestroyFontsTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
41
backends/imgui_impl_sdlrenderer2.h
Normal file
41
backends/imgui_impl_sdlrenderer2.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// dear imgui: Renderer Backend for SDL_Renderer for SDL2
|
||||||
|
// (Requires: SDL 2.0.17+)
|
||||||
|
|
||||||
|
// Note how SDL_Renderer is an _optional_ component of SDL2.
|
||||||
|
// For a multi-platform app consider using e.g. SDL+DirectX on Windows and SDL+OpenGL on Linux/OSX.
|
||||||
|
// If your application will want to render any non trivial amount of graphics other than UI,
|
||||||
|
// please be aware that SDL_Renderer currently offers a limited graphic API to the end-user and
|
||||||
|
// it might be difficult to step out of those boundaries.
|
||||||
|
|
||||||
|
// Implemented features:
|
||||||
|
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// Missing features:
|
||||||
|
// [ ] Renderer: Multi-viewport support (multiple windows).
|
||||||
|
|
||||||
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
|
||||||
|
struct SDL_Renderer;
|
||||||
|
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_Init(SDL_Renderer* renderer);
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_Shutdown();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_NewFrame();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data);
|
||||||
|
|
||||||
|
// Called by Init/NewFrame/Shutdown
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_CreateFontsTexture();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_DestroyFontsTexture();
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_CreateDeviceObjects();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_DestroyDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
262
backends/imgui_impl_sdlrenderer3.cpp
Normal file
262
backends/imgui_impl_sdlrenderer3.cpp
Normal file
@@ -0,0 +1,262 @@
|
|||||||
|
// dear imgui: Renderer Backend for SDL_Renderer for SDL3
|
||||||
|
// (Requires: SDL 3.0.0+)
|
||||||
|
|
||||||
|
// Note how SDL_Renderer is an _optional_ component of SDL3.
|
||||||
|
// For a multi-platform app consider using e.g. SDL+DirectX on Windows and SDL+OpenGL on Linux/OSX.
|
||||||
|
// If your application will want to render any non trivial amount of graphics other than UI,
|
||||||
|
// please be aware that SDL_Renderer currently offers a limited graphic API to the end-user and
|
||||||
|
// it might be difficult to step out of those boundaries.
|
||||||
|
|
||||||
|
// Implemented features:
|
||||||
|
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// Missing features:
|
||||||
|
// [ ] Renderer: Multi-viewport support (multiple windows).
|
||||||
|
|
||||||
|
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
|
// CHANGELOG
|
||||||
|
// 2024-02-12: Amend to query SDL_RenderViewportSet() and restore viewport accordingly.
|
||||||
|
// 2023-05-30: Initial version.
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
#include "imgui_impl_sdlrenderer3.h"
|
||||||
|
#include <stdint.h> // intptr_t
|
||||||
|
|
||||||
|
// Clang warnings with -Weverything
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// SDL
|
||||||
|
#include <SDL3/SDL.h>
|
||||||
|
#if !SDL_VERSION_ATLEAST(3,0,0)
|
||||||
|
#error This backend requires SDL 3.0.0+
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// SDL_Renderer data
|
||||||
|
struct ImGui_ImplSDLRenderer3_Data
|
||||||
|
{
|
||||||
|
SDL_Renderer* SDLRenderer;
|
||||||
|
SDL_Texture* FontTexture;
|
||||||
|
ImGui_ImplSDLRenderer3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
|
||||||
|
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
|
||||||
|
static ImGui_ImplSDLRenderer3_Data* ImGui_ImplSDLRenderer3_GetBackendData()
|
||||||
|
{
|
||||||
|
return ImGui::GetCurrentContext() ? (ImGui_ImplSDLRenderer3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer)
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
|
IM_ASSERT(renderer != nullptr && "SDL_Renderer not initialized!");
|
||||||
|
|
||||||
|
// Setup backend capabilities flags
|
||||||
|
ImGui_ImplSDLRenderer3_Data* bd = IM_NEW(ImGui_ImplSDLRenderer3_Data)();
|
||||||
|
io.BackendRendererUserData = (void*)bd;
|
||||||
|
io.BackendRendererName = "imgui_impl_sdlrenderer3";
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
|
||||||
|
bd->SDLRenderer = renderer;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplSDLRenderer3_Shutdown()
|
||||||
|
{
|
||||||
|
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
||||||
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplSDLRenderer3_DestroyDeviceObjects();
|
||||||
|
|
||||||
|
io.BackendRendererName = nullptr;
|
||||||
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
||||||
|
IM_DELETE(bd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDLRenderer3_SetupRenderState()
|
||||||
|
{
|
||||||
|
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
||||||
|
|
||||||
|
// Clear out any viewports and cliprect set by the user
|
||||||
|
// FIXME: Technically speaking there are lots of other things we could backup/setup/restore during our render process.
|
||||||
|
SDL_SetRenderViewport(bd->SDLRenderer, nullptr);
|
||||||
|
SDL_SetRenderClipRect(bd->SDLRenderer, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplSDLRenderer3_NewFrame()
|
||||||
|
{
|
||||||
|
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
||||||
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplSDLRenderer3_Init()?");
|
||||||
|
|
||||||
|
if (!bd->FontTexture)
|
||||||
|
ImGui_ImplSDLRenderer3_CreateDeviceObjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
||||||
|
|
||||||
|
// If there's a scale factor set by the user, use that instead
|
||||||
|
// If the user has specified a scale factor to SDL_Renderer already via SDL_RenderSetScale(), SDL will scale whatever we pass
|
||||||
|
// to SDL_RenderGeometryRaw() by that scale factor. In that case we don't want to be also scaling it ourselves here.
|
||||||
|
float rsx = 1.0f;
|
||||||
|
float rsy = 1.0f;
|
||||||
|
SDL_GetRenderScale(bd->SDLRenderer, &rsx, &rsy);
|
||||||
|
ImVec2 render_scale;
|
||||||
|
render_scale.x = (rsx == 1.0f) ? draw_data->FramebufferScale.x : 1.0f;
|
||||||
|
render_scale.y = (rsy == 1.0f) ? draw_data->FramebufferScale.y : 1.0f;
|
||||||
|
|
||||||
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||||
|
int fb_width = (int)(draw_data->DisplaySize.x * render_scale.x);
|
||||||
|
int fb_height = (int)(draw_data->DisplaySize.y * render_scale.y);
|
||||||
|
if (fb_width == 0 || fb_height == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Backup SDL_Renderer state that will be modified to restore it afterwards
|
||||||
|
struct BackupSDLRendererState
|
||||||
|
{
|
||||||
|
SDL_Rect Viewport;
|
||||||
|
bool ViewportEnabled;
|
||||||
|
bool ClipEnabled;
|
||||||
|
SDL_Rect ClipRect;
|
||||||
|
};
|
||||||
|
BackupSDLRendererState old = {};
|
||||||
|
old.ViewportEnabled = SDL_RenderViewportSet(bd->SDLRenderer) == SDL_TRUE;
|
||||||
|
old.ClipEnabled = SDL_RenderClipEnabled(bd->SDLRenderer) == SDL_TRUE;
|
||||||
|
SDL_GetRenderViewport(bd->SDLRenderer, &old.Viewport);
|
||||||
|
SDL_GetRenderClipRect(bd->SDLRenderer, &old.ClipRect);
|
||||||
|
|
||||||
|
// Will project scissor/clipping rectangles into framebuffer space
|
||||||
|
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||||
|
ImVec2 clip_scale = render_scale;
|
||||||
|
|
||||||
|
// Render command lists
|
||||||
|
ImGui_ImplSDLRenderer3_SetupRenderState();
|
||||||
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
|
{
|
||||||
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||||
|
const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
|
||||||
|
const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
|
||||||
|
|
||||||
|
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||||
|
{
|
||||||
|
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
||||||
|
if (pcmd->UserCallback)
|
||||||
|
{
|
||||||
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
|
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||||
|
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||||
|
ImGui_ImplSDLRenderer3_SetupRenderState();
|
||||||
|
else
|
||||||
|
pcmd->UserCallback(cmd_list, pcmd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Project scissor/clipping rectangles into framebuffer space
|
||||||
|
ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y);
|
||||||
|
ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y);
|
||||||
|
if (clip_min.x < 0.0f) { clip_min.x = 0.0f; }
|
||||||
|
if (clip_min.y < 0.0f) { clip_min.y = 0.0f; }
|
||||||
|
if (clip_max.x > (float)fb_width) { clip_max.x = (float)fb_width; }
|
||||||
|
if (clip_max.y > (float)fb_height) { clip_max.y = (float)fb_height; }
|
||||||
|
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
SDL_Rect r = { (int)(clip_min.x), (int)(clip_min.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y) };
|
||||||
|
SDL_SetRenderClipRect(bd->SDLRenderer, &r);
|
||||||
|
|
||||||
|
const float* xy = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, pos));
|
||||||
|
const float* uv = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, uv));
|
||||||
|
const SDL_Color* color = (const SDL_Color*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, col)); // SDL 2.0.19+
|
||||||
|
|
||||||
|
// Bind texture, Draw
|
||||||
|
SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID();
|
||||||
|
SDL_RenderGeometryRaw(bd->SDLRenderer, tex,
|
||||||
|
xy, (int)sizeof(ImDrawVert),
|
||||||
|
color, (int)sizeof(ImDrawVert),
|
||||||
|
uv, (int)sizeof(ImDrawVert),
|
||||||
|
cmd_list->VtxBuffer.Size - pcmd->VtxOffset,
|
||||||
|
idx_buffer + pcmd->IdxOffset, pcmd->ElemCount, sizeof(ImDrawIdx));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore modified SDL_Renderer state
|
||||||
|
SDL_SetRenderViewport(bd->SDLRenderer, old.ViewportEnabled ? &old.Viewport : nullptr);
|
||||||
|
SDL_SetRenderClipRect(bd->SDLRenderer, old.ClipEnabled ? &old.ClipRect : nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called by Init/NewFrame/Shutdown
|
||||||
|
bool ImGui_ImplSDLRenderer3_CreateFontsTexture()
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
||||||
|
|
||||||
|
// Build texture atlas
|
||||||
|
unsigned char* pixels;
|
||||||
|
int width, height;
|
||||||
|
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
|
||||||
|
|
||||||
|
// Upload texture to graphics system
|
||||||
|
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||||
|
bd->FontTexture = SDL_CreateTexture(bd->SDLRenderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STATIC, width, height);
|
||||||
|
if (bd->FontTexture == nullptr)
|
||||||
|
{
|
||||||
|
SDL_Log("error creating texture");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SDL_UpdateTexture(bd->FontTexture, nullptr, pixels, 4 * width);
|
||||||
|
SDL_SetTextureBlendMode(bd->FontTexture, SDL_BLENDMODE_BLEND);
|
||||||
|
SDL_SetTextureScaleMode(bd->FontTexture, SDL_SCALEMODE_LINEAR);
|
||||||
|
|
||||||
|
// Store our identifier
|
||||||
|
io.Fonts->SetTexID((ImTextureID)(intptr_t)bd->FontTexture);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplSDLRenderer3_DestroyFontsTexture()
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
||||||
|
if (bd->FontTexture)
|
||||||
|
{
|
||||||
|
io.Fonts->SetTexID(0);
|
||||||
|
SDL_DestroyTexture(bd->FontTexture);
|
||||||
|
bd->FontTexture = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ImGui_ImplSDLRenderer3_CreateDeviceObjects()
|
||||||
|
{
|
||||||
|
return ImGui_ImplSDLRenderer3_CreateFontsTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplSDLRenderer3_DestroyDeviceObjects()
|
||||||
|
{
|
||||||
|
ImGui_ImplSDLRenderer3_DestroyFontsTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
41
backends/imgui_impl_sdlrenderer3.h
Normal file
41
backends/imgui_impl_sdlrenderer3.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// dear imgui: Renderer Backend for SDL_Renderer for SDL3
|
||||||
|
// (Requires: SDL 3.0.0+)
|
||||||
|
|
||||||
|
// Note how SDL_Renderer is an _optional_ component of SDL3.
|
||||||
|
// For a multi-platform app consider using e.g. SDL+DirectX on Windows and SDL+OpenGL on Linux/OSX.
|
||||||
|
// If your application will want to render any non trivial amount of graphics other than UI,
|
||||||
|
// please be aware that SDL_Renderer currently offers a limited graphic API to the end-user and
|
||||||
|
// it might be difficult to step out of those boundaries.
|
||||||
|
|
||||||
|
// Implemented features:
|
||||||
|
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// Missing features:
|
||||||
|
// [ ] Renderer: Multi-viewport support (multiple windows).
|
||||||
|
|
||||||
|
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
|
struct SDL_Renderer;
|
||||||
|
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer);
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_Shutdown();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_NewFrame();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data);
|
||||||
|
|
||||||
|
// Called by Init/NewFrame/Shutdown
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer3_CreateFontsTexture();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_DestroyFontsTexture();
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer3_CreateDeviceObjects();
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_DestroyDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -2,20 +2,24 @@
|
|||||||
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [!] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions.
|
// [x] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions.
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [x] Renderer: Multi-viewport / platform windows. With issues (flickering when creating a new viewport).
|
||||||
|
|
||||||
// Important: on 32-bit systems, user texture binding is only supported if your imconfig file has '#define ImTextureID ImU64'.
|
// Important: on 32-bit systems, user texture binding is only supported if your imconfig file has '#define ImTextureID ImU64'.
|
||||||
// See imgui_impl_vulkan.cpp file for details.
|
// See imgui_impl_vulkan.cpp file for details.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
|
||||||
|
|
||||||
// The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification.
|
// The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification.
|
||||||
// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
|
// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
|
||||||
|
|
||||||
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app.
|
// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app.
|
||||||
// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h.
|
// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h.
|
||||||
// You will use those if you want to use this rendering backend in your engine/app.
|
// You will use those if you want to use this rendering backend in your engine/app.
|
||||||
@@ -24,6 +28,7 @@
|
|||||||
// Read comments in imgui_impl_vulkan.h.
|
// Read comments in imgui_impl_vulkan.h.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
|
||||||
// [Configuration] in order to use a custom Vulkan function loader:
|
// [Configuration] in order to use a custom Vulkan function loader:
|
||||||
@@ -42,9 +47,20 @@
|
|||||||
#if defined(IMGUI_IMPL_VULKAN_NO_PROTOTYPES) && !defined(VK_NO_PROTOTYPES)
|
#if defined(IMGUI_IMPL_VULKAN_NO_PROTOTYPES) && !defined(VK_NO_PROTOTYPES)
|
||||||
#define VK_NO_PROTOTYPES
|
#define VK_NO_PROTOTYPES
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(VK_USE_PLATFORM_WIN32_KHR) && !defined(NOMINMAX)
|
||||||
|
#define NOMINMAX
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
|
#else
|
||||||
|
#include <vulkan/vulkan.h>
|
||||||
|
#endif
|
||||||
|
#if defined(VK_VERSION_1_3) || defined(VK_KHR_dynamic_rendering)
|
||||||
|
#define IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
#endif
|
||||||
|
|
||||||
// Initialization data, for ImGui_ImplVulkan_Init()
|
// Initialization data, for ImGui_ImplVulkan_Init()
|
||||||
|
// - VkDescriptorPool should be created with VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
|
||||||
|
// and must contain a pool size large enough to hold an ImGui VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER descriptor.
|
||||||
|
// - When using dynamic rendering, set UseDynamicRendering=true and fill PipelineRenderingCreateInfo structure.
|
||||||
// [Please zero-clear before use!]
|
// [Please zero-clear before use!]
|
||||||
struct ImGui_ImplVulkan_InitInfo
|
struct ImGui_ImplVulkan_InitInfo
|
||||||
{
|
{
|
||||||
@@ -53,23 +69,36 @@ struct ImGui_ImplVulkan_InitInfo
|
|||||||
VkDevice Device;
|
VkDevice Device;
|
||||||
uint32_t QueueFamily;
|
uint32_t QueueFamily;
|
||||||
VkQueue Queue;
|
VkQueue Queue;
|
||||||
|
VkDescriptorPool DescriptorPool; // See requirements in note above
|
||||||
|
VkRenderPass RenderPass; // Ignored if using dynamic rendering
|
||||||
|
uint32_t MinImageCount; // >= 2
|
||||||
|
uint32_t ImageCount; // >= MinImageCount
|
||||||
|
VkSampleCountFlagBits MSAASamples; // 0 defaults to VK_SAMPLE_COUNT_1_BIT
|
||||||
|
|
||||||
|
// (Optional)
|
||||||
VkPipelineCache PipelineCache;
|
VkPipelineCache PipelineCache;
|
||||||
VkDescriptorPool DescriptorPool;
|
|
||||||
uint32_t Subpass;
|
uint32_t Subpass;
|
||||||
uint32_t MinImageCount; // >= 2
|
|
||||||
uint32_t ImageCount; // >= MinImageCount
|
// (Optional) Dynamic Rendering
|
||||||
VkSampleCountFlagBits MSAASamples; // >= VK_SAMPLE_COUNT_1_BIT (0 -> default to VK_SAMPLE_COUNT_1_BIT)
|
// Need to explicitly enable VK_KHR_dynamic_rendering extension to use this, even for Vulkan 1.3.
|
||||||
|
bool UseDynamicRendering;
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
VkPipelineRenderingCreateInfoKHR PipelineRenderingCreateInfo;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// (Optional) Allocation, Debugging
|
||||||
const VkAllocationCallbacks* Allocator;
|
const VkAllocationCallbacks* Allocator;
|
||||||
void (*CheckVkResultFn)(VkResult err);
|
void (*CheckVkResultFn)(VkResult err);
|
||||||
|
VkDeviceSize MinAllocationSize; // Minimum allocation size. Set to 1024*1024 to satisfy zealous best practices validation layer and waste a little memory.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Called by user code
|
// Called by user code
|
||||||
IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass);
|
IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info);
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE);
|
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer);
|
IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateFontsTexture();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_DestroyFontUploadObjects();
|
IMGUI_IMPL_API void ImGui_ImplVulkan_DestroyFontsTexture();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
|
IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
|
||||||
|
|
||||||
// Register a texture (VkDescriptorSet == ImTextureID)
|
// Register a texture (VkDescriptorSet == ImTextureID)
|
||||||
@@ -139,10 +168,12 @@ struct ImGui_ImplVulkanH_Window
|
|||||||
VkPresentModeKHR PresentMode;
|
VkPresentModeKHR PresentMode;
|
||||||
VkRenderPass RenderPass;
|
VkRenderPass RenderPass;
|
||||||
VkPipeline Pipeline; // The window pipeline may uses a different VkRenderPass than the one passed in ImGui_ImplVulkan_InitInfo
|
VkPipeline Pipeline; // The window pipeline may uses a different VkRenderPass than the one passed in ImGui_ImplVulkan_InitInfo
|
||||||
|
bool UseDynamicRendering;
|
||||||
bool ClearEnable;
|
bool ClearEnable;
|
||||||
VkClearValue ClearValue;
|
VkClearValue ClearValue;
|
||||||
uint32_t FrameIndex; // Current frame being rendered to (0 <= FrameIndex < FrameInFlightCount)
|
uint32_t FrameIndex; // Current frame being rendered to (0 <= FrameIndex < FrameInFlightCount)
|
||||||
uint32_t ImageCount; // Number of simultaneous in-flight frames (returned by vkGetSwapchainImagesKHR, usually derived from min_image_count)
|
uint32_t ImageCount; // Number of simultaneous in-flight frames (returned by vkGetSwapchainImagesKHR, usually derived from min_image_count)
|
||||||
|
uint32_t SemaphoreCount; // Number of simultaneous in-flight frames + 1, to be able to use it in vkAcquireNextImageKHR
|
||||||
uint32_t SemaphoreIndex; // Current set of swapchain wait semaphores we're using (needs to be distinct from per frame data)
|
uint32_t SemaphoreIndex; // Current set of swapchain wait semaphores we're using (needs to be distinct from per frame data)
|
||||||
ImGui_ImplVulkanH_Frame* Frames;
|
ImGui_ImplVulkanH_Frame* Frames;
|
||||||
ImGui_ImplVulkanH_FrameSemaphores* FrameSemaphores;
|
ImGui_ImplVulkanH_FrameSemaphores* FrameSemaphores;
|
||||||
@@ -155,3 +186,4 @@ struct ImGui_ImplVulkanH_Window
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -5,14 +5,24 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// Missing features:
|
||||||
|
// [ ] Renderer: Multi-viewport support (multiple windows). Not meaningful on the web.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-01-22: Added configurable PipelineMultisampleState struct. (#7240)
|
||||||
|
// 2024-01-22: (Breaking) ImGui_ImplWGPU_Init() now takes a ImGui_ImplWGPU_InitInfo structure instead of variety of parameters, allowing for easier further changes.
|
||||||
|
// 2024-01-22: Fixed pipeline layout leak. (#7245)
|
||||||
|
// 2024-01-17: Explicitly fill all of WGPUDepthStencilState since standard removed defaults.
|
||||||
|
// 2023-07-13: Use WGPUShaderModuleWGSLDescriptor's code instead of source. use WGPUMipmapFilterMode_Linear instead of WGPUFilterMode_Linear. (#6602)
|
||||||
// 2023-04-11: Align buffer sizes. Use WGSL shaders instead of precompiled SPIR-V.
|
// 2023-04-11: Align buffer sizes. Use WGSL shaders instead of precompiled SPIR-V.
|
||||||
// 2023-04-11: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2023-04-11: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2023-01-25: Revert automatic pipeline layout generation (see https://github.com/gpuweb/gpuweb/issues/2470)
|
// 2023-01-25: Revert automatic pipeline layout generation (see https://github.com/gpuweb/gpuweb/issues/2470)
|
||||||
@@ -28,6 +38,7 @@
|
|||||||
// 2021-01-28: Initial version.
|
// 2021-01-28: Initial version.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_wgpu.h"
|
#include "imgui_impl_wgpu.h"
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <webgpu/webgpu.h>
|
#include <webgpu/webgpu.h>
|
||||||
@@ -67,16 +78,17 @@ struct Uniforms
|
|||||||
|
|
||||||
struct ImGui_ImplWGPU_Data
|
struct ImGui_ImplWGPU_Data
|
||||||
{
|
{
|
||||||
WGPUDevice wgpuDevice = nullptr;
|
ImGui_ImplWGPU_InitInfo initInfo;
|
||||||
WGPUQueue defaultQueue = nullptr;
|
WGPUDevice wgpuDevice = nullptr;
|
||||||
WGPUTextureFormat renderTargetFormat = WGPUTextureFormat_Undefined;
|
WGPUQueue defaultQueue = nullptr;
|
||||||
WGPUTextureFormat depthStencilFormat = WGPUTextureFormat_Undefined;
|
WGPUTextureFormat renderTargetFormat = WGPUTextureFormat_Undefined;
|
||||||
WGPURenderPipeline pipelineState = nullptr;
|
WGPUTextureFormat depthStencilFormat = WGPUTextureFormat_Undefined;
|
||||||
|
WGPURenderPipeline pipelineState = nullptr;
|
||||||
|
|
||||||
RenderResources renderResources;
|
RenderResources renderResources;
|
||||||
FrameResources* pFrameResources = nullptr;
|
FrameResources* pFrameResources = nullptr;
|
||||||
unsigned int numFramesInFlight = 0;
|
unsigned int numFramesInFlight = 0;
|
||||||
unsigned int frameIndex = UINT_MAX;
|
unsigned int frameIndex = UINT_MAX;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
|
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
|
||||||
@@ -174,6 +186,12 @@ static void SafeRelease(WGPUBuffer& res)
|
|||||||
wgpuBufferRelease(res);
|
wgpuBufferRelease(res);
|
||||||
res = nullptr;
|
res = nullptr;
|
||||||
}
|
}
|
||||||
|
static void SafeRelease(WGPUPipelineLayout& res)
|
||||||
|
{
|
||||||
|
if (res)
|
||||||
|
wgpuPipelineLayoutRelease(res);
|
||||||
|
res = nullptr;
|
||||||
|
}
|
||||||
static void SafeRelease(WGPURenderPipeline& res)
|
static void SafeRelease(WGPURenderPipeline& res)
|
||||||
{
|
{
|
||||||
if (res)
|
if (res)
|
||||||
@@ -230,7 +248,7 @@ static WGPUProgrammableStageDescriptor ImGui_ImplWGPU_CreateShaderModule(const c
|
|||||||
|
|
||||||
WGPUShaderModuleWGSLDescriptor wgsl_desc = {};
|
WGPUShaderModuleWGSLDescriptor wgsl_desc = {};
|
||||||
wgsl_desc.chain.sType = WGPUSType_ShaderModuleWGSLDescriptor;
|
wgsl_desc.chain.sType = WGPUSType_ShaderModuleWGSLDescriptor;
|
||||||
wgsl_desc.source = wgsl_source;
|
wgsl_desc.code = wgsl_source;
|
||||||
|
|
||||||
WGPUShaderModuleDescriptor desc = {};
|
WGPUShaderModuleDescriptor desc = {};
|
||||||
desc.nextInChain = reinterpret_cast<WGPUChainedStruct*>(&wgsl_desc);
|
desc.nextInChain = reinterpret_cast<WGPUChainedStruct*>(&wgsl_desc);
|
||||||
@@ -324,7 +342,9 @@ static void ImGui_ImplWGPU_SetupRenderState(ImDrawData* draw_data, WGPURenderPas
|
|||||||
void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder)
|
void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder)
|
||||||
{
|
{
|
||||||
// Avoid rendering when minimized
|
// Avoid rendering when minimized
|
||||||
if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
|
if (fb_width <= 0 || fb_height <= 0 || draw_data->CmdListsCount == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// FIXME: Assuming that this only gets called once per frame!
|
// FIXME: Assuming that this only gets called once per frame!
|
||||||
@@ -443,6 +463,12 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder
|
|||||||
// Project scissor/clipping rectangles into framebuffer space
|
// Project scissor/clipping rectangles into framebuffer space
|
||||||
ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y);
|
ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y);
|
||||||
ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y);
|
ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y);
|
||||||
|
|
||||||
|
// Clamp to viewport as wgpuRenderPassEncoderSetScissorRect() won't accept values that are off bounds
|
||||||
|
if (clip_min.x < 0.0f) { clip_min.x = 0.0f; }
|
||||||
|
if (clip_min.y < 0.0f) { clip_min.y = 0.0f; }
|
||||||
|
if (clip_max.x > fb_width) { clip_max.x = (float)fb_width; }
|
||||||
|
if (clip_max.y > fb_height) { clip_max.y = (float)fb_height; }
|
||||||
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -511,7 +537,7 @@ static void ImGui_ImplWGPU_CreateFontsTexture()
|
|||||||
WGPUSamplerDescriptor sampler_desc = {};
|
WGPUSamplerDescriptor sampler_desc = {};
|
||||||
sampler_desc.minFilter = WGPUFilterMode_Linear;
|
sampler_desc.minFilter = WGPUFilterMode_Linear;
|
||||||
sampler_desc.magFilter = WGPUFilterMode_Linear;
|
sampler_desc.magFilter = WGPUFilterMode_Linear;
|
||||||
sampler_desc.mipmapFilter = WGPUFilterMode_Linear;
|
sampler_desc.mipmapFilter = WGPUMipmapFilterMode_Linear;
|
||||||
sampler_desc.addressModeU = WGPUAddressMode_Repeat;
|
sampler_desc.addressModeU = WGPUAddressMode_Repeat;
|
||||||
sampler_desc.addressModeV = WGPUAddressMode_Repeat;
|
sampler_desc.addressModeV = WGPUAddressMode_Repeat;
|
||||||
sampler_desc.addressModeW = WGPUAddressMode_Repeat;
|
sampler_desc.addressModeW = WGPUAddressMode_Repeat;
|
||||||
@@ -552,9 +578,7 @@ bool ImGui_ImplWGPU_CreateDeviceObjects()
|
|||||||
graphics_pipeline_desc.primitive.stripIndexFormat = WGPUIndexFormat_Undefined;
|
graphics_pipeline_desc.primitive.stripIndexFormat = WGPUIndexFormat_Undefined;
|
||||||
graphics_pipeline_desc.primitive.frontFace = WGPUFrontFace_CW;
|
graphics_pipeline_desc.primitive.frontFace = WGPUFrontFace_CW;
|
||||||
graphics_pipeline_desc.primitive.cullMode = WGPUCullMode_None;
|
graphics_pipeline_desc.primitive.cullMode = WGPUCullMode_None;
|
||||||
graphics_pipeline_desc.multisample.count = 1;
|
graphics_pipeline_desc.multisample = bd->initInfo.PipelineMultisampleState;
|
||||||
graphics_pipeline_desc.multisample.mask = UINT_MAX;
|
|
||||||
graphics_pipeline_desc.multisample.alphaToCoverageEnabled = false;
|
|
||||||
|
|
||||||
// Bind group layouts
|
// Bind group layouts
|
||||||
WGPUBindGroupLayoutEntry common_bg_layout_entries[2] = {};
|
WGPUBindGroupLayoutEntry common_bg_layout_entries[2] = {};
|
||||||
@@ -596,9 +620,9 @@ bool ImGui_ImplWGPU_CreateDeviceObjects()
|
|||||||
// Vertex input configuration
|
// Vertex input configuration
|
||||||
WGPUVertexAttribute attribute_desc[] =
|
WGPUVertexAttribute attribute_desc[] =
|
||||||
{
|
{
|
||||||
{ WGPUVertexFormat_Float32x2, (uint64_t)IM_OFFSETOF(ImDrawVert, pos), 0 },
|
{ WGPUVertexFormat_Float32x2, (uint64_t)offsetof(ImDrawVert, pos), 0 },
|
||||||
{ WGPUVertexFormat_Float32x2, (uint64_t)IM_OFFSETOF(ImDrawVert, uv), 1 },
|
{ WGPUVertexFormat_Float32x2, (uint64_t)offsetof(ImDrawVert, uv), 1 },
|
||||||
{ WGPUVertexFormat_Unorm8x4, (uint64_t)IM_OFFSETOF(ImDrawVert, col), 2 },
|
{ WGPUVertexFormat_Unorm8x4, (uint64_t)offsetof(ImDrawVert, col), 2 },
|
||||||
};
|
};
|
||||||
|
|
||||||
WGPUVertexBufferLayout buffer_layouts[1];
|
WGPUVertexBufferLayout buffer_layouts[1];
|
||||||
@@ -641,7 +665,13 @@ bool ImGui_ImplWGPU_CreateDeviceObjects()
|
|||||||
depth_stencil_state.depthWriteEnabled = false;
|
depth_stencil_state.depthWriteEnabled = false;
|
||||||
depth_stencil_state.depthCompare = WGPUCompareFunction_Always;
|
depth_stencil_state.depthCompare = WGPUCompareFunction_Always;
|
||||||
depth_stencil_state.stencilFront.compare = WGPUCompareFunction_Always;
|
depth_stencil_state.stencilFront.compare = WGPUCompareFunction_Always;
|
||||||
|
depth_stencil_state.stencilFront.failOp = WGPUStencilOperation_Keep;
|
||||||
|
depth_stencil_state.stencilFront.depthFailOp = WGPUStencilOperation_Keep;
|
||||||
|
depth_stencil_state.stencilFront.passOp = WGPUStencilOperation_Keep;
|
||||||
depth_stencil_state.stencilBack.compare = WGPUCompareFunction_Always;
|
depth_stencil_state.stencilBack.compare = WGPUCompareFunction_Always;
|
||||||
|
depth_stencil_state.stencilBack.failOp = WGPUStencilOperation_Keep;
|
||||||
|
depth_stencil_state.stencilBack.depthFailOp = WGPUStencilOperation_Keep;
|
||||||
|
depth_stencil_state.stencilBack.passOp = WGPUStencilOperation_Keep;
|
||||||
|
|
||||||
// Configure disabled depth-stencil state
|
// Configure disabled depth-stencil state
|
||||||
graphics_pipeline_desc.depthStencil = (bd->depthStencilFormat == WGPUTextureFormat_Undefined) ? nullptr : &depth_stencil_state;
|
graphics_pipeline_desc.depthStencil = (bd->depthStencilFormat == WGPUTextureFormat_Undefined) ? nullptr : &depth_stencil_state;
|
||||||
@@ -671,6 +701,7 @@ bool ImGui_ImplWGPU_CreateDeviceObjects()
|
|||||||
|
|
||||||
SafeRelease(vertex_shader_desc.module);
|
SafeRelease(vertex_shader_desc.module);
|
||||||
SafeRelease(pixel_shader_desc.module);
|
SafeRelease(pixel_shader_desc.module);
|
||||||
|
SafeRelease(graphics_pipeline_desc.layout);
|
||||||
SafeRelease(bg_layouts[0]);
|
SafeRelease(bg_layouts[0]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -692,7 +723,7 @@ void ImGui_ImplWGPU_InvalidateDeviceObjects()
|
|||||||
SafeRelease(bd->pFrameResources[i]);
|
SafeRelease(bd->pFrameResources[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplWGPU_Init(WGPUDevice device, int num_frames_in_flight, WGPUTextureFormat rt_format, WGPUTextureFormat depth_format)
|
bool ImGui_ImplWGPU_Init(ImGui_ImplWGPU_InitInfo* init_info)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
@@ -703,11 +734,12 @@ bool ImGui_ImplWGPU_Init(WGPUDevice device, int num_frames_in_flight, WGPUTextur
|
|||||||
io.BackendRendererName = "imgui_impl_webgpu";
|
io.BackendRendererName = "imgui_impl_webgpu";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
|
||||||
bd->wgpuDevice = device;
|
bd->initInfo = *init_info;
|
||||||
|
bd->wgpuDevice = init_info->Device;
|
||||||
bd->defaultQueue = wgpuDeviceGetQueue(bd->wgpuDevice);
|
bd->defaultQueue = wgpuDeviceGetQueue(bd->wgpuDevice);
|
||||||
bd->renderTargetFormat = rt_format;
|
bd->renderTargetFormat = init_info->RenderTargetFormat;
|
||||||
bd->depthStencilFormat = depth_format;
|
bd->depthStencilFormat = init_info->DepthStencilFormat;
|
||||||
bd->numFramesInFlight = num_frames_in_flight;
|
bd->numFramesInFlight = init_info->NumFramesInFlight;
|
||||||
bd->frameIndex = UINT_MAX;
|
bd->frameIndex = UINT_MAX;
|
||||||
|
|
||||||
bd->renderResources.FontTexture = nullptr;
|
bd->renderResources.FontTexture = nullptr;
|
||||||
@@ -720,8 +752,8 @@ bool ImGui_ImplWGPU_Init(WGPUDevice device, int num_frames_in_flight, WGPUTextur
|
|||||||
bd->renderResources.ImageBindGroupLayout = nullptr;
|
bd->renderResources.ImageBindGroupLayout = nullptr;
|
||||||
|
|
||||||
// Create buffers with a default size (they will later be grown as needed)
|
// Create buffers with a default size (they will later be grown as needed)
|
||||||
bd->pFrameResources = new FrameResources[num_frames_in_flight];
|
bd->pFrameResources = new FrameResources[bd->numFramesInFlight];
|
||||||
for (int i = 0; i < num_frames_in_flight; i++)
|
for (int i = 0; i < bd->numFramesInFlight; i++)
|
||||||
{
|
{
|
||||||
FrameResources* fr = &bd->pFrameResources[i];
|
FrameResources* fr = &bd->pFrameResources[i];
|
||||||
fr->IndexBuffer = nullptr;
|
fr->IndexBuffer = nullptr;
|
||||||
@@ -751,6 +783,7 @@ void ImGui_ImplWGPU_Shutdown()
|
|||||||
|
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -760,3 +793,7 @@ void ImGui_ImplWGPU_NewFrame()
|
|||||||
if (!bd->pipelineState)
|
if (!bd->pipelineState)
|
||||||
ImGui_ImplWGPU_CreateDeviceObjects();
|
ImGui_ImplWGPU_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -5,17 +5,41 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// Missing features:
|
||||||
|
// [ ] Renderer: Multi-viewport support (multiple windows). Not meaningful on the web.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
#include <webgpu/webgpu.h>
|
#include <webgpu/webgpu.h>
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplWGPU_Init(WGPUDevice device, int num_frames_in_flight, WGPUTextureFormat rt_format, WGPUTextureFormat depth_format = WGPUTextureFormat_Undefined);
|
// Initialization data, for ImGui_ImplWGPU_Init()
|
||||||
|
struct ImGui_ImplWGPU_InitInfo
|
||||||
|
{
|
||||||
|
WGPUDevice Device;
|
||||||
|
int NumFramesInFlight = 3;
|
||||||
|
WGPUTextureFormat RenderTargetFormat = WGPUTextureFormat_Undefined;
|
||||||
|
WGPUTextureFormat DepthStencilFormat = WGPUTextureFormat_Undefined;
|
||||||
|
WGPUMultisampleState PipelineMultisampleState = {};
|
||||||
|
|
||||||
|
ImGui_ImplWGPU_InitInfo()
|
||||||
|
{
|
||||||
|
PipelineMultisampleState.count = 1;
|
||||||
|
PipelineMultisampleState.mask = -1u;
|
||||||
|
PipelineMultisampleState.alphaToCoverageEnabled = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplWGPU_Init(ImGui_ImplWGPU_InitInfo* init_info);
|
||||||
IMGUI_IMPL_API void ImGui_ImplWGPU_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplWGPU_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplWGPU_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplWGPU_NewFrame();
|
||||||
IMGUI_IMPL_API void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder);
|
IMGUI_IMPL_API void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder);
|
||||||
@@ -23,3 +47,5 @@ IMGUI_IMPL_API void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURen
|
|||||||
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
||||||
IMGUI_IMPL_API void ImGui_ImplWGPU_InvalidateDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplWGPU_InvalidateDeviceObjects();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplWGPU_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplWGPU_CreateDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -7,13 +7,18 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
|
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_win32.h"
|
#include "imgui_impl_win32.h"
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
@@ -35,6 +40,11 @@ typedef DWORD (WINAPI *PFN_XInputGetState)(DWORD, XINPUT_STATE*);
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
||||||
|
// 2023-09-25: Inputs: Synthesize key-down event on key-up for VK_SNAPSHOT / ImGuiKey_PrintScreen as Windows doesn't emit it (same behavior as GLFW/SDL).
|
||||||
|
// 2023-09-07: Inputs: Added support for keyboard codepage conversion for when application is compiled in MBCS mode and using a non-Unicode window.
|
||||||
|
// 2023-04-19: Added ImGui_ImplWin32_InitForOpenGL() to facilitate combining raw Win32/Winapi with OpenGL. (#3218)
|
||||||
// 2023-04-04: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_TouchScreen/ImGuiMouseSource_Pen. (#2702)
|
// 2023-04-04: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_TouchScreen/ImGuiMouseSource_Pen. (#2702)
|
||||||
// 2023-02-15: Inputs: Use WM_NCMOUSEMOVE / WM_NCMOUSELEAVE to track mouse position over non-client area (e.g. OS decorations) when app is not focused. (#6045, #6162)
|
// 2023-02-15: Inputs: Use WM_NCMOUSEMOVE / WM_NCMOUSELEAVE to track mouse position over non-client area (e.g. OS decorations) when app is not focused. (#6045, #6162)
|
||||||
// 2023-02-02: Inputs: Flipping WM_MOUSEHWHEEL (horizontal mouse-wheel) value to match other backends and offer consistent horizontal scrolling direction. (#4019, #6096, #1463)
|
// 2023-02-02: Inputs: Flipping WM_MOUSEHWHEEL (horizontal mouse-wheel) value to match other backends and offer consistent horizontal scrolling direction. (#4019, #6096, #1463)
|
||||||
@@ -83,6 +93,11 @@ typedef DWORD (WINAPI *PFN_XInputGetState)(DWORD, XINPUT_STATE*);
|
|||||||
// 2017-10-23: Inputs: Using Win32 ::SetCapture/::GetCapture() to retrieve mouse positions outside the client area when dragging.
|
// 2017-10-23: Inputs: Using Win32 ::SetCapture/::GetCapture() to retrieve mouse positions outside the client area when dragging.
|
||||||
// 2016-11-12: Inputs: Only call Win32 ::SetCursor(nullptr) when io.MouseDrawCursor is set.
|
// 2016-11-12: Inputs: Only call Win32 ::SetCursor(nullptr) when io.MouseDrawCursor is set.
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplWin32_InitPlatformInterface(bool platformHasOwnDC);
|
||||||
|
static void ImGui_ImplWin32_ShutdownPlatformInterface();
|
||||||
|
static void ImGui_ImplWin32_UpdateMonitors();
|
||||||
|
|
||||||
struct ImGui_ImplWin32_Data
|
struct ImGui_ImplWin32_Data
|
||||||
{
|
{
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
@@ -92,6 +107,8 @@ struct ImGui_ImplWin32_Data
|
|||||||
INT64 Time;
|
INT64 Time;
|
||||||
INT64 TicksPerSecond;
|
INT64 TicksPerSecond;
|
||||||
ImGuiMouseCursor LastMouseCursor;
|
ImGuiMouseCursor LastMouseCursor;
|
||||||
|
UINT32 KeyboardCodePage;
|
||||||
|
bool WantUpdateMonitors;
|
||||||
|
|
||||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
bool HasGamepad;
|
bool HasGamepad;
|
||||||
@@ -114,7 +131,17 @@ static ImGui_ImplWin32_Data* ImGui_ImplWin32_GetBackendData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
bool ImGui_ImplWin32_Init(void* hwnd)
|
static void ImGui_ImplWin32_UpdateKeyboardCodePage()
|
||||||
|
{
|
||||||
|
// Retrieve keyboard code page, required for handling of non-Unicode Windows.
|
||||||
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
|
HKL keyboard_layout = ::GetKeyboardLayout(0);
|
||||||
|
LCID keyboard_lcid = MAKELCID(HIWORD(keyboard_layout), SORT_DEFAULT);
|
||||||
|
if (::GetLocaleInfoA(keyboard_lcid, (LOCALE_RETURN_NUMBER | LOCALE_IDEFAULTANSICODEPAGE), (LPSTR)&bd->KeyboardCodePage, sizeof(bd->KeyboardCodePage)) == 0)
|
||||||
|
bd->KeyboardCodePage = CP_ACP; // Fallback to default ANSI code page when fails.
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplWin32_InitEx(void* hwnd, bool platform_has_own_dc)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
||||||
@@ -131,14 +158,21 @@ bool ImGui_ImplWin32_Init(void* hwnd)
|
|||||||
io.BackendPlatformName = "imgui_impl_win32";
|
io.BackendPlatformName = "imgui_impl_win32";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can call io.AddMouseViewportEvent() with correct data (optional)
|
||||||
|
|
||||||
bd->hWnd = (HWND)hwnd;
|
bd->hWnd = (HWND)hwnd;
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
bd->TicksPerSecond = perf_frequency;
|
bd->TicksPerSecond = perf_frequency;
|
||||||
bd->Time = perf_counter;
|
bd->Time = perf_counter;
|
||||||
bd->LastMouseCursor = ImGuiMouseCursor_COUNT;
|
bd->LastMouseCursor = ImGuiMouseCursor_COUNT;
|
||||||
|
ImGui_ImplWin32_UpdateKeyboardCodePage();
|
||||||
|
|
||||||
// Set platform dependent data in viewport
|
// Our mouse update function expect PlatformHandle to be filled for the main viewport
|
||||||
ImGui::GetMainViewport()->PlatformHandleRaw = (void*)hwnd;
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
main_viewport->PlatformHandle = main_viewport->PlatformHandleRaw = (void*)bd->hWnd;
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplWin32_InitPlatformInterface(platform_has_own_dc);
|
||||||
|
|
||||||
// Dynamically load XInput library
|
// Dynamically load XInput library
|
||||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
@@ -164,12 +198,25 @@ bool ImGui_ImplWin32_Init(void* hwnd)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd)
|
||||||
|
{
|
||||||
|
return ImGui_ImplWin32_InitEx(hwnd, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplWin32_InitForOpenGL(void* hwnd)
|
||||||
|
{
|
||||||
|
// OpenGL needs CS_OWNDC
|
||||||
|
return ImGui_ImplWin32_InitEx(hwnd, true);
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplWin32_Shutdown()
|
void ImGui_ImplWin32_Shutdown()
|
||||||
{
|
{
|
||||||
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplWin32_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Unload XInput library
|
// Unload XInput library
|
||||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
if (bd->XInputDLL)
|
if (bd->XInputDLL)
|
||||||
@@ -178,6 +225,7 @@ void ImGui_ImplWin32_Shutdown()
|
|||||||
|
|
||||||
io.BackendPlatformName = nullptr;
|
io.BackendPlatformName = nullptr;
|
||||||
io.BackendPlatformUserData = nullptr;
|
io.BackendPlatformUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,33 +299,59 @@ static void ImGui_ImplWin32_UpdateKeyModifiers()
|
|||||||
io.AddKeyEvent(ImGuiMod_Super, IsVkDown(VK_APPS));
|
io.AddKeyEvent(ImGuiMod_Super, IsVkDown(VK_APPS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This code supports multi-viewports (multiple OS Windows mapped into different Dear ImGui viewports)
|
||||||
|
// Because of that, it is a little more complicated than your typical single-viewport binding code!
|
||||||
static void ImGui_ImplWin32_UpdateMouseData()
|
static void ImGui_ImplWin32_UpdateMouseData()
|
||||||
{
|
{
|
||||||
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IM_ASSERT(bd->hWnd != 0);
|
IM_ASSERT(bd->hWnd != 0);
|
||||||
|
|
||||||
|
POINT mouse_screen_pos;
|
||||||
|
bool has_mouse_screen_pos = ::GetCursorPos(&mouse_screen_pos) != 0;
|
||||||
|
|
||||||
HWND focused_window = ::GetForegroundWindow();
|
HWND focused_window = ::GetForegroundWindow();
|
||||||
const bool is_app_focused = (focused_window == bd->hWnd);
|
const bool is_app_focused = (focused_window && (focused_window == bd->hWnd || ::IsChild(focused_window, bd->hWnd) || ImGui::FindViewportByPlatformHandle((void*)focused_window)));
|
||||||
if (is_app_focused)
|
if (is_app_focused)
|
||||||
{
|
{
|
||||||
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
||||||
|
// When multi-viewports are enabled, all Dear ImGui positions are same as OS positions.
|
||||||
if (io.WantSetMousePos)
|
if (io.WantSetMousePos)
|
||||||
{
|
{
|
||||||
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
|
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
|
||||||
if (::ClientToScreen(bd->hWnd, &pos))
|
if ((io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) == 0)
|
||||||
::SetCursorPos(pos.x, pos.y);
|
::ClientToScreen(focused_window, &pos);
|
||||||
|
::SetCursorPos(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// (Optional) Fallback to provide mouse position when focused (WM_MOUSEMOVE already provides this when hovered or captured)
|
// (Optional) Fallback to provide mouse position when focused (WM_MOUSEMOVE already provides this when hovered or captured)
|
||||||
// This also fills a short gap when clicking non-client area: WM_NCMOUSELEAVE -> modal OS move -> gap -> WM_NCMOUSEMOVE
|
// This also fills a short gap when clicking non-client area: WM_NCMOUSELEAVE -> modal OS move -> gap -> WM_NCMOUSEMOVE
|
||||||
if (!io.WantSetMousePos && bd->MouseTrackedArea == 0)
|
if (!io.WantSetMousePos && bd->MouseTrackedArea == 0 && has_mouse_screen_pos)
|
||||||
{
|
{
|
||||||
POINT pos;
|
// Single viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
|
||||||
if (::GetCursorPos(&pos) && ::ScreenToClient(bd->hWnd, &pos))
|
// (This is the position you can get with ::GetCursorPos() + ::ScreenToClient() or WM_MOUSEMOVE.)
|
||||||
io.AddMousePosEvent((float)pos.x, (float)pos.y);
|
// Multi-viewport mode: mouse position in OS absolute coordinates (io.MousePos is (0,0) when the mouse is on the upper-left of the primary monitor)
|
||||||
|
// (This is the position you can get with ::GetCursorPos() or WM_MOUSEMOVE + ::ClientToScreen(). In theory adding viewport->Pos to a client position would also be the same.)
|
||||||
|
POINT mouse_pos = mouse_screen_pos;
|
||||||
|
if (!(io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable))
|
||||||
|
::ScreenToClient(bd->hWnd, &mouse_pos);
|
||||||
|
io.AddMousePosEvent((float)mouse_pos.x, (float)mouse_pos.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// (Optional) When using multiple viewports: call io.AddMouseViewportEvent() with the viewport the OS mouse cursor is hovering.
|
||||||
|
// If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the backend, Dear imGui will ignore this field and infer the information using its flawed heuristic.
|
||||||
|
// - [X] Win32 backend correctly ignore viewports with the _NoInputs flag (here using ::WindowFromPoint with WM_NCHITTEST + HTTRANSPARENT in WndProc does that)
|
||||||
|
// Some backend are not able to handle that correctly. If a backend report an hovered viewport that has the _NoInputs flag (e.g. when dragging a window
|
||||||
|
// for docking, the viewport has the _NoInputs flag in order to allow us to find the viewport under), then Dear ImGui is forced to ignore the value reported
|
||||||
|
// by the backend, and use its flawed heuristic to guess the viewport behind.
|
||||||
|
// - [X] Win32 backend correctly reports this regardless of another viewport behind focused and dragged from (we need this to find a useful drag and drop target).
|
||||||
|
ImGuiID mouse_viewport_id = 0;
|
||||||
|
if (has_mouse_screen_pos)
|
||||||
|
if (HWND hovered_hwnd = ::WindowFromPoint(mouse_screen_pos))
|
||||||
|
if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle((void*)hovered_hwnd))
|
||||||
|
mouse_viewport_id = viewport->ID;
|
||||||
|
io.AddMouseViewportEvent(mouse_viewport_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gamepad navigation mapping
|
// Gamepad navigation mapping
|
||||||
@@ -337,6 +411,35 @@ static void ImGui_ImplWin32_UpdateGamepads()
|
|||||||
#endif // #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#endif // #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL CALLBACK ImGui_ImplWin32_UpdateMonitors_EnumFunc(HMONITOR monitor, HDC, LPRECT, LPARAM)
|
||||||
|
{
|
||||||
|
MONITORINFO info = {};
|
||||||
|
info.cbSize = sizeof(MONITORINFO);
|
||||||
|
if (!::GetMonitorInfo(monitor, &info))
|
||||||
|
return TRUE;
|
||||||
|
ImGuiPlatformMonitor imgui_monitor;
|
||||||
|
imgui_monitor.MainPos = ImVec2((float)info.rcMonitor.left, (float)info.rcMonitor.top);
|
||||||
|
imgui_monitor.MainSize = ImVec2((float)(info.rcMonitor.right - info.rcMonitor.left), (float)(info.rcMonitor.bottom - info.rcMonitor.top));
|
||||||
|
imgui_monitor.WorkPos = ImVec2((float)info.rcWork.left, (float)info.rcWork.top);
|
||||||
|
imgui_monitor.WorkSize = ImVec2((float)(info.rcWork.right - info.rcWork.left), (float)(info.rcWork.bottom - info.rcWork.top));
|
||||||
|
imgui_monitor.DpiScale = ImGui_ImplWin32_GetDpiScaleForMonitor(monitor);
|
||||||
|
imgui_monitor.PlatformHandle = (void*)monitor;
|
||||||
|
ImGuiPlatformIO& io = ImGui::GetPlatformIO();
|
||||||
|
if (info.dwFlags & MONITORINFOF_PRIMARY)
|
||||||
|
io.Monitors.push_front(imgui_monitor);
|
||||||
|
else
|
||||||
|
io.Monitors.push_back(imgui_monitor);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_UpdateMonitors()
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
|
ImGui::GetPlatformIO().Monitors.resize(0);
|
||||||
|
::EnumDisplayMonitors(nullptr, nullptr, ImGui_ImplWin32_UpdateMonitors_EnumFunc, 0);
|
||||||
|
bd->WantUpdateMonitors = false;
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplWin32_NewFrame()
|
void ImGui_ImplWin32_NewFrame()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@@ -347,6 +450,8 @@ void ImGui_ImplWin32_NewFrame()
|
|||||||
RECT rect = { 0, 0, 0, 0 };
|
RECT rect = { 0, 0, 0, 0 };
|
||||||
::GetClientRect(bd->hWnd, &rect);
|
::GetClientRect(bd->hWnd, &rect);
|
||||||
io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
|
io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
|
||||||
|
if (bd->WantUpdateMonitors)
|
||||||
|
ImGui_ImplWin32_UpdateMonitors();
|
||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
INT64 current_time = 0;
|
INT64 current_time = 0;
|
||||||
@@ -484,6 +589,20 @@ static ImGuiKey ImGui_ImplWin32_VirtualKeyToImGuiKey(WPARAM wParam)
|
|||||||
case VK_F10: return ImGuiKey_F10;
|
case VK_F10: return ImGuiKey_F10;
|
||||||
case VK_F11: return ImGuiKey_F11;
|
case VK_F11: return ImGuiKey_F11;
|
||||||
case VK_F12: return ImGuiKey_F12;
|
case VK_F12: return ImGuiKey_F12;
|
||||||
|
case VK_F13: return ImGuiKey_F13;
|
||||||
|
case VK_F14: return ImGuiKey_F14;
|
||||||
|
case VK_F15: return ImGuiKey_F15;
|
||||||
|
case VK_F16: return ImGuiKey_F16;
|
||||||
|
case VK_F17: return ImGuiKey_F17;
|
||||||
|
case VK_F18: return ImGuiKey_F18;
|
||||||
|
case VK_F19: return ImGuiKey_F19;
|
||||||
|
case VK_F20: return ImGuiKey_F20;
|
||||||
|
case VK_F21: return ImGuiKey_F21;
|
||||||
|
case VK_F22: return ImGuiKey_F22;
|
||||||
|
case VK_F23: return ImGuiKey_F23;
|
||||||
|
case VK_F24: return ImGuiKey_F24;
|
||||||
|
case VK_BROWSER_BACK: return ImGuiKey_AppBack;
|
||||||
|
case VK_BROWSER_FORWARD: return ImGuiKey_AppForward;
|
||||||
default: return ImGuiKey_None;
|
default: return ImGuiKey_None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -548,8 +667,11 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
bd->MouseTrackedArea = area;
|
bd->MouseTrackedArea = area;
|
||||||
}
|
}
|
||||||
POINT mouse_pos = { (LONG)GET_X_LPARAM(lParam), (LONG)GET_Y_LPARAM(lParam) };
|
POINT mouse_pos = { (LONG)GET_X_LPARAM(lParam), (LONG)GET_Y_LPARAM(lParam) };
|
||||||
if (msg == WM_NCMOUSEMOVE && ::ScreenToClient(hwnd, &mouse_pos) == FALSE) // WM_NCMOUSEMOVE are provided in absolute coordinates.
|
bool want_absolute_pos = (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) != 0;
|
||||||
break;
|
if (msg == WM_MOUSEMOVE && want_absolute_pos) // WM_MOUSEMOVE are client-relative coordinates.
|
||||||
|
::ClientToScreen(hwnd, &mouse_pos);
|
||||||
|
if (msg == WM_NCMOUSEMOVE && !want_absolute_pos) // WM_NCMOUSEMOVE are absolute coordinates.
|
||||||
|
::ScreenToClient(hwnd, &mouse_pos);
|
||||||
io.AddMouseSourceEvent(mouse_source);
|
io.AddMouseSourceEvent(mouse_source);
|
||||||
io.AddMousePosEvent((float)mouse_pos.x, (float)mouse_pos.y);
|
io.AddMousePosEvent((float)mouse_pos.x, (float)mouse_pos.y);
|
||||||
break;
|
break;
|
||||||
@@ -625,10 +747,14 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
int vk = (int)wParam;
|
int vk = (int)wParam;
|
||||||
if ((wParam == VK_RETURN) && (HIWORD(lParam) & KF_EXTENDED))
|
if ((wParam == VK_RETURN) && (HIWORD(lParam) & KF_EXTENDED))
|
||||||
vk = IM_VK_KEYPAD_ENTER;
|
vk = IM_VK_KEYPAD_ENTER;
|
||||||
|
|
||||||
// Submit key event
|
|
||||||
const ImGuiKey key = ImGui_ImplWin32_VirtualKeyToImGuiKey(vk);
|
const ImGuiKey key = ImGui_ImplWin32_VirtualKeyToImGuiKey(vk);
|
||||||
const int scancode = (int)LOBYTE(HIWORD(lParam));
|
const int scancode = (int)LOBYTE(HIWORD(lParam));
|
||||||
|
|
||||||
|
// Special behavior for VK_SNAPSHOT / ImGuiKey_PrintScreen as Windows doesn't emit the key down event.
|
||||||
|
if (key == ImGuiKey_PrintScreen && !is_key_down)
|
||||||
|
ImGui_ImplWin32_AddKeyEvent(key, true, vk, scancode);
|
||||||
|
|
||||||
|
// Submit key event
|
||||||
if (key != ImGuiKey_None)
|
if (key != ImGuiKey_None)
|
||||||
ImGui_ImplWin32_AddKeyEvent(key, is_key_down, vk, scancode);
|
ImGui_ImplWin32_AddKeyEvent(key, is_key_down, vk, scancode);
|
||||||
|
|
||||||
@@ -656,6 +782,9 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
case WM_KILLFOCUS:
|
case WM_KILLFOCUS:
|
||||||
io.AddFocusEvent(msg == WM_SETFOCUS);
|
io.AddFocusEvent(msg == WM_SETFOCUS);
|
||||||
return 0;
|
return 0;
|
||||||
|
case WM_INPUTLANGCHANGE:
|
||||||
|
ImGui_ImplWin32_UpdateKeyboardCodePage();
|
||||||
|
return 0;
|
||||||
case WM_CHAR:
|
case WM_CHAR:
|
||||||
if (::IsWindowUnicode(hwnd))
|
if (::IsWindowUnicode(hwnd))
|
||||||
{
|
{
|
||||||
@@ -666,7 +795,7 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
wchar_t wch = 0;
|
wchar_t wch = 0;
|
||||||
::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (char*)&wParam, 1, &wch, 1);
|
::MultiByteToWideChar(bd->KeyboardCodePage, MB_PRECOMPOSED, (char*)&wParam, 1, &wch, 1);
|
||||||
io.AddInputCharacter(wch);
|
io.AddInputCharacter(wch);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -681,6 +810,9 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
bd->WantUpdateHasGamepad = true;
|
bd->WantUpdateHasGamepad = true;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
case WM_DISPLAYCHANGE:
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -745,6 +877,10 @@ typedef DPI_AWARENESS_CONTEXT(WINAPI* PFN_SetThreadDpiAwarenessContext)(DPI_AWAR
|
|||||||
// Helper function to enable DPI awareness without setting up a manifest
|
// Helper function to enable DPI awareness without setting up a manifest
|
||||||
void ImGui_ImplWin32_EnableDpiAwareness()
|
void ImGui_ImplWin32_EnableDpiAwareness()
|
||||||
{
|
{
|
||||||
|
// Make sure monitors will be updated with latest correct scaling
|
||||||
|
if (ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData())
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
|
|
||||||
if (_IsWindows10OrGreater())
|
if (_IsWindows10OrGreater())
|
||||||
{
|
{
|
||||||
static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process
|
static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process
|
||||||
@@ -845,3 +981,347 @@ void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplWin32_ViewportData
|
||||||
|
{
|
||||||
|
HWND Hwnd;
|
||||||
|
HWND HwndParent;
|
||||||
|
bool HwndOwned;
|
||||||
|
DWORD DwStyle;
|
||||||
|
DWORD DwExStyle;
|
||||||
|
|
||||||
|
ImGui_ImplWin32_ViewportData() { Hwnd = HwndParent = nullptr; HwndOwned = false; DwStyle = DwExStyle = 0; }
|
||||||
|
~ImGui_ImplWin32_ViewportData() { IM_ASSERT(Hwnd == nullptr); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_GetWin32StyleFromViewportFlags(ImGuiViewportFlags flags, DWORD* out_style, DWORD* out_ex_style)
|
||||||
|
{
|
||||||
|
if (flags & ImGuiViewportFlags_NoDecoration)
|
||||||
|
*out_style = WS_POPUP;
|
||||||
|
else
|
||||||
|
*out_style = WS_OVERLAPPEDWINDOW;
|
||||||
|
|
||||||
|
if (flags & ImGuiViewportFlags_NoTaskBarIcon)
|
||||||
|
*out_ex_style = WS_EX_TOOLWINDOW;
|
||||||
|
else
|
||||||
|
*out_ex_style = WS_EX_APPWINDOW;
|
||||||
|
|
||||||
|
if (flags & ImGuiViewportFlags_TopMost)
|
||||||
|
*out_ex_style |= WS_EX_TOPMOST;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HWND ImGui_ImplWin32_GetHwndFromViewportID(ImGuiID viewport_id)
|
||||||
|
{
|
||||||
|
if (viewport_id != 0)
|
||||||
|
if (ImGuiViewport* viewport = ImGui::FindViewportByID(viewport_id))
|
||||||
|
return (HWND)viewport->PlatformHandle;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = IM_NEW(ImGui_ImplWin32_ViewportData)();
|
||||||
|
viewport->PlatformUserData = vd;
|
||||||
|
|
||||||
|
// Select style and parent window
|
||||||
|
ImGui_ImplWin32_GetWin32StyleFromViewportFlags(viewport->Flags, &vd->DwStyle, &vd->DwExStyle);
|
||||||
|
vd->HwndParent = ImGui_ImplWin32_GetHwndFromViewportID(viewport->ParentViewportId);
|
||||||
|
|
||||||
|
// Create window
|
||||||
|
RECT rect = { (LONG)viewport->Pos.x, (LONG)viewport->Pos.y, (LONG)(viewport->Pos.x + viewport->Size.x), (LONG)(viewport->Pos.y + viewport->Size.y) };
|
||||||
|
::AdjustWindowRectEx(&rect, vd->DwStyle, FALSE, vd->DwExStyle);
|
||||||
|
vd->Hwnd = ::CreateWindowEx(
|
||||||
|
vd->DwExStyle, _T("ImGui Platform"), _T("Untitled"), vd->DwStyle, // Style, class name, window name
|
||||||
|
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, // Window area
|
||||||
|
vd->HwndParent, nullptr, ::GetModuleHandle(nullptr), nullptr); // Owner window, Menu, Instance, Param
|
||||||
|
vd->HwndOwned = true;
|
||||||
|
viewport->PlatformRequestResize = false;
|
||||||
|
viewport->PlatformHandle = viewport->PlatformHandleRaw = vd->Hwnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
|
if (ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData)
|
||||||
|
{
|
||||||
|
if (::GetCapture() == vd->Hwnd)
|
||||||
|
{
|
||||||
|
// Transfer capture so if we started dragging from a window that later disappears, we'll still receive the MOUSEUP event.
|
||||||
|
::ReleaseCapture();
|
||||||
|
::SetCapture(bd->hWnd);
|
||||||
|
}
|
||||||
|
if (vd->Hwnd && vd->HwndOwned)
|
||||||
|
::DestroyWindow(vd->Hwnd);
|
||||||
|
vd->Hwnd = nullptr;
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->PlatformUserData = viewport->PlatformHandle = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_ShowWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing)
|
||||||
|
::ShowWindow(vd->Hwnd, SW_SHOWNA);
|
||||||
|
else
|
||||||
|
::ShowWindow(vd->Hwnd, SW_SHOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_UpdateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
|
||||||
|
// Update Win32 parent if it changed _after_ creation
|
||||||
|
// Unlike style settings derived from configuration flags, this is more likely to change for advanced apps that are manipulating ParentViewportID manually.
|
||||||
|
HWND new_parent = ImGui_ImplWin32_GetHwndFromViewportID(viewport->ParentViewportId);
|
||||||
|
if (new_parent != vd->HwndParent)
|
||||||
|
{
|
||||||
|
// Win32 windows can either have a "Parent" (for WS_CHILD window) or an "Owner" (which among other thing keeps window above its owner).
|
||||||
|
// Our Dear Imgui-side concept of parenting only mostly care about what Win32 call "Owner".
|
||||||
|
// The parent parameter of CreateWindowEx() sets up Parent OR Owner depending on WS_CHILD flag. In our case an Owner as we never use WS_CHILD.
|
||||||
|
// Calling ::SetParent() here would be incorrect: it will create a full child relation, alter coordinate system and clipping.
|
||||||
|
// Calling ::SetWindowLongPtr() with GWLP_HWNDPARENT seems correct although poorly documented.
|
||||||
|
// https://devblogs.microsoft.com/oldnewthing/20100315-00/?p=14613
|
||||||
|
vd->HwndParent = new_parent;
|
||||||
|
::SetWindowLongPtr(vd->Hwnd, GWLP_HWNDPARENT, (LONG_PTR)vd->HwndParent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// (Optional) Update Win32 style if it changed _after_ creation.
|
||||||
|
// Generally they won't change unless configuration flags are changed, but advanced uses (such as manually rewriting viewport flags) make this useful.
|
||||||
|
DWORD new_style;
|
||||||
|
DWORD new_ex_style;
|
||||||
|
ImGui_ImplWin32_GetWin32StyleFromViewportFlags(viewport->Flags, &new_style, &new_ex_style);
|
||||||
|
|
||||||
|
// Only reapply the flags that have been changed from our point of view (as other flags are being modified by Windows)
|
||||||
|
if (vd->DwStyle != new_style || vd->DwExStyle != new_ex_style)
|
||||||
|
{
|
||||||
|
// (Optional) Update TopMost state if it changed _after_ creation
|
||||||
|
bool top_most_changed = (vd->DwExStyle & WS_EX_TOPMOST) != (new_ex_style & WS_EX_TOPMOST);
|
||||||
|
HWND insert_after = top_most_changed ? ((viewport->Flags & ImGuiViewportFlags_TopMost) ? HWND_TOPMOST : HWND_NOTOPMOST) : 0;
|
||||||
|
UINT swp_flag = top_most_changed ? 0 : SWP_NOZORDER;
|
||||||
|
|
||||||
|
// Apply flags and position (since it is affected by flags)
|
||||||
|
vd->DwStyle = new_style;
|
||||||
|
vd->DwExStyle = new_ex_style;
|
||||||
|
::SetWindowLong(vd->Hwnd, GWL_STYLE, vd->DwStyle);
|
||||||
|
::SetWindowLong(vd->Hwnd, GWL_EXSTYLE, vd->DwExStyle);
|
||||||
|
RECT rect = { (LONG)viewport->Pos.x, (LONG)viewport->Pos.y, (LONG)(viewport->Pos.x + viewport->Size.x), (LONG)(viewport->Pos.y + viewport->Size.y) };
|
||||||
|
::AdjustWindowRectEx(&rect, vd->DwStyle, FALSE, vd->DwExStyle); // Client to Screen
|
||||||
|
::SetWindowPos(vd->Hwnd, insert_after, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, swp_flag | SWP_NOACTIVATE | SWP_FRAMECHANGED);
|
||||||
|
::ShowWindow(vd->Hwnd, SW_SHOWNA); // This is necessary when we alter the style
|
||||||
|
viewport->PlatformRequestMove = viewport->PlatformRequestResize = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplWin32_GetWindowPos(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
POINT pos = { 0, 0 };
|
||||||
|
::ClientToScreen(vd->Hwnd, &pos);
|
||||||
|
return ImVec2((float)pos.x, (float)pos.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
RECT rect = { (LONG)pos.x, (LONG)pos.y, (LONG)pos.x, (LONG)pos.y };
|
||||||
|
::AdjustWindowRectEx(&rect, vd->DwStyle, FALSE, vd->DwExStyle);
|
||||||
|
::SetWindowPos(vd->Hwnd, nullptr, rect.left, rect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplWin32_GetWindowSize(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
RECT rect;
|
||||||
|
::GetClientRect(vd->Hwnd, &rect);
|
||||||
|
return ImVec2(float(rect.right - rect.left), float(rect.bottom - rect.top));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
RECT rect = { 0, 0, (LONG)size.x, (LONG)size.y };
|
||||||
|
::AdjustWindowRectEx(&rect, vd->DwStyle, FALSE, vd->DwExStyle); // Client to Screen
|
||||||
|
::SetWindowPos(vd->Hwnd, nullptr, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_SetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
::BringWindowToTop(vd->Hwnd);
|
||||||
|
::SetForegroundWindow(vd->Hwnd);
|
||||||
|
::SetFocus(vd->Hwnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplWin32_GetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
return ::GetForegroundWindow() == vd->Hwnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplWin32_GetWindowMinimized(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
return ::IsIconic(vd->Hwnd) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_SetWindowTitle(ImGuiViewport* viewport, const char* title)
|
||||||
|
{
|
||||||
|
// ::SetWindowTextA() doesn't properly handle UTF-8 so we explicitely convert our string.
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
int n = ::MultiByteToWideChar(CP_UTF8, 0, title, -1, nullptr, 0);
|
||||||
|
ImVector<wchar_t> title_w;
|
||||||
|
title_w.resize(n);
|
||||||
|
::MultiByteToWideChar(CP_UTF8, 0, title, -1, title_w.Data, n);
|
||||||
|
::SetWindowTextW(vd->Hwnd, title_w.Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
IM_ASSERT(alpha >= 0.0f && alpha <= 1.0f);
|
||||||
|
if (alpha < 1.0f)
|
||||||
|
{
|
||||||
|
DWORD style = ::GetWindowLongW(vd->Hwnd, GWL_EXSTYLE) | WS_EX_LAYERED;
|
||||||
|
::SetWindowLongW(vd->Hwnd, GWL_EXSTYLE, style);
|
||||||
|
::SetLayeredWindowAttributes(vd->Hwnd, 0, (BYTE)(255 * alpha), LWA_ALPHA);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DWORD style = ::GetWindowLongW(vd->Hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED;
|
||||||
|
::SetWindowLongW(vd->Hwnd, GWL_EXSTYLE, style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static float ImGui_ImplWin32_GetWindowDpiScale(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
return ImGui_ImplWin32_GetDpiScaleForHwnd(vd->Hwnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME-DPI: Testing DPI related ideas
|
||||||
|
static void ImGui_ImplWin32_OnChangedViewport(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
(void)viewport;
|
||||||
|
#if 0
|
||||||
|
ImGuiStyle default_style;
|
||||||
|
//default_style.WindowPadding = ImVec2(0, 0);
|
||||||
|
//default_style.WindowBorderSize = 0.0f;
|
||||||
|
//default_style.ItemSpacing.y = 3.0f;
|
||||||
|
//default_style.FramePadding = ImVec2(0, 0);
|
||||||
|
default_style.ScaleAllSizes(viewport->DpiScale);
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
style = default_style;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static LRESULT CALLBACK ImGui_ImplWin32_WndProcHandler_PlatformWindow(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle((void*)hWnd))
|
||||||
|
{
|
||||||
|
switch (msg)
|
||||||
|
{
|
||||||
|
case WM_CLOSE:
|
||||||
|
viewport->PlatformRequestClose = true;
|
||||||
|
return 0;
|
||||||
|
case WM_MOVE:
|
||||||
|
viewport->PlatformRequestMove = true;
|
||||||
|
break;
|
||||||
|
case WM_SIZE:
|
||||||
|
viewport->PlatformRequestResize = true;
|
||||||
|
break;
|
||||||
|
case WM_MOUSEACTIVATE:
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnClick)
|
||||||
|
return MA_NOACTIVATE;
|
||||||
|
break;
|
||||||
|
case WM_NCHITTEST:
|
||||||
|
// Let mouse pass-through the window. This will allow the backend to call io.AddMouseViewportEvent() correctly. (which is optional).
|
||||||
|
// The ImGuiViewportFlags_NoInputs flag is set while dragging a viewport, as want to detect the window behind the one we are dragging.
|
||||||
|
// If you cannot easily access those viewport flags from your windowing/event code: you may manually synchronize its state e.g. in
|
||||||
|
// your main loop after calling UpdatePlatformWindows(). Iterate all viewports/platform windows and pass the flag to your windowing system.
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoInputs)
|
||||||
|
return HTTRANSPARENT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_InitPlatformInterface(bool platform_has_own_dc)
|
||||||
|
{
|
||||||
|
WNDCLASSEX wcex;
|
||||||
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||||
|
wcex.style = CS_HREDRAW | CS_VREDRAW | (platform_has_own_dc ? CS_OWNDC : 0);
|
||||||
|
wcex.lpfnWndProc = ImGui_ImplWin32_WndProcHandler_PlatformWindow;
|
||||||
|
wcex.cbClsExtra = 0;
|
||||||
|
wcex.cbWndExtra = 0;
|
||||||
|
wcex.hInstance = ::GetModuleHandle(nullptr);
|
||||||
|
wcex.hIcon = nullptr;
|
||||||
|
wcex.hCursor = nullptr;
|
||||||
|
wcex.hbrBackground = (HBRUSH)(COLOR_BACKGROUND + 1);
|
||||||
|
wcex.lpszMenuName = nullptr;
|
||||||
|
wcex.lpszClassName = _T("ImGui Platform");
|
||||||
|
wcex.hIconSm = nullptr;
|
||||||
|
::RegisterClassEx(&wcex);
|
||||||
|
|
||||||
|
ImGui_ImplWin32_UpdateMonitors();
|
||||||
|
|
||||||
|
// Register platform interface (will be coupled with a renderer interface)
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Platform_CreateWindow = ImGui_ImplWin32_CreateWindow;
|
||||||
|
platform_io.Platform_DestroyWindow = ImGui_ImplWin32_DestroyWindow;
|
||||||
|
platform_io.Platform_ShowWindow = ImGui_ImplWin32_ShowWindow;
|
||||||
|
platform_io.Platform_SetWindowPos = ImGui_ImplWin32_SetWindowPos;
|
||||||
|
platform_io.Platform_GetWindowPos = ImGui_ImplWin32_GetWindowPos;
|
||||||
|
platform_io.Platform_SetWindowSize = ImGui_ImplWin32_SetWindowSize;
|
||||||
|
platform_io.Platform_GetWindowSize = ImGui_ImplWin32_GetWindowSize;
|
||||||
|
platform_io.Platform_SetWindowFocus = ImGui_ImplWin32_SetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowFocus = ImGui_ImplWin32_GetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowMinimized = ImGui_ImplWin32_GetWindowMinimized;
|
||||||
|
platform_io.Platform_SetWindowTitle = ImGui_ImplWin32_SetWindowTitle;
|
||||||
|
platform_io.Platform_SetWindowAlpha = ImGui_ImplWin32_SetWindowAlpha;
|
||||||
|
platform_io.Platform_UpdateWindow = ImGui_ImplWin32_UpdateWindow;
|
||||||
|
platform_io.Platform_GetWindowDpiScale = ImGui_ImplWin32_GetWindowDpiScale; // FIXME-DPI
|
||||||
|
platform_io.Platform_OnChangedViewport = ImGui_ImplWin32_OnChangedViewport; // FIXME-DPI
|
||||||
|
|
||||||
|
// Register main window handle (which is owned by the main application, not by us)
|
||||||
|
// This is mostly for simplicity and consistency, so that our code (e.g. mouse handling etc.) can use same logic for main and secondary viewports.
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = IM_NEW(ImGui_ImplWin32_ViewportData)();
|
||||||
|
vd->Hwnd = bd->hWnd;
|
||||||
|
vd->HwndOwned = false;
|
||||||
|
main_viewport->PlatformUserData = vd;
|
||||||
|
main_viewport->PlatformHandle = (void*)bd->hWnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
::UnregisterClass(_T("ImGui Platform"), ::GetModuleHandle(nullptr));
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -7,16 +7,22 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
|
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
// Learn about Dear ImGui:
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd);
|
IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd);
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplWin32_InitForOpenGL(void* hwnd);
|
||||||
IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame();
|
||||||
|
|
||||||
@@ -43,3 +49,5 @@ IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); //
|
|||||||
// - Use to enable alpha compositing transparency with the desktop.
|
// - Use to enable alpha compositing transparency with the desktop.
|
||||||
// - Use together with e.g. clearing your framebuffer with zero-alpha.
|
// - Use together with e.g. clearing your framebuffer with zero-alpha.
|
||||||
IMGUI_IMPL_API void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd); // HWND hwnd
|
IMGUI_IMPL_API void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd); // HWND hwnd
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ List of Platforms Backends:
|
|||||||
imgui_impl_glfw.cpp ; GLFW (Windows, macOS, Linux, etc.) http://www.glfw.org/
|
imgui_impl_glfw.cpp ; GLFW (Windows, macOS, Linux, etc.) http://www.glfw.org/
|
||||||
imgui_impl_osx.mm ; macOS native API (not as feature complete as glfw/sdl backends)
|
imgui_impl_osx.mm ; macOS native API (not as feature complete as glfw/sdl backends)
|
||||||
imgui_impl_sdl2.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
|
imgui_impl_sdl2.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
|
||||||
imgui_impl_sdl3.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org (*EXPERIMENTAL*)
|
imgui_impl_sdl3.cpp ; SDL3 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org (*EXPERIMENTAL UNTIL SDL3 IS RELEASED*)
|
||||||
imgui_impl_win32.cpp ; Win32 native API (Windows)
|
imgui_impl_win32.cpp ; Win32 native API (Windows)
|
||||||
imgui_impl_glut.cpp ; GLUT/FreeGLUT (this is prehistoric software and absolutely not recommended today!)
|
imgui_impl_glut.cpp ; GLUT/FreeGLUT (this is prehistoric software and absolutely not recommended today!)
|
||||||
|
|
||||||
@@ -76,7 +76,8 @@ List of Renderer Backends:
|
|||||||
imgui_impl_metal.mm ; Metal (with ObjC)
|
imgui_impl_metal.mm ; Metal (with ObjC)
|
||||||
imgui_impl_opengl2.cpp ; OpenGL 2 (legacy, fixed pipeline <- don't use with modern OpenGL context)
|
imgui_impl_opengl2.cpp ; OpenGL 2 (legacy, fixed pipeline <- don't use with modern OpenGL context)
|
||||||
imgui_impl_opengl3.cpp ; OpenGL 3/4, OpenGL ES 2, OpenGL ES 3 (modern programmable pipeline)
|
imgui_impl_opengl3.cpp ; OpenGL 3/4, OpenGL ES 2, OpenGL ES 3 (modern programmable pipeline)
|
||||||
imgui_impl_sdlrenderer.cpp; SDL_Renderer (optional component of SDL2 available from SDL 2.0.18+)
|
imgui_impl_sdlrenderer2.cpp ; SDL_Renderer (optional component of SDL2 available from SDL 2.0.18+)
|
||||||
|
imgui_impl_sdlrenderer3.cpp ; SDL_Renderer (optional component of SDL3 available from SDL 3.0.0+)
|
||||||
imgui_impl_vulkan.cpp ; Vulkan
|
imgui_impl_vulkan.cpp ; Vulkan
|
||||||
imgui_impl_wgpu.cpp ; WebGPU
|
imgui_impl_wgpu.cpp ; WebGPU
|
||||||
|
|
||||||
|
|||||||
1183
docs/CHANGELOG.txt
1183
docs/CHANGELOG.txt
File diff suppressed because it is too large
Load Diff
@@ -11,27 +11,30 @@
|
|||||||
## Getting Started & General Advice
|
## Getting Started & General Advice
|
||||||
|
|
||||||
- Article: [How To Ask Good Questions](https://bit.ly/3nwRnx1).
|
- Article: [How To Ask Good Questions](https://bit.ly/3nwRnx1).
|
||||||
- Please browse the [Wiki](https://github.com/ocornut/imgui/wiki) to find code snippets, links and other resources (e.g. [Useful extensions](https://github.com/ocornut/imgui/wiki/Useful-Extensions)).
|
- Please browse the [Wiki](https://github.com/ocornut/imgui/wiki) to find code snippets, links and other resources (e.g. [Getting Started](https://github.com/ocornut/imgui/wiki/Getting-Started), [Useful extensions](https://github.com/ocornut/imgui/wiki/Useful-Extensions)).
|
||||||
|
- Please read [Getting Started](https://github.com/ocornut/imgui/wiki/Getting-Started) if your question relates to setting up Dear ImGui.
|
||||||
- Please read [docs/FAQ.md](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md).
|
- Please read [docs/FAQ.md](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md).
|
||||||
- Please read [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) if your question relates to fonts or text.
|
- Please read [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) if your question relates to fonts or text.
|
||||||
- Please read one of the [examples/](https://github.com/ocornut/imgui/tree/master/examples) application if your question relates to setting up Dear ImGui.
|
|
||||||
- Please run `ImGui::ShowDemoWindow()` to explore the demo and its sources.
|
- Please run `ImGui::ShowDemoWindow()` to explore the demo and its sources.
|
||||||
- Please use the search function of your IDE to search in for comments related to your situation.
|
- Please use the search function of your IDE to search for symbols and comments related to your situation.
|
||||||
- Please use the search function of GitHub to look for similar issues. You may [browse issues by Labels](https://github.com/ocornut/imgui/labels).
|
- Please use the search function of GitHub to look for similar topics (always include 'Closed' issues/pr in your search).
|
||||||
|
- You may [browse issues by Labels](https://github.com/ocornut/imgui/labels).
|
||||||
- Please use a web search engine to look for similar issues.
|
- Please use a web search engine to look for similar issues.
|
||||||
- If you get a crash or assert, use a debugger to locate the line triggering it and read the comments around.
|
- If you get a crash or assert, use a debugger to locate the line triggering it and read the comments around.
|
||||||
- Please don't be a [Help Vampire](https://slash7.com/2006/12/22/vampires/).
|
- Please don't be a [Help Vampire](https://slash7.com/2006/12/22/vampires/).
|
||||||
|
|
||||||
## Issues vs Discussions
|
## 'Issues' vs 'Discussions'
|
||||||
|
|
||||||
If you:
|
We are happy to use 'Issues' for many type of open-ended questions. We are encouraging 'Issues' becoming an enormous, centralized and cross-referenced database of Dear ImGui contents.
|
||||||
|
|
||||||
|
Only if you:
|
||||||
- Cannot BUILD or LINK examples.
|
- Cannot BUILD or LINK examples.
|
||||||
- Cannot BUILD, or LINK, or RUN Dear ImGui in your application or custom engine.
|
- Cannot BUILD, or LINK, or RUN Dear ImGui in your application or custom engine.
|
||||||
- Cannot LOAD a font.
|
- Cannot LOAD a font.
|
||||||
|
|
||||||
Then please [use the Discussions forums](https://github.com/ocornut/imgui/discussions) instead of opening an issue.
|
Then please [use the Discussions forums](https://github.com/ocornut/imgui/discussions) instead of opening an issue.
|
||||||
|
|
||||||
If Dear ImGui is successfully showing in your app and you have used Dear ImGui before, you can open an issue. Any form of discussions is welcome as a new issue.
|
If Dear ImGui is successfully showing in your app and you have used Dear ImGui before, you can open an Issue. Any form of discussions is welcome as a new issue.
|
||||||
|
|
||||||
## How to open an issue
|
## How to open an issue
|
||||||
|
|
||||||
@@ -46,16 +49,16 @@ Steps:
|
|||||||
- Article: [How To Ask Good Questions](https://bit.ly/3nwRnx1).
|
- Article: [How To Ask Good Questions](https://bit.ly/3nwRnx1).
|
||||||
- **PLEASE DO FILL THE REQUESTED NEW ISSUE TEMPLATE.** Including Dear ImGui version number, branch name, platform/renderer back-ends (imgui_impl_XXX files), operating system.
|
- **PLEASE DO FILL THE REQUESTED NEW ISSUE TEMPLATE.** Including Dear ImGui version number, branch name, platform/renderer back-ends (imgui_impl_XXX files), operating system.
|
||||||
- **Try to be explicit with your GOALS, your EXPECTATIONS and what you have tried**. Be mindful of [The XY Problem](http://xyproblem.info/). What you have in mind or in your code is not obvious to other people. People frequently discuss problems and suggest incorrect solutions without first clarifying their goals. When requesting a new feature, please describe the usage context (how you intend to use it, why you need it, etc.). If you tried something and it failed, show us what you tried.
|
- **Try to be explicit with your GOALS, your EXPECTATIONS and what you have tried**. Be mindful of [The XY Problem](http://xyproblem.info/). What you have in mind or in your code is not obvious to other people. People frequently discuss problems and suggest incorrect solutions without first clarifying their goals. When requesting a new feature, please describe the usage context (how you intend to use it, why you need it, etc.). If you tried something and it failed, show us what you tried.
|
||||||
|
- **Please INCLUDE CODE. Provide a Minimal, Complete, and Verifiable Example ([MCVE](https://stackoverflow.com/help/mcve)) to demonstrate your problem**. An ideal submission includes a small piece of code that anyone can paste into one of the examples applications (examples/../main.cpp) or demo (imgui_demo.cpp) to understand and reproduce it. **Narrowing your problem to its shortest and purest form is the easiest way to understand it, explain it and fix it**. Please test your shortened code to ensure it exhibits the problem. **Often while creating the MCVE you will solve the problem!** Many questions that are missing a standalone verifiable example are missing the actual cause of their issue in the description, which ends up wasting everyone's time.
|
||||||
- **Attach screenshots (or GIF/video) to clarify the context**. They often convey useful information that is omitted by the description. You can drag pictures/files in the message edit box. Avoid using 3rd party image hosting services, prefer the long-term longevity of GitHub attachments (you can drag pictures into your post). On Windows, you can use [ScreenToGif](https://www.screentogif.com/) to easily capture .gif files.
|
- **Attach screenshots (or GIF/video) to clarify the context**. They often convey useful information that is omitted by the description. You can drag pictures/files in the message edit box. Avoid using 3rd party image hosting services, prefer the long-term longevity of GitHub attachments (you can drag pictures into your post). On Windows, you can use [ScreenToGif](https://www.screentogif.com/) to easily capture .gif files.
|
||||||
- **If you are discussing an assert or a crash, please provide a debugger callstack**. Never state "it crashes" without additional information. If you don't know how to use a debugger and retrieve a callstack, learning about it will be useful.
|
- **If you are discussing an assert or a crash, please provide a debugger callstack**. Never state "it crashes" without additional information. If you don't know how to use a debugger and retrieve a callstack, learning about it will be useful.
|
||||||
- **Please make sure that your project has asserts enabled.** Calls to IM_ASSERT() are scattered in the code to help catch common issues. When an assert is triggered read the comments around it. By default IM_ASSERT() calls the standard assert() function. To verify that your asserts are enabled, add the line `IM_ASSERT(false);` in your main() function. Your application should display an error message and abort. If your application doesn't report an error, your asserts are disabled.
|
- **Please make sure that your project has asserts enabled.** Calls to IM_ASSERT() are scattered in the code to help catch common issues. When an assert is triggered read the comments around it. By default IM_ASSERT() calls the standard assert() function. To verify that your asserts are enabled, add the line `IM_ASSERT(false);` in your main() function. Your application should display an error message and abort. If your application doesn't report an error, your asserts are disabled.
|
||||||
- **Please provide a Minimal, Complete, and Verifiable Example ([MCVE](https://stackoverflow.com/help/mcve)) to demonstrate your problem**. An ideal submission includes a small piece of code that anyone can paste into one of the examples applications (examples/../main.cpp) or demo (imgui_demo.cpp) to understand and reproduce it. Narrowing your problem to its shortest and purest form is the easiest way to understand it. Please test your shortened code to ensure it exhibits the problem. **Often while creating the MCVE you will end up solving the problem!** Many questions that are missing a standalone verifiable example are missing the actual cause of their issue in the description, which ends up wasting everyone's time.
|
|
||||||
- Please state if you have made substantial modifications to your copy of Dear ImGui or the back-end.
|
- Please state if you have made substantial modifications to your copy of Dear ImGui or the back-end.
|
||||||
- If you are not calling Dear ImGui directly from C++, please provide information about your Language and the wrapper/binding you are using.
|
- If you are not calling Dear ImGui directly from C++, please provide information about your Language and the wrapper/binding you are using.
|
||||||
- Be mindful that messages are being sent to the mailbox of "Watching" users. Try to proofread your messages before sending them. Edits are not seen by those users unless they browse the site.
|
- Be mindful that messages are being sent to the mailbox of "Watching" users. Try to proofread your messages before sending them. Edits are not seen by those users unless they browse the site.
|
||||||
|
|
||||||
**Some unfortunate words of warning**
|
**Some unfortunate words of warning**
|
||||||
- If you are involved in cheating schemes (e.g. DLL injection) for competitive online multiplayer games, please don't try posting here. We won't answer and you will be blocked. It doesn't matter if your question relates to said project. We've had too many of you and need to project our time and sanity.
|
- If you are involved in cheating schemes (e.g. DLL injection) for competitive online multiplayer games, please don't post here. We won't answer and you will be blocked. It doesn't matter if your question relates to said project. We've had too many of you and need to protect our time and sanity.
|
||||||
- Due to frequent abuse of this service from the aforementioned users, if your GitHub account is anonymous and was created five minutes ago please understand that your post will receive more scrutiny and incomplete questions will be harshly dismissed.
|
- Due to frequent abuse of this service from the aforementioned users, if your GitHub account is anonymous and was created five minutes ago please understand that your post will receive more scrutiny and incomplete questions will be harshly dismissed.
|
||||||
|
|
||||||
If you have been using Dear ImGui for a while or have been using C/C++ for several years or have demonstrated good behavior here, it is ok to not fulfill every item to the letter. Those are guidelines and experienced users or members of the community will know which information is useful in a given context.
|
If you have been using Dear ImGui for a while or have been using C/C++ for several years or have demonstrated good behavior here, it is ok to not fulfill every item to the letter. Those are guidelines and experienced users or members of the community will know which information is useful in a given context.
|
||||||
@@ -63,15 +66,13 @@ If you have been using Dear ImGui for a while or have been using C/C++ for sever
|
|||||||
## How to open a Pull Request
|
## How to open a Pull Request
|
||||||
|
|
||||||
- **Please understand that by submitting a PR you are also submitting a request for the maintainer to review your code and then take over its maintenance.** PR should be crafted both in the interest of the end-users and also to ease the maintainer into understanding and accepting it.
|
- **Please understand that by submitting a PR you are also submitting a request for the maintainer to review your code and then take over its maintenance.** PR should be crafted both in the interest of the end-users and also to ease the maintainer into understanding and accepting it.
|
||||||
- Many PRs are useful to demonstrate a need and a possible solution but aren't adequate for merging (causing other issues, not seeing other aspects of the big picture, etc.). In doubt, don't hesitate to push a PR because that is always the first step toward finding the mergeable solution! Even if a PR stays unmerged for a long time, its presence can be useful for other users and helps toward finding a general solution.
|
- Many PRs are useful to demonstrate a need and a possible solution but aren't adequate for merging (causing other issues, not seeing other aspects of the big picture, etc.). In doubt, don't hesitate to push a PR because that is always the first step toward pointing toward a problem, and finding the mergeable solution! Even if a PR stays unmerged for a long time, its presence can be useful for other users and helps toward finding a general solution.
|
||||||
- **When adding a feature,** please describe the usage context (how you intend to use it, why you need it, etc.). Be mindful of [The XY Problem](http://xyproblem.info/).
|
- **When adding a feature,** please describe the usage context (how you intend to use it, why you need it, etc.). Be mindful of [The XY Problem](http://xyproblem.info/).
|
||||||
- **When fixing a warning or compilation problem,** please post the compiler log and specify the compiler version and platform you are using.
|
- **When fixing a warning or compilation problem,** please post the compiler log and specify the compiler version and platform you are using.
|
||||||
- **Attach screenshots (or GIF/video) to clarify the context and demonstrate the feature at a glance.** You can drag pictures/files in the message edit box. Prefer the long-term longevity of GitHub attachments over 3rd party hosting (you can drag pictures into your post).
|
- **Attach screenshots (or GIF/video) to clarify the context and demonstrate the feature at a glance.** You can drag pictures/files in the message edit box. Prefer the long-term longevity of GitHub attachments over 3rd party hosting (you can drag pictures into your post).
|
||||||
- **Make sure your code follows the coding style already used in the codebase:** 4 spaces indentations (no tabs), `local_variable`, `FunctionName()`, `MemberName`, `// Text Comment`, `//CodeComment();`, C-style casts, etc.. We don't use modern C++ idioms and tend to use only a minimum of C++11 features. The applications under examples/ are generally less consistent because they sometimes try to mimic the coding style often adopted by a certain ecosystem (e.g. DirectX-related code tend to use the style of their sample).
|
- **Make sure your code follows the coding style already used in the codebase:** 4 spaces indentations (no tabs), `local_variable`, `FunctionName()`, `MemberName`, `// Text Comment`, `//CodeComment();`, C-style casts, etc.. We don't use modern C++ idioms and tend to use only a minimum of C++11 features. The applications under examples/ are generally less consistent because they sometimes try to mimic the coding style often adopted by a certain ecosystem (e.g. DirectX-related code tend to use the style of their sample).
|
||||||
- **Make sure you create a branch dedicated to the pull request**. In Git, 1 PR is associated to 1 branch. If you keep pushing to the same branch after you submitted the PR, your new commits will appear in the PR (we can still cherry-pick individual commits).
|
- **Make sure you create a branch dedicated to the pull request**. In Git, 1 PR is associated to 1 branch. If you keep pushing to the same branch after you submitted the PR, your new commits will appear in the PR (we can still cherry-pick individual commits).
|
||||||
|
|
||||||
Thank you for reading!
|
|
||||||
|
|
||||||
## Copyright / Contributor License Agreement
|
## Copyright / Contributor License Agreement
|
||||||
|
|
||||||
Any code you submit will become part of the repository and be distributed under the [Dear ImGui license](https://github.com/ocornut/imgui/blob/master/LICENSE.txt). By submitting code to the project you agree that the code is your work and that you can give it to the project.
|
Any code you submit will become part of the repository and be distributed under the [Dear ImGui license](https://github.com/ocornut/imgui/blob/master/LICENSE.txt). By submitting code to the project you agree that the code is your work and that you can give it to the project.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ integrating Dear ImGui in your own application/game/engine.
|
|||||||
**Once Dear ImGui is setup and running, run and refer to `ImGui::ShowDemoWindow()` in imgui_demo.cpp for usage of the end-user API.**
|
**Once Dear ImGui is setup and running, run and refer to `ImGui::ShowDemoWindow()` in imgui_demo.cpp for usage of the end-user API.**
|
||||||
|
|
||||||
You can find Windows binaries for some of those example applications at:
|
You can find Windows binaries for some of those example applications at:
|
||||||
http://www.dearimgui.com/binaries
|
https://www.dearimgui.com/binaries
|
||||||
|
|
||||||
|
|
||||||
### Getting Started
|
### Getting Started
|
||||||
@@ -74,7 +74,7 @@ ImGui::DestroyContext();
|
|||||||
|
|
||||||
Please read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
|
Please read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
|
||||||
Please read the comments and instruction at the top of each file.
|
Please read the comments and instruction at the top of each file.
|
||||||
Please read FAQ at http://www.dearimgui.com/faq
|
Please read FAQ at https://www.dearimgui.com/faq
|
||||||
|
|
||||||
If you are using any of the backends provided here, you can add the backends/imgui_impl_xxxx(.cpp,.h)
|
If you are using any of the backends provided here, you can add the backends/imgui_impl_xxxx(.cpp,.h)
|
||||||
files to your project and use as-in. Each imgui_impl_xxxx.cpp file comes with its own individual
|
files to your project and use as-in. Each imgui_impl_xxxx.cpp file comes with its own individual
|
||||||
@@ -171,11 +171,10 @@ This uses more modern GL calls and custom shaders. <BR>
|
|||||||
This support building with Emscripten and targetting WebGL.<BR>
|
This support building with Emscripten and targetting WebGL.<BR>
|
||||||
Prefer using that if you are using modern GL or WebGL in your application.
|
Prefer using that if you are using modern GL or WebGL in your application.
|
||||||
|
|
||||||
[example_sdl2_sdlrenderer/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl2_sdlrenderer/) <BR>
|
[example_sdl2_sdlrenderer2/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl2_sdlrenderer2/) <BR>
|
||||||
SDL2 (Win32, Mac, Linux, etc.) + SDL_Renderer (most graphics backends are supported underneath) <BR>
|
SDL2 (Win32, Mac, Linux, etc.) + SDL_Renderer for SDL2 (most graphics backends are supported underneath) <BR>
|
||||||
= main.cpp + imgui_impl_sdl2.cpp + imgui_impl_sdlrenderer.cpp <BR>
|
= main.cpp + imgui_impl_sdl2.cpp + imgui_impl_sdlrenderer.cpp <BR>
|
||||||
This requires SDL 2.0.18+ (released November 2021) <BR>
|
This requires SDL 2.0.18+ (released November 2021) <BR>
|
||||||
We do not really recommend using SDL_Renderer as it is a rather primitive API.
|
|
||||||
|
|
||||||
[example_sdl2_vulkan/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl2_vulkan/) <BR>
|
[example_sdl2_vulkan/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl2_vulkan/) <BR>
|
||||||
SDL2 (Win32, Mac, Linux, etc.) + Vulkan example. <BR>
|
SDL2 (Win32, Mac, Linux, etc.) + Vulkan example. <BR>
|
||||||
@@ -200,6 +199,10 @@ DirectX12 example, Windows only. <BR>
|
|||||||
= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx12.cpp <BR>
|
= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx12.cpp <BR>
|
||||||
This is quite long and tedious, because: DirectX12.
|
This is quite long and tedious, because: DirectX12.
|
||||||
|
|
||||||
|
[example_win32_opengl3/](https://github.com/ocornut/imgui/blob/master/examples/example_win32_opengl3/) <BR>
|
||||||
|
Raw Windows + OpenGL3 + example (modern, programmable pipeline) <BR>
|
||||||
|
= main.cpp + imgui_impl_win32.cpp + imgui_impl_opengl3.cpp <BR>
|
||||||
|
|
||||||
|
|
||||||
### Miscellaneous
|
### Miscellaneous
|
||||||
|
|
||||||
|
|||||||
75
docs/FAQ.md
75
docs/FAQ.md
@@ -50,7 +50,8 @@ or view this file with any Markdown viewer.
|
|||||||
|
|
||||||
**This library is poorly documented at the moment and expects the user to be acquainted with C/C++.**
|
**This library is poorly documented at the moment and expects the user to be acquainted with C/C++.**
|
||||||
- The [Wiki](https://github.com/ocornut/imgui/wiki) is a hub to many resources and links.
|
- The [Wiki](https://github.com/ocornut/imgui/wiki) is a hub to many resources and links.
|
||||||
- Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the [examples/](https://github.com/ocornut/imgui/blob/master/examples/) folder to explain how to integrate Dear ImGui with your own engine/application. You can run those applications and explore them.
|
- Handy [Getting Started](https://github.com/ocornut/imgui/wiki/Getting-Started) guide to integrate Dear ImGui in an existing application.
|
||||||
|
- 20+ standalone example applications using e.g. OpenGL/DirectX are provided in the [examples/](https://github.com/ocornut/imgui/blob/master/examples/) folder to explain how to integrate Dear ImGui with your own engine/application. You can run those applications and explore them.
|
||||||
- See demo code in [imgui_demo.cpp](https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp) and particularly the `ImGui::ShowDemoWindow()` function. The demo covers most features of Dear ImGui, so you can read the code and see its output.
|
- See demo code in [imgui_demo.cpp](https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp) and particularly the `ImGui::ShowDemoWindow()` function. The demo covers most features of Dear ImGui, so you can read the code and see its output.
|
||||||
- See documentation: [Backends](https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md), [Examples](https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md), [Fonts](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md).
|
- See documentation: [Backends](https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md), [Examples](https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md), [Fonts](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md).
|
||||||
- See documentation and comments at the top of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) + general API comments in [imgui.h](https://github.com/ocornut/imgui/blob/master/imgui.h).
|
- See documentation and comments at the top of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) + general API comments in [imgui.h](https://github.com/ocornut/imgui/blob/master/imgui.h).
|
||||||
@@ -90,6 +91,7 @@ Many projects are using this branch and it is kept in sync with master regularly
|
|||||||
|
|
||||||
### Q: How to get started?
|
### Q: How to get started?
|
||||||
|
|
||||||
|
Read [Getting Started](https://github.com/ocornut/imgui/wiki/Getting-Started). <BR>
|
||||||
Read [EXAMPLES.md](https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md). <BR>
|
Read [EXAMPLES.md](https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md). <BR>
|
||||||
Read [BACKENDS.md](https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md). <BR>
|
Read [BACKENDS.md](https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md). <BR>
|
||||||
Read `PROGRAMMER GUIDE` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp). <BR>
|
Read `PROGRAMMER GUIDE` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp). <BR>
|
||||||
@@ -123,13 +125,8 @@ void MyLowLevelMouseButtonHandler(int button, bool down)
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
**Note:** The `io.WantCaptureMouse` is more correct that any manual attempt to "check if the mouse is hovering a window" (don't do that!). It handles mouse dragging correctly (both dragging that started over your application or over a Dear ImGui window) and handle e.g. popup and modal windows blocking inputs.
|
**Note:** The `io.WantCaptureMouse` is more correct that any manual attempt to "check if the mouse is hovering a window" (don't do that!). It handles mouse dragging correctly (both dragging that started over your application or over a Dear ImGui window) and handle e.g. popup and modal windows blocking inputs.
|
||||||
|
|
||||||
**Note:** Those flags are updated by `ImGui::NewFrame()`. However it is generally more correct and easier that you poll flags from the previous frame, then submit your inputs, then call `NewFrame()`. If you attempt to do the opposite (which is generally harder) you are likely going to submit your inputs after `NewFrame()`, and therefore too late.
|
|
||||||
|
|
||||||
**Note:** If you are using a touch device, you may find use for an early call to `UpdateHoveredWindowAndCaptureFlags()` to correctly dispatch your initial touch. We will work on better out-of-the-box touch support in the future.
|
|
||||||
|
|
||||||
**Note:** Text input widget releases focus on the "KeyDown" event of the Return key, so the subsequent "KeyUp" event that your application receive will typically have `io.WantCaptureKeyboard == false`. Depending on your application logic it may or not be inconvenient to receive that KeyUp event. You might want to track which key-downs were targeted for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.)
|
**Note:** Text input widget releases focus on the "KeyDown" event of the Return key, so the subsequent "KeyUp" event that your application receive will typically have `io.WantCaptureKeyboard == false`. Depending on your application logic it may or not be inconvenient to receive that KeyUp event. You might want to track which key-downs were targeted for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.)
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
@@ -140,7 +137,7 @@ void MyLowLevelMouseButtonHandler(int button, bool down)
|
|||||||
- The gamepad/keyboard navigation is fairly functional and keeps being improved. The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable. Gamepad support is particularly useful to use Dear ImGui on a game console (e.g. PS4, Switch, XB1) without a mouse connected!
|
- The gamepad/keyboard navigation is fairly functional and keeps being improved. The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable. Gamepad support is particularly useful to use Dear ImGui on a game console (e.g. PS4, Switch, XB1) without a mouse connected!
|
||||||
- Keyboard: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard` to enable.
|
- Keyboard: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard` to enable.
|
||||||
- Gamepad: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad` to enable (with a supporting backend).
|
- Gamepad: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad` to enable (with a supporting backend).
|
||||||
- See [Control Sheets for Gamepads](http://www.dearimgui.com/controls_sheets) (reference PNG/PSD for PS4, XB1, Switch gamepads).
|
- See [Control Sheets for Gamepads](https://www.dearimgui.com/controls_sheets) (reference PNG/PSD for PS4, XB1, Switch gamepads).
|
||||||
- See `USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) for more details.
|
- See `USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) for more details.
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
@@ -163,8 +160,8 @@ Console SDK also sometimes provide equivalent tooling or wrapper for Synergy-lik
|
|||||||
---
|
---
|
||||||
|
|
||||||
### Q: I integrated Dear ImGui in my engine and little squares are showing instead of text...
|
### Q: I integrated Dear ImGui in my engine and little squares are showing instead of text...
|
||||||
Your renderer is not using the font texture correctly or it hasn't been uploaded to the GPU.
|
Your renderer backend is not using the font texture correctly or it hasn't been uploaded to the GPU.
|
||||||
- If this happens using the standard backends: A) have you modified the font atlas after `ImGui_ImplXXX_NewFrame()`? B) maybe the texture failed to upload, which could happens if for some reason your texture is too big. Also see [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md).
|
- If this happens using the standard backends: A) have you modified the font atlas after `ImGui_ImplXXX_NewFrame()`? B) maybe the texture failed to upload, which **can if your texture atlas is too big**. Also see [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md).
|
||||||
- If this happens with a custom backend: make sure you have uploaded the font texture to the GPU, that all shaders are rendering states are setup properly (e.g. texture is bound). Compare your code to existing backends and use a graphics debugger such as [RenderDoc](https://renderdoc.org) to debug your rendering states.
|
- If this happens with a custom backend: make sure you have uploaded the font texture to the GPU, that all shaders are rendering states are setup properly (e.g. texture is bound). Compare your code to existing backends and use a graphics debugger such as [RenderDoc](https://renderdoc.org) to debug your rendering states.
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
@@ -215,7 +212,7 @@ Interactive widgets (such as calls to Button buttons) need a unique ID.
|
|||||||
**Unique IDs are used internally to track active widgets and occasionally associate state to widgets.<BR>
|
**Unique IDs are used internally to track active widgets and occasionally associate state to widgets.<BR>
|
||||||
Unique IDs are implicitly built from the hash of multiple elements that identify the "path" to the UI element.**
|
Unique IDs are implicitly built from the hash of multiple elements that identify the "path" to the UI element.**
|
||||||
|
|
||||||
Since Dear ImGui 1.85, you can use `Demo>Tools>Stack Tool` or call `ImGui::ShowStackToolWindow()`. The tool display intermediate values leading to the creation of a unique ID, making things easier to debug and understand.
|
Since Dear ImGui 1.85, you can use `Demo>Tools>ID Stack Tool` or call `ImGui::ShowIDStackToolWindow()`. The tool display intermediate values leading to the creation of a unique ID, making things easier to debug and understand.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -429,7 +426,7 @@ Finally, you may call `ImGui::ShowMetricsWindow()` to explore/visualize/understa
|
|||||||
|
|
||||||
### Q: How can I use maths operators with ImVec2?
|
### Q: How can I use maths operators with ImVec2?
|
||||||
|
|
||||||
We do not export maths operators by default in imgui.h in order to not conflict with the use of your own maths types and maths operators. As a convenience, you may use `#defne IMGUI_DEFINE_MATH_OPERATORS` + `#include "imgui.h"` to access our basic maths operators.
|
We do not export maths operators by default in imgui.h in order to not conflict with the use of your own maths types and maths operators. As a convenience, you may use `#define IMGUI_DEFINE_MATH_OPERATORS` + `#include "imgui.h"` to access our basic maths operators.
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
@@ -528,7 +525,7 @@ This approach is relatively easy and functional but comes with two issues:
|
|||||||
- Style override may be lost during the `Begin()` call crossing monitor boundaries. You may need to do some custom scaling mumbo-jumbo if you want your `OnChangedViewport()` handler to preserve style overrides.
|
- Style override may be lost during the `Begin()` call crossing monitor boundaries. You may need to do some custom scaling mumbo-jumbo if you want your `OnChangedViewport()` handler to preserve style overrides.
|
||||||
|
|
||||||
Please note that if you are not using multi-viewports with multi-monitors using different DPI scales, you can ignore that and use the simpler technique recommended at the top.
|
Please note that if you are not using multi-viewports with multi-monitors using different DPI scales, you can ignore that and use the simpler technique recommended at the top.
|
||||||
|
|
||||||
On Windows, in addition to scaling the font size (make sure to round to an integer) and using `style.ScaleAllSizes()`, you will need to inform Windows that your application is DPI aware. If this is not done, Windows will scale the application window and the UI text will be blurry. Potential solutions to indicate DPI awareness on Windows are:
|
On Windows, in addition to scaling the font size (make sure to round to an integer) and using `style.ScaleAllSizes()`, you will need to inform Windows that your application is DPI aware. If this is not done, Windows will scale the application window and the UI text will be blurry. Potential solutions to indicate DPI awareness on Windows are:
|
||||||
|
|
||||||
- For SDL: the flag `SDL_WINDOW_ALLOW_HIGHDPI` needs to be passed to `SDL_CreateWindow()``.
|
- For SDL: the flag `SDL_WINDOW_ALLOW_HIGHDPI` needs to be passed to `SDL_CreateWindow()``.
|
||||||
@@ -557,7 +554,7 @@ backslash \ within a string literal, you need to write it double backslash "\\":
|
|||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
io.Fonts->AddFontFromFileTTF("MyFolder\MyFont.ttf", size); // WRONG (you are escaping the M here!)
|
io.Fonts->AddFontFromFileTTF("MyFolder\MyFont.ttf", size); // WRONG (you are escaping the M here!)
|
||||||
io.Fonts->AddFontFromFileTTF("MyFolder\\MyFont.ttf", size; // CORRECT (Windows only)
|
io.Fonts->AddFontFromFileTTF("MyFolder\\MyFont.ttf", size); // CORRECT (Windows only)
|
||||||
io.Fonts->AddFontFromFileTTF("MyFolder/MyFont.ttf", size); // ALSO CORRECT
|
io.Fonts->AddFontFromFileTTF("MyFolder/MyFont.ttf", size); // ALSO CORRECT
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -568,44 +565,15 @@ io.Fonts->AddFontFromFileTTF("MyFolder/MyFont.ttf", size); // ALSO CORRECT
|
|||||||
### Q: How can I easily use icons in my application?
|
### Q: How can I easily use icons in my application?
|
||||||
The most convenient and practical way is to merge an icon font such as FontAwesome inside your
|
The most convenient and practical way is to merge an icon font such as FontAwesome inside your
|
||||||
main font. Then you can refer to icons within your strings.
|
main font. Then you can refer to icons within your strings.
|
||||||
You may want to see `ImFontConfig::GlyphMinAdvanceX` to make your icon look monospace to facilitate alignment.
|
Read the [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) file for more details about icons font loading.
|
||||||
(Read the [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) file for more details about icons font loading.)
|
|
||||||
With some extra effort, you may use colorful icons by registering custom rectangle space inside the font atlas,
|
|
||||||
and copying your own graphics data into it. See docs/FONTS.md about using the AddCustomRectFontGlyph API.
|
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Q: How can I load multiple fonts?
|
### Q: How can I load multiple fonts?
|
||||||
Use the font atlas to pack them into a single texture:
|
|
||||||
(Read the [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) file and the code in ImFontAtlas for more details.)
|
|
||||||
|
|
||||||
```cpp
|
Use the font atlas to pack them into a single texture. Read [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) for more details.
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
ImFont* font0 = io.Fonts->AddFontDefault();
|
|
||||||
ImFont* font1 = io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels);
|
|
||||||
ImFont* font2 = io.Fonts->AddFontFromFileTTF("myfontfile2.ttf", size_in_pixels);
|
|
||||||
io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8()
|
|
||||||
// the first loaded font gets used by default
|
|
||||||
// use ImGui::PushFont()/ImGui::PopFont() to change the font at runtime
|
|
||||||
|
|
||||||
// Options
|
|
||||||
ImFontConfig config;
|
|
||||||
config.OversampleH = 2;
|
|
||||||
config.OversampleV = 1;
|
|
||||||
config.GlyphOffset.y -= 1.0f; // Move everything by 1 pixel up
|
|
||||||
config.GlyphExtraSpacing.x = 1.0f; // Increase spacing between characters
|
|
||||||
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_pixels, &config);
|
|
||||||
|
|
||||||
// Combine multiple fonts into one (e.g. for icon fonts)
|
|
||||||
static ImWchar ranges[] = { 0xf000, 0xf3ff, 0 };
|
|
||||||
ImFontConfig config;
|
|
||||||
config.MergeMode = true;
|
|
||||||
io.Fonts->AddFontDefault();
|
|
||||||
io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 16.0f, &config, ranges); // Merge icon font
|
|
||||||
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_pixels, nullptr, &config, io.Fonts->GetGlyphRangesJapanese()); // Merge japanese glyphs
|
|
||||||
```
|
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
@@ -628,10 +596,11 @@ builder.BuildRanges(&ranges); // Build the final result
|
|||||||
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", 16.0f, nullptr, ranges.Data);
|
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", 16.0f, nullptr, ranges.Data);
|
||||||
```
|
```
|
||||||
|
|
||||||
All your strings need to use UTF-8 encoding. In C++11 you can encode a string literal in UTF-8
|
All your strings need to use UTF-8 encoding.
|
||||||
by using the u8"hello" syntax. Specifying literal in your source code using a local code page
|
You need to tell your compiler to use UTF-8, or in C++11 you can encode a string literal in UTF-8 by using the u8"hello" syntax.
|
||||||
(such as CP-923 for Japanese or CP-1251 for Cyrillic) will NOT work!
|
Specifying literal in your source code using a local code page (such as CP-923 for Japanese or CP-1251 for Cyrillic) will NOT work!
|
||||||
Otherwise, you can convert yourself to UTF-8 or load text data from a file already saved as UTF-8.
|
See [About UTF-8 Encoding](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md#about-utf-8-encoding) section
|
||||||
|
of [FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) for details about UTF-8 Encoding.
|
||||||
|
|
||||||
Text input: it is up to your application to pass the right character code by calling `io.AddInputCharacter()`.
|
Text input: it is up to your application to pass the right character code by calling `io.AddInputCharacter()`.
|
||||||
The applications in examples/ are doing that.
|
The applications in examples/ are doing that.
|
||||||
@@ -653,7 +622,7 @@ You may take a look at:
|
|||||||
- [Quotes](https://github.com/ocornut/imgui/wiki/Quotes)
|
- [Quotes](https://github.com/ocornut/imgui/wiki/Quotes)
|
||||||
- [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui)
|
- [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui)
|
||||||
- [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors)
|
- [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors)
|
||||||
- [Gallery](https://github.com/ocornut/imgui/issues/5886)
|
- [Gallery](https://github.com/ocornut/imgui/issues/6897)
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
@@ -665,7 +634,7 @@ Yes. People have written game editors, data browsers, debuggers, profilers, and
|
|||||||
|
|
||||||
Dear ImGui is very programmer centric and the immediate-mode GUI paradigm might require you to readjust some habits before you can realize its full potential. Dear ImGui is about making things that are simple, efficient, and powerful.
|
Dear ImGui is very programmer centric and the immediate-mode GUI paradigm might require you to readjust some habits before you can realize its full potential. Dear ImGui is about making things that are simple, efficient, and powerful.
|
||||||
|
|
||||||
Dear ImGui is built to be efficient and scalable toward the needs for AAA-quality applications running all day. The IMGUI paradigm offers different opportunities for optimization that the more typical RMGUI paradigm.
|
Dear ImGui is built to be efficient and scalable toward the needs for AAA-quality applications running all day. The IMGUI paradigm offers different opportunities for optimization than the more typical RMGUI paradigm.
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
@@ -673,7 +642,7 @@ Dear ImGui is built to be efficient and scalable toward the needs for AAA-qualit
|
|||||||
|
|
||||||
### Q: Can you reskin the look of Dear ImGui?
|
### Q: Can you reskin the look of Dear ImGui?
|
||||||
|
|
||||||
Somehow. You can alter the look of the interface to some degree: changing colors, sizes, padding, rounding, and fonts. However, as Dear ImGui is designed and optimized to create debug tools, the amount of skinning you can apply is limited. There is only so much you can stray away from the default look and feel of the interface. Dear ImGui is NOT designed to create a user interface for games, although with ingenious use of the low-level API you can do it.
|
Somewhat. You can alter the look of the interface to some degree: changing colors, sizes, padding, rounding, and fonts. However, as Dear ImGui is designed and optimized to create debug tools, the amount of skinning you can apply is limited. There is only so much you can stray away from the default look and feel of the interface. Dear ImGui is NOT designed to create a user interface for games, although with ingenious use of the low-level API you can do it.
|
||||||
|
|
||||||
A reasonably skinned application may look like (screenshot from [#2529](https://github.com/ocornut/imgui/issues/2529#issuecomment-524281119)):
|
A reasonably skinned application may look like (screenshot from [#2529](https://github.com/ocornut/imgui/issues/2529#issuecomment-524281119)):
|
||||||

|

|
||||||
@@ -695,11 +664,11 @@ There is an auto-generated [c-api for Dear ImGui (cimgui)](https://github.com/ci
|
|||||||
# Q&A: Community
|
# Q&A: Community
|
||||||
|
|
||||||
### Q: How can I help?
|
### Q: How can I help?
|
||||||
- Businesses: please reach out to `contact AT dearimgui.com` if you work in a place using Dear ImGui! We can discuss ways for your company to fund development via invoiced technical support, maintenance, or sponsoring contacts. This is among the most useful thing you can do for Dear ImGui. With increased funding, we can hire more people to work on this project.
|
- Businesses: please reach out to `omar AT dearimgui.com` if you work in a place using Dear ImGui! We can discuss ways for your company to fund development via invoiced technical support, maintenance, or sponsoring contacts. This is among the most useful thing you can do for Dear ImGui. With increased funding, we can hire more people to work on this project.
|
||||||
- Individuals: you can support continued maintenance and development via PayPal donations. See [README](https://github.com/ocornut/imgui/blob/master/docs/README.md).
|
- Individuals: you can support continued maintenance and development via PayPal donations. See [README](https://github.com/ocornut/imgui/blob/master/docs/README.md).
|
||||||
- If you are experienced with Dear ImGui and C++, look at [GitHub Issues](https://github.com/ocornut/imgui/issues), [GitHub Discussions](https://github.com/ocornut/imgui/discussions), the [Wiki](https://github.com/ocornut/imgui/wiki), read [docs/TODO.txt](https://github.com/ocornut/imgui/blob/master/docs/TODO.txt), and see how you want to help and can help!
|
- If you are experienced with Dear ImGui and C++, look at [GitHub Issues](https://github.com/ocornut/imgui/issues), [GitHub Discussions](https://github.com/ocornut/imgui/discussions), the [Wiki](https://github.com/ocornut/imgui/wiki), read [docs/TODO.txt](https://github.com/ocornut/imgui/blob/master/docs/TODO.txt), and see how you want to help and can help!
|
||||||
- Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere, etc.
|
- Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere, etc.
|
||||||
You may post screenshots or links in the [gallery threads](https://github.com/ocornut/imgui/issues/5886). Visuals are ideal as they inspire other programmers. Disclosing your use of Dear ImGui helps the library grow credibility, and helps other teams and programmers with taking decisions.
|
You may post screenshots or links in the [gallery threads](https://github.com/ocornut/imgui/issues/6897). Visuals are ideal as they inspire other programmers. Disclosing your use of Dear ImGui helps the library grow credibility, and helps other teams and programmers with taking decisions.
|
||||||
- If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues or sometimes incomplete PR.
|
- If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues or sometimes incomplete PR.
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|||||||
227
docs/FONTS.md
227
docs/FONTS.md
@@ -11,50 +11,68 @@ In the [misc/fonts/](https://github.com/ocornut/imgui/tree/master/misc/fonts) fo
|
|||||||
**Also read the FAQ:** https://www.dearimgui.com/faq (there is a Fonts section!)
|
**Also read the FAQ:** https://www.dearimgui.com/faq (there is a Fonts section!)
|
||||||
|
|
||||||
## Index
|
## Index
|
||||||
- [Readme First](#readme-first)
|
- [Troubleshooting](#troubleshooting)
|
||||||
- [How should I handle DPI in my application?](#how-should-i-handle-dpi-in-my-application)
|
- [How should I handle DPI in my application?](#how-should-i-handle-dpi-in-my-application)
|
||||||
- [Fonts Loading Instructions](#font-loading-instructions)
|
- [Fonts Loading Instructions](#fonts-loading-instructions)
|
||||||
|
- [Loading Font Data from Memory](#loading-font-data-from-memory)
|
||||||
|
- [Loading Font Data Embedded In Source Code](#loading-font-data-embedded-in-source-code)
|
||||||
- [Using Icon Fonts](#using-icon-fonts)
|
- [Using Icon Fonts](#using-icon-fonts)
|
||||||
- [Using FreeType Rasterizer (imgui_freetype)](#using-freetype-rasterizer-imgui_freetype)
|
- [Using FreeType Rasterizer (imgui_freetype)](#using-freetype-rasterizer-imgui_freetype)
|
||||||
- [Using Colorful Glyphs/Emojis](#using-colorful-glyphsemojis)
|
- [Using Colorful Glyphs/Emojis](#using-colorful-glyphsemojis)
|
||||||
- [Using Custom Glyph Ranges](#using-custom-glyph-ranges)
|
- [Using Custom Glyph Ranges](#using-custom-glyph-ranges)
|
||||||
- [Using Custom Colorful Icons](#using-custom-colorful-icons)
|
- [Using Custom Colorful Icons](#using-custom-colorful-icons)
|
||||||
- [Using Font Data Embedded In Source Code](#using-font-data-embedded-in-source-code)
|
- [About Filenames](#about-filenames)
|
||||||
- [About filenames](#about-filenames)
|
- [About UTF-8 Encoding](#about-utf-8-encoding)
|
||||||
|
- [Debug Tools](#debug-tools)
|
||||||
- [Credits/Licenses For Fonts Included In Repository](#creditslicenses-for-fonts-included-in-repository)
|
- [Credits/Licenses For Fonts Included In Repository](#creditslicenses-for-fonts-included-in-repository)
|
||||||
- [Font Links](#font-links)
|
- [Font Links](#font-links)
|
||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
## Readme First
|
|
||||||
|
|
||||||
- You can use the `Metrics/Debugger` window (available in `Demo>Tools`) to browse your fonts and understand what's going on if you have an issue. You can also reach it in `Demo->Tools->Style Editor->Fonts`. The same information are also available in the Style Editor under Fonts.
|
## Troubleshooting
|
||||||
|
|
||||||

|
**A vast majority of font and text related issues encountered comes from 4 things:**
|
||||||
|
|
||||||
- You can use the `UTF-8 Encoding viewer` in `Metrics/Debugger` to verify the content of your UTF-8 strings. From C/C++ code, you can call `ImGui::DebugTextEncoding("my string");` function to verify that your UTF-8 encoding is correct.
|
### (1) Invalid filename due to use of `\` or unexpected working directory.
|
||||||
|
|
||||||

|
See [About Filenames](#about-filenames). AddFontXXX functions should assert if the filename is incorrect.
|
||||||
|
|
||||||
- All loaded fonts glyphs are rendered into a single texture atlas ahead of time. Calling either of `io.Fonts->GetTexDataAsAlpha8()`, `io.Fonts->GetTexDataAsRGBA32()` or `io.Fonts->Build()` will build the atlas.
|
### (2) Invalid UTF-8 encoding of your non-ASCII strings.
|
||||||
|
|
||||||
- Make sure your font ranges data are persistent (available during the calls to `GetTexDataAsAlpha8()`/`GetTexDataAsRGBA32()/`Build()`.
|
See [About UTF-8 Encoding](#about-utf-8-encoding). Use the encoding viewer to confirm encoding of string literal in your source code is correct.
|
||||||
|
|
||||||
- Use C++11 u8"my text" syntax to encode literal strings as UTF-8. e.g.:
|
### (3) Missing glyph ranges.
|
||||||
```cpp
|
|
||||||
u8"hello"
|
You need to load a font with explicit glyph ranges if you want to use non-ASCII characters. See [Fonts Loading Instructions](#fonts-loading-instructions). Use [Debug Tools](#debug-tools) confirm loaded fonts and loaded glyph ranges.
|
||||||
u8"こんにちは" // this will be encoded as UTF-8
|
|
||||||
```
|
This is a current constraint of Dear ImGui (which we will lift in the future): when loading a font you need to specify which characters glyphs to load.
|
||||||
|
All loaded fonts glyphs are rendered into a single texture atlas ahead of time. Calling either of `io.Fonts->GetTexDataAsAlpha8()`, `io.Fonts->GetTexDataAsRGBA32()` or `io.Fonts->Build()` will build the atlas. This is generally called by the Renderer backend, e.g. `ImGui_ImplDX11_NewFrame()` calls it. **If you use custom glyphs ranges, make sure the array is persistent** and available during the calls to `GetTexDataAsAlpha8()/GetTexDataAsRGBA32()/Build()`.
|
||||||
|
|
||||||
|
### (4) Font atlas texture fails to upload to GPU.
|
||||||
|
|
||||||
|
This is often of byproduct of point 3. If you have large number of glyphs or multiple fonts, the texture may become too big for your graphics API. **The typical result of failing to upload a texture is if every glyph or everything appears as empty black or white rectangle.** Mind the fact that some graphics drivers have texture size limitation. If you are building a PC application, mind the fact that your users may use hardware with lower limitations than yours.
|
||||||
|
|
||||||
|
Some solutions:
|
||||||
|
- You may reduce oversampling, e.g. `font_config.OversampleH = 1`, this will half your texture size for a quality loss.
|
||||||
|
Note that while OversampleH = 2 looks visibly very close to 3 in most situations, with OversampleH = 1 the quality drop will be noticeable. Read about oversampling [here](https://github.com/nothings/stb/blob/master/tests/oversample).
|
||||||
|
- Reduce glyphs ranges by calculating them from source localization data.
|
||||||
|
You can use the `ImFontGlyphRangesBuilder` for this purpose and rebuilding your atlas between frames when new characters are needed. This will be the biggest win!
|
||||||
|
- Set `io.Fonts.Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight;` to disable rounding the texture height to the next power of two.
|
||||||
|
- Set `io.Fonts.TexDesiredWidth` to specify a texture width to reduce maximum texture height (see comment in `ImFontAtlas::Build()` function).
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
## How should I handle DPI in my application?
|
## How should I handle DPI in my application?
|
||||||
|
|
||||||
See [FAQ entry](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#q-how-should-i-handle-dpi-in-my-application).
|
See [FAQ entry](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#q-how-should-i-handle-dpi-in-my-application).
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
## Font Loading Instructions
|
## Fonts Loading Instructions
|
||||||
|
|
||||||
**Load default font:**
|
**Load default font:**
|
||||||
```cpp
|
```cpp
|
||||||
@@ -62,14 +80,12 @@ ImGuiIO& io = ImGui::GetIO();
|
|||||||
io.Fonts->AddFontDefault();
|
io.Fonts->AddFontDefault();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
**Load .TTF/.OTF file with:**
|
**Load .TTF/.OTF file with:**
|
||||||
```cpp
|
```cpp
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
|
io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
|
||||||
```
|
```
|
||||||
If you get an assert stating "Could not load font file!", your font filename is likely incorrect. Read "[About filenames](#about-filenames)" carefully.
|
If you get an assert stating "Could not load font file!", your font filename is likely incorrect. Read [About filenames](#about-filenames) carefully.
|
||||||
|
|
||||||
|
|
||||||
**Load multiple fonts:**
|
**Load multiple fonts:**
|
||||||
```cpp
|
```cpp
|
||||||
@@ -78,15 +94,15 @@ ImGuiIO& io = ImGui::GetIO();
|
|||||||
ImFont* font1 = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
|
ImFont* font1 = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
|
||||||
ImFont* font2 = io.Fonts->AddFontFromFileTTF("anotherfont.otf", size_pixels);
|
ImFont* font2 = io.Fonts->AddFontFromFileTTF("anotherfont.otf", size_pixels);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In your application loop, select which font to use:
|
||||||
```cpp
|
```cpp
|
||||||
// In application loop: select font at runtime
|
|
||||||
ImGui::Text("Hello"); // use the default font (which is the first loaded font)
|
ImGui::Text("Hello"); // use the default font (which is the first loaded font)
|
||||||
ImGui::PushFont(font2);
|
ImGui::PushFont(font2);
|
||||||
ImGui::Text("Hello with another font");
|
ImGui::Text("Hello with another font");
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
**For advanced options create a ImFontConfig structure and pass it to the AddFont() function (it will be copied internally):**
|
**For advanced options create a ImFontConfig structure and pass it to the AddFont() function (it will be copied internally):**
|
||||||
```cpp
|
```cpp
|
||||||
ImFontConfig config;
|
ImFontConfig config;
|
||||||
@@ -96,7 +112,6 @@ config.GlyphExtraSpacing.x = 1.0f;
|
|||||||
ImFont* font = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, &config);
|
ImFont* font = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, &config);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
**Combine multiple fonts into one:**
|
**Combine multiple fonts into one:**
|
||||||
```cpp
|
```cpp
|
||||||
// Load a first font
|
// Load a first font
|
||||||
@@ -127,7 +142,6 @@ io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, nullptr, io.Fonts->GetGlyp
|
|||||||
```
|
```
|
||||||
See [Using Custom Glyph Ranges](#using-custom-glyph-ranges) section to create your own ranges.
|
See [Using Custom Glyph Ranges](#using-custom-glyph-ranges) section to create your own ranges.
|
||||||
|
|
||||||
|
|
||||||
**Example loading and using a Japanese font:**
|
**Example loading and using a Japanese font:**
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
@@ -147,24 +161,50 @@ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
|||||||

|

|
||||||
<br>_(settings: Dark style (left), Light style (right) / Font: NotoSansCJKjp-Medium, 20px / Rounding: 5)_
|
<br>_(settings: Dark style (left), Light style (right) / Font: NotoSansCJKjp-Medium, 20px / Rounding: 5)_
|
||||||
|
|
||||||
**Font Atlas too large?**
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
- If you have very large number of glyphs or multiple fonts, the texture may become too big for your graphics API. The typical result of failing to upload a texture is if every glyph appears as a white rectangle.
|
---------------------------------------
|
||||||
- Mind the fact that some graphics drivers have texture size limitation. If you are building a PC application, mind the fact that your users may use hardware with lower limitations than yours.
|
|
||||||
|
|
||||||
Some solutions:
|
## Loading Font Data from Memory
|
||||||
|
|
||||||
1. Reduce glyphs ranges by calculating them from source localization data.
|
```cpp
|
||||||
You can use the `ImFontGlyphRangesBuilder` for this purpose and rebuilding your atlas between frames when new characters are needed. This will be the biggest win!
|
ImFont* font = io.Fonts->AddFontFromMemoryTTF(data, data_size, size_pixels, ...);
|
||||||
2. You may reduce oversampling, e.g. `font_config.OversampleH = 2`, this will largely reduce your texture size.
|
```
|
||||||
Note that while OversampleH = 2 looks visibly very close to 3 in most situations, with OversampleH = 1 the quality drop will be noticeable.
|
|
||||||
3. Set `io.Fonts.TexDesiredWidth` to specify a texture width to minimize texture height (see comment in `ImFontAtlas::Build()` function).
|
IMPORTANT: `AddFontFromMemoryTTF()` by default transfer ownership of the data buffer to the font atlas, which will attempt to free it on destruction.
|
||||||
4. Set `io.Fonts.Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight;` to disable rounding the texture height to the next power of two.
|
This was to avoid an unnecessary copy, and is perhaps not a good API (a future version will redesign it).
|
||||||
5. Read about oversampling [here](https://github.com/nothings/stb/blob/master/tests/oversample).
|
If you want to keep ownership of the data and free it yourself, you need to clear the `FontDataOwnedByAtlas` field:
|
||||||
6. To support the extended range of unicode beyond 0xFFFF (e.g. emoticons, dingbats, symbols, shapes, ancient languages, etc...) add `#define IMGUI_USE_WCHAR32`in your `imconfig.h`.
|
|
||||||
|
```cpp
|
||||||
|
ImFontConfig font_cfg;
|
||||||
|
font_cfg.FontDataOwnedByAtlas = false;
|
||||||
|
ImFont* font = io.Fonts->AddFontFromMemoryTTF(data, data_size, size_pixels, &font_cfg);
|
||||||
|
```
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
|
## Loading Font Data Embedded In Source Code
|
||||||
|
|
||||||
|
- Compile and use [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/blob/master/misc/fonts/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](https://github.com/ocornut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) for instructions on how to use the tool.
|
||||||
|
- You may find a precompiled version binary_to_compressed_c.exe for Windows inside the demo binaries package (see [README](https://github.com/ocornut/imgui/blob/master/docs/README.md)).
|
||||||
|
- The tool can optionally output Base85 encoding to reduce the size of _source code_ but the read-only arrays in the actual binary will be about 20% bigger.
|
||||||
|
|
||||||
|
Then load the font with:
|
||||||
|
```cpp
|
||||||
|
ImFont* font = io.Fonts->AddFontFromMemoryCompressedTTF(compressed_data, compressed_data_size, size_pixels, ...);
|
||||||
|
```
|
||||||
|
or
|
||||||
|
```cpp
|
||||||
|
ImFont* font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(compressed_data_base85, size_pixels, ...);
|
||||||
|
```
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
## Using Icon Fonts
|
## Using Icon Fonts
|
||||||
|
|
||||||
Using an icon font (such as [FontAwesome](http://fontawesome.io) or [OpenFontIcons](https://github.com/traverseda/OpenFontIcons)) is an easy and practical way to use icons in your Dear ImGui application.
|
Using an icon font (such as [FontAwesome](http://fontawesome.io) or [OpenFontIcons](https://github.com/traverseda/OpenFontIcons)) is an easy and practical way to use icons in your Dear ImGui application.
|
||||||
@@ -197,11 +237,19 @@ ImGui::Button(ICON_FA_SEARCH " Search");
|
|||||||
```
|
```
|
||||||
See Links below for other icons fonts and related tools.
|
See Links below for other icons fonts and related tools.
|
||||||
|
|
||||||
|
**Monospace Icons?**
|
||||||
|
|
||||||
|
To make your icon look more monospace and facilitate alignment, you may want to set the ImFontConfig::GlyphMinAdvanceX value when loading an icon font.
|
||||||
|
|
||||||
|
**Screenshot**
|
||||||
|
|
||||||
Here's an application using icons ("Avoyd", https://www.avoyd.com):
|
Here's an application using icons ("Avoyd", https://www.avoyd.com):
|
||||||

|

|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
## Using FreeType Rasterizer (imgui_freetype)
|
## Using FreeType Rasterizer (imgui_freetype)
|
||||||
|
|
||||||
- Dear ImGui uses imstb\_truetype.h to rasterize fonts (with optional oversampling). This technique and its implementation are not ideal for fonts rendered at small sizes, which may appear a little blurry or hard to read.
|
- Dear ImGui uses imstb\_truetype.h to rasterize fonts (with optional oversampling). This technique and its implementation are not ideal for fonts rendered at small sizes, which may appear a little blurry or hard to read.
|
||||||
@@ -212,9 +260,11 @@ Here's an application using icons ("Avoyd", https://www.avoyd.com):
|
|||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
## Using Colorful Glyphs/Emojis
|
## Using Colorful Glyphs/Emojis
|
||||||
|
|
||||||
- Rendering of colored emojis is only supported by imgui_freetype with FreeType 2.10+.
|
- Rendering of colored emojis is supported by imgui_freetype with FreeType 2.10+.
|
||||||
- You will need to load fonts with the `ImGuiFreeTypeBuilderFlags_LoadColor` flag.
|
- You will need to load fonts with the `ImGuiFreeTypeBuilderFlags_LoadColor` flag.
|
||||||
- Emojis are frequently encoded in upper Unicode layers (character codes >0x10000) and will need dear imgui compiled with `IMGUI_USE_WCHAR32`.
|
- Emojis are frequently encoded in upper Unicode layers (character codes >0x10000) and will need dear imgui compiled with `IMGUI_USE_WCHAR32`.
|
||||||
- Not all types of color fonts are supported by FreeType at the moment.
|
- Not all types of color fonts are supported by FreeType at the moment.
|
||||||
@@ -234,6 +284,8 @@ io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\seguiemj.ttf", 16.0f, &cfg, ra
|
|||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
## Using Custom Glyph Ranges
|
## Using Custom Glyph Ranges
|
||||||
|
|
||||||
You can use the `ImFontGlyphRangesBuilder` helper to create glyph ranges based on text input. For example: 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.
|
You can use the `ImFontGlyphRangesBuilder` helper to create glyph ranges based on text input. For example: 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.
|
||||||
@@ -251,6 +303,8 @@ io.Fonts->Build(); // Build the atlas while
|
|||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
## Using Custom Colorful Icons
|
## Using Custom Colorful Icons
|
||||||
|
|
||||||
As an alternative to rendering colorful glyphs using imgui_freetype with `ImGuiFreeTypeBuilderFlags_LoadColor`, you may allocate your own space in the texture atlas and write yourself into it. **(This is a BETA api, use if you are familiar with dear imgui and with your rendering backend)**
|
As an alternative to rendering colorful glyphs using imgui_freetype with `ImGuiFreeTypeBuilderFlags_LoadColor`, you may allocate your own space in the texture atlas and write yourself into it. **(This is a BETA api, use if you are familiar with dear imgui and with your rendering backend)**
|
||||||
@@ -293,46 +347,89 @@ for (int rect_n = 0; rect_n < IM_ARRAYSIZE(rect_ids); rect_n++)
|
|||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
## Using Font Data Embedded In Source Code
|
---------------------------------------
|
||||||
|
|
||||||
- Compile and use [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) to create a compressed C style array that you can embed in source code.
|
## About Filenames
|
||||||
- See the documentation in [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) for instructions on how to use the tool.
|
|
||||||
- You may find a precompiled version binary_to_compressed_c.exe for Windows inside the demo binaries package (see [README](https://github.com/ocornut/imgui/blob/master/docs/README.md)).
|
|
||||||
- The tool can optionally output Base85 encoding to reduce the size of _source code_ but the read-only arrays in the actual binary will be about 20% bigger.
|
|
||||||
|
|
||||||
Then load the font with:
|
**Please note that many new C/C++ users have issues loading their files _because the filename they provide is wrong_ due to incorrect assumption of what is the current directory.**
|
||||||
```cpp
|
|
||||||
ImFont* font = io.Fonts->AddFontFromMemoryCompressedTTF(compressed_data, compressed_data_size, size_pixels, ...);
|
|
||||||
```
|
|
||||||
or
|
|
||||||
```cpp
|
|
||||||
ImFont* font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(compressed_data_base85, size_pixels, ...);
|
|
||||||
```
|
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
|
||||||
|
|
||||||
## About filenames
|
|
||||||
|
|
||||||
**Please note that many new C/C++ users have issues loading their files _because the filename they provide is wrong_.**
|
|
||||||
|
|
||||||
Two things to watch for:
|
Two things to watch for:
|
||||||
- Make sure your IDE/debugger settings starts your executable from the right working directory. In Visual Studio you can change your working directory in project `Properties > General > Debugging > Working Directory`. People assume that their execution will start from the root folder of the project, where by default it often starts from the folder where object or executable files are stored.
|
|
||||||
```cpp
|
|
||||||
// Relative filename depends on your Working Directory when running your program!
|
|
||||||
io.Fonts->AddFontFromFileTTF("MyImage01.jpg", ...);
|
|
||||||
|
|
||||||
// Load from the parent folder of your Working Directory
|
(1) In C/C++ and most programming languages if you want to use a backslash `\` within a string literal, you need to write it double backslash `\\`. At it happens, Windows uses backslashes as a path separator, so be mindful.
|
||||||
io.Fonts->AddFontFromFileTTF("../MyImage01.jpg", ...);
|
|
||||||
```
|
|
||||||
- In C/C++ and most programming languages if you want to use a backslash `\` within a string literal, you need to write it double backslash `\\`. At it happens, Windows uses backslashes as a path separator, so be mindful.
|
|
||||||
```cpp
|
```cpp
|
||||||
io.Fonts->AddFontFromFileTTF("MyFiles\MyImage01.jpg", ...); // This is INCORRECT!!
|
io.Fonts->AddFontFromFileTTF("MyFiles\MyImage01.jpg", ...); // This is INCORRECT!!
|
||||||
io.Fonts->AddFontFromFileTTF("MyFiles\\MyImage01.jpg", ...); // This is CORRECT
|
io.Fonts->AddFontFromFileTTF("MyFiles\\MyImage01.jpg", ...); // This is CORRECT
|
||||||
```
|
```
|
||||||
In some situations, you may also use `/` path separator under Windows.
|
In some situations, you may also use `/` path separator under Windows.
|
||||||
|
|
||||||
|
(2) Make sure your IDE/debugger settings starts your executable from the right working (current) directory. In Visual Studio you can change your working directory in project `Properties > General > Debugging > Working Directory`. People assume that their execution will start from the root folder of the project, where by default it often starts from the folder where object or executable files are stored.
|
||||||
|
```cpp
|
||||||
|
io.Fonts->AddFontFromFileTTF("MyImage01.jpg", ...); // Relative filename depends on your Working Directory when running your program!
|
||||||
|
io.Fonts->AddFontFromFileTTF("../MyImage01.jpg", ...); // Load from the parent folder of your Working Directory
|
||||||
|
```
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
|
## About UTF-8 Encoding
|
||||||
|
|
||||||
|
**For non-ASCII characters display, a common user issue is not passing correctly UTF-8 encoded strings.**
|
||||||
|
|
||||||
|
(1) We provide a function `ImGui::DebugTextEncoding(const char* text)` which you can call to verify the content of your UTF-8 strings.
|
||||||
|
This is a convenient way to confirm that your encoding is correct.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
ImGui::SeparatorText("CORRECT");
|
||||||
|
ImGui::DebugTextEncoding(u8"こんにちは");
|
||||||
|
|
||||||
|
ImGui::SeparatorText("INCORRECT");
|
||||||
|
ImGui::DebugTextEncoding("こんにちは");
|
||||||
|
```
|
||||||
|

|
||||||
|
|
||||||
|
You can also find this tool under `Metrics/Debuggers->Tools->UTF-8 Encoding viewer` if you want to paste from clipboard, but this won't validate the UTF-8 encoding done by your compiler.
|
||||||
|
|
||||||
|
(2) To encode in UTF-8:
|
||||||
|
|
||||||
|
There are also compiler-specific ways to enforce UTF-8 encoding by default:
|
||||||
|
|
||||||
|
- Visual Studio compiler: `/utf-8` command-line flag.
|
||||||
|
- Visual Studio compiler: `#pragma execution_character_set("utf-8")` inside your code.
|
||||||
|
- Since May 2023 we have changed the Visual Studio projects of all our examples to use `/utf-8` ([see commit](https://github.com/ocornut/imgui/commit/513af1efc9080857bbd10000d98f98f2a0c96803)).
|
||||||
|
|
||||||
|
Or, since C++11, you can use the `u8"my text"` syntax to encode literal strings as UTF-8. e.g.:
|
||||||
|
```cpp
|
||||||
|
ImGui::Text(u8"hello");
|
||||||
|
ImGui::Text(u8"こんにちは"); // this will always be encoded as UTF-8
|
||||||
|
ImGui::Text("こんにちは"); // the encoding of this is depending on compiler settings/flags and may be incorrect.
|
||||||
|
```
|
||||||
|
|
||||||
|
Since C++20, because the C++ committee hate its users, they decided to change the `u8""` syntax to not return `const char*` but a new type `const char8_t*` which doesn't cast to `const char*`.
|
||||||
|
Because of type usage of `u8""` in C++20 is a little more tedious:
|
||||||
|
```cpp
|
||||||
|
ImGui::Text((const char*)u8"こんにちは");
|
||||||
|
```
|
||||||
|
However, you can disable this behavior completely using the compiler option [`/Zc:char8_t-`](https://learn.microsoft.com/en-us/cpp/build/reference/zc-char8-t?view=msvc-170) for MSVC and [`-fno-char8_t`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1423r3.html) for Clang and GCC.
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
|
## Debug Tools
|
||||||
|
|
||||||
|
#### Metrics/Debugger->Fonts
|
||||||
|
You can use the `Metrics/Debugger` window (available in `Demo>Tools`) to browse your fonts and understand what's going on if you have an issue. You can also reach it in `Demo->Tools->Style Editor->Fonts`. The same information are also available in the Style Editor under Fonts.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
#### UTF-8 Encoding Viewer**
|
||||||
|
You can use the `UTF-8 Encoding viewer` in `Metrics/Debugger` to verify the content of your UTF-8 strings. From C/C++ code, you can call `ImGui::DebugTextEncoding("my string");` function to verify that your UTF-8 encoding is correct.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
## Credits/Licenses For Fonts Included In Repository
|
## Credits/Licenses For Fonts Included In Repository
|
||||||
|
|
||||||
Some fonts files are available in the `misc/fonts/` folder:
|
Some fonts files are available in the `misc/fonts/` folder:
|
||||||
@@ -385,7 +482,7 @@ Some fonts files are available in the `misc/fonts/` folder:
|
|||||||
#### MONOSPACE FONTS
|
#### MONOSPACE FONTS
|
||||||
|
|
||||||
Pixel Perfect:
|
Pixel Perfect:
|
||||||
- Proggy Fonts, by Tristan Grimmer http://www.proggyfonts.net or http://upperbounds.net
|
- Proggy Fonts, by Tristan Grimmer http://www.proggyfonts.net or http://upperboundsinteractive.com/fonts.php
|
||||||
- Sweet16, Sweet16 Mono, by Martin Sedlak (Latin + Supplemental + Extended A) https://github.com/kmar/Sweet16Font (also include an .inl file to use directly in dear imgui.)
|
- Sweet16, Sweet16 Mono, by Martin Sedlak (Latin + Supplemental + Extended A) https://github.com/kmar/Sweet16Font (also include an .inl file to use directly in dear imgui.)
|
||||||
|
|
||||||
Regular:
|
Regular:
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Businesses: support continued development and maintenance via invoiced sponsorin
|
|||||||
| [The Pitch](#the-pitch) - [Usage](#usage) - [How it works](#how-it-works) - [Releases & Changelogs](#releases--changelogs) - [Demo](#demo) - [Integration](#integration) |
|
| [The Pitch](#the-pitch) - [Usage](#usage) - [How it works](#how-it-works) - [Releases & Changelogs](#releases--changelogs) - [Demo](#demo) - [Integration](#integration) |
|
||||||
:----------------------------------------------------------: |
|
:----------------------------------------------------------: |
|
||||||
| [Gallery](#gallery) - [Support, FAQ](#support-frequently-asked-questions-faq) - [How to help](#how-to-help) - [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors) - [Credits](#credits) - [License](#license) |
|
| [Gallery](#gallery) - [Support, FAQ](#support-frequently-asked-questions-faq) - [How to help](#how-to-help) - [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors) - [Credits](#credits) - [License](#license) |
|
||||||
| [Wiki](https://github.com/ocornut/imgui/wiki) - [Languages & frameworks backends/bindings](https://github.com/ocornut/imgui/wiki/Bindings) - [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) - [User quotes](https://github.com/ocornut/imgui/wiki/Quotes) |
|
| [Wiki](https://github.com/ocornut/imgui/wiki) - [Extensions](https://github.com/ocornut/imgui/wiki/Useful-Extensions) - [Languages bindings & frameworks backends](https://github.com/ocornut/imgui/wiki/Bindings) - [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) - [User quotes](https://github.com/ocornut/imgui/wiki/Quotes) |
|
||||||
|
|
||||||
### The Pitch
|
### The Pitch
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ Dear ImGui is designed to **enable fast iterations** and to **empower programmer
|
|||||||
Dear ImGui is particularly suited to integration in game engines (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on console platforms where operating system features are non-standard.
|
Dear ImGui is particularly suited to integration in game engines (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on console platforms where operating system features are non-standard.
|
||||||
|
|
||||||
- Minimize state synchronization.
|
- Minimize state synchronization.
|
||||||
- Minimize state storage on user side.
|
- Minimize UI-related state storage on user side.
|
||||||
- Minimize setup and maintenance.
|
- Minimize setup and maintenance.
|
||||||
- Easy to use to create dynamic UI which are the reflection of a dynamic data set.
|
- Easy to use to create dynamic UI which are the reflection of a dynamic data set.
|
||||||
- Easy to use to create code-driven and data-driven tools.
|
- Easy to use to create code-driven and data-driven tools.
|
||||||
@@ -41,7 +41,9 @@ Dear ImGui is particularly suited to integration in game engines (for tooling),
|
|||||||
|
|
||||||
**The core of Dear ImGui is self-contained within a few platform-agnostic files** which you can easily compile in your application/engine. They are all the files in the root folder of the repository (imgui*.cpp, imgui*.h). **No specific build process is required**. You can add the .cpp files into your existing project.
|
**The core of Dear ImGui is self-contained within a few platform-agnostic files** which you can easily compile in your application/engine. They are all the files in the root folder of the repository (imgui*.cpp, imgui*.h). **No specific build process is required**. You can add the .cpp files into your existing project.
|
||||||
|
|
||||||
**Backends for a variety of graphics API and rendering platforms** are provided in the [backends/](https://github.com/ocornut/imgui/tree/master/backends) folder, along with example applications in the [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder. See the [Integration](#integration) section of this document for details. You may also create your own backend. Anywhere where you can render textured triangles, you can render Dear ImGui.
|
**Backends for a variety of graphics API and rendering platforms** are provided in the [backends/](https://github.com/ocornut/imgui/tree/master/backends) folder, along with example applications in the [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder. You may also create your own backend. Anywhere where you can render textured triangles, you can render Dear ImGui.
|
||||||
|
|
||||||
|
See the [Getting Started](https://github.com/ocornut/imgui/wiki/Getting-Started) guide and [Integration](#integration) section of this document for more details.
|
||||||
|
|
||||||
After Dear ImGui is set up in your application, you can use it from \_anywhere\_ in your program loop:
|
After Dear ImGui is set up in your application, you can use it from \_anywhere\_ in your program loop:
|
||||||
```cpp
|
```cpp
|
||||||
@@ -92,7 +94,7 @@ Dear ImGui allows you to **create elaborate tools** as well as very short-lived
|
|||||||
|
|
||||||
### How it works
|
### How it works
|
||||||
|
|
||||||
Check out the Wiki's [About the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#about-the-imgui-paradigm) section if you want to understand the core principles behind the IMGUI paradigm. An IMGUI tries to minimize superfluous state duplication, state synchronization, and state retention from the user's point of view. It is less error-prone (less code and fewer bugs) than traditional retained-mode interfaces, and lends itself to creating dynamic user interfaces.
|
The IMGUI paradigm through its API tries to minimize superfluous state duplication, state synchronization, and state retention from the user's point of view. It is less error-prone (less code and fewer bugs) than traditional retained-mode interfaces, and lends itself to creating dynamic user interfaces. Check out the Wiki's [About the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#about-the-imgui-paradigm) section for more details.
|
||||||
|
|
||||||
Dear ImGui outputs vertex buffers and command lists that you can easily render in your application. The number of draw calls and state changes required to render them is fairly small. Because Dear ImGui doesn't know or touch graphics state directly, you can call its functions anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate Dear ImGui with your existing codebase.
|
Dear ImGui outputs vertex buffers and command lists that you can easily render in your application. The number of draw calls and state changes required to render them is fairly small. Because Dear ImGui doesn't know or touch graphics state directly, you can call its functions anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate Dear ImGui with your existing codebase.
|
||||||
|
|
||||||
@@ -108,34 +110,38 @@ Reading the changelogs is a good way to keep up to date with the things Dear ImG
|
|||||||
Calling the `ImGui::ShowDemoWindow()` function will create a demo window showcasing a variety of features and examples. The code is always available for reference in `imgui_demo.cpp`. [Here's how the demo looks](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v167/v167-misc.png).
|
Calling the `ImGui::ShowDemoWindow()` function will create a demo window showcasing a variety of features and examples. The code is always available for reference in `imgui_demo.cpp`. [Here's how the demo looks](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v167/v167-misc.png).
|
||||||
|
|
||||||
You should be able to build the examples from sources. If you don't, let us know! If you want to have a quick look at some Dear ImGui features, you can download Windows binaries of the demo app here:
|
You should be able to build the examples from sources. If you don't, let us 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-20220504.zip](https://www.dearimgui.com/binaries/imgui-demo-binaries-20220504.zip) (Windows, 1.88 WIP, built 2022/05/04, master) or [older binaries](https://www.dearimgui.com/binaries).
|
- [imgui-demo-binaries-20240105.zip](https://www.dearimgui.com/binaries/imgui-demo-binaries-20240105.zip) (Windows, 1.90.1 WIP, built 2024/01/05, master) or [older binaries](https://www.dearimgui.com/binaries).
|
||||||
|
|
||||||
The demo applications are not DPI aware so expect some blurriness on a 4K screen. For DPI awareness in your application, you can load/reload your font at a different scale and scale your style with `style.ScaleAllSizes()` (see [FAQ](https://www.dearimgui.com/faq)).
|
The demo applications are not DPI aware so expect some blurriness on a 4K screen. For DPI awareness in your application, you can load/reload your font at a different scale and scale your style with `style.ScaleAllSizes()` (see [FAQ](https://www.dearimgui.com/faq)).
|
||||||
|
|
||||||
### Integration
|
### Integration
|
||||||
|
|
||||||
|
See the [Getting Started](https://github.com/ocornut/imgui/wiki/Getting-Started) guide for details.
|
||||||
|
|
||||||
On most platforms and when using C++, **you should be able to use a combination of the [imgui_impl_xxxx](https://github.com/ocornut/imgui/tree/master/backends) backends without modification** (e.g. `imgui_impl_win32.cpp` + `imgui_impl_dx11.cpp`). If your engine supports multiple platforms, consider using more imgui_impl_xxxx files instead of rewriting them: this will be less work for you, and you can get Dear ImGui running immediately. You can _later_ decide to rewrite a custom backend using your custom engine functions if you wish so.
|
On most platforms and when using C++, **you should be able to use a combination of the [imgui_impl_xxxx](https://github.com/ocornut/imgui/tree/master/backends) backends without modification** (e.g. `imgui_impl_win32.cpp` + `imgui_impl_dx11.cpp`). If your engine supports multiple platforms, consider using more imgui_impl_xxxx files instead of rewriting them: this will be less work for you, and you can get Dear ImGui running immediately. You can _later_ decide to rewrite a custom backend using your custom engine functions if you wish so.
|
||||||
|
|
||||||
Integrating Dear ImGui within your custom engine is a matter of 1) wiring mouse/keyboard/gamepad inputs 2) uploading a texture to your GPU/render engine 3) providing a render function that can bind textures and render textured triangles. The [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder is populated with applications doing just that. If you are an experienced programmer at ease with those concepts, it should take you less than two hours to integrate Dear ImGui into your custom engine. **Make sure to spend time reading the [FAQ](https://www.dearimgui.com/faq), comments, and the examples applications!**
|
Integrating Dear ImGui within your custom engine is a matter of 1) wiring mouse/keyboard/gamepad inputs 2) uploading a texture to your GPU/render engine 3) providing a render function that can bind textures and render textured triangles, which is essentially what Backends are doing. The [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder is populated with applications doing just that: setting up a window and using backends. If you follow the [Getting Started](https://github.com/ocornut/imgui/wiki/Getting-Started) guide it should in theory takes you less than an hour to integrate Dear ImGui. **Make sure to spend time reading the [FAQ](https://www.dearimgui.com/faq), comments, and the examples applications!**
|
||||||
|
|
||||||
Officially maintained backends/bindings (in repository):
|
Officially maintained backends/bindings (in repository):
|
||||||
- Renderers: DirectX9, DirectX10, DirectX11, DirectX12, Metal, OpenGL/ES/ES2, SDL_Renderer, Vulkan, WebGPU.
|
- Renderers: DirectX9, DirectX10, DirectX11, DirectX12, Metal, OpenGL/ES/ES2, SDL_Renderer, Vulkan, WebGPU.
|
||||||
- Platforms: GLFW, SDL2, Win32, Glut, OSX, Android.
|
- Platforms: GLFW, SDL2/SDL3, Win32, Glut, OSX, Android.
|
||||||
- Frameworks: Allegro5, Emscripten.
|
- Frameworks: Allegro5, Emscripten.
|
||||||
|
|
||||||
[Third-party backends/bindings](https://github.com/ocornut/imgui/wiki/Bindings) wiki page:
|
[Third-party backends/bindings](https://github.com/ocornut/imgui/wiki/Bindings) wiki page:
|
||||||
- Languages: C, C# and: Beef, ChaiScript, Crystal, D, Go, Haskell, Haxe/hxcpp, Java, JavaScript, Julia, Kotlin, Lobster, Lua, Odin, Pascal, PureBasic, Python, Ruby, Rust, Swift...
|
- Languages: C, C# and: Beef, ChaiScript, CovScript, Crystal, D, Go, Haskell, Haxe/hxcpp, Java, JavaScript, Julia, Kotlin, Lobster, Lua, Nim, Odin, Pascal, PureBasic, Python, ReaScript, Ruby, Rust, Swift, Zig...
|
||||||
- Frameworks: AGS/Adventure Game Studio, Amethyst, Blender, bsf, Cinder, Cocos2d-x, Diligent Engine, Flexium, GML/Game Maker Studio2, GLEQ, Godot, GTK3+OpenGL3, Irrlicht Engine, LÖVE+LUA, Magnum, Monogame, NanoRT, nCine, Nim Game Lib, Nintendo 3DS & Switch (homebrew), Ogre, openFrameworks, OSG/OpenSceneGraph, Orx, Photoshop, px_render, Qt/QtDirect3D, SDL_Renderer, SFML, Sokol, Unity, Unreal Engine 4, vtk, VulkanHpp, VulkanSceneGraph, Win32 GDI, WxWidgets.
|
- Frameworks: AGS/Adventure Game Studio, Amethyst, Blender, bsf, Cinder, Cocos2d-x, Defold, Diligent Engine, Ebiten, Flexium, GML/Game Maker Studio, GLEQ, Godot, GTK3, Irrlicht Engine, JUCE, LÖVE+LUA, Mach Engine, Magnum, Marmalade, Monogame, NanoRT, nCine, Nim Game Lib, Nintendo 3DS/Switch/WiiU (homebrew), Ogre, openFrameworks, OSG/OpenSceneGraph, Orx, Photoshop, px_render, Qt/QtDirect3D, raylib, SFML, Sokol, Unity, Unreal Engine 4/5, UWP, vtk, VulkanHpp, VulkanSceneGraph, Win32 GDI, WxWidgets.
|
||||||
- Many bindings are auto-generated (by good old [cimgui](https://github.com/cimgui/cimgui) or newer/experimental [dear_bindings](https://github.com/dearimgui/dear_bindings)), you can use their metadata output to generate bindings for other languages.
|
- Many bindings are auto-generated (by good old [cimgui](https://github.com/cimgui/cimgui) or newer/experimental [dear_bindings](https://github.com/dearimgui/dear_bindings)), you can use their metadata output to generate bindings for other languages.
|
||||||
|
|
||||||
[Useful Extensions/Widgets](https://github.com/ocornut/imgui/wiki/Useful-Extensions) wiki page:
|
[Useful Extensions/Widgets](https://github.com/ocornut/imgui/wiki/Useful-Extensions) wiki page:
|
||||||
- Automation/testing, Text editors, node editors, timeline editors, plotting, software renderers, remote network access, memory editors, gizmos, etc. One of the most notable and well supported extension is [ImPlot](https://github.com/epezent/implot).
|
- Automation/testing, Text editors, node editors, timeline editors, plotting, software renderers, remote network access, memory editors, gizmos, etc. Notable and well supported extensions include [ImPlot](https://github.com/epezent/implot) and [Dear ImGui Test Engine](https://github.com/ocornut/imgui_test_engine).
|
||||||
|
|
||||||
Also see [Wiki](https://github.com/ocornut/imgui/wiki) for more links and ideas.
|
Also see [Wiki](https://github.com/ocornut/imgui/wiki) for more links and ideas.
|
||||||
|
|
||||||
### Gallery
|
### Gallery
|
||||||
|
|
||||||
For more user-submitted screenshots of projects using Dear ImGui, check out the [Gallery Threads](https://github.com/ocornut/imgui/issues/5886)!
|
Examples projects using Dear ImGui: [Tracy](https://github.com/wolfpld/tracy) (profiler), [ImHex](https://github.com/WerWolv/ImHex) (hex editor/data analysis), [RemedyBG](https://remedybg.itch.io/remedybg) (debugger) and [hundreds of others](https://github.com/ocornut/imgui/wiki/Software-using-Dear-ImGui).
|
||||||
|
|
||||||
|
For more user-submitted screenshots of projects using Dear ImGui, check out the [Gallery Threads](https://github.com/ocornut/imgui/issues/6897)!
|
||||||
|
|
||||||
For a list of third-party widgets and extensions, check out the [Useful Extensions/Widgets](https://github.com/ocornut/imgui/wiki/Useful-Extensions) wiki page.
|
For a list of third-party widgets and extensions, check out the [Useful Extensions/Widgets](https://github.com/ocornut/imgui/wiki/Useful-Extensions) wiki page.
|
||||||
|
|
||||||
@@ -148,7 +154,7 @@ For a list of third-party widgets and extensions, check out the [Useful Extensio
|
|||||||
|
|
||||||
See: [Frequently Asked Questions (FAQ)](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md) where common questions are answered.
|
See: [Frequently Asked Questions (FAQ)](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md) where common questions are answered.
|
||||||
|
|
||||||
See: [Wiki](https://github.com/ocornut/imgui/wiki) for many links, references, articles.
|
See: [Getting Started](https://github.com/ocornut/imgui/wiki/Getting-Started) and [Wiki](https://github.com/ocornut/imgui/wiki) for many links, references, articles.
|
||||||
|
|
||||||
See: [Articles about the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#about-the-imgui-paradigm) to read/learn about the Immediate Mode GUI paradigm.
|
See: [Articles about the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#about-the-imgui-paradigm) to read/learn about the Immediate Mode GUI paradigm.
|
||||||
|
|
||||||
@@ -156,27 +162,27 @@ See: [Upcoming Changes](https://github.com/ocornut/imgui/wiki/Upcoming-Changes).
|
|||||||
|
|
||||||
See: [Dear ImGui Test Engine + Test Suite](https://github.com/ocornut/imgui_test_engine) for Automation & Testing.
|
See: [Dear ImGui Test Engine + Test Suite](https://github.com/ocornut/imgui_test_engine) for Automation & Testing.
|
||||||
|
|
||||||
Getting started? For first-time users having issues compiling/linking/running or issues loading fonts, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions). For other questions, bug reports, requests, feedback, you may post on [GitHub Issues](https://github.com/ocornut/imgui/issues). Please read and fill the New Issue template carefully.
|
Getting started? For first-time users having issues compiling/linking/running or issues loading fonts, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions). For ANY other questions, bug reports, requests, feedback, please post on [GitHub Issues](https://github.com/ocornut/imgui/issues). Please read and fill the New Issue template carefully.
|
||||||
|
|
||||||
Private support is available for paying business customers (E-mail: _contact @ dearimgui dot com_).
|
Private support is available for paying business customers (E-mail: _contact @ dearimgui dot com_).
|
||||||
|
|
||||||
**Which version should I get?**
|
**Which version should I get?**
|
||||||
|
|
||||||
We occasionally tag [Releases](https://github.com/ocornut/imgui/releases) (with nice releases notes) but it is generally safe and recommended to sync to master/latest. The library is fairly stable and regressions tend to be fixed fast when reported. Advanced users may want to use the `docking` branch with [Multi-Viewport](https://github.com/ocornut/imgui/issues/1542) and [Docking](https://github.com/ocornut/imgui/issues/2109) features. This branch is kept in sync with master regularly.
|
We occasionally tag [Releases](https://github.com/ocornut/imgui/releases) (with nice releases notes) but it is generally safe and recommended to sync to latest `master` or `docking` branch. The library is fairly stable and regressions tend to be fixed fast when reported. Advanced users may want to use the `docking` branch with [Multi-Viewport](https://github.com/ocornut/imgui/issues/1542) and [Docking](https://github.com/ocornut/imgui/issues/2109) features. This branch is kept in sync with master regularly.
|
||||||
|
|
||||||
**Who uses Dear ImGui?**
|
**Who uses Dear ImGui?**
|
||||||
|
|
||||||
See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes), [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors), and [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) Wiki pages for an idea of who is using Dear ImGui. Please add your game/software if you can! Also, see the [Gallery Threads](https://github.com/ocornut/imgui/issues/5886)!
|
See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes), [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors), and [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) Wiki pages for an idea of who is using Dear ImGui. Please add your game/software if you can! Also, see the [Gallery Threads](https://github.com/ocornut/imgui/issues/6897)!
|
||||||
|
|
||||||
How to help
|
How to help
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
**How can I help?**
|
**How can I help?**
|
||||||
|
|
||||||
- See [GitHub Forum/Issues](https://github.com/ocornut/imgui/issues) and [GitHub Discussions](https://github.com/ocornut/imgui/discussions).
|
- See [GitHub Forum/Issues](https://github.com/ocornut/imgui/issues).
|
||||||
- You may help with development and submit pull requests! Please understand that by submitting a PR you are also submitting a request for the maintainer to review your code and then take over its maintenance forever. PR should be crafted both in the interest of the end-users and also to ease the maintainer into understanding and accepting it.
|
- You may help with development and submit pull requests! Please understand that by submitting a PR you are also submitting a request for the maintainer to review your code and then take over its maintenance forever. PR should be crafted both in the interest of the end-users and also to ease the maintainer into understanding and accepting it.
|
||||||
- See [Help wanted](https://github.com/ocornut/imgui/wiki/Help-Wanted) on the [Wiki](https://github.com/ocornut/imgui/wiki/) for some more ideas.
|
- See [Help wanted](https://github.com/ocornut/imgui/wiki/Help-Wanted) on the [Wiki](https://github.com/ocornut/imgui/wiki/) for some more ideas.
|
||||||
- Have your company financially support this project with invoiced sponsoring/support contracts or by buying a license for [Dear ImGui Test Engine](https://github.com/ocornut/imgui_test_engine) (please reach out: contact at dearimgui dot com).
|
- Be a [sponsor](https://github.com/ocornut/imgui/wiki/Sponsors)! Have your company financially support this project via invoiced sponsors/maintenance or by buying a license for [Dear ImGui Test Engine](https://github.com/ocornut/imgui_test_engine) (please reach out: omar AT dearimgui DOT com).
|
||||||
|
|
||||||
Sponsors
|
Sponsors
|
||||||
--------
|
--------
|
||||||
@@ -197,13 +203,13 @@ Credits
|
|||||||
|
|
||||||
Developed by [Omar Cornut](https://www.miracleworld.net) and every direct or indirect [contributors](https://github.com/ocornut/imgui/graphs/contributors) to the GitHub. The early version of this library was developed with the support of [Media Molecule](https://www.mediamolecule.com) and first used internally on the game [Tearaway](https://tearaway.mediamolecule.com) (PS Vita).
|
Developed by [Omar Cornut](https://www.miracleworld.net) and every direct or indirect [contributors](https://github.com/ocornut/imgui/graphs/contributors) to the GitHub. The early version of this library was developed with the support of [Media Molecule](https://www.mediamolecule.com) and first used internally on the game [Tearaway](https://tearaway.mediamolecule.com) (PS Vita).
|
||||||
|
|
||||||
Recurring contributors (2022): Omar Cornut [@ocornut](https://github.com/ocornut), Rokas Kupstys [@rokups](https://github.com/rokups) (a good portion of work on automation system and regression tests now available in [Dear ImGui Test Engine](https://github.com/ocornut/imgui_test_engine)).
|
Recurring contributors include Rokas Kupstys [@rokups](https://github.com/rokups) (2020-2022): a good portion of work on automation system and regression tests now available in [Dear ImGui Test Engine](https://github.com/ocornut/imgui_test_engine).
|
||||||
|
|
||||||
Sponsoring, support contracts and other B2B transactions are hosted and handled by [Disco Hello](https://www.discohello.com).
|
Sponsoring, maintenance/support contracts and other B2B transactions are hosted and handled by [Disco Hello](https://www.discohello.com).
|
||||||
|
|
||||||
Omar: "I first discovered the IMGUI paradigm at [Q-Games](https://www.q-games.com) where Atman Binstock had dropped his own simple implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating and improving it."
|
Omar: "I first discovered the IMGUI paradigm at [Q-Games](https://www.q-games.com) where Atman Binstock had dropped his own simple implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating and improving it."
|
||||||
|
|
||||||
Embeds [ProggyClean.ttf](http://upperbounds.net) font by Tristan Grimmer (MIT license).
|
Embeds [ProggyClean.ttf](https://www.proggyfonts.net) font by Tristan Grimmer (MIT license).
|
||||||
<br>Embeds [stb_textedit.h, stb_truetype.h, stb_rect_pack.h](https://github.com/nothings/stb/) by Sean Barrett (public domain).
|
<br>Embeds [stb_textedit.h, stb_truetype.h, stb_rect_pack.h](https://github.com/nothings/stb/) by Sean Barrett (public domain).
|
||||||
|
|
||||||
Inspiration, feedback, and testing for early versions: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. Also thank you to everyone posting feedback, questions and patches on GitHub.
|
Inspiration, feedback, and testing for early versions: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. Also thank you to everyone posting feedback, questions and patches on GitHub.
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ dear imgui
|
|||||||
ISSUES & TODO LIST
|
ISSUES & TODO LIST
|
||||||
|
|
||||||
Issue numbers (#) refer to GitHub issues listed at https://github.com/ocornut/imgui/issues/XXXX
|
Issue numbers (#) refer to GitHub issues listed at https://github.com/ocornut/imgui/issues/XXXX
|
||||||
This list is not well maintained, most of the work happens on GitHub nowadays.
|
THIS LIST IS NOT WELL MAINTAINED. MOST OF THE WORK HAPPENS ON GITHUB NOWADAYS.
|
||||||
The list below consist mostly of ideas noted down before they are requested/discussed by users (at which point they usually exist on the github issue tracker).
|
The list below consist mostly of ideas noted down before they are requested/discussed by users (at which point they usually exist on the github issue tracker).
|
||||||
It's mostly a bunch of personal notes, probably incomplete. Feel free to query if you have any questions.
|
It's mostly a bunch of personal notes, probably incomplete. Feel free to query if you have any questions.
|
||||||
|
|
||||||
- doc/test: add a proper documentation+regression testing system (#435)
|
- doc: add a proper documentation system (maybe relying on automation? #435)
|
||||||
- doc/test: checklist app to verify backends/integration of imgui (test inputs, rendering, callback, etc.).
|
- doc: checklist app to verify backends/integration of imgui (test inputs, rendering, callback, etc.).
|
||||||
- doc/tips: tips of the day: website? applet in imgui_club?
|
- doc/tips: tips of the day: website? applet in imgui_club?
|
||||||
- doc/wiki: work on the wiki https://github.com/ocornut/imgui/wiki
|
- doc/wiki: work on the wiki https://github.com/ocornut/imgui/wiki
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- window: begin with *p_open == false could return false.
|
- window: begin with *p_open == false could 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: when window is very small, prioritize resize button over close button.
|
- window: when window is very small, prioritize resize button over close button.
|
||||||
- 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 interaction, perhaps move to single-click on left-most collapse icon?
|
||||||
- window: expose contents size. (#1045)
|
- window: expose contents size. (#1045)
|
||||||
- window: using SetWindowPos() inside Begin() and moving the window with the mouse reacts a very ugly glitch. We should just defer the SetWindowPos() call.
|
- window: using SetWindowPos() inside Begin() and moving the window with the mouse reacts a very ugly glitch. We should just defer the SetWindowPos() call.
|
||||||
- window: GetWindowSize() returns (0,0) when not calculated? (#1045)
|
- window: GetWindowSize() returns (0,0) when not calculated? (#1045)
|
||||||
@@ -31,29 +31,26 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- window/child: allow resizing of child windows (possibly given min/max for each axis?.)
|
- window/child: allow resizing of child windows (possibly given min/max for each axis?.)
|
||||||
- window/child: allow SetNextWindowContentSize() to work on child windows.
|
- window/child: allow SetNextWindowContentSize() to work on child windows.
|
||||||
- window/clipping: some form of clipping when DisplaySize (or corresponding viewport) is zero.
|
- window/clipping: some form of clipping when DisplaySize (or corresponding viewport) is zero.
|
||||||
- window/tabbing: add a way to signify that a window or docked window requires attention (e.g. blinking title bar).
|
- window/tabbing: add a way to signify that a window or docked window requires attention (e.g. blinking title bar, trying to click behind a modal).
|
||||||
- window/id_stack: add e.g. window->GetIDFromPath() with support for leading / and ../ (#1390, #331)
|
- window/id_stack: add e.g. window->GetIDFromPath() with support for leading / and ../ (#1390, #331) -> model from test engine.
|
||||||
! scrolling: exposing horizontal scrolling with Shift+Wheel even when scrollbar is disabled expose lots of issues (#2424, #1463)
|
! scrolling: exposing horizontal scrolling with Shift+Wheel even when scrollbar is disabled expose lots of issues (#2424, #1463)
|
||||||
- scrolling: while holding down a scrollbar, try to keep the same contents visible (at least while not moving mouse)
|
- scrolling: while holding down a scrollbar, try to keep the same contents visible (at least while not moving mouse)
|
||||||
- scrolling: allow immediately effective change of scroll after Begin() if we haven't appended items yet.
|
- scrolling: allow immediately effective change of scroll after Begin() if we haven't appended items yet.
|
||||||
- scrolling: forward mouse wheel scrolling to parent window when at the edge of scrolling limits? (useful for listbox,tables?)
|
- scrolling: forward mouse wheel scrolling to parent window when at the edge of scrolling limits? (useful for listbox,tables?)
|
||||||
- scrolling/clipping: separator on the initial position of a window is not visible (cursorpos.y <= clippos.y). (2017-08-20: can't repro)
|
|
||||||
- scrolling/style: shadows on scrollable areas to denote that there is more contents (see e.g. DaVinci Resolve ui)
|
- scrolling/style: shadows on scrollable areas to denote that there is more contents (see e.g. DaVinci Resolve ui)
|
||||||
|
|
||||||
- drawdata: make it easy to deep-copy (or swap?) a full ImDrawData so user can easily save that data if they use threaded rendering. (e.g. #2646)
|
- drawdata: make it easy to deep-copy (or swap?) a full ImDrawData so user can easily save that data if they use threaded rendering. (e.g. #2646)
|
||||||
! drawlist: add CalcTextSize() func to facilitate consistent code from user pov (currently need to use ImGui or ImFont alternatives!)
|
! drawlist: add CalcTextSize() func to facilitate consistent code from user pov (currently need to use ImGui or ImFont alternatives!)
|
||||||
- drawlist: 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). (WIP branch)
|
- 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). (WIP branch)
|
||||||
- drawlist: primitives/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: 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), glitch especially on RenderCheckmark() and ColorPicker4().
|
- drawlist: non-AA strokes have gaps between points (#593, #288), glitch especially on RenderCheckmark() and ColorPicker4().
|
||||||
- drawlist: rendering: provide a way for imgui to output to a single/global vertex buffer, re-order indices only at the end of the frame (ref: https://gist.github.com/floooh/10388a0afbe08fce9e617d8aefa7d302)
|
|
||||||
- drawlist: callback: add an extra void* in ImDrawCallback to allow passing render-local data to the callback (would break API).
|
- drawlist: callback: add an extra void* in ImDrawCallback to allow passing render-local data to the callback (would break API).
|
||||||
- drawlist: AddRect vs AddLine position confusing (#2441)
|
- drawlist: AddRect vs AddLine position confusing (#2441)
|
||||||
- drawlist/opt: store rounded corners in texture to use 1 quad per corner (filled and wireframe) to lower the cost of rounding. (#1962)
|
- drawlist/opt: store rounded corners in texture to use 1 quad per corner (filled and wireframe) to lower the cost of rounding. (#1962)
|
||||||
- drawlist/opt: AddRect() axis aligned pixel aligned (no-aa) could use 8 triangles instead of 16 and no normal calculation.
|
- drawlist/opt: AddRect() axis aligned pixel aligned (no-aa) could use 8 triangles instead of 16 and no normal calculation.
|
||||||
- drawlist/opt: thick AA line could be doable in same number of triangles as 1.0 AA line by storing gradient+full color in atlas.
|
- drawlist/opt: thick AA line could be doable in same number of triangles as 1.0 AA line by storing gradient+full color in atlas.
|
||||||
|
|
||||||
- main: IsItemHovered() info stored in a stack? so that 'if TreeNode() { Text; TreePop; } if IsHovered' return the hover state of the TreeNode?
|
- items: IsItemHovered() info stored in a stack? so that 'if TreeNode() { Text; TreePop; } if IsHovered' return the hover state of the TreeNode?
|
||||||
|
|
||||||
- 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.
|
||||||
@@ -61,8 +58,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- widgets: start exposing PushItemFlag() and ImGuiItemFlags
|
- widgets: start exposing PushItemFlag() and ImGuiItemFlags
|
||||||
- widgets: alignment options in style (e.g. center Selectable, Right-Align within Button, etc.) #1260
|
- widgets: alignment options in style (e.g. center Selectable, Right-Align within Button, etc.) #1260
|
||||||
- widgets: activate by identifier (trigger button, focus given id)
|
- widgets: activate by identifier (trigger button, focus given id)
|
||||||
- widgets: a way to represent "mixed" values, so e.g. all values replaced with *, including check-boxes, colors, etc. with support for multi-components widgets (e.g. SliderFloat3, make only "Y" mixed) (#2644)
|
- widgets: custom glyph/shapes replacements for stock sapes. (also #6090 #2431 #2235 #6517)
|
||||||
- widgets: checkbox: checkbox with custom glyph inside frame.
|
|
||||||
- widgets: coloredit: keep reporting as active when picker is on?
|
- widgets: coloredit: keep reporting as active when picker is on?
|
||||||
- widgets: group/scalarn functions: expose more per-component information. e.g. store NextItemData.ComponentIdx set by scalarn function, groups can expose them back somehow.
|
- widgets: group/scalarn functions: expose more per-component information. e.g. store NextItemData.ComponentIdx set by scalarn function, groups can expose them back somehow.
|
||||||
- selectable: using (size.x == 0.0f) and (SelectableTextAlign.x > 0.0f) followed by SameLine() is currently not supported.
|
- selectable: using (size.x == 0.0f) and (SelectableTextAlign.x > 0.0f) followed by SameLine() is currently not supported.
|
||||||
@@ -81,7 +77,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- input text: option to Tab after an Enter validation.
|
- 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 flag (e.g. ImGuiInputTextFlags_EscapeClearsBuffer) to clear instead of revert. what to do with focus? (also see #2890)
|
|
||||||
- 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)
|
||||||
- input text: display bug when clicking a drag/slider after an input text in a different window has all-selected text (order dependent). actually a very old bug but no one appears to have noticed it.
|
- input text: display bug when clicking a drag/slider after an input text in a different window has all-selected text (order dependent). actually a very old bug but no one appears to have noticed it.
|
||||||
- input text: allow centering/positioning text so that ctrl+clicking Drag or Slider keeps the textual value at the same pixel position.
|
- input text: allow centering/positioning text so that ctrl+clicking Drag or Slider keeps the textual value at the same pixel position.
|
||||||
@@ -116,20 +111,14 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- tables: see https://github.com/ocornut/imgui/issues/2957#issuecomment-569726095
|
- tables: see https://github.com/ocornut/imgui/issues/2957#issuecomment-569726095
|
||||||
|
|
||||||
- group: BeginGroup() needs a border option. (~#1496)
|
- group: BeginGroup() needs a border option. (~#1496)
|
||||||
- group: IsHovered() after EndGroup() covers whole AABB rather than the intersection of individual items. Is that desirable?
|
- group: IsItemHovered() after EndGroup() covers whole AABB rather than the intersection of individual items. Is that desirable?
|
||||||
- group: merge deactivation/activation within same group (fwd WasEdited flag). (#2550)
|
- group: merge deactivation/activation within same group (fwd WasEdited flag). (#2550)
|
||||||
|
|
||||||
!- color: the color conversion helpers/types are a mess and needs sorting out.
|
!- color: the color conversion helpers/types are a mess and needs sorting out.
|
||||||
- color: (api breaking) ImGui::ColorConvertXXX functions should be loose ImColorConvertXX to match imgui_internals.h
|
- color: (api breaking) ImGui::ColorConvertXXX functions should be loose ImColorConvertXX to match imgui_internals.h
|
||||||
|
|
||||||
- plot: full featured plot/graph api w/ scrolling, zooming etc. all bell & whistle. why not!
|
- plot: full featured plot/graph api w/ scrolling, zooming etc. --> ImPlot
|
||||||
- plot: PlotLines() should use the polygon-stroke facilities, less vertices (currently issues with averaging normals)
|
- (plot: deleted all other todo lines on 2023-06-28)
|
||||||
- plot: make it easier for user to draw extra stuff into the graph (e.g: draw basis, highlight certain points, 2d plots, multiple plots)
|
|
||||||
- plot: "smooth" automatic scale over time, user give an input 0.0(full user scale) 1.0(full derived from value)
|
|
||||||
- plot: option/feature: draw the zero line
|
|
||||||
- plot: option/feature: draw grid, vertical markers
|
|
||||||
- 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)
|
|
||||||
|
|
||||||
- clipper: ability to disable the clipping through a simple flag/bool.
|
- clipper: ability to disable the clipping through a simple flag/bool.
|
||||||
- clipper: ability to run without knowing full count in advance.
|
- clipper: ability to run without knowing full count in advance.
|
||||||
@@ -137,24 +126,47 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
|
|
||||||
- separator: expose flags (#759)
|
- separator: expose flags (#759)
|
||||||
- separator: take indent into consideration (optional)
|
- separator: take indent into consideration (optional)
|
||||||
- separator: width, thickness, centering (#1643)
|
- separator: width, thickness, centering (#1643, #2657)
|
||||||
- splitter: formalize the splitter idiom into an official api (we want to handle n-way split) (#319)
|
- splitter: formalize the splitter idiom into an official api (we want to handle n-way split) (#319)
|
||||||
|
|
||||||
- dock: merge docking branch (#2109)
|
- docking: B: ordering currently held in tab bar should be implicitly held by windows themselves (also see #2304)
|
||||||
|
- docking: B- tab bar: the order/focus restoring code could be part of TabBar and not DockNode? (#8)
|
||||||
|
- docking: B~ rework code to be able to lazily create tab bar instance in a single place. The _Unsorted tab flag could be replacing a trailing-counter in DockNode?
|
||||||
|
- docking: B~ fully track windows/settings reference in dock nodes. perhaps find a representation that allows facilitate use of dock builder functions.
|
||||||
|
- docking: B~ Unreal style document system (requires low-level controls of dockspace serialization fork/copy/delete). this is mostly working but the DockBuilderXXX api are not exposed/finished.
|
||||||
|
- docking: B: when docking outer, perform size locking on neighbors nodes the same way we do it with splitters, so other nodes are not resized.
|
||||||
|
- docking: B~ central node resizing behavior incorrect.
|
||||||
|
- docking: B: changing title font/style per-window is not supported as dock nodes are created in NewFrame.
|
||||||
|
- docking: B- dock node inside its own viewports creates 1 temporary viewport per window on startup before ditching them (doesn't affect the user nor request platform windows to be created, but unnecessary)
|
||||||
|
- docking: B- resize sibling locking behavior may be less desirable if we merged same-axis sibling in a same node level?
|
||||||
|
- docking: B- single visible node part of a hidden split hierarchy (OnlyNodeWithWindows != NULL) should show a normal title bar (not a tab bar)
|
||||||
|
- docking: B~ SetNextWindowDock() calls (with conditional) -> defer everything to DockContextUpdate (repro: Documents->[X]Windows->Dock 1 elsewhere->Click Redock All
|
||||||
|
- docking: B~ tidy up tab list popup buttons features (available with manual tab-bar, see ImGuiTabBarFlags_NoTabListPopupButton code, not used by docking nodes)
|
||||||
|
- docking: B- SetNextWindowDockId(0) with a second Begin() in the frame will asserts
|
||||||
|
- docking: B: resize grip drawn in host window typically appears under scrollbar.
|
||||||
|
- docking: B: resize grip auto-resize on multiple node hierarchy doesn't make much sense or should be improved?
|
||||||
|
- docking: B- SetNextWindowFocus() doesn't seem to apply if the window is hidden this frame, need repro (#4)
|
||||||
|
- docking: B- resizing a dock tree small currently has glitches (overlapping collapse and close button, etc.)
|
||||||
|
- docking: B- dpi: look at interaction with the hi-dpi and multi-dpi stuff.
|
||||||
|
- docking: B- tab bar: appearing on first frame with a dumb layout would do less harm that not appearing? (when behind dynamic branch) or store titles + render in EndTabBar()
|
||||||
|
- docking: B- tab bar: make selected tab always shows its full title?
|
||||||
|
- docking: B- hide close button on single tab bar?
|
||||||
|
- docking: B- nav: design interactions so nav controls can dock/undock
|
||||||
|
- docking: B- dockspace: flag to lock the dock tree and/or sizes (ImGuiDockNodeFlags_Locked?)
|
||||||
|
- docking: B- reintroduce collapsing a floating dock node. also collapsing a docked dock node!
|
||||||
|
- docking: B- allow dragging a non-floating dock node by clicking on the title-bar-looking section (not just the collapse/menu button)
|
||||||
|
- docking: B- option to remember undocked window size? (instead of keeping their docked size) (relate to #2104)
|
||||||
|
- docking: C- nav: CTRL+TAB highlighting tabs shows the mismatch between focus-stack and tab-order (not visible in VS because it doesn't highlight the tabs)
|
||||||
|
- docking: C- after a dock/undock, the Scrollbar Status update in Begin() should use an updated e.g. size_y_for_scrollbars to avoid a 1 frame scrollbar flicker.
|
||||||
|
|
||||||
- tabs: "there is currently a problem because TabItem() will try to submit their own tooltip after 0.50 second, and this will have the effect of making your tooltip flicker once." -> tooltip priority work (WIP branch)
|
- tabs: "there is currently a problem because TabItem() will try to submit their own tooltip after 0.50 second, and this will have the effect of making your tooltip flicker once." -> tooltip priority work (WIP branch)
|
||||||
- tabs: make EndTabBar fail if users doesn't respect BeginTabBar return value, for consistency/future-proofing.
|
- tabs: make EndTabBar fail if users doesn't respect BeginTabBar return value, for consistency/future-proofing.
|
||||||
- tabs: persistent order/focus in BeginTabBar() api (#261, #351)
|
- tabs: persistent order/focus in BeginTabBar() api (#261, #351)
|
||||||
- tabs: TabItem could honor SetNextItemWidth()?
|
|
||||||
- tabs: explicit api (even if internal) to cleanly manipulate tab order.
|
- tabs: explicit api (even if internal) to cleanly manipulate tab order.
|
||||||
- tabs: Mouse wheel over tab bar could scroll? (with shift?) (#2702)
|
|
||||||
|
|
||||||
- image/image button: misalignment on padded/bordered button?
|
- image/image button: misalignment on padded/bordered button?
|
||||||
- image/image button: parameters are confusing, image() has tint_col,border_col whereas imagebutton() has bg_col/tint_col. Even thou they are different parameters ordering could be more consistent. can we fix that?
|
- image/image button: parameters are confusing, image() has tint_col,border_col whereas imagebutton() has bg_col/tint_col. Even thou they are different parameters ordering could be more consistent. can we fix that?
|
||||||
- image button: not taking an explicit id can be problematic. (#2464, #1390)
|
|
||||||
- slider/drag: ctrl+click when format doesn't include a % character.. disable? display underlying value in default format? (see TempInputTextScalar)
|
|
||||||
- slider: allow using the [-]/[+] buttons used by InputFloat()/InputInt()
|
- slider: allow using the [-]/[+] buttons used by InputFloat()/InputInt()
|
||||||
- slider: initial absolute click is imprecise. change to relative movement slider (same as scrollbar). (#1946)
|
|
||||||
- slider: add dragging-based widgets to edit values with mouse (on 2 axises), saving screen real-estate.
|
- slider: add dragging-based widgets to edit values with mouse (on 2 axises), saving screen real-estate.
|
||||||
- slider: tint background based on value (e.g. v_min -> v_max, or use 0.0f either side of the sign)
|
- slider: tint background based on value (e.g. v_min -> v_max, or use 0.0f either side of the sign)
|
||||||
- slider: relative dragging? + precision dragging
|
- slider: relative dragging? + precision dragging
|
||||||
@@ -167,7 +179,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- 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: use clipper.
|
- combo: use clipper.
|
||||||
- combo: flag for BeginCombo to not return true when unchanged (#1182)
|
|
||||||
- combo: a way/helper to customize the combo preview (#1658) -> experimental BeginComboPreview()
|
- combo: a way/helper to customize the combo preview (#1658) -> experimental BeginComboPreview()
|
||||||
- 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 (WIP range-select branch)
|
- listbox: multiple selection (WIP range-select branch)
|
||||||
@@ -189,7 +200,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
|
|
||||||
- tooltip: drag and drop with tooltip near monitor edges lose/changes its last direction instead of locking one. The drag and drop tooltip should always follow without changing direction.
|
- tooltip: drag and drop with tooltip near monitor edges lose/changes its last direction instead of locking one. The drag and drop tooltip should always follow without changing direction.
|
||||||
- tooltip: allow to set the width of a tooltip to allow TextWrapped() etc. while keeping the height automatic.
|
- tooltip: allow to set the width of a tooltip to allow TextWrapped() etc. while keeping the height automatic.
|
||||||
- tooltip: tooltips with delay timers? or general timer policy? (instantaneous vs timed): IsItemHovered() with timer + implicit aabb-id for items with no ID. (#1485) (WIP branch)
|
|
||||||
- tooltip: drag tooltip hovering over source widget with IsItemHovered/SetTooltip flickers (WIP branch)
|
- tooltip: drag tooltip hovering over source widget with IsItemHovered/SetTooltip flickers (WIP branch)
|
||||||
|
|
||||||
- status-bar: add a per-window status bar helper similar to what menu-bar does. generalize concept of layer0 rect in window (can make _MenuBar window flag obsolete too).
|
- status-bar: add a per-window status bar helper similar to what menu-bar does. generalize concept of layer0 rect in window (can make _MenuBar window flag obsolete too).
|
||||||
@@ -198,7 +208,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- shortcuts: programmatically access shortcuts "Focus("&Save"))
|
- shortcuts: programmatically access shortcuts "Focus("&Save"))
|
||||||
- menus: menu-bar: main menu-bar could affect clamping of windows position (~ akin to modifying DisplayMin)
|
- menus: menu-bar: main menu-bar could affect clamping of windows position (~ akin to modifying DisplayMin)
|
||||||
- menus: hovering from menu to menu on a menu-bar has 1 frame without any menu, which is a little annoying. ideally either 0 either longer.
|
- menus: hovering from menu to menu on a menu-bar has 1 frame without any menu, which is a little annoying. ideally either 0 either longer.
|
||||||
- menus: could merge draw call in most cases (how about storing an optional aabb in ImDrawCmd to move the burden of merging in a single spot).
|
|
||||||
- menus: would be nice if the Selectable() supported horizontal alignment (must be given the equivalent of WorkRect.Max.x matching the position of the shortcut column)
|
- menus: would be nice if the Selectable() supported horizontal alignment (must be given the equivalent of WorkRect.Max.x matching the position of the shortcut column)
|
||||||
|
|
||||||
- tree node: add treenode/treepush int variants? not there because (void*) cast from int warns on some platforms/settings?
|
- tree node: add treenode/treepush int variants? not there because (void*) cast from int warns on some platforms/settings?
|
||||||
@@ -206,7 +215,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- tree node / selectable render mismatch which is visible if you use them both next to each other (e.g. cf. property viewer)
|
- tree node / selectable render mismatch which is visible if you use them both next to each other (e.g. cf. property viewer)
|
||||||
- tree node: tweak color scheme to distinguish headers from selected tree node (#581)
|
- tree node: tweak color scheme to distinguish headers from selected tree node (#581)
|
||||||
- tree node: leaf/non-leaf highlight mismatch.
|
- tree node: leaf/non-leaf highlight mismatch.
|
||||||
- tree node: flag to disable formatting and/or detect "%s"
|
|
||||||
- tree node/opt: could avoid formatting when clipped (flag assuming we don't care about width/height, assume single line height? format only %s/%c to be able to count height?)
|
- tree node/opt: could avoid formatting when clipped (flag assuming we don't care about width/height, assume single line height? format only %s/%c to be able to count height?)
|
||||||
|
|
||||||
- settings: write more decent code to allow saving/loading new fields: columns, selected tree nodes?
|
- settings: write more decent code to allow saving/loading new fields: columns, selected tree nodes?
|
||||||
@@ -244,7 +252,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- drag and drop: drag source on a group object (would need e.g. an invisible button covering group in EndGroup) https://twitter.com/paniq/status/1121446364909535233
|
- drag and drop: drag source on a group object (would need e.g. an invisible button covering group in EndGroup) https://twitter.com/paniq/status/1121446364909535233
|
||||||
- drag and drop: have some way to know when a drag begin from BeginDragDropSource() pov. (see 2018/01/11 post in #143)
|
- drag and drop: have some way to know when a drag begin from BeginDragDropSource() pov. (see 2018/01/11 post in #143)
|
||||||
- drag and drop: allow preview tooltip to be submitted from a different place than the drag source. (#1725)
|
- drag and drop: allow preview tooltip to be submitted from a different place than the drag source. (#1725)
|
||||||
- drag and drop: allow using with other mouse buttons (where activeid won't be set). (#1637)
|
|
||||||
- drag and drop: make it easier and provide a demo to have tooltip both are source and target site, with a more detailed one on target site (tooltip ordering problem)
|
- drag and drop: make it easier and provide a demo to have tooltip both are source and target site, with a more detailed one on target site (tooltip ordering problem)
|
||||||
- drag and drop: demo with reordering nodes (in a list, or a tree node). (#143)
|
- drag and drop: demo with reordering nodes (in a list, or a tree node). (#143)
|
||||||
- drag and drop: test integrating with os drag and drop (make it easy to do a naive WM_DROPFILE integration)
|
- drag and drop: test integrating with os drag and drop (make it easy to do a naive WM_DROPFILE integration)
|
||||||
@@ -296,10 +303,10 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- font/opt: Considering storing standalone AdvanceX table as 16-bit fixed point integer?
|
- font/opt: Considering storing standalone AdvanceX table as 16-bit fixed point integer?
|
||||||
- font/opt: Glyph currently 40 bytes (2+9*4). Consider storing UV as 16-bits integer? (->32 bytes). X0/Y0/X1/Y1 as 16 fixed-point integers? Or X0/Y0 as float and X1/Y1 as fixed8_8?
|
- font/opt: Glyph currently 40 bytes (2+9*4). Consider storing UV as 16-bits integer? (->32 bytes). X0/Y0/X1/Y1 as 16 fixed-point integers? Or X0/Y0 as float and X1/Y1 as fixed8_8?
|
||||||
|
|
||||||
|
- nav: visual feedback on button press.
|
||||||
- nav: some features such as PageUp/Down/Home/End should probably work without ImGuiConfigFlags_NavEnableKeyboard? (where do we draw the line? how about CTRL+Tab)
|
- nav: some features such as PageUp/Down/Home/End should probably work without ImGuiConfigFlags_NavEnableKeyboard? (where do we draw the line? how about CTRL+Tab)
|
||||||
! nav: never clear NavId on some setup (e.g. gamepad centric)
|
! nav: never clear NavId on some setup (e.g. gamepad centric)
|
||||||
- nav: there's currently no way to completely clear focus with the keyboard. depending on patterns used by the application to dispatch inputs, it may be desirable.
|
- nav: there's currently no way to completely clear focus with the keyboard. depending on patterns used by the application to dispatch inputs, it may be desirable.
|
||||||
- nav: code to focus child-window on restoring NavId appears to have issue: e.g. when focus change is implicit because of window closure.
|
|
||||||
- nav: Home/End behavior when navigable item is not fully visible at the edge of scrolling? should be backtrack to keep item into view?
|
- nav: Home/End behavior when navigable item is not fully visible at the edge of scrolling? should be backtrack to keep item into view?
|
||||||
- nav: NavScrollToBringItemIntoView() with item bigger than view should focus top-right? Repro: using Nav in "About Window"
|
- nav: NavScrollToBringItemIntoView() with item bigger than view should focus top-right? Repro: using Nav in "About Window"
|
||||||
- nav: wrap around logic to allow e.g. grid based layout (pressing NavRight on the right-most element would go to the next row, etc.). see internal's NavMoveRequestTryWrapping().
|
- nav: wrap around logic to allow e.g. grid based layout (pressing NavRight on the right-most element would go to the next row, etc.). see internal's NavMoveRequestTryWrapping().
|
||||||
@@ -320,12 +327,24 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- nav/menus: when using the main menu bar, even though we restore focus after, the underlying window loses its title bar highlight during menu manipulation. could we prevent it?
|
- nav/menus: when using the main menu bar, even though we restore focus after, the underlying window loses its title bar highlight during menu manipulation. could we prevent it?
|
||||||
- nav/menus: main menu bar currently cannot restore a nullptr focus. Could save NavWindow at the time of being focused, similarly to what popup do?
|
- nav/menus: main menu bar currently cannot restore a nullptr focus. Could save NavWindow at the time of being focused, similarly to what popup do?
|
||||||
- nav/menus: Alt,Up could open the first menu (e.g. "File") currently it tends to nav into the window/collapse menu. Do do that we would need custom transition?
|
- nav/menus: Alt,Up could open the first menu (e.g. "File") currently it tends to nav into the window/collapse menu. Do do that we would need custom transition?
|
||||||
- nav/windowing: configure fade-in/fade-out delay on Ctrl+Tab?
|
|
||||||
- nav/windowing: when CTRL+Tab/windowing is active, the HoveredWindow detection doesn't take account of the window display re-ordering.
|
- nav/windowing: when CTRL+Tab/windowing is active, the HoveredWindow detection doesn't take account of the window display re-ordering.
|
||||||
- nav/windowing: Resizing window will currently fail with certain types of resizing constraints/callback applied
|
- nav/windowing: Resizing window will currently fail with certain types of resizing constraints/callback applied
|
||||||
- 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)
|
||||||
|
|
||||||
- inputs: we need an explicit flag about whether the platform window is focused, to be able to distinguish focused key releases vs alt-tabbing all release behaviors.
|
- viewport: make it possible to have no main/hosting viewport
|
||||||
|
- viewport: We set ImGuiViewportFlags_NoFocusOnAppearing in a way that is required for GLFW/SDL binding, but could be handled better without
|
||||||
|
on a custom e.g. Win32 bindings. It prevents newly dragged-out viewports from taking the focus, which makes ALT+F4 more ambiguous.
|
||||||
|
- viewport: not focusing newly undocked viewport means clicking back on previous one doesn't bring OS window to front.
|
||||||
|
- viewport: with platform decoration enabled, platform may force constraint (e.g. minimum size)
|
||||||
|
- viewport: use getfocus/setfocus api to synchronize imgui<>platform focus better (e.g imgui-side ctrl-tab can focus os window, OS initial setup and alt-tab can focus imgui window etc.)
|
||||||
|
- viewport: store per-viewport/monitor DPI in .ini file so an application reload or main window changing DPI on reload can be properly patched for.
|
||||||
|
- viewport: implicit/fallback Debug window can hog a zombie viewport (harmless, noisy?) > could at least clear out the reference on a per session basis?
|
||||||
|
- viewport: need to clarify how to use GetMousePos() from a user point of view.
|
||||||
|
- platform: glfw: no support for ImGuiBackendFlags_HasMouseHoveredViewport.
|
||||||
|
- platform: sdl: no support for ImGuiBackendFlags_HasMouseHoveredViewport. maybe we could use SDL_GetMouseFocus() / SDL_WINDOW_MOUSE_FOCUS if imgui could fallback on its heuristic when NoInputs is set
|
||||||
|
- platform: sdl: no refresh of monitor/display (SDL doesn't seem to have an event for it).
|
||||||
|
- platform: sdl: multi-viewport + minimized window seems to break mouse wheel events (at least under Win32).
|
||||||
|
|
||||||
- inputs: support track pad style scrolling & slider edit.
|
- inputs: support track pad style scrolling & slider edit.
|
||||||
- inputs/io: backspace and arrows in the context of a text input could use system repeat rate.
|
- inputs/io: backspace and arrows in the context of a text input could use system repeat rate.
|
||||||
- inputs/io: clarify/standardize/expose repeat rate and repeat delays (#1808)
|
- inputs/io: clarify/standardize/expose repeat rate and repeat delays (#1808)
|
||||||
@@ -351,7 +370,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- examples: provide a zero frame-rate/idle example.
|
- examples: provide a zero frame-rate/idle example.
|
||||||
- examples: dx11/dx12: try to use new swapchain blit models (#2970)
|
- examples: dx11/dx12: try to use new swapchain blit models (#2970)
|
||||||
- backends: report it better when not able to create texture?
|
- backends: report it better when not able to create texture?
|
||||||
- backends: apple: example_apple should be using modern GL3.
|
|
||||||
- backends: glfw: could go idle when minimized? if (glfwGetWindowAttrib(window, GLFW_ICONIFIED)) { glfwWaitEvents(); continue; } // issue: DeltaTime will be super high on resume, perhaps provide a way to let impl know (#440)
|
- backends: glfw: could go idle when minimized? if (glfwGetWindowAttrib(window, GLFW_ICONIFIED)) { glfwWaitEvents(); continue; } // issue: DeltaTime will be super high on resume, perhaps provide a way to let impl know (#440)
|
||||||
- backends: opengl: rename imgui_impl_opengl2 to impl_opengl_legacy and imgui_impl_opengl3 to imgui_impl_opengl? (#1900)
|
- backends: opengl: rename imgui_impl_opengl2 to impl_opengl_legacy and imgui_impl_opengl3 to imgui_impl_opengl? (#1900)
|
||||||
- backends: opengl: could use a single vertex buffer and glBufferSubData for uploads?
|
- backends: opengl: could use a single vertex buffer and glBufferSubData for uploads?
|
||||||
|
|||||||
@@ -32,5 +32,5 @@ vcpkg integrate install ; register include / libs in Visual Studio
|
|||||||
Build:
|
Build:
|
||||||
```
|
```
|
||||||
set ALLEGRODIR=path_to_your_allegro5_folder
|
set ALLEGRODIR=path_to_your_allegro5_folder
|
||||||
cl /Zi /MD /I %ALLEGRODIR%\include /DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" /I .. /I ..\.. /I ..\..\backends main.cpp ..\..\backends\imgui_impl_allegro5.cpp ..\..\imgui*.cpp /link /LIBPATH:%ALLEGRODIR%\lib allegro-5.0.10-monolith-md.lib user32.lib
|
cl /Zi /MD /utf-8 /I %ALLEGRODIR%\include /DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" /I .. /I ..\.. /I ..\..\backends main.cpp ..\..\backends\imgui_impl_allegro5.cpp ..\..\imgui*.cpp /link /LIBPATH:%ALLEGRODIR%\lib allegro-5.0.10-monolith-md.lib user32.lib
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -91,6 +91,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -105,6 +106,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -122,6 +124,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -142,6 +145,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
// Dear ImGui: standalone example application for Allegro 5
|
// Dear ImGui: standalone example application for Allegro 5
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// On Windows, you can install Allegro5 using vcpkg:
|
// On Windows, you can install Allegro5 using vcpkg:
|
||||||
// git clone https://github.com/Microsoft/vcpkg
|
// git clone https://github.com/Microsoft/vcpkg
|
||||||
@@ -36,6 +40,7 @@ int main(int, char**)
|
|||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
// dear imgui: standalone example application for Android + OpenGL ES 3
|
// dear imgui: standalone example application for Android + OpenGL ES 3
|
||||||
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
|
||||||
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_android.h"
|
#include "imgui_impl_android.h"
|
||||||
|
|||||||
@@ -7,7 +7,10 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
050450AB2768052600AB6805 /* imgui_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5079822D257677DB0038A28D /* imgui_tables.cpp */; };
|
||||||
|
050450AD276863B000AB6805 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 050450AC276863B000AB6805 /* QuartzCore.framework */; };
|
||||||
05318E0F274C397200A8DE2E /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05318E0E274C397200A8DE2E /* GameController.framework */; };
|
05318E0F274C397200A8DE2E /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05318E0E274C397200A8DE2E /* GameController.framework */; };
|
||||||
|
05A275442773BEA20084EF39 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05A275432773BEA20084EF39 /* QuartzCore.framework */; };
|
||||||
07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; };
|
07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; };
|
||||||
07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; };
|
07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; };
|
||||||
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5079822D257677DB0038A28D /* imgui_tables.cpp */; };
|
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5079822D257677DB0038A28D /* imgui_tables.cpp */; };
|
||||||
@@ -33,7 +36,11 @@
|
|||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
050450AC276863B000AB6805 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
|
||||||
05318E0E274C397200A8DE2E /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; };
|
05318E0E274C397200A8DE2E /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; };
|
||||||
|
05A2754027728F5B0084EF39 /* imgui_impl_metal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_metal.h; path = ../../backends/imgui_impl_metal.h; sourceTree = "<group>"; };
|
||||||
|
05A2754127728F5B0084EF39 /* imgui_impl_osx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_osx.h; path = ../../backends/imgui_impl_osx.h; sourceTree = "<group>"; };
|
||||||
|
05A275432773BEA20084EF39 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk/System/Library/Frameworks/QuartzCore.framework; sourceTree = DEVELOPER_DIR; };
|
||||||
07A82ED62139413C0078D120 /* imgui_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_internal.h; path = ../../imgui_internal.h; sourceTree = "<group>"; };
|
07A82ED62139413C0078D120 /* imgui_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_internal.h; path = ../../imgui_internal.h; sourceTree = "<group>"; };
|
||||||
07A82ED72139413C0078D120 /* imgui_widgets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_widgets.cpp; path = ../../imgui_widgets.cpp; sourceTree = "<group>"; };
|
07A82ED72139413C0078D120 /* imgui_widgets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_widgets.cpp; path = ../../imgui_widgets.cpp; sourceTree = "<group>"; };
|
||||||
5079822D257677DB0038A28D /* imgui_tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_tables.cpp; path = ../../imgui_tables.cpp; sourceTree = "<group>"; };
|
5079822D257677DB0038A28D /* imgui_tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_tables.cpp; path = ../../imgui_tables.cpp; sourceTree = "<group>"; };
|
||||||
@@ -66,6 +73,7 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
05A275442773BEA20084EF39 /* QuartzCore.framework in Frameworks */,
|
||||||
8309BD8F253CCAAA0045E2A1 /* UIKit.framework in Frameworks */,
|
8309BD8F253CCAAA0045E2A1 /* UIKit.framework in Frameworks */,
|
||||||
83BBE9E720EB46BD00295997 /* MetalKit.framework in Frameworks */,
|
83BBE9E720EB46BD00295997 /* MetalKit.framework in Frameworks */,
|
||||||
83BBE9E520EB46B900295997 /* Metal.framework in Frameworks */,
|
83BBE9E520EB46B900295997 /* Metal.framework in Frameworks */,
|
||||||
@@ -76,6 +84,7 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
050450AD276863B000AB6805 /* QuartzCore.framework in Frameworks */,
|
||||||
8309BDC6253CCCFE0045E2A1 /* AppKit.framework in Frameworks */,
|
8309BDC6253CCCFE0045E2A1 /* AppKit.framework in Frameworks */,
|
||||||
83BBE9EC20EB471700295997 /* MetalKit.framework in Frameworks */,
|
83BBE9EC20EB471700295997 /* MetalKit.framework in Frameworks */,
|
||||||
05318E0F274C397200A8DE2E /* GameController.framework in Frameworks */,
|
05318E0F274C397200A8DE2E /* GameController.framework in Frameworks */,
|
||||||
@@ -136,6 +145,8 @@
|
|||||||
83BBE9E320EB46B800295997 /* Frameworks */ = {
|
83BBE9E320EB46B800295997 /* Frameworks */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
050450AC276863B000AB6805 /* QuartzCore.framework */,
|
||||||
|
05A275432773BEA20084EF39 /* QuartzCore.framework */,
|
||||||
05318E0E274C397200A8DE2E /* GameController.framework */,
|
05318E0E274C397200A8DE2E /* GameController.framework */,
|
||||||
8309BDC5253CCCFE0045E2A1 /* AppKit.framework */,
|
8309BDC5253CCCFE0045E2A1 /* AppKit.framework */,
|
||||||
8309BD8E253CCAAA0045E2A1 /* UIKit.framework */,
|
8309BD8E253CCAAA0045E2A1 /* UIKit.framework */,
|
||||||
@@ -153,7 +164,9 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
5079822D257677DB0038A28D /* imgui_tables.cpp */,
|
5079822D257677DB0038A28D /* imgui_tables.cpp */,
|
||||||
|
05A2754027728F5B0084EF39 /* imgui_impl_metal.h */,
|
||||||
8309BDB5253CCC9D0045E2A1 /* imgui_impl_metal.mm */,
|
8309BDB5253CCC9D0045E2A1 /* imgui_impl_metal.mm */,
|
||||||
|
05A2754127728F5B0084EF39 /* imgui_impl_osx.h */,
|
||||||
8309BDB6253CCC9D0045E2A1 /* imgui_impl_osx.mm */,
|
8309BDB6253CCC9D0045E2A1 /* imgui_impl_osx.mm */,
|
||||||
83BBEA0420EB54E700295997 /* imconfig.h */,
|
83BBEA0420EB54E700295997 /* imconfig.h */,
|
||||||
83BBEA0320EB54E700295997 /* imgui.cpp */,
|
83BBEA0320EB54E700295997 /* imgui.cpp */,
|
||||||
@@ -268,9 +281,9 @@
|
|||||||
8309BDBB253CCCAD0045E2A1 /* imgui_impl_metal.mm in Sources */,
|
8309BDBB253CCCAD0045E2A1 /* imgui_impl_metal.mm in Sources */,
|
||||||
83BBEA0920EB54E700295997 /* imgui.cpp in Sources */,
|
83BBEA0920EB54E700295997 /* imgui.cpp in Sources */,
|
||||||
83BBEA0720EB54E700295997 /* imgui_demo.cpp in Sources */,
|
83BBEA0720EB54E700295997 /* imgui_demo.cpp in Sources */,
|
||||||
83BBEA0520EB54E700295997 /* imgui_draw.cpp in Sources */,
|
83BBEA0520EB54E700295997 /* imgui_draw.cpp in Sources */,
|
||||||
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */,
|
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */,
|
||||||
07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */,
|
07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */,
|
||||||
8309BDA5253CCC070045E2A1 /* main.mm in Sources */,
|
8309BDA5253CCC070045E2A1 /* main.mm in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@@ -281,10 +294,10 @@
|
|||||||
files = (
|
files = (
|
||||||
8309BDBE253CCCB60045E2A1 /* imgui_impl_metal.mm in Sources */,
|
8309BDBE253CCCB60045E2A1 /* imgui_impl_metal.mm in Sources */,
|
||||||
8309BDBF253CCCB60045E2A1 /* imgui_impl_osx.mm in Sources */,
|
8309BDBF253CCCB60045E2A1 /* imgui_impl_osx.mm in Sources */,
|
||||||
83BBEA0A20EB54E700295997 /* imgui.cpp in Sources */,
|
83BBEA0A20EB54E700295997 /* imgui.cpp in Sources */,
|
||||||
83BBEA0820EB54E700295997 /* imgui_demo.cpp in Sources */,
|
83BBEA0820EB54E700295997 /* imgui_demo.cpp in Sources */,
|
||||||
83BBEA0620EB54E700295997 /* imgui_draw.cpp in Sources */,
|
83BBEA0620EB54E700295997 /* imgui_draw.cpp in Sources */,
|
||||||
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */,
|
050450AB2768052600AB6805 /* imgui_tables.cpp in Sources */,
|
||||||
07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */,
|
07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */,
|
||||||
8309BDA8253CCC080045E2A1 /* main.mm in Sources */,
|
8309BDA8253CCC080045E2A1 /* main.mm in Sources */,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
// Dear ImGui: standalone example application for OSX + Metal.
|
// Dear ImGui: standalone example application for OSX + Metal.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
@@ -56,11 +60,21 @@
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Renderer backend
|
// Setup Renderer backend
|
||||||
ImGui_ImplMetal_Init(_device);
|
ImGui_ImplMetal_Init(_device);
|
||||||
|
|
||||||
@@ -191,6 +205,13 @@
|
|||||||
// Present
|
// Present
|
||||||
[commandBuffer presentDrawable:view.currentDrawable];
|
[commandBuffer presentDrawable:view.currentDrawable];
|
||||||
[commandBuffer commit];
|
[commandBuffer commit];
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)mtkView:(MTKView*)view drawableSizeWillChange:(CGSize)size
|
-(void)mtkView:(MTKView*)view drawableSizeWillChange:(CGSize)size
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
// Dear ImGui: standalone example application for OSX + OpenGL2, using legacy fixed pipeline
|
// Dear ImGui: standalone example application for OSX + OpenGL2, using legacy fixed pipeline
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#import <OpenGL/gl.h>
|
#import <OpenGL/gl.h>
|
||||||
@@ -43,11 +47,21 @@
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplOSX_Init(self);
|
ImGui_ImplOSX_Init(self);
|
||||||
ImGui_ImplOpenGL2_Init();
|
ImGui_ImplOpenGL2_Init();
|
||||||
@@ -132,6 +146,13 @@
|
|||||||
|
|
||||||
ImGui_ImplOpenGL2_RenderDrawData(draw_data);
|
ImGui_ImplOpenGL2_RenderDrawData(draw_data);
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
// Present
|
// Present
|
||||||
[[self openGLContext] flushBuffer];
|
[[self openGLContext] flushBuffer];
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
- You may also refer to our [Continuous Integration setup](https://github.com/ocornut/imgui/tree/master/.github/workflows) for Emscripten setup.
|
- You may also refer to our [Continuous Integration setup](https://github.com/ocornut/imgui/tree/master/.github/workflows) for Emscripten setup.
|
||||||
|
|
||||||
- Then build using `make` while in the `example_emscripten_wgpu/` directory.
|
- Then build using `make -f Makefile.emscripten` while in the `example_emscripten_wgpu/` directory.
|
||||||
|
|
||||||
- Requires recent Emscripten as WGPU is still a work-in-progress API.
|
- Requires recent Emscripten as WGPU is still a work-in-progress API.
|
||||||
|
|
||||||
|
|||||||
@@ -1,36 +1,65 @@
|
|||||||
// Dear ImGui: standalone example application for Emscripten, using GLFW + WebGPU
|
// Dear ImGui: standalone example application for Emscripten, using GLFW + WebGPU
|
||||||
// (Emscripten is a C++-to-javascript compiler, used to publish executables for the web. See https://emscripten.org/)
|
// (Emscripten is a C++-to-javascript compiler, used to publish executables for the web. See https://emscripten.org/)
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_glfw.h"
|
#include "imgui_impl_glfw.h"
|
||||||
#include "imgui_impl_wgpu.h"
|
#include "imgui_impl_wgpu.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
#include <emscripten.h>
|
#include <emscripten.h>
|
||||||
#include <emscripten/html5.h>
|
#include <emscripten/html5.h>
|
||||||
#include <emscripten/html5_webgpu.h>
|
#include <emscripten/html5_webgpu.h>
|
||||||
|
#endif
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <webgpu/webgpu.h>
|
#include <webgpu/webgpu.h>
|
||||||
#include <webgpu/webgpu_cpp.h>
|
#include <webgpu/webgpu_cpp.h>
|
||||||
|
|
||||||
|
// This example can also compile and run with Emscripten! See 'Makefile.emscripten' for details.
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
#include "../libs/emscripten/emscripten_mainloop_stub.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// Global WebGPU required states
|
// Global WebGPU required states
|
||||||
static WGPUDevice wgpu_device = nullptr;
|
static WGPUDevice wgpu_device = nullptr;
|
||||||
static WGPUSurface wgpu_surface = nullptr;
|
static WGPUSurface wgpu_surface = nullptr;
|
||||||
static WGPUSwapChain wgpu_swap_chain = nullptr;
|
static WGPUTextureFormat wgpu_preferred_fmt = WGPUTextureFormat_RGBA8Unorm;
|
||||||
static int wgpu_swap_chain_width = 0;
|
static WGPUSwapChain wgpu_swap_chain = nullptr;
|
||||||
static int wgpu_swap_chain_height = 0;
|
static int wgpu_swap_chain_width = 0;
|
||||||
|
static int wgpu_swap_chain_height = 0;
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
static void MainLoopStep(void* window);
|
|
||||||
static bool InitWGPU();
|
static bool InitWGPU();
|
||||||
static void print_glfw_error(int error, const char* description);
|
static void CreateSwapChain(int width, int height);
|
||||||
static void print_wgpu_error(WGPUErrorType error_type, const char* message, void*);
|
|
||||||
|
static void glfw_error_callback(int error, const char* description)
|
||||||
|
{
|
||||||
|
printf("GLFW Error %d: %s\n", error, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void wgpu_error_callback(WGPUErrorType error_type, const char* message, void*)
|
||||||
|
{
|
||||||
|
const char* error_type_lbl = "";
|
||||||
|
switch (error_type)
|
||||||
|
{
|
||||||
|
case WGPUErrorType_Validation: error_type_lbl = "Validation"; break;
|
||||||
|
case WGPUErrorType_OutOfMemory: error_type_lbl = "Out of memory"; break;
|
||||||
|
case WGPUErrorType_Unknown: error_type_lbl = "Unknown"; break;
|
||||||
|
case WGPUErrorType_DeviceLost: error_type_lbl = "Device lost"; break;
|
||||||
|
default: error_type_lbl = "Unknown";
|
||||||
|
}
|
||||||
|
printf("%s error: %s\n", error_type_lbl, message);
|
||||||
|
}
|
||||||
|
|
||||||
// Main code
|
// Main code
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
glfwSetErrorCallback(print_glfw_error);
|
glfwSetErrorCallback(glfw_error_callback);
|
||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@@ -38,11 +67,8 @@ int main(int, char**)
|
|||||||
// This needs to be done explicitly later.
|
// This needs to be done explicitly later.
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||||
GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+WebGPU example", nullptr, nullptr);
|
GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+WebGPU example", nullptr, nullptr);
|
||||||
if (!window)
|
if (window == nullptr)
|
||||||
{
|
|
||||||
glfwTerminate();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize the WebGPU environment
|
// Initialize the WebGPU environment
|
||||||
if (!InitWGPU())
|
if (!InitWGPU())
|
||||||
@@ -61,17 +87,21 @@ int main(int, char**)
|
|||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
|
||||||
// For an Emscripten build we are disabling file-system access, so let's not attempt to do a fopen() of the imgui.ini file.
|
|
||||||
// You may manually call LoadIniSettingsFromMemory() to load settings from your own storage.
|
|
||||||
io.IniFilename = nullptr;
|
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplGlfw_InitForOther(window, true);
|
ImGui_ImplGlfw_InitForOther(window, true);
|
||||||
ImGui_ImplWGPU_Init(wgpu_device, 3, WGPUTextureFormat_RGBA8Unorm, WGPUTextureFormat_Undefined);
|
#ifdef __EMSCRIPTEN__
|
||||||
|
ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback("#canvas");
|
||||||
|
#endif
|
||||||
|
ImGui_ImplWGPU_InitInfo init_info;
|
||||||
|
init_info.Device = wgpu_device;
|
||||||
|
init_info.NumFramesInFlight = 3;
|
||||||
|
init_info.RenderTargetFormat = wgpu_preferred_fmt;
|
||||||
|
init_info.DepthStencilFormat = WGPUTextureFormat_Undefined;
|
||||||
|
ImGui_ImplWGPU_Init(&init_info);
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - 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.
|
||||||
@@ -93,10 +123,117 @@ int main(int, char**)
|
|||||||
//IM_ASSERT(font != nullptr);
|
//IM_ASSERT(font != nullptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This function will directly return and exit the main function.
|
// Our state
|
||||||
// Make sure that no required objects get cleaned up.
|
bool show_demo_window = true;
|
||||||
// This way we can use the browsers 'requestAnimationFrame' to control the rendering.
|
bool show_another_window = false;
|
||||||
emscripten_set_main_loop_arg(MainLoopStep, window, 0, false);
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
|
||||||
|
// Main loop
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
// For an Emscripten build we are disabling file-system access, so let's not attempt to do a fopen() of the imgui.ini file.
|
||||||
|
// You may manually call LoadIniSettingsFromMemory() to load settings from your own storage.
|
||||||
|
io.IniFilename = nullptr;
|
||||||
|
EMSCRIPTEN_MAINLOOP_BEGIN
|
||||||
|
#else
|
||||||
|
while (!glfwWindowShouldClose(window))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
// Poll and handle events (inputs, window resize, etc.)
|
||||||
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||||
|
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
|
||||||
|
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
|
||||||
|
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||||
|
glfwPollEvents();
|
||||||
|
|
||||||
|
// React to changes in screen size
|
||||||
|
int width, height;
|
||||||
|
glfwGetFramebufferSize((GLFWwindow*)window, &width, &height);
|
||||||
|
if (width != wgpu_swap_chain_width && height != wgpu_swap_chain_height)
|
||||||
|
{
|
||||||
|
ImGui_ImplWGPU_InvalidateDeviceObjects();
|
||||||
|
CreateSwapChain(width, height);
|
||||||
|
ImGui_ImplWGPU_CreateDeviceObjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start the Dear ImGui frame
|
||||||
|
ImGui_ImplWGPU_NewFrame();
|
||||||
|
ImGui_ImplGlfw_NewFrame();
|
||||||
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
||||||
|
if (show_demo_window)
|
||||||
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
|
|
||||||
|
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to create a named window.
|
||||||
|
{
|
||||||
|
static float f = 0.0f;
|
||||||
|
static int counter = 0;
|
||||||
|
|
||||||
|
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
|
||||||
|
|
||||||
|
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
|
||||||
|
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
|
||||||
|
ImGui::Checkbox("Another Window", &show_another_window);
|
||||||
|
|
||||||
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
||||||
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
||||||
|
|
||||||
|
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||||
|
counter++;
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Text("counter = %d", counter);
|
||||||
|
|
||||||
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Show another simple window.
|
||||||
|
if (show_another_window)
|
||||||
|
{
|
||||||
|
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
|
||||||
|
ImGui::Text("Hello from another window!");
|
||||||
|
if (ImGui::Button("Close Me"))
|
||||||
|
show_another_window = false;
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rendering
|
||||||
|
ImGui::Render();
|
||||||
|
|
||||||
|
WGPURenderPassColorAttachment color_attachments = {};
|
||||||
|
color_attachments.loadOp = WGPULoadOp_Clear;
|
||||||
|
color_attachments.storeOp = WGPUStoreOp_Store;
|
||||||
|
color_attachments.clearValue = { clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w };
|
||||||
|
color_attachments.view = wgpuSwapChainGetCurrentTextureView(wgpu_swap_chain);
|
||||||
|
|
||||||
|
WGPURenderPassDescriptor render_pass_desc = {};
|
||||||
|
render_pass_desc.colorAttachmentCount = 1;
|
||||||
|
render_pass_desc.colorAttachments = &color_attachments;
|
||||||
|
render_pass_desc.depthStencilAttachment = nullptr;
|
||||||
|
|
||||||
|
WGPUCommandEncoderDescriptor enc_desc = {};
|
||||||
|
WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(wgpu_device, &enc_desc);
|
||||||
|
|
||||||
|
WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &render_pass_desc);
|
||||||
|
ImGui_ImplWGPU_RenderDrawData(ImGui::GetDrawData(), pass);
|
||||||
|
wgpuRenderPassEncoderEnd(pass);
|
||||||
|
|
||||||
|
WGPUCommandBufferDescriptor cmd_buffer_desc = {};
|
||||||
|
WGPUCommandBuffer cmd_buffer = wgpuCommandEncoderFinish(encoder, &cmd_buffer_desc);
|
||||||
|
WGPUQueue queue = wgpuDeviceGetQueue(wgpu_device);
|
||||||
|
wgpuQueueSubmit(queue, 1, &cmd_buffer);
|
||||||
|
}
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
EMSCRIPTEN_MAINLOOP_END;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
ImGui_ImplWGPU_Shutdown();
|
||||||
|
ImGui_ImplGlfw_Shutdown();
|
||||||
|
ImGui::DestroyContext();
|
||||||
|
|
||||||
|
glfwDestroyWindow(window);
|
||||||
|
glfwTerminate();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -107,7 +244,7 @@ static bool InitWGPU()
|
|||||||
if (!wgpu_device)
|
if (!wgpu_device)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
wgpuDeviceSetUncapturedErrorCallback(wgpu_device, print_wgpu_error, nullptr);
|
wgpuDeviceSetUncapturedErrorCallback(wgpu_device, wgpu_error_callback, nullptr);
|
||||||
|
|
||||||
// Use C++ wrapper due to misbehavior in Emscripten.
|
// Use C++ wrapper due to misbehavior in Emscripten.
|
||||||
// Some offset computation for wgpuInstanceCreateSurface in JavaScript
|
// Some offset computation for wgpuInstanceCreateSurface in JavaScript
|
||||||
@@ -118,129 +255,26 @@ static bool InitWGPU()
|
|||||||
wgpu::SurfaceDescriptor surface_desc = {};
|
wgpu::SurfaceDescriptor surface_desc = {};
|
||||||
surface_desc.nextInChain = &html_surface_desc;
|
surface_desc.nextInChain = &html_surface_desc;
|
||||||
|
|
||||||
// Use 'null' instance
|
wgpu::Instance instance = wgpuCreateInstance(nullptr);
|
||||||
wgpu::Instance instance = {};
|
wgpu::Surface surface = instance.CreateSurface(&surface_desc);
|
||||||
wgpu_surface = instance.CreateSurface(&surface_desc).Release();
|
wgpu::Adapter adapter = {};
|
||||||
|
wgpu_preferred_fmt = (WGPUTextureFormat)surface.GetPreferredFormat(adapter);
|
||||||
|
wgpu_surface = surface.MoveToCHandle();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MainLoopStep(void* window)
|
static void CreateSwapChain(int width, int height)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
if (wgpu_swap_chain)
|
||||||
|
wgpuSwapChainRelease(wgpu_swap_chain);
|
||||||
glfwPollEvents();
|
wgpu_swap_chain_width = width;
|
||||||
|
wgpu_swap_chain_height = height;
|
||||||
int width, height;
|
WGPUSwapChainDescriptor swap_chain_desc = {};
|
||||||
glfwGetFramebufferSize((GLFWwindow*)window, &width, &height);
|
swap_chain_desc.usage = WGPUTextureUsage_RenderAttachment;
|
||||||
|
swap_chain_desc.format = wgpu_preferred_fmt;
|
||||||
// React to changes in screen size
|
swap_chain_desc.width = width;
|
||||||
if (width != wgpu_swap_chain_width && height != wgpu_swap_chain_height)
|
swap_chain_desc.height = height;
|
||||||
{
|
swap_chain_desc.presentMode = WGPUPresentMode_Fifo;
|
||||||
ImGui_ImplWGPU_InvalidateDeviceObjects();
|
wgpu_swap_chain = wgpuDeviceCreateSwapChain(wgpu_device, wgpu_surface, &swap_chain_desc);
|
||||||
if (wgpu_swap_chain)
|
|
||||||
wgpuSwapChainRelease(wgpu_swap_chain);
|
|
||||||
wgpu_swap_chain_width = width;
|
|
||||||
wgpu_swap_chain_height = height;
|
|
||||||
WGPUSwapChainDescriptor swap_chain_desc = {};
|
|
||||||
swap_chain_desc.usage = WGPUTextureUsage_RenderAttachment;
|
|
||||||
swap_chain_desc.format = WGPUTextureFormat_RGBA8Unorm;
|
|
||||||
swap_chain_desc.width = width;
|
|
||||||
swap_chain_desc.height = height;
|
|
||||||
swap_chain_desc.presentMode = WGPUPresentMode_Fifo;
|
|
||||||
wgpu_swap_chain = wgpuDeviceCreateSwapChain(wgpu_device, wgpu_surface, &swap_chain_desc);
|
|
||||||
ImGui_ImplWGPU_CreateDeviceObjects();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start the Dear ImGui frame
|
|
||||||
ImGui_ImplWGPU_NewFrame();
|
|
||||||
ImGui_ImplGlfw_NewFrame();
|
|
||||||
ImGui::NewFrame();
|
|
||||||
|
|
||||||
// Our state
|
|
||||||
// (we use static, which essentially makes the variable globals, as a convenience to keep the example code easy to follow)
|
|
||||||
static bool show_demo_window = true;
|
|
||||||
static bool show_another_window = false;
|
|
||||||
static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
|
||||||
|
|
||||||
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
|
||||||
if (show_demo_window)
|
|
||||||
ImGui::ShowDemoWindow(&show_demo_window);
|
|
||||||
|
|
||||||
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to create a named window.
|
|
||||||
{
|
|
||||||
static float f = 0.0f;
|
|
||||||
static int counter = 0;
|
|
||||||
|
|
||||||
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
|
|
||||||
|
|
||||||
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
|
|
||||||
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
|
|
||||||
ImGui::Checkbox("Another Window", &show_another_window);
|
|
||||||
|
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
|
||||||
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
|
||||||
|
|
||||||
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
|
||||||
counter++;
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::Text("counter = %d", counter);
|
|
||||||
|
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
|
||||||
ImGui::End();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Show another simple window.
|
|
||||||
if (show_another_window)
|
|
||||||
{
|
|
||||||
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
|
|
||||||
ImGui::Text("Hello from another window!");
|
|
||||||
if (ImGui::Button("Close Me"))
|
|
||||||
show_another_window = false;
|
|
||||||
ImGui::End();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rendering
|
|
||||||
ImGui::Render();
|
|
||||||
|
|
||||||
WGPURenderPassColorAttachment color_attachments = {};
|
|
||||||
color_attachments.loadOp = WGPULoadOp_Clear;
|
|
||||||
color_attachments.storeOp = WGPUStoreOp_Store;
|
|
||||||
color_attachments.clearValue = { clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w };
|
|
||||||
color_attachments.view = wgpuSwapChainGetCurrentTextureView(wgpu_swap_chain);
|
|
||||||
WGPURenderPassDescriptor render_pass_desc = {};
|
|
||||||
render_pass_desc.colorAttachmentCount = 1;
|
|
||||||
render_pass_desc.colorAttachments = &color_attachments;
|
|
||||||
render_pass_desc.depthStencilAttachment = nullptr;
|
|
||||||
|
|
||||||
WGPUCommandEncoderDescriptor enc_desc = {};
|
|
||||||
WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(wgpu_device, &enc_desc);
|
|
||||||
|
|
||||||
WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &render_pass_desc);
|
|
||||||
ImGui_ImplWGPU_RenderDrawData(ImGui::GetDrawData(), pass);
|
|
||||||
wgpuRenderPassEncoderEnd(pass);
|
|
||||||
|
|
||||||
WGPUCommandBufferDescriptor cmd_buffer_desc = {};
|
|
||||||
WGPUCommandBuffer cmd_buffer = wgpuCommandEncoderFinish(encoder, &cmd_buffer_desc);
|
|
||||||
WGPUQueue queue = wgpuDeviceGetQueue(wgpu_device);
|
|
||||||
wgpuQueueSubmit(queue, 1, &cmd_buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void print_glfw_error(int error, const char* description)
|
|
||||||
{
|
|
||||||
printf("GLFW Error %d: %s\n", error, description);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void print_wgpu_error(WGPUErrorType error_type, const char* message, void*)
|
|
||||||
{
|
|
||||||
const char* error_type_lbl = "";
|
|
||||||
switch (error_type)
|
|
||||||
{
|
|
||||||
case WGPUErrorType_Validation: error_type_lbl = "Validation"; break;
|
|
||||||
case WGPUErrorType_OutOfMemory: error_type_lbl = "Out of memory"; break;
|
|
||||||
case WGPUErrorType_Unknown: error_type_lbl = "Unknown"; break;
|
|
||||||
case WGPUErrorType_DeviceLost: error_type_lbl = "Device lost"; break;
|
|
||||||
default: error_type_lbl = "Unknown";
|
|
||||||
}
|
|
||||||
printf("%s error: %s\n", error_type_lbl, message);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui
|
|||||||
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
|
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
|
||||||
|
|
||||||
LIBS = -framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore
|
LIBS = -framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore
|
||||||
LIBS += -L/usr/local/lib -L/opt/homebrew/lib
|
LIBS += -L/usr/local/lib -L/opt/homebrew/lib -L/opt/local/lib
|
||||||
LIBS += -lglfw
|
LIBS += -lglfw
|
||||||
|
|
||||||
CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -I/usr/local/include -I/opt/homebrew/include
|
CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -I/usr/local/include -I/opt/homebrew/include -I/opt/local/include
|
||||||
CXXFLAGS += -Wall -Wformat
|
CXXFLAGS += -Wall -Wformat
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
// Dear ImGui: standalone example application for GLFW + Metal, using programmable pipeline
|
// Dear ImGui: standalone example application for GLFW + Metal, using programmable pipeline
|
||||||
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_glfw.h"
|
#include "imgui_impl_glfw.h"
|
||||||
@@ -29,11 +33,21 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
|
||||||
// Setup style
|
// Setup style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - 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.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
@@ -65,7 +79,7 @@ int main(int, char**)
|
|||||||
id <MTLCommandQueue> commandQueue = [device newCommandQueue];
|
id <MTLCommandQueue> commandQueue = [device newCommandQueue];
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
ImGui_ImplGlfw_InitForOther(window, true);
|
||||||
ImGui_ImplMetal_Init(device);
|
ImGui_ImplMetal_Init(device);
|
||||||
|
|
||||||
NSWindow *nswin = glfwGetCocoaWindow(window);
|
NSWindow *nswin = glfwGetCocoaWindow(window);
|
||||||
@@ -153,6 +167,13 @@ int main(int, char**)
|
|||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder);
|
ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder);
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
[renderEncoder popDebugGroup];
|
[renderEncoder popDebugGroup];
|
||||||
[renderEncoder endEncoding];
|
[renderEncoder endEncoding];
|
||||||
|
|
||||||
|
|||||||
@@ -5,4 +5,4 @@
|
|||||||
@set SOURCES=main.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp
|
@set SOURCES=main.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp
|
||||||
@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
|
@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
|
||||||
mkdir %OUT_DIR%
|
mkdir %OUT_DIR%
|
||||||
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
|
|||||||
@@ -91,6 +91,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -105,6 +106,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -122,6 +124,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -142,6 +145,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
// Dear ImGui: standalone example application for GLFW + OpenGL2, using legacy fixed pipeline
|
// Dear ImGui: standalone example application for GLFW + OpenGL2, using legacy fixed pipeline
|
||||||
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
// **Prefer using the code in the example_glfw_opengl2/ folder**
|
// **Prefer using the code in the example_glfw_opengl2/ folder**
|
||||||
@@ -48,11 +52,23 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||||
ImGui_ImplOpenGL2_Init();
|
ImGui_ImplOpenGL2_Init();
|
||||||
@@ -146,6 +162,17 @@ int main(int, char**)
|
|||||||
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
||||||
//glUseProgram(last_program);
|
//glUseProgram(last_program);
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
|
||||||
|
// For this specific demo app we could also call glfwMakeContextCurrent(window) directly)
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
GLFWwindow* backup_current_context = glfwGetCurrentContext();
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
glfwMakeContextCurrent(backup_current_context);
|
||||||
|
}
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ endif
|
|||||||
CPPFLAGS += -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
|
CPPFLAGS += -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
|
||||||
#CPPFLAGS += -g
|
#CPPFLAGS += -g
|
||||||
CPPFLAGS += -Wall -Wformat -Os $(EMS)
|
CPPFLAGS += -Wall -Wformat -Os $(EMS)
|
||||||
# LDFLAGS += --shell-file ../libs/emscripten/shell_minimal.html
|
LDFLAGS += --shell-file ../libs/emscripten/shell_minimal.html
|
||||||
LDFLAGS += $(EMS)
|
LDFLAGS += $(EMS)
|
||||||
|
|
||||||
##---------------------------------------------------------------------
|
##---------------------------------------------------------------------
|
||||||
|
|||||||
@@ -5,4 +5,4 @@
|
|||||||
@set SOURCES=main.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp
|
@set SOURCES=main.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp
|
||||||
@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
|
@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
|
||||||
mkdir %OUT_DIR%
|
mkdir %OUT_DIR%
|
||||||
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
|
|||||||
@@ -91,6 +91,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -105,6 +106,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -122,6 +124,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -142,6 +145,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
// Dear ImGui: standalone example application for GLFW + OpenGL 3, using programmable pipeline
|
// Dear ImGui: standalone example application for GLFW + OpenGL 3, using programmable pipeline
|
||||||
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_glfw.h"
|
#include "imgui_impl_glfw.h"
|
||||||
@@ -73,13 +77,28 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback("#canvas");
|
||||||
|
#endif
|
||||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
@@ -172,6 +191,17 @@ int main(int, char**)
|
|||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
|
||||||
|
// For this specific demo app we could also call glfwMakeContextCurrent(window) directly)
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
GLFWwindow* backup_current_context = glfwGetCurrentContext();
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
glfwMakeContextCurrent(backup_current_context);
|
||||||
|
}
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
}
|
}
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
@set OUT_DIR=Debug
|
@set OUT_DIR=Debug
|
||||||
mkdir %OUT_DIR%
|
mkdir %OUT_DIR%
|
||||||
cl /nologo /Zi /MD %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
cl /nologo /Zi /MD /utf-8 %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
|
|
||||||
@set OUT_DIR=Release
|
@set OUT_DIR=Release
|
||||||
mkdir %OUT_DIR%
|
mkdir %OUT_DIR%
|
||||||
cl /nologo /Zi /MD /Ox /Oi %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
cl /nologo /Zi /MD /utf-8 /Ox /Oi %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
@set OUT_DIR=Debug
|
@set OUT_DIR=Debug
|
||||||
mkdir %OUT_DIR%
|
mkdir %OUT_DIR%
|
||||||
cl /nologo /Zi /MD %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
cl /nologo /Zi /MD /utf-8 %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
|
|
||||||
@set OUT_DIR=Release
|
@set OUT_DIR=Release
|
||||||
mkdir %OUT_DIR%
|
mkdir %OUT_DIR%
|
||||||
cl /nologo /Zi /MD /Ox /Oi %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
cl /nologo /Zi /MD /utf-8 /Ox /Oi %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
|
|||||||
@@ -92,6 +92,7 @@
|
|||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -107,6 +108,7 @@
|
|||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -125,6 +127,7 @@
|
|||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
<PreprocessorDefinitions>ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -146,6 +149,7 @@
|
|||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
<PreprocessorDefinitions>ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>ImTextureID=ImU64;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
// Dear ImGui: standalone example application for Glfw + Vulkan
|
// Dear ImGui: standalone example application for Glfw + Vulkan
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app.
|
// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app.
|
||||||
// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h.
|
// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h.
|
||||||
@@ -27,9 +31,9 @@
|
|||||||
#pragma comment(lib, "legacy_stdio_definitions")
|
#pragma comment(lib, "legacy_stdio_definitions")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define IMGUI_UNLIMITED_FRAME_RATE
|
//#define APP_USE_UNLIMITED_FRAME_RATE
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define IMGUI_VULKAN_DEBUG_REPORT
|
#define APP_USE_VULKAN_DEBUG_REPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
@@ -60,14 +64,14 @@ static void check_vk_result(VkResult err)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
||||||
static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData)
|
static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData)
|
||||||
{
|
{
|
||||||
(void)flags; (void)object; (void)location; (void)messageCode; (void)pUserData; (void)pLayerPrefix; // Unused arguments
|
(void)flags; (void)object; (void)location; (void)messageCode; (void)pUserData; (void)pLayerPrefix; // Unused arguments
|
||||||
fprintf(stderr, "[vulkan] Debug report from ObjectType: %i\nMessage: %s\n\n", objectType, pMessage);
|
fprintf(stderr, "[vulkan] Debug report from ObjectType: %i\nMessage: %s\n\n", objectType, pMessage);
|
||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
}
|
}
|
||||||
#endif // IMGUI_VULKAN_DEBUG_REPORT
|
#endif // APP_USE_VULKAN_DEBUG_REPORT
|
||||||
|
|
||||||
static bool IsExtensionAvailable(const ImVector<VkExtensionProperties>& properties, const char* extension)
|
static bool IsExtensionAvailable(const ImVector<VkExtensionProperties>& properties, const char* extension)
|
||||||
{
|
{
|
||||||
@@ -99,6 +103,10 @@ static VkPhysicalDevice SetupVulkan_SelectPhysicalDevice()
|
|||||||
if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
|
if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use first GPU (Integrated) is a Discrete one is not available.
|
||||||
|
if (gpu_count > 0)
|
||||||
|
return gpus[0];
|
||||||
return VK_NULL_HANDLE;
|
return VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +139,7 @@ static void SetupVulkan(ImVector<const char*> instance_extensions)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Enabling validation layers
|
// Enabling validation layers
|
||||||
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
||||||
const char* layers[] = { "VK_LAYER_KHRONOS_validation" };
|
const char* layers[] = { "VK_LAYER_KHRONOS_validation" };
|
||||||
create_info.enabledLayerCount = 1;
|
create_info.enabledLayerCount = 1;
|
||||||
create_info.ppEnabledLayerNames = layers;
|
create_info.ppEnabledLayerNames = layers;
|
||||||
@@ -145,7 +153,7 @@ static void SetupVulkan(ImVector<const char*> instance_extensions)
|
|||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
|
|
||||||
// Setup the debug report callback
|
// Setup the debug report callback
|
||||||
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
||||||
auto vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT");
|
auto vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT");
|
||||||
IM_ASSERT(vkCreateDebugReportCallbackEXT != nullptr);
|
IM_ASSERT(vkCreateDebugReportCallbackEXT != nullptr);
|
||||||
VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
|
VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
|
||||||
@@ -211,25 +219,17 @@ static void SetupVulkan(ImVector<const char*> instance_extensions)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create Descriptor Pool
|
// Create Descriptor Pool
|
||||||
|
// The example only requires a single combined image sampler descriptor for the font image and only uses one descriptor set (for that)
|
||||||
|
// If you wish to load e.g. additional textures you may need to alter pools sizes.
|
||||||
{
|
{
|
||||||
VkDescriptorPoolSize pool_sizes[] =
|
VkDescriptorPoolSize pool_sizes[] =
|
||||||
{
|
{
|
||||||
{ VK_DESCRIPTOR_TYPE_SAMPLER, 1000 },
|
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1 },
|
||||||
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1000 }
|
|
||||||
};
|
};
|
||||||
VkDescriptorPoolCreateInfo pool_info = {};
|
VkDescriptorPoolCreateInfo pool_info = {};
|
||||||
pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
||||||
pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
|
pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
|
||||||
pool_info.maxSets = 1000 * IM_ARRAYSIZE(pool_sizes);
|
pool_info.maxSets = 1;
|
||||||
pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes);
|
pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes);
|
||||||
pool_info.pPoolSizes = pool_sizes;
|
pool_info.pPoolSizes = pool_sizes;
|
||||||
err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool);
|
err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool);
|
||||||
@@ -258,7 +258,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
|
|||||||
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace);
|
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace);
|
||||||
|
|
||||||
// Select Present Mode
|
// Select Present Mode
|
||||||
#ifdef IMGUI_UNLIMITED_FRAME_RATE
|
#ifdef APP_USE_UNLIMITED_FRAME_RATE
|
||||||
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR };
|
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR };
|
||||||
#else
|
#else
|
||||||
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR };
|
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR };
|
||||||
@@ -275,11 +275,11 @@ static void CleanupVulkan()
|
|||||||
{
|
{
|
||||||
vkDestroyDescriptorPool(g_Device, g_DescriptorPool, g_Allocator);
|
vkDestroyDescriptorPool(g_Device, g_DescriptorPool, g_Allocator);
|
||||||
|
|
||||||
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
||||||
// Remove the debug report callback
|
// Remove the debug report callback
|
||||||
auto vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT");
|
auto vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT");
|
||||||
vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator);
|
vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator);
|
||||||
#endif // IMGUI_VULKAN_DEBUG_REPORT
|
#endif // APP_USE_VULKAN_DEBUG_REPORT
|
||||||
|
|
||||||
vkDestroyDevice(g_Device, g_Allocator);
|
vkDestroyDevice(g_Device, g_Allocator);
|
||||||
vkDestroyInstance(g_Instance, g_Allocator);
|
vkDestroyInstance(g_Instance, g_Allocator);
|
||||||
@@ -376,7 +376,7 @@ static void FramePresent(ImGui_ImplVulkanH_Window* wd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->ImageCount; // Now we can use the next set of semaphores
|
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->SemaphoreCount; // Now we can use the next set of semaphores
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main code
|
// Main code
|
||||||
@@ -419,11 +419,23 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplGlfw_InitForVulkan(window, true);
|
ImGui_ImplGlfw_InitForVulkan(window, true);
|
||||||
ImGui_ImplVulkan_InitInfo init_info = {};
|
ImGui_ImplVulkan_InitInfo init_info = {};
|
||||||
@@ -434,13 +446,14 @@ int main(int, char**)
|
|||||||
init_info.Queue = g_Queue;
|
init_info.Queue = g_Queue;
|
||||||
init_info.PipelineCache = g_PipelineCache;
|
init_info.PipelineCache = g_PipelineCache;
|
||||||
init_info.DescriptorPool = g_DescriptorPool;
|
init_info.DescriptorPool = g_DescriptorPool;
|
||||||
|
init_info.RenderPass = wd->RenderPass;
|
||||||
init_info.Subpass = 0;
|
init_info.Subpass = 0;
|
||||||
init_info.MinImageCount = g_MinImageCount;
|
init_info.MinImageCount = g_MinImageCount;
|
||||||
init_info.ImageCount = wd->ImageCount;
|
init_info.ImageCount = wd->ImageCount;
|
||||||
init_info.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
|
init_info.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
init_info.Allocator = g_Allocator;
|
init_info.Allocator = g_Allocator;
|
||||||
init_info.CheckVkResultFn = check_vk_result;
|
init_info.CheckVkResultFn = check_vk_result;
|
||||||
ImGui_ImplVulkan_Init(&init_info, wd->RenderPass);
|
ImGui_ImplVulkan_Init(&init_info);
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - 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.
|
||||||
@@ -458,36 +471,6 @@ int main(int, char**)
|
|||||||
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, nullptr, io.Fonts->GetGlyphRangesJapanese());
|
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, nullptr, io.Fonts->GetGlyphRangesJapanese());
|
||||||
//IM_ASSERT(font != nullptr);
|
//IM_ASSERT(font != nullptr);
|
||||||
|
|
||||||
// Upload Fonts
|
|
||||||
{
|
|
||||||
// Use any command queue
|
|
||||||
VkCommandPool command_pool = wd->Frames[wd->FrameIndex].CommandPool;
|
|
||||||
VkCommandBuffer command_buffer = wd->Frames[wd->FrameIndex].CommandBuffer;
|
|
||||||
|
|
||||||
err = vkResetCommandPool(g_Device, command_pool, 0);
|
|
||||||
check_vk_result(err);
|
|
||||||
VkCommandBufferBeginInfo begin_info = {};
|
|
||||||
begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
|
|
||||||
begin_info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
|
|
||||||
err = vkBeginCommandBuffer(command_buffer, &begin_info);
|
|
||||||
check_vk_result(err);
|
|
||||||
|
|
||||||
ImGui_ImplVulkan_CreateFontsTexture(command_buffer);
|
|
||||||
|
|
||||||
VkSubmitInfo end_info = {};
|
|
||||||
end_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
|
||||||
end_info.commandBufferCount = 1;
|
|
||||||
end_info.pCommandBuffers = &command_buffer;
|
|
||||||
err = vkEndCommandBuffer(command_buffer);
|
|
||||||
check_vk_result(err);
|
|
||||||
err = vkQueueSubmit(g_Queue, 1, &end_info, VK_NULL_HANDLE);
|
|
||||||
check_vk_result(err);
|
|
||||||
|
|
||||||
err = vkDeviceWaitIdle(g_Device);
|
|
||||||
check_vk_result(err);
|
|
||||||
ImGui_ImplVulkan_DestroyFontUploadObjects();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Our state
|
// Our state
|
||||||
bool show_demo_window = true;
|
bool show_demo_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
@@ -561,17 +544,25 @@ int main(int, char**)
|
|||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImDrawData* draw_data = ImGui::GetDrawData();
|
ImDrawData* main_draw_data = ImGui::GetDrawData();
|
||||||
const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f);
|
const bool main_is_minimized = (main_draw_data->DisplaySize.x <= 0.0f || main_draw_data->DisplaySize.y <= 0.0f);
|
||||||
if (!is_minimized)
|
wd->ClearValue.color.float32[0] = clear_color.x * clear_color.w;
|
||||||
|
wd->ClearValue.color.float32[1] = clear_color.y * clear_color.w;
|
||||||
|
wd->ClearValue.color.float32[2] = clear_color.z * clear_color.w;
|
||||||
|
wd->ClearValue.color.float32[3] = clear_color.w;
|
||||||
|
if (!main_is_minimized)
|
||||||
|
FrameRender(wd, main_draw_data);
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
{
|
{
|
||||||
wd->ClearValue.color.float32[0] = clear_color.x * clear_color.w;
|
ImGui::UpdatePlatformWindows();
|
||||||
wd->ClearValue.color.float32[1] = clear_color.y * clear_color.w;
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
wd->ClearValue.color.float32[2] = clear_color.z * clear_color.w;
|
|
||||||
wd->ClearValue.color.float32[3] = clear_color.w;
|
|
||||||
FrameRender(wd, draw_data);
|
|
||||||
FramePresent(wd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Present Main Platform Window
|
||||||
|
if (!main_is_minimized)
|
||||||
|
FramePresent(wd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
|
|||||||
@@ -91,6 +91,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>$(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -105,6 +106,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>$(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -122,6 +124,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>$(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -142,6 +145,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>$(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
// Dear ImGui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline
|
// Dear ImGui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// !!! GLUT/FreeGLUT IS OBSOLETE PREHISTORIC SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
|
// !!! GLUT/FreeGLUT IS OBSOLETE PREHISTORIC SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
|
||||||
// !!! If someone or something is teaching you GLUT today, you are being abused. Please show some resistance. !!!
|
// !!! If someone or something is teaching you GLUT today, you are being abused. Please show some resistance. !!!
|
||||||
@@ -57,6 +61,7 @@ int main(int argc, char** argv)
|
|||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
@@ -74,7 +79,6 @@ int main(int argc, char** argv)
|
|||||||
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||||
ImGui_ImplGLUT_InstallFuncs();
|
ImGui_ImplGLUT_InstallFuncs();
|
||||||
|
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - 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.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
@@ -107,6 +111,8 @@ void MainLoopStep()
|
|||||||
// Start the Dear ImGui frame
|
// Start the Dear ImGui frame
|
||||||
ImGui_ImplOpenGL2_NewFrame();
|
ImGui_ImplOpenGL2_NewFrame();
|
||||||
ImGui_ImplGLUT_NewFrame();
|
ImGui_ImplGLUT_NewFrame();
|
||||||
|
ImGui::NewFrame();
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
||||||
if (show_demo_window)
|
if (show_demo_window)
|
||||||
@@ -147,7 +153,6 @@ void MainLoopStep()
|
|||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
|
glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y);
|
||||||
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
|
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
|
||||||
mkdir Debug
|
mkdir Debug
|
||||||
cl /nologo /Zi /MD /I ..\.. %* *.cpp ..\..\*.cpp /FeDebug/example_null.exe /FoDebug/ /link gdi32.lib shell32.lib imm32.lib
|
cl /nologo /Zi /MD /utf-8 /I ..\.. %* *.cpp ..\..\*.cpp /FeDebug/example_null.exe /FoDebug/ /link gdi32.lib shell32.lib imm32.lib
|
||||||
|
|||||||
@@ -5,4 +5,4 @@
|
|||||||
@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_dx11.cpp ..\..\imgui*.cpp
|
@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_dx11.cpp ..\..\imgui*.cpp
|
||||||
@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib shell32.lib
|
@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib shell32.lib
|
||||||
mkdir %OUT_DIR%
|
mkdir %OUT_DIR%
|
||||||
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
|
cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
|
||||||
|
|||||||
@@ -92,6 +92,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -106,6 +107,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -123,6 +125,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -143,6 +146,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
// Dear ImGui: standalone example application for SDL2 + DirectX 11
|
// Dear ImGui: standalone example application for SDL2 + DirectX 11
|
||||||
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_sdl2.h"
|
#include "imgui_impl_sdl2.h"
|
||||||
@@ -43,6 +47,12 @@ int main(int, char**)
|
|||||||
// Setup window
|
// Setup window
|
||||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+DirectX11 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+DirectX11 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
|
||||||
|
if (window == nullptr)
|
||||||
|
{
|
||||||
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_SysWMinfo wmInfo;
|
SDL_SysWMinfo wmInfo;
|
||||||
SDL_VERSION(&wmInfo.version);
|
SDL_VERSION(&wmInfo.version);
|
||||||
SDL_GetWindowWMInfo(window, &wmInfo);
|
SDL_GetWindowWMInfo(window, &wmInfo);
|
||||||
@@ -61,11 +71,23 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplSDL2_InitForD3D(window);
|
ImGui_ImplSDL2_InitForD3D(window);
|
||||||
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
|
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
|
||||||
@@ -166,6 +188,13 @@ int main(int, char**)
|
|||||||
g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
|
g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
|
||||||
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
g_pSwapChain->Present(1, 0); // Present with vsync
|
g_pSwapChain->Present(1, 0); // Present with vsync
|
||||||
//g_pSwapChain->Present(0, 0); // Present without vsync
|
//g_pSwapChain->Present(0, 0); // Present without vsync
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
// Dear ImGui: standalone example application for SDL2 + Metal
|
// Dear ImGui: standalone example application for SDL2 + Metal
|
||||||
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_sdl2.h"
|
#include "imgui_impl_sdl2.h"
|
||||||
@@ -20,11 +24,21 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
|
||||||
// Setup style
|
// Setup style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - 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.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
@@ -164,6 +178,13 @@ int main(int, char**)
|
|||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder);
|
ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder);
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
[renderEncoder popDebugGroup];
|
[renderEncoder popDebugGroup];
|
||||||
[renderEncoder endEncoding];
|
[renderEncoder endEncoding];
|
||||||
|
|
||||||
|
|||||||
@@ -5,4 +5,4 @@
|
|||||||
@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\imgui*.cpp
|
@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\imgui*.cpp
|
||||||
@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib shell32.lib
|
@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib shell32.lib
|
||||||
mkdir %OUT_DIR%
|
mkdir %OUT_DIR%
|
||||||
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
|
cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
|
||||||
|
|||||||
@@ -91,6 +91,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -105,6 +106,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -122,6 +124,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -142,6 +145,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
// Dear ImGui: standalone example application for SDL2 + OpenGL
|
// Dear ImGui: standalone example application for SDL2 + OpenGL
|
||||||
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
// **Prefer using the code in the example_sdl2_opengl3/ folder**
|
// **Prefer using the code in the example_sdl2_opengl3/ folder**
|
||||||
@@ -37,6 +41,12 @@ int main(int, char**)
|
|||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
||||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
|
||||||
|
if (window == nullptr)
|
||||||
|
{
|
||||||
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_GLContext gl_context = SDL_GL_CreateContext(window);
|
SDL_GLContext gl_context = SDL_GL_CreateContext(window);
|
||||||
SDL_GL_MakeCurrent(window, gl_context);
|
SDL_GL_MakeCurrent(window, gl_context);
|
||||||
SDL_GL_SetSwapInterval(1); // Enable vsync
|
SDL_GL_SetSwapInterval(1); // Enable vsync
|
||||||
@@ -47,11 +57,23 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
||||||
ImGui_ImplOpenGL2_Init();
|
ImGui_ImplOpenGL2_Init();
|
||||||
@@ -145,6 +167,19 @@ int main(int, char**)
|
|||||||
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
|
||||||
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
|
||||||
|
// For this specific demo app we could also call SDL_GL_MakeCurrent(window, gl_context) directly)
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();
|
||||||
|
SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext();
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
SDL_GL_MakeCurrent(backup_current_window, backup_current_context);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ Use the provided project file (.vcxproj). Add to solution (imgui_examples.sln) i
|
|||||||
Use build_win32.bat or directly:
|
Use build_win32.bat or directly:
|
||||||
```
|
```
|
||||||
set SDL2_DIR=path_to_your_sdl2_folder
|
set SDL2_DIR=path_to_your_sdl2_folder
|
||||||
cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console
|
cl /Zi /MD /utf-8 /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console
|
||||||
# ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries
|
# ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries
|
||||||
# or for 64-bit:
|
# or for 64-bit:
|
||||||
cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console
|
cl /Zi /MD /utf-8 /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console
|
||||||
```
|
```
|
||||||
|
|
||||||
## Linux and similar Unixes
|
## Linux and similar Unixes
|
||||||
|
|||||||
@@ -5,4 +5,4 @@
|
|||||||
@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp
|
@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp
|
||||||
@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib shell32.lib
|
@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib shell32.lib
|
||||||
mkdir %OUT_DIR%
|
mkdir %OUT_DIR%
|
||||||
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
|
cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
|
||||||
|
|||||||
@@ -91,6 +91,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -105,6 +106,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -122,6 +124,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -142,6 +145,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
// Dear ImGui: standalone example application for SDL2 + OpenGL
|
// Dear ImGui: standalone example application for SDL2 + OpenGL
|
||||||
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_sdl2.h"
|
#include "imgui_impl_sdl2.h"
|
||||||
@@ -64,6 +68,12 @@ int main(int, char**)
|
|||||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL3 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL3 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
|
||||||
|
if (window == nullptr)
|
||||||
|
{
|
||||||
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_GLContext gl_context = SDL_GL_CreateContext(window);
|
SDL_GLContext gl_context = SDL_GL_CreateContext(window);
|
||||||
SDL_GL_MakeCurrent(window, gl_context);
|
SDL_GL_MakeCurrent(window, gl_context);
|
||||||
SDL_GL_SetSwapInterval(1); // Enable vsync
|
SDL_GL_SetSwapInterval(1); // Enable vsync
|
||||||
@@ -74,11 +84,23 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
||||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||||
@@ -179,6 +201,19 @@ int main(int, char**)
|
|||||||
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
|
||||||
|
// For this specific demo app we could also call SDL_GL_MakeCurrent(window, gl_context) directly)
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();
|
||||||
|
SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext();
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
SDL_GL_MakeCurrent(backup_current_window, backup_current_context);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
}
|
}
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
|
|
||||||
# How to Build
|
|
||||||
|
|
||||||
- On Windows with Visual Studio's CLI
|
|
||||||
|
|
||||||
```
|
|
||||||
set SDL2_DIR=path_to_your_sdl2_folder
|
|
||||||
cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_sdlrenderer.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_sdlrenderer.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib /subsystem:console
|
|
||||||
# ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries
|
|
||||||
# or for 64-bit:
|
|
||||||
cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_sdlrenderer.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_sdlrenderer.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib /subsystem:console
|
|
||||||
```
|
|
||||||
|
|
||||||
- On Linux and similar Unixes
|
|
||||||
|
|
||||||
```
|
|
||||||
c++ `sdl2-config --cflags` -I .. -I ../.. main.cpp ../../backends/imgui_impl_sdl2.cpp ../../backends/imgui_impl_sdlrenderer.cpp ../../imgui*.cpp `sdl2-config --libs` -lGL
|
|
||||||
```
|
|
||||||
|
|
||||||
- On Mac OS X
|
|
||||||
|
|
||||||
```
|
|
||||||
brew install sdl2
|
|
||||||
c++ `sdl2-config --cflags` -I .. -I ../.. main.cpp ../../backends/imgui_impl_sdl2.cpp ../../backends/imgui_impl_sdlrenderer.cpp ../../imgui*.cpp `sdl2-config --libs` -framework OpenGl
|
|
||||||
```
|
|
||||||
@@ -14,11 +14,11 @@
|
|||||||
#CXX = g++
|
#CXX = g++
|
||||||
#CXX = clang++
|
#CXX = clang++
|
||||||
|
|
||||||
EXE = example_sdl2_sdlrenderer
|
EXE = example_sdl2_sdlrenderer2
|
||||||
IMGUI_DIR = ../..
|
IMGUI_DIR = ../..
|
||||||
SOURCES = main.cpp
|
SOURCES = main.cpp
|
||||||
SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
|
SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
|
||||||
SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl2.cpp $(IMGUI_DIR)/backends/imgui_impl_sdlrenderer.cpp
|
SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl2.cpp $(IMGUI_DIR)/backends/imgui_impl_sdlrenderer2.cpp
|
||||||
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
|
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
|
|
||||||
25
examples/example_sdl2_sdlrenderer2/README.md
Normal file
25
examples/example_sdl2_sdlrenderer2/README.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
# How to Build
|
||||||
|
|
||||||
|
- On Windows with Visual Studio's CLI
|
||||||
|
|
||||||
|
```
|
||||||
|
set SDL2_DIR=path_to_your_sdl2_folder
|
||||||
|
cl /Zi /MD /utf-8 /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_sdlrenderer2.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_sdlrenderer.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib /subsystem:console
|
||||||
|
# ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries
|
||||||
|
# or for 64-bit:
|
||||||
|
cl /Zi /MD /utf-8 /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_sdlrenderer2.cpp ..\..\imgui*.cpp /FeDebug/example_sdl2_sdlrenderer.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib /subsystem:console
|
||||||
|
```
|
||||||
|
|
||||||
|
- On Linux and similar Unixes
|
||||||
|
|
||||||
|
```
|
||||||
|
c++ `sdl2-config --cflags` -I .. -I ../.. main.cpp ../../backends/imgui_impl_sdl2.cpp ../../backends/imgui_impl_sdlrenderer2.cpp ../../imgui*.cpp `sdl2-config --libs` -lGL
|
||||||
|
```
|
||||||
|
|
||||||
|
- On Mac OS X
|
||||||
|
|
||||||
|
```
|
||||||
|
brew install sdl2
|
||||||
|
c++ `sdl2-config --cflags` -I .. -I ../.. main.cpp ../../backends/imgui_impl_sdl2.cpp ../../backends/imgui_impl_sdlrenderer2.cpp ../../imgui*.cpp `sdl2-config --libs` -framework OpenGl
|
||||||
|
```
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
@set OUT_DIR=Debug
|
@set OUT_DIR=Debug
|
||||||
@set OUT_EXE=example_sdl2_sdlrenderer_
|
@set OUT_EXE=example_sdl2_sdlrenderer_
|
||||||
@set INCLUDES=/I..\.. /I..\..\backends /I%SDL2_DIR%\include
|
@set INCLUDES=/I..\.. /I..\..\backends /I%SDL2_DIR%\include
|
||||||
@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_sdlrenderer.cpp ..\..\imgui*.cpp
|
@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl2.cpp ..\..\backends\imgui_impl_sdlrenderer2.cpp ..\..\imgui*.cpp
|
||||||
@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib
|
@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib
|
||||||
mkdir %OUT_DIR%
|
mkdir %OUT_DIR%
|
||||||
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
|
cl /nologo /Zi /MD /utf-8 %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
|
||||||
@@ -20,8 +20,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{0C0B2BEA-311F-473C-9652-87923EF639E3}</ProjectGuid>
|
<ProjectGuid>{0C0B2BEA-311F-473C-9652-87923EF639E3}</ProjectGuid>
|
||||||
<RootNamespace>example_sdl2_sdlrenderer</RootNamespace>
|
<RootNamespace>example_sdl2_sdlrenderer2</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||||
|
<ProjectName>example_sdl2_sdlrenderer2</ProjectName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
@@ -91,6 +92,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -105,6 +107,7 @@
|
|||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -122,6 +125,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -142,6 +146,7 @@
|
|||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
@@ -161,7 +166,7 @@
|
|||||||
<ClCompile Include="..\..\imgui_tables.cpp" />
|
<ClCompile Include="..\..\imgui_tables.cpp" />
|
||||||
<ClCompile Include="..\..\imgui_widgets.cpp" />
|
<ClCompile Include="..\..\imgui_widgets.cpp" />
|
||||||
<ClCompile Include="..\..\backends\imgui_impl_sdl2.cpp" />
|
<ClCompile Include="..\..\backends\imgui_impl_sdl2.cpp" />
|
||||||
<ClCompile Include="..\..\backends\imgui_impl_sdlrenderer.cpp" />
|
<ClCompile Include="..\..\backends\imgui_impl_sdlrenderer2.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -169,7 +174,7 @@
|
|||||||
<ClInclude Include="..\..\imgui.h" />
|
<ClInclude Include="..\..\imgui.h" />
|
||||||
<ClInclude Include="..\..\imgui_internal.h" />
|
<ClInclude Include="..\..\imgui_internal.h" />
|
||||||
<ClInclude Include="..\..\backends\imgui_impl_sdl2.h" />
|
<ClInclude Include="..\..\backends\imgui_impl_sdl2.h" />
|
||||||
<ClInclude Include="..\..\backends\imgui_impl_sdlrenderer.h" />
|
<ClInclude Include="..\..\backends\imgui_impl_sdlrenderer2.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\..\misc\debuggers\imgui.natstepfilter" />
|
<None Include="..\..\misc\debuggers\imgui.natstepfilter" />
|
||||||
@@ -179,4 +184,4 @@
|
|||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
<ClCompile Include="..\..\backends\imgui_impl_sdl2.cpp">
|
<ClCompile Include="..\..\backends\imgui_impl_sdl2.cpp">
|
||||||
<Filter>sources</Filter>
|
<Filter>sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\backends\imgui_impl_sdlrenderer.cpp">
|
<ClCompile Include="..\..\backends\imgui_impl_sdlrenderer2.cpp">
|
||||||
<Filter>sources</Filter>
|
<Filter>sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
<ClInclude Include="..\..\imgui_internal.h">
|
<ClInclude Include="..\..\imgui_internal.h">
|
||||||
<Filter>imgui</Filter>
|
<Filter>imgui</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\backends\imgui_impl_sdlrenderer.h">
|
<ClInclude Include="..\..\backends\imgui_impl_sdlrenderer2.h">
|
||||||
<Filter>sources</Filter>
|
<Filter>sources</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\backends\imgui_impl_sdl2.h">
|
<ClInclude Include="..\..\backends\imgui_impl_sdl2.h">
|
||||||
@@ -61,4 +61,4 @@
|
|||||||
<Filter>imgui</Filter>
|
<Filter>imgui</Filter>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,15 +1,18 @@
|
|||||||
// Dear ImGui: standalone example application for SDL2 + SDL_Renderer
|
// Dear ImGui: standalone example application for SDL2 + SDL_Renderer
|
||||||
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
|
||||||
|
|
||||||
// Important to understand: SDL_Renderer is an _optional_ component of SDL. We do not recommend you use SDL_Renderer
|
// Learn about Dear ImGui:
|
||||||
// because it provides a rather limited API to the end-user. We provide this backend for the sake of completeness.
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
|
// Important to understand: SDL_Renderer is an _optional_ component of SDL2.
|
||||||
// For a multi-platform app consider using e.g. SDL+DirectX on Windows and SDL+OpenGL on Linux/OSX.
|
// For a multi-platform app consider using e.g. SDL+DirectX on Windows and SDL+OpenGL on Linux/OSX.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_sdl2.h"
|
#include "imgui_impl_sdl2.h"
|
||||||
#include "imgui_impl_sdlrenderer.h"
|
#include "imgui_impl_sdlrenderer2.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
@@ -35,6 +38,11 @@ int main(int, char**)
|
|||||||
// Create window with SDL_Renderer graphics context
|
// Create window with SDL_Renderer graphics context
|
||||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+SDL_Renderer example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+SDL_Renderer example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
|
||||||
|
if (window == nullptr)
|
||||||
|
{
|
||||||
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
||||||
if (renderer == nullptr)
|
if (renderer == nullptr)
|
||||||
{
|
{
|
||||||
@@ -58,7 +66,7 @@ int main(int, char**)
|
|||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplSDL2_InitForSDLRenderer(window, renderer);
|
ImGui_ImplSDL2_InitForSDLRenderer(window, renderer);
|
||||||
ImGui_ImplSDLRenderer_Init(renderer);
|
ImGui_ImplSDLRenderer2_Init(renderer);
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - 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.
|
||||||
@@ -101,7 +109,7 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start the Dear ImGui frame
|
// Start the Dear ImGui frame
|
||||||
ImGui_ImplSDLRenderer_NewFrame();
|
ImGui_ImplSDLRenderer2_NewFrame();
|
||||||
ImGui_ImplSDL2_NewFrame();
|
ImGui_ImplSDL2_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
@@ -147,12 +155,12 @@ int main(int, char**)
|
|||||||
SDL_RenderSetScale(renderer, io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y);
|
SDL_RenderSetScale(renderer, io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y);
|
||||||
SDL_SetRenderDrawColor(renderer, (Uint8)(clear_color.x * 255), (Uint8)(clear_color.y * 255), (Uint8)(clear_color.z * 255), (Uint8)(clear_color.w * 255));
|
SDL_SetRenderDrawColor(renderer, (Uint8)(clear_color.x * 255), (Uint8)(clear_color.y * 255), (Uint8)(clear_color.z * 255), (Uint8)(clear_color.w * 255));
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
ImGui_ImplSDLRenderer_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplSDLRenderer2_RenderDrawData(ImGui::GetDrawData());
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
ImGui_ImplSDLRenderer_Shutdown();
|
ImGui_ImplSDLRenderer2_Shutdown();
|
||||||
ImGui_ImplSDL2_Shutdown();
|
ImGui_ImplSDL2_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
|
|
||||||
@@ -7,4 +7,4 @@
|
|||||||
|
|
||||||
@set OUT_DIR=Debug
|
@set OUT_DIR=Debug
|
||||||
mkdir %OUT_DIR%
|
mkdir %OUT_DIR%
|
||||||
cl /nologo /Zi /MD %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
|
cl /nologo /Zi /MD /utf-8 %INCLUDES% /D ImTextureID=ImU64 %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user