mirror of
https://github.com/ocornut/imgui.git
synced 2026-07-09 02:49:39 +00:00
Compare commits
1571 Commits
v1.90
...
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 | ||
|
|
6695006bea | ||
|
|
0941adc931 | ||
|
|
9d950444a2 | ||
|
|
450f1d7e7b | ||
|
|
37ea320b96 | ||
|
|
208b8242bc | ||
|
|
4cde40dbe1 | ||
|
|
9298e310b2 | ||
|
|
04e9a2fac1 | ||
|
|
2a6d7b1eaa | ||
|
|
51d1a72e9b | ||
|
|
4521dec85d | ||
|
|
83c4336828 | ||
|
|
f7fc186408 | ||
|
|
72ebd91567 | ||
|
|
9064dbd404 | ||
|
|
d27b4ad366 | ||
|
|
17bfafda55 | ||
|
|
ff534b0d0a | ||
|
|
f8aed6499f | ||
|
|
b7c250925f | ||
|
|
bb2fb74645 | ||
|
|
c418685315 | ||
|
|
2c0007731f | ||
|
|
61acb34e32 | ||
|
|
3ce6b06feb | ||
|
|
64b1e448d2 | ||
|
|
ac3bc73c13 | ||
|
|
afd0d3fca1 | ||
|
|
72d760ba00 | ||
|
|
f693c3d806 | ||
|
|
7e246a7bb9 | ||
|
|
1612813114 | ||
|
|
14f8b76c1a | ||
|
|
72dbe45adc | ||
|
|
1d8e48c161 | ||
|
|
a1b60fc1f5 | ||
|
|
300464a487 | ||
|
|
7d6e83efca | ||
|
|
762ec445e6 | ||
|
|
475453668d | ||
|
|
61d35972e2 | ||
|
|
676497fe05 | ||
|
|
1161301386 | ||
|
|
f422e7826f | ||
|
|
63b6300c39 | ||
|
|
f8704cd085 | ||
|
|
30594c37d0 | ||
|
|
f8f805f046 | ||
|
|
07d1709ca2 | ||
|
|
023e59a5f2 | ||
|
|
0110f4c8cc | ||
|
|
51b348095c | ||
|
|
f4942bca32 | ||
|
|
27c735e3e9 | ||
|
|
f6feddd1ee | ||
|
|
b79751ebad | ||
|
|
a5aff5fd3e | ||
|
|
8566fec661 | ||
|
|
dc3e531ff2 | ||
|
|
ac8573884d | ||
|
|
677c7b2258 | ||
|
|
a88e5be7f4 | ||
|
|
6b01114057 | ||
|
|
057fcae30c | ||
|
|
35b41949fb | ||
|
|
099e8533e2 | ||
|
|
66c09fc05b | ||
|
|
7d81a166f9 | ||
|
|
e4aeef4b9f | ||
|
|
1450d23b60 | ||
|
|
b9db5c566b | ||
|
|
ef07ddf087 | ||
|
|
fa5d2656b0 | ||
|
|
3f63cee4c1 | ||
|
|
0664877998 | ||
|
|
8fd0a04135 | ||
|
|
823a1385a2 | ||
|
|
3418d50949 | ||
|
|
f0f3b927e0 | ||
|
|
6cc967a124 | ||
|
|
2e810d575c | ||
|
|
19b436f68d | ||
|
|
54c1ac3e38 | ||
|
|
e590b5114e | ||
|
|
530134d125 | ||
|
|
031148dc56 | ||
|
|
594cc4793a | ||
|
|
d2291df551 | ||
|
|
bba39762dc | ||
|
|
ac38c8e6fe | ||
|
|
c11128891e | ||
|
|
adf693c061 | ||
|
|
07e07030a6 | ||
|
|
88ac2ced7c | ||
|
|
f498f084d6 | ||
|
|
4bc51c6ff4 | ||
|
|
1f2b84a654 | ||
|
|
4f692ba840 | ||
|
|
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 PROBLEMS COMPILING/LINKING/RUNNING or LOADING FONTS, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions). EVERYTHING ELSE CAN BE POSTED HERE!
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
@@ -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,7 +6,8 @@
|
|||||||
// [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.
|
||||||
|
|
||||||
@@ -27,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)
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
// [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.
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -156,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);
|
||||||
@@ -183,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);
|
||||||
@@ -221,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));
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -29,7 +30,7 @@ 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();
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
// 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.
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 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)
|
||||||
@@ -79,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)
|
||||||
{
|
{
|
||||||
@@ -541,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;
|
||||||
@@ -557,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,12 +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;
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -584,6 +594,129 @@ void ImGui_ImplDX10_NewFrame()
|
|||||||
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
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
// 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.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
// 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.
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 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)
|
||||||
@@ -80,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)
|
||||||
{
|
{
|
||||||
@@ -553,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;
|
||||||
@@ -572,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -581,13 +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;
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -600,6 +611,129 @@ void ImGui_ImplDX11_NewFrame()
|
|||||||
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
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
// 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.
|
||||||
|
|||||||
@@ -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*.
|
||||||
@@ -23,6 +25,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 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)
|
||||||
@@ -54,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;
|
||||||
@@ -67,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
|
||||||
@@ -89,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)
|
||||||
{
|
{
|
||||||
@@ -167,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)
|
||||||
@@ -678,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();
|
||||||
@@ -689,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,
|
||||||
@@ -709,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;
|
||||||
}
|
}
|
||||||
@@ -738,12 +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;
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,6 +839,246 @@ void ImGui_ImplDX12_NewFrame()
|
|||||||
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
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
// 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.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
// 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.
|
||||||
@@ -15,6 +16,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: 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.
|
||||||
@@ -75,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)
|
||||||
{
|
{
|
||||||
@@ -271,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);
|
||||||
@@ -291,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,14 +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;
|
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
|
||||||
@@ -323,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)
|
||||||
@@ -347,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
|
||||||
|
|
||||||
@@ -361,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,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()
|
||||||
@@ -383,6 +425,148 @@ void ImGui_ImplDX9_NewFrame()
|
|||||||
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
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
// 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.
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
// [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.
|
||||||
@@ -20,6 +24,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: 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-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-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-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)
|
||||||
@@ -27,6 +33,7 @@
|
|||||||
// 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)
|
||||||
@@ -99,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()
|
||||||
@@ -113,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
|
||||||
@@ -124,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;
|
||||||
@@ -137,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)); }
|
||||||
@@ -155,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)
|
||||||
{
|
{
|
||||||
@@ -380,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();
|
||||||
@@ -405,6 +443,13 @@ void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window, double x, double y)
|
|||||||
bd->PrevUserCallbackCursorPos(window, x, y);
|
bd->PrevUserCallbackCursorPos(window, x, y);
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
@@ -443,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__
|
||||||
@@ -465,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)
|
||||||
@@ -557,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;
|
||||||
@@ -601,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__)
|
||||||
@@ -610,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;
|
||||||
@@ -643,6 +678,8 @@ 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__
|
#ifdef __EMSCRIPTEN__
|
||||||
@@ -652,16 +689,16 @@ void ImGui_ImplGlfw_Shutdown()
|
|||||||
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);
|
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -669,11 +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();
|
||||||
|
|
||||||
|
ImGuiID mouse_viewport_id = 0;
|
||||||
// (those braces are here to reduce diff with multi-viewports support in 'docking' branch)
|
const ImVec2 mouse_pos_prev = io.MousePos;
|
||||||
|
for (int n = 0; n < platform_io.Viewports.Size; n++)
|
||||||
{
|
{
|
||||||
GLFWwindow* window = bd->Window;
|
ImGuiViewport* viewport = platform_io.Viewports[n];
|
||||||
|
GLFWwindow* window = (GLFWwindow*)viewport->PlatformHandle;
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
const bool is_window_focused = true;
|
const bool is_window_focused = true;
|
||||||
@@ -683,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()
|
||||||
@@ -706,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
|
||||||
@@ -777,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();
|
||||||
@@ -791,6 +909,8 @@ 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)
|
// (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)
|
||||||
@@ -807,6 +927,435 @@ 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__)
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
// 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.
|
||||||
@@ -30,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.
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
// 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.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
// 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.
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: 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.
|
||||||
@@ -38,6 +40,12 @@
|
|||||||
#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
|
||||||
@@ -130,10 +138,14 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,13 +153,14 @@ void ImGui_ImplMetal_Shutdown()
|
|||||||
{
|
{
|
||||||
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
|
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_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?");
|
||||||
|
ImGui_ImplMetal_ShutdownPlatformInterface();
|
||||||
ImGui_ImplMetal_DestroyDeviceObjects();
|
ImGui_ImplMetal_DestroyDeviceObjects();
|
||||||
ImGui_ImplMetal_DestroyBackendData();
|
ImGui_ImplMetal_DestroyBackendData();
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor)
|
void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor)
|
||||||
@@ -365,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;
|
||||||
@@ -374,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
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
// 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.
|
||||||
@@ -22,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.
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,6 +305,35 @@ 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__)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
// 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.
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
// 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:
|
// About WebGL/ES:
|
||||||
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
||||||
@@ -22,7 +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)
|
||||||
// 2023-11-08: OpenGL: Update GL3W based imgui_impl_opengl3_loader.h to load "libGL.so" instead of "libGL.so.1", accomodating for NetBSD systems having only "libGL.so.3" available. (#6983)
|
// 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-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-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-05-09: OpenGL: Support for glBindSampler() backup/restore on ES3. (#6375)
|
||||||
@@ -175,9 +178,20 @@
|
|||||||
#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
|
||||||
|
|
||||||
|
// Desktop GL 2.1+ and GL ES 3.0+ have glBindBuffer() with GL_PIXEL_UNPACK_BUFFER target.
|
||||||
|
#if !defined(IMGUI_IMPL_OPENGL_ES2)
|
||||||
|
#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_BUFFER_PIXEL_UNPACK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Desktop GL 3.1+ has GL_PRIMITIVE_RESTART state
|
||||||
|
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_1)
|
||||||
|
#define IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
|
// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
|
||||||
@@ -190,16 +204,6 @@
|
|||||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Desktop GL 3.1+ has GL_PRIMITIVE_RESTART state
|
|
||||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_1)
|
|
||||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Desktop GL use extension detection
|
|
||||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3)
|
|
||||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_EXTENSIONS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// [Debugging]
|
// [Debugging]
|
||||||
//#define IMGUI_IMPL_OPENGL_DEBUG
|
//#define IMGUI_IMPL_OPENGL_DEBUG
|
||||||
#ifdef IMGUI_IMPL_OPENGL_DEBUG
|
#ifdef IMGUI_IMPL_OPENGL_DEBUG
|
||||||
@@ -241,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
|
||||||
@@ -332,6 +340,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
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.
|
||||||
@@ -358,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++)
|
||||||
@@ -369,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,10 +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;
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,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
|
||||||
|
|
||||||
@@ -499,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);
|
||||||
@@ -638,7 +651,7 @@ 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
|
||||||
// Desktop OpenGL 3.0 and OpenGL 3.1 had separate polygon draw modes for front-facing and back-facing faces of polygons
|
// Desktop OpenGL 3.0 and OpenGL 3.1 had separate polygon draw modes for front-facing and back-facing faces of polygons
|
||||||
if (bd->GlVersion <= 310 || bd->GlProfileIsCompat)
|
if (bd->GlVersion <= 310 || bd->GlProfileIsCompat)
|
||||||
{
|
{
|
||||||
@@ -649,7 +662,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
{
|
{
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
|
glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
|
||||||
}
|
}
|
||||||
#endif // IMGUI_IMPL_HAS_POLYGON_MODE
|
#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]);
|
||||||
@@ -746,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);
|
||||||
@@ -919,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
|
||||||
@@ -935,6 +955,34 @@ 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__)
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
// 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:
|
// About WebGL/ES:
|
||||||
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
||||||
|
|||||||
@@ -260,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);
|
||||||
@@ -608,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
|
||||||
@@ -668,6 +670,10 @@ static int open_libgl(void)
|
|||||||
{
|
{
|
||||||
// While most systems use libGL.so.1, NetBSD seems to use that libGL.so.3. See https://github.com/ocornut/imgui/issues/6983
|
// 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);
|
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");
|
||||||
@@ -800,7 +806,7 @@ 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,6 +10,8 @@
|
|||||||
// [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.
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
// [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.
|
||||||
@@ -29,6 +31,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: 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-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).
|
||||||
@@ -80,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)); }
|
||||||
};
|
};
|
||||||
@@ -91,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);
|
||||||
|
|
||||||
@@ -134,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
|
||||||
@@ -234,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
|
||||||
|
|
||||||
@@ -251,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
|
||||||
@@ -398,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;
|
||||||
@@ -490,12 +527,12 @@ void ImGui_ImplOSX_Shutdown()
|
|||||||
bd->Monitor = nullptr;
|
bd->Monitor = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui_ImplOSX_ShutdownPlatformInterface();
|
||||||
ImGui_ImplOSX_DestroyBackendData();
|
ImGui_ImplOSX_DestroyBackendData();
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.BackendPlatformName = nullptr;
|
io.BackendPlatformName = nullptr;
|
||||||
io.BackendPlatformUserData = nullptr;
|
io.BackendPlatformUserData = nullptr;
|
||||||
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasGamepad);
|
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplOSX_UpdateMouseCursor()
|
static void ImGui_ImplOSX_UpdateMouseCursor()
|
||||||
@@ -534,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;
|
||||||
|
|
||||||
@@ -672,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;
|
||||||
@@ -807,6 +852,294 @@ static void ImGui_ImplOSX_AddTrackingArea(NSView* _Nonnull view)
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// 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
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -9,7 +9,10 @@
|
|||||||
// [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.
|
||||||
@@ -21,6 +24,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: 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-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)
|
||||||
@@ -46,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.
|
||||||
@@ -87,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__)
|
||||||
@@ -98,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)); }
|
||||||
};
|
};
|
||||||
@@ -126,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*)
|
||||||
{
|
{
|
||||||
@@ -142,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);
|
||||||
@@ -306,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;
|
||||||
@@ -357,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.
|
||||||
@@ -368,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!");
|
||||||
@@ -402,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);
|
||||||
@@ -428,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);
|
||||||
@@ -461,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)
|
||||||
@@ -475,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)
|
||||||
@@ -483,42 +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)
|
bool ImGui_ImplSDL2_InitForOther(SDL_Window* window)
|
||||||
{
|
{
|
||||||
return ImGui_ImplSDL2_Init(window, nullptr);
|
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);
|
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();
|
||||||
@@ -529,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()
|
||||||
@@ -567,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()
|
||||||
@@ -642,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();
|
||||||
@@ -651,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();
|
||||||
|
|
||||||
@@ -665,6 +891,253 @@ 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__)
|
||||||
|
|||||||
@@ -8,7 +8,10 @@
|
|||||||
// [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.
|
||||||
@@ -24,6 +27,7 @@
|
|||||||
|
|
||||||
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);
|
||||||
@@ -36,8 +40,9 @@ 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
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
// [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.
|
||||||
@@ -22,6 +24,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: 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-11-13: Updated for recent SDL3 API changes.
|
||||||
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
||||||
// 2023-05-04: Fixed build on Emscripten/iOS/Android. (#6391)
|
// 2023-05-04: Fixed build on Emscripten/iOS/Android. (#6391)
|
||||||
@@ -61,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)); }
|
||||||
};
|
};
|
||||||
@@ -84,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*)
|
||||||
{
|
{
|
||||||
@@ -99,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);
|
||||||
@@ -263,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;
|
||||||
@@ -309,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,
|
||||||
@@ -321,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:
|
||||||
@@ -330,17 +365,38 @@ 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 void ImGui_ImplSDL3_SetupPlatformHandles(ImGuiViewport* viewport, SDL_Window* window)
|
static void ImGui_ImplSDL3_SetupPlatformHandles(ImGuiViewport* viewport, SDL_Window* window)
|
||||||
{
|
{
|
||||||
|
viewport->PlatformHandle = window;
|
||||||
viewport->PlatformHandleRaw = nullptr;
|
viewport->PlatformHandleRaw = nullptr;
|
||||||
#if defined(__WIN32__) && !defined(__WINRT__)
|
#if defined(__WIN32__) && !defined(__WINRT__)
|
||||||
viewport->PlatformHandleRaw = (HWND)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.win32.hwnd", NULL);
|
viewport->PlatformHandleRaw = (HWND)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.win32.hwnd", nullptr);
|
||||||
#elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA)
|
#elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA)
|
||||||
viewport->PlatformHandleRaw = (void*)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.cocoa.window", NULL);
|
viewport->PlatformHandleRaw = (void*)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.cocoa.window", nullptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,16 +423,31 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
|||||||
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);
|
||||||
@@ -398,27 +469,34 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
|||||||
// (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, sdl_gl_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL3_InitForVulkan(SDL_Window* window)
|
bool ImGui_ImplSDL3_InitForVulkan(SDL_Window* window)
|
||||||
{
|
{
|
||||||
return ImGui_ImplSDL3_Init(window, nullptr, 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)
|
||||||
@@ -444,24 +522,29 @@ bool ImGui_ImplSDL3_InitForOther(SDL_Window* window)
|
|||||||
return ImGui_ImplSDL3_Init(window, nullptr, nullptr);
|
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);
|
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();
|
||||||
@@ -472,7 +555,7 @@ 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;
|
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
|
||||||
@@ -481,19 +564,48 @@ static void ImGui_ImplSDL3_UpdateMouseData()
|
|||||||
{
|
{
|
||||||
// (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()
|
||||||
@@ -513,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_WEST); // 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_EAST); // Xbox B, PS Circle
|
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadLeft, SDL_GAMEPAD_BUTTON_DPAD_LEFT);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadFaceUp, SDL_GAMEPAD_BUTTON_NORTH); // Xbox Y, PS Triangle
|
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadRight, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
|
||||||
MAP_BUTTON(ImGuiKey_GamepadFaceDown, SDL_GAMEPAD_BUTTON_SOUTH); // 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()
|
||||||
@@ -585,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();
|
||||||
@@ -594,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();
|
||||||
|
|
||||||
@@ -608,6 +819,232 @@ 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__)
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
// [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.
|
||||||
@@ -26,6 +28,7 @@
|
|||||||
|
|
||||||
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);
|
||||||
@@ -38,4 +41,9 @@ 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
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
// 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.
|
||||||
// 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.
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
// 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 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.
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
// 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.
|
||||||
// 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.
|
||||||
@@ -20,6 +22,7 @@
|
|||||||
// - Introduction, links and more at the top of imgui.cpp
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
|
// 2024-02-12: Amend to query SDL_RenderViewportSet() and restore viewport accordingly.
|
||||||
// 2023-05-30: Initial version.
|
// 2023-05-30: Initial version.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
@@ -129,10 +132,12 @@ void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
struct BackupSDLRendererState
|
struct BackupSDLRendererState
|
||||||
{
|
{
|
||||||
SDL_Rect Viewport;
|
SDL_Rect Viewport;
|
||||||
|
bool ViewportEnabled;
|
||||||
bool ClipEnabled;
|
bool ClipEnabled;
|
||||||
SDL_Rect ClipRect;
|
SDL_Rect ClipRect;
|
||||||
};
|
};
|
||||||
BackupSDLRendererState old = {};
|
BackupSDLRendererState old = {};
|
||||||
|
old.ViewportEnabled = SDL_RenderViewportSet(bd->SDLRenderer) == SDL_TRUE;
|
||||||
old.ClipEnabled = SDL_RenderClipEnabled(bd->SDLRenderer) == SDL_TRUE;
|
old.ClipEnabled = SDL_RenderClipEnabled(bd->SDLRenderer) == SDL_TRUE;
|
||||||
SDL_GetRenderViewport(bd->SDLRenderer, &old.Viewport);
|
SDL_GetRenderViewport(bd->SDLRenderer, &old.Viewport);
|
||||||
SDL_GetRenderClipRect(bd->SDLRenderer, &old.ClipRect);
|
SDL_GetRenderClipRect(bd->SDLRenderer, &old.ClipRect);
|
||||||
@@ -178,11 +183,7 @@ void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
|
|
||||||
const float* xy = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + 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) + 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)
|
|
||||||
const SDL_Color* color = (const SDL_Color*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + 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
|
|
||||||
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
|
|
||||||
|
|
||||||
// Bind texture, Draw
|
// Bind texture, Draw
|
||||||
SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID();
|
SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID();
|
||||||
@@ -197,7 +198,7 @@ void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Restore modified SDL_Renderer state
|
// Restore modified SDL_Renderer state
|
||||||
SDL_SetRenderViewport(bd->SDLRenderer, &old.Viewport);
|
SDL_SetRenderViewport(bd->SDLRenderer, old.ViewportEnabled ? &old.Viewport : nullptr);
|
||||||
SDL_SetRenderClipRect(bd->SDLRenderer, old.ClipEnabled ? &old.ClipRect : nullptr);
|
SDL_SetRenderClipRect(bd->SDLRenderer, old.ClipEnabled ? &old.ClipRect : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
// 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.
|
||||||
// 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.
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
// 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'.
|
||||||
// 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*.
|
||||||
@@ -33,6 +34,14 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2024-02-14: *BREAKING CHANGE*: Moved RenderPass parameter from ImGui_ImplVulkan_Init() function to ImGui_ImplVulkan_InitInfo structure. Not required when using dynamic rendering.
|
||||||
|
// 2024-02-12: *BREAKING CHANGE*: Dynamic rendering now require filling PipelineRenderingCreateInfo structure.
|
||||||
|
// 2024-01-19: Vulkan: Fixed vkAcquireNextImageKHR() validation errors in VulkanSDK 1.3.275 by allocating one extra semaphore than in-flight frames. (#7236)
|
||||||
|
// 2024-01-11: Vulkan: Fixed vkMapMemory() calls unnecessarily using full buffer size (#3957). Fixed MinAllocationSize handing (#7189).
|
||||||
|
// 2024-01-03: Vulkan: Added MinAllocationSize field in ImGui_ImplVulkan_InitInfo to workaround zealous "best practice" validation layer. (#7189, #4238)
|
||||||
|
// 2024-01-03: Vulkan: Stopped creating command pools with VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT as we don't reset them.
|
||||||
|
// 2023-11-29: Vulkan: Fixed mismatching allocator passed to vkCreateCommandPool() vs vkDestroyCommandPool(). (#7075)
|
||||||
// 2023-11-10: *BREAKING CHANGE*: Removed parameter from ImGui_ImplVulkan_CreateFontsTexture(): backend now creates its own command-buffer to upload fonts.
|
// 2023-11-10: *BREAKING CHANGE*: Removed parameter from ImGui_ImplVulkan_CreateFontsTexture(): backend now creates its own command-buffer to upload fonts.
|
||||||
// *BREAKING CHANGE*: Removed ImGui_ImplVulkan_DestroyFontUploadObjects() which is now unecessary as we create and destroy those objects in the backend.
|
// *BREAKING CHANGE*: Removed ImGui_ImplVulkan_DestroyFontUploadObjects() which is now unecessary as we create and destroy those objects in the backend.
|
||||||
// ImGui_ImplVulkan_CreateFontsTexture() is automatically called by NewFrame() the first time.
|
// ImGui_ImplVulkan_CreateFontsTexture() is automatically called by NewFrame() the first time.
|
||||||
@@ -78,73 +87,25 @@
|
|||||||
#ifndef IMGUI_DISABLE
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_vulkan.h"
|
#include "imgui_impl_vulkan.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#ifndef IM_MAX
|
||||||
|
#define IM_MAX(A, B) (((A) >= (B)) ? (A) : (B))
|
||||||
|
#endif
|
||||||
|
|
||||||
// Visual Studio warnings
|
// Visual Studio warnings
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning (disable: 4127) // condition expression is constant
|
#pragma warning (disable: 4127) // condition expression is constant
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Reusable buffers used for rendering 1 current in-flight frame, for ImGui_ImplVulkan_RenderDrawData()
|
|
||||||
// [Please zero-clear before use!]
|
|
||||||
struct ImGui_ImplVulkanH_FrameRenderBuffers
|
|
||||||
{
|
|
||||||
VkDeviceMemory VertexBufferMemory;
|
|
||||||
VkDeviceMemory IndexBufferMemory;
|
|
||||||
VkDeviceSize VertexBufferSize;
|
|
||||||
VkDeviceSize IndexBufferSize;
|
|
||||||
VkBuffer VertexBuffer;
|
|
||||||
VkBuffer IndexBuffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Each viewport will hold 1 ImGui_ImplVulkanH_WindowRenderBuffers
|
|
||||||
// [Please zero-clear before use!]
|
|
||||||
struct ImGui_ImplVulkanH_WindowRenderBuffers
|
|
||||||
{
|
|
||||||
uint32_t Index;
|
|
||||||
uint32_t Count;
|
|
||||||
ImGui_ImplVulkanH_FrameRenderBuffers* FrameRenderBuffers;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Vulkan data
|
|
||||||
struct ImGui_ImplVulkan_Data
|
|
||||||
{
|
|
||||||
ImGui_ImplVulkan_InitInfo VulkanInitInfo;
|
|
||||||
VkRenderPass RenderPass;
|
|
||||||
VkDeviceSize BufferMemoryAlignment;
|
|
||||||
VkPipelineCreateFlags PipelineCreateFlags;
|
|
||||||
VkDescriptorSetLayout DescriptorSetLayout;
|
|
||||||
VkPipelineLayout PipelineLayout;
|
|
||||||
VkPipeline Pipeline;
|
|
||||||
uint32_t Subpass;
|
|
||||||
VkShaderModule ShaderModuleVert;
|
|
||||||
VkShaderModule ShaderModuleFrag;
|
|
||||||
|
|
||||||
// Font data
|
|
||||||
VkSampler FontSampler;
|
|
||||||
VkDeviceMemory FontMemory;
|
|
||||||
VkImage FontImage;
|
|
||||||
VkImageView FontView;
|
|
||||||
VkDescriptorSet FontDescriptorSet;
|
|
||||||
VkCommandPool FontCommandPool;
|
|
||||||
VkCommandBuffer FontCommandBuffer;
|
|
||||||
|
|
||||||
// Render buffers for main window
|
|
||||||
ImGui_ImplVulkanH_WindowRenderBuffers MainWindowRenderBuffers;
|
|
||||||
|
|
||||||
ImGui_ImplVulkan_Data()
|
|
||||||
{
|
|
||||||
memset((void*)this, 0, sizeof(*this));
|
|
||||||
BufferMemoryAlignment = 256;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Forward Declarations
|
// Forward Declarations
|
||||||
|
struct ImGui_ImplVulkan_FrameRenderBuffers;
|
||||||
|
struct ImGui_ImplVulkan_WindowRenderBuffers;
|
||||||
bool ImGui_ImplVulkan_CreateDeviceObjects();
|
bool ImGui_ImplVulkan_CreateDeviceObjects();
|
||||||
void ImGui_ImplVulkan_DestroyDeviceObjects();
|
void ImGui_ImplVulkan_DestroyDeviceObjects();
|
||||||
|
void ImGui_ImplVulkan_DestroyFrameRenderBuffers(VkDevice device, ImGui_ImplVulkan_FrameRenderBuffers* buffers, const VkAllocationCallbacks* allocator);
|
||||||
|
void ImGui_ImplVulkan_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulkan_WindowRenderBuffers* buffers, const VkAllocationCallbacks* allocator);
|
||||||
void ImGui_ImplVulkanH_DestroyFrame(VkDevice device, ImGui_ImplVulkanH_Frame* fd, const VkAllocationCallbacks* allocator);
|
void ImGui_ImplVulkanH_DestroyFrame(VkDevice device, ImGui_ImplVulkanH_Frame* fd, const VkAllocationCallbacks* allocator);
|
||||||
void ImGui_ImplVulkanH_DestroyFrameSemaphores(VkDevice device, ImGui_ImplVulkanH_FrameSemaphores* fsd, const VkAllocationCallbacks* allocator);
|
void ImGui_ImplVulkanH_DestroyFrameSemaphores(VkDevice device, ImGui_ImplVulkanH_FrameSemaphores* fsd, const VkAllocationCallbacks* allocator);
|
||||||
void ImGui_ImplVulkanH_DestroyFrameRenderBuffers(VkDevice device, ImGui_ImplVulkanH_FrameRenderBuffers* buffers, const VkAllocationCallbacks* allocator);
|
void ImGui_ImplVulkanH_DestroyAllViewportsRenderBuffers(VkDevice device, const VkAllocationCallbacks* allocator);
|
||||||
void ImGui_ImplVulkanH_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulkanH_WindowRenderBuffers* buffers, const VkAllocationCallbacks* allocator);
|
|
||||||
void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
|
void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
|
||||||
void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator);
|
void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator);
|
||||||
|
|
||||||
@@ -160,15 +121,18 @@ static bool g_FunctionsLoaded = true;
|
|||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateCommandBuffers) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateCommandBuffers) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateDescriptorSets) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateDescriptorSets) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateMemory) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateMemory) \
|
||||||
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAcquireNextImageKHR) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkBeginCommandBuffer) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkBeginCommandBuffer) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkBindBufferMemory) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkBindBufferMemory) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkBindImageMemory) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkBindImageMemory) \
|
||||||
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBeginRenderPass) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindDescriptorSets) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindDescriptorSets) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindIndexBuffer) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindIndexBuffer) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindPipeline) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindPipeline) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindVertexBuffers) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindVertexBuffers) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdCopyBufferToImage) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdCopyBufferToImage) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdDrawIndexed) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdDrawIndexed) \
|
||||||
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdEndRenderPass) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdPipelineBarrier) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdPipelineBarrier) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdPushConstants) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdPushConstants) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdSetScissor) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdSetScissor) \
|
||||||
@@ -214,13 +178,17 @@ static bool g_FunctionsLoaded = true;
|
|||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceFormatsKHR) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceFormatsKHR) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfacePresentModesKHR) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfacePresentModesKHR) \
|
||||||
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceSupportKHR) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetSwapchainImagesKHR) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetSwapchainImagesKHR) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkMapMemory) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkMapMemory) \
|
||||||
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkQueuePresentKHR) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkQueueSubmit) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkQueueSubmit) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkQueueWaitIdle) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkQueueWaitIdle) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkResetCommandPool) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkResetCommandPool) \
|
||||||
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkResetFences) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkUnmapMemory) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkUnmapMemory) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkUpdateDescriptorSets)
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkUpdateDescriptorSets) \
|
||||||
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkWaitForFences)
|
||||||
|
|
||||||
// Define function pointers
|
// Define function pointers
|
||||||
#define IMGUI_VULKAN_FUNC_DEF(func) static PFN_##func func;
|
#define IMGUI_VULKAN_FUNC_DEF(func) static PFN_##func func;
|
||||||
@@ -228,17 +196,84 @@ IMGUI_VULKAN_FUNC_MAP(IMGUI_VULKAN_FUNC_DEF)
|
|||||||
#undef IMGUI_VULKAN_FUNC_DEF
|
#undef IMGUI_VULKAN_FUNC_DEF
|
||||||
#endif // VK_NO_PROTOTYPES
|
#endif // VK_NO_PROTOTYPES
|
||||||
|
|
||||||
#if defined(VK_VERSION_1_3) || defined(VK_KHR_dynamic_rendering)
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
#define IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
|
||||||
static PFN_vkCmdBeginRenderingKHR ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR;
|
static PFN_vkCmdBeginRenderingKHR ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR;
|
||||||
static PFN_vkCmdEndRenderingKHR ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR;
|
static PFN_vkCmdEndRenderingKHR ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Reusable buffers used for rendering 1 current in-flight frame, for ImGui_ImplVulkan_RenderDrawData()
|
||||||
|
// [Please zero-clear before use!]
|
||||||
|
struct ImGui_ImplVulkan_FrameRenderBuffers
|
||||||
|
{
|
||||||
|
VkDeviceMemory VertexBufferMemory;
|
||||||
|
VkDeviceMemory IndexBufferMemory;
|
||||||
|
VkDeviceSize VertexBufferSize;
|
||||||
|
VkDeviceSize IndexBufferSize;
|
||||||
|
VkBuffer VertexBuffer;
|
||||||
|
VkBuffer IndexBuffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Each viewport will hold 1 ImGui_ImplVulkanH_WindowRenderBuffers
|
||||||
|
// [Please zero-clear before use!]
|
||||||
|
struct ImGui_ImplVulkan_WindowRenderBuffers
|
||||||
|
{
|
||||||
|
uint32_t Index;
|
||||||
|
uint32_t Count;
|
||||||
|
ImGui_ImplVulkan_FrameRenderBuffers* FrameRenderBuffers;
|
||||||
|
};
|
||||||
|
|
||||||
|
// For multi-viewport support:
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplVulkan_ViewportData
|
||||||
|
{
|
||||||
|
bool WindowOwned;
|
||||||
|
ImGui_ImplVulkanH_Window Window; // Used by secondary viewports only
|
||||||
|
ImGui_ImplVulkan_WindowRenderBuffers RenderBuffers; // Used by all viewports
|
||||||
|
|
||||||
|
ImGui_ImplVulkan_ViewportData() { WindowOwned = false; memset(&RenderBuffers, 0, sizeof(RenderBuffers)); }
|
||||||
|
~ImGui_ImplVulkan_ViewportData() { }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Vulkan data
|
||||||
|
struct ImGui_ImplVulkan_Data
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_InitInfo VulkanInitInfo;
|
||||||
|
VkDeviceSize BufferMemoryAlignment;
|
||||||
|
VkPipelineCreateFlags PipelineCreateFlags;
|
||||||
|
VkDescriptorSetLayout DescriptorSetLayout;
|
||||||
|
VkPipelineLayout PipelineLayout;
|
||||||
|
VkPipeline Pipeline;
|
||||||
|
VkShaderModule ShaderModuleVert;
|
||||||
|
VkShaderModule ShaderModuleFrag;
|
||||||
|
|
||||||
|
// Font data
|
||||||
|
VkSampler FontSampler;
|
||||||
|
VkDeviceMemory FontMemory;
|
||||||
|
VkImage FontImage;
|
||||||
|
VkImageView FontView;
|
||||||
|
VkDescriptorSet FontDescriptorSet;
|
||||||
|
VkCommandPool FontCommandPool;
|
||||||
|
VkCommandBuffer FontCommandBuffer;
|
||||||
|
|
||||||
|
// Render buffers for main window
|
||||||
|
ImGui_ImplVulkan_WindowRenderBuffers MainWindowRenderBuffers;
|
||||||
|
|
||||||
|
ImGui_ImplVulkan_Data()
|
||||||
|
{
|
||||||
|
memset((void*)this, 0, sizeof(*this));
|
||||||
|
BufferMemoryAlignment = 256;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// SHADERS
|
// SHADERS
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// glsl_shader.vert, compiled with:
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplVulkan_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplVulkan_ShutdownPlatformInterface();
|
||||||
|
|
||||||
|
// backends/vulkan/glsl_shader.vert, compiled with:
|
||||||
// # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert
|
// # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert
|
||||||
/*
|
/*
|
||||||
#version 450 core
|
#version 450 core
|
||||||
@@ -302,7 +337,7 @@ static uint32_t __glsl_shader_vert_spv[] =
|
|||||||
0x0000002d,0x0000002c,0x000100fd,0x00010038
|
0x0000002d,0x0000002c,0x000100fd,0x00010038
|
||||||
};
|
};
|
||||||
|
|
||||||
// glsl_shader.frag, compiled with:
|
// backends/vulkan/glsl_shader.frag, compiled with:
|
||||||
// # glslangValidator -V -x -o glsl_shader.frag.u32 glsl_shader.frag
|
// # glslangValidator -V -x -o glsl_shader.frag.u32 glsl_shader.frag
|
||||||
/*
|
/*
|
||||||
#version 450 core
|
#version 450 core
|
||||||
@@ -377,7 +412,13 @@ static void check_vk_result(VkResult err)
|
|||||||
v->CheckVkResultFn(err);
|
v->CheckVkResultFn(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CreateOrResizeBuffer(VkBuffer& buffer, VkDeviceMemory& buffer_memory, VkDeviceSize& p_buffer_size, size_t new_size, VkBufferUsageFlagBits usage)
|
// Same as IM_MEMALIGN(). 'alignment' must be a power of two.
|
||||||
|
static inline VkDeviceSize AlignBufferSize(VkDeviceSize size, VkDeviceSize alignment)
|
||||||
|
{
|
||||||
|
return (size + alignment - 1) & ~(alignment - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CreateOrResizeBuffer(VkBuffer& buffer, VkDeviceMemory& buffer_memory, VkDeviceSize& buffer_size, size_t new_size, VkBufferUsageFlagBits usage)
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
@@ -387,10 +428,10 @@ static void CreateOrResizeBuffer(VkBuffer& buffer, VkDeviceMemory& buffer_memory
|
|||||||
if (buffer_memory != VK_NULL_HANDLE)
|
if (buffer_memory != VK_NULL_HANDLE)
|
||||||
vkFreeMemory(v->Device, buffer_memory, v->Allocator);
|
vkFreeMemory(v->Device, buffer_memory, v->Allocator);
|
||||||
|
|
||||||
VkDeviceSize vertex_buffer_size_aligned = ((new_size - 1) / bd->BufferMemoryAlignment + 1) * bd->BufferMemoryAlignment;
|
VkDeviceSize buffer_size_aligned = AlignBufferSize(IM_MAX(v->MinAllocationSize, new_size), bd->BufferMemoryAlignment);
|
||||||
VkBufferCreateInfo buffer_info = {};
|
VkBufferCreateInfo buffer_info = {};
|
||||||
buffer_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
|
buffer_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
|
||||||
buffer_info.size = vertex_buffer_size_aligned;
|
buffer_info.size = buffer_size_aligned;
|
||||||
buffer_info.usage = usage;
|
buffer_info.usage = usage;
|
||||||
buffer_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
buffer_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
err = vkCreateBuffer(v->Device, &buffer_info, v->Allocator, &buffer);
|
err = vkCreateBuffer(v->Device, &buffer_info, v->Allocator, &buffer);
|
||||||
@@ -408,10 +449,10 @@ static void CreateOrResizeBuffer(VkBuffer& buffer, VkDeviceMemory& buffer_memory
|
|||||||
|
|
||||||
err = vkBindBufferMemory(v->Device, buffer, buffer_memory, 0);
|
err = vkBindBufferMemory(v->Device, buffer, buffer_memory, 0);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
p_buffer_size = req.size;
|
buffer_size = buffer_size_aligned;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkPipeline pipeline, VkCommandBuffer command_buffer, ImGui_ImplVulkanH_FrameRenderBuffers* rb, int fb_width, int fb_height)
|
static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkPipeline pipeline, VkCommandBuffer command_buffer, ImGui_ImplVulkan_FrameRenderBuffers* rb, int fb_width, int fb_height)
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
|
|
||||||
@@ -469,24 +510,26 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
if (pipeline == VK_NULL_HANDLE)
|
if (pipeline == VK_NULL_HANDLE)
|
||||||
pipeline = bd->Pipeline;
|
pipeline = bd->Pipeline;
|
||||||
|
|
||||||
// Allocate array to store enough vertex/index buffers
|
// Allocate array to store enough vertex/index buffers. Each unique viewport gets its own storage.
|
||||||
ImGui_ImplVulkanH_WindowRenderBuffers* wrb = &bd->MainWindowRenderBuffers;
|
ImGui_ImplVulkan_ViewportData* viewport_renderer_data = (ImGui_ImplVulkan_ViewportData*)draw_data->OwnerViewport->RendererUserData;
|
||||||
|
IM_ASSERT(viewport_renderer_data != nullptr);
|
||||||
|
ImGui_ImplVulkan_WindowRenderBuffers* wrb = &viewport_renderer_data->RenderBuffers;
|
||||||
if (wrb->FrameRenderBuffers == nullptr)
|
if (wrb->FrameRenderBuffers == nullptr)
|
||||||
{
|
{
|
||||||
wrb->Index = 0;
|
wrb->Index = 0;
|
||||||
wrb->Count = v->ImageCount;
|
wrb->Count = v->ImageCount;
|
||||||
wrb->FrameRenderBuffers = (ImGui_ImplVulkanH_FrameRenderBuffers*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_FrameRenderBuffers) * wrb->Count);
|
wrb->FrameRenderBuffers = (ImGui_ImplVulkan_FrameRenderBuffers*)IM_ALLOC(sizeof(ImGui_ImplVulkan_FrameRenderBuffers) * wrb->Count);
|
||||||
memset(wrb->FrameRenderBuffers, 0, sizeof(ImGui_ImplVulkanH_FrameRenderBuffers) * wrb->Count);
|
memset(wrb->FrameRenderBuffers, 0, sizeof(ImGui_ImplVulkan_FrameRenderBuffers) * wrb->Count);
|
||||||
}
|
}
|
||||||
IM_ASSERT(wrb->Count == v->ImageCount);
|
IM_ASSERT(wrb->Count == v->ImageCount);
|
||||||
wrb->Index = (wrb->Index + 1) % wrb->Count;
|
wrb->Index = (wrb->Index + 1) % wrb->Count;
|
||||||
ImGui_ImplVulkanH_FrameRenderBuffers* rb = &wrb->FrameRenderBuffers[wrb->Index];
|
ImGui_ImplVulkan_FrameRenderBuffers* rb = &wrb->FrameRenderBuffers[wrb->Index];
|
||||||
|
|
||||||
if (draw_data->TotalVtxCount > 0)
|
if (draw_data->TotalVtxCount > 0)
|
||||||
{
|
{
|
||||||
// Create or resize the vertex/index buffers
|
// Create or resize the vertex/index buffers
|
||||||
size_t vertex_size = draw_data->TotalVtxCount * sizeof(ImDrawVert);
|
size_t vertex_size = AlignBufferSize(draw_data->TotalVtxCount * sizeof(ImDrawVert), bd->BufferMemoryAlignment);
|
||||||
size_t index_size = draw_data->TotalIdxCount * sizeof(ImDrawIdx);
|
size_t index_size = AlignBufferSize(draw_data->TotalIdxCount * sizeof(ImDrawIdx), bd->BufferMemoryAlignment);
|
||||||
if (rb->VertexBuffer == VK_NULL_HANDLE || rb->VertexBufferSize < vertex_size)
|
if (rb->VertexBuffer == VK_NULL_HANDLE || rb->VertexBufferSize < vertex_size)
|
||||||
CreateOrResizeBuffer(rb->VertexBuffer, rb->VertexBufferMemory, rb->VertexBufferSize, vertex_size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
|
CreateOrResizeBuffer(rb->VertexBuffer, rb->VertexBufferMemory, rb->VertexBufferSize, vertex_size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
|
||||||
if (rb->IndexBuffer == VK_NULL_HANDLE || rb->IndexBufferSize < index_size)
|
if (rb->IndexBuffer == VK_NULL_HANDLE || rb->IndexBufferSize < index_size)
|
||||||
@@ -495,9 +538,9 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
// Upload vertex/index data into a single contiguous GPU buffer
|
// Upload vertex/index data into a single contiguous GPU buffer
|
||||||
ImDrawVert* vtx_dst = nullptr;
|
ImDrawVert* vtx_dst = nullptr;
|
||||||
ImDrawIdx* idx_dst = nullptr;
|
ImDrawIdx* idx_dst = nullptr;
|
||||||
VkResult err = vkMapMemory(v->Device, rb->VertexBufferMemory, 0, rb->VertexBufferSize, 0, (void**)(&vtx_dst));
|
VkResult err = vkMapMemory(v->Device, rb->VertexBufferMemory, 0, vertex_size, 0, (void**)&vtx_dst);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
err = vkMapMemory(v->Device, rb->IndexBufferMemory, 0, rb->IndexBufferSize, 0, (void**)(&idx_dst));
|
err = vkMapMemory(v->Device, rb->IndexBufferMemory, 0, index_size, 0, (void**)&idx_dst);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
@@ -616,9 +659,9 @@ bool ImGui_ImplVulkan_CreateFontsTexture()
|
|||||||
{
|
{
|
||||||
VkCommandPoolCreateInfo info = {};
|
VkCommandPoolCreateInfo info = {};
|
||||||
info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||||
info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
|
info.flags = 0;
|
||||||
info.queueFamilyIndex = v->QueueFamily;
|
info.queueFamilyIndex = v->QueueFamily;
|
||||||
vkCreateCommandPool(v->Device, &info, nullptr, &bd->FontCommandPool);
|
vkCreateCommandPool(v->Device, &info, v->Allocator, &bd->FontCommandPool);
|
||||||
}
|
}
|
||||||
if (bd->FontCommandBuffer == VK_NULL_HANDLE)
|
if (bd->FontCommandBuffer == VK_NULL_HANDLE)
|
||||||
{
|
{
|
||||||
@@ -668,7 +711,7 @@ bool ImGui_ImplVulkan_CreateFontsTexture()
|
|||||||
vkGetImageMemoryRequirements(v->Device, bd->FontImage, &req);
|
vkGetImageMemoryRequirements(v->Device, bd->FontImage, &req);
|
||||||
VkMemoryAllocateInfo alloc_info = {};
|
VkMemoryAllocateInfo alloc_info = {};
|
||||||
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||||
alloc_info.allocationSize = req.size;
|
alloc_info.allocationSize = IM_MAX(v->MinAllocationSize, req.size);
|
||||||
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, req.memoryTypeBits);
|
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, req.memoryTypeBits);
|
||||||
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &bd->FontMemory);
|
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &bd->FontMemory);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
@@ -709,7 +752,7 @@ bool ImGui_ImplVulkan_CreateFontsTexture()
|
|||||||
bd->BufferMemoryAlignment = (bd->BufferMemoryAlignment > req.alignment) ? bd->BufferMemoryAlignment : req.alignment;
|
bd->BufferMemoryAlignment = (bd->BufferMemoryAlignment > req.alignment) ? bd->BufferMemoryAlignment : req.alignment;
|
||||||
VkMemoryAllocateInfo alloc_info = {};
|
VkMemoryAllocateInfo alloc_info = {};
|
||||||
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||||
alloc_info.allocationSize = req.size;
|
alloc_info.allocationSize = IM_MAX(v->MinAllocationSize, req.size);
|
||||||
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
|
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
|
||||||
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &upload_buffer_memory);
|
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &upload_buffer_memory);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
@@ -783,7 +826,7 @@ bool ImGui_ImplVulkan_CreateFontsTexture()
|
|||||||
err = vkQueueSubmit(v->Queue, 1, &end_info, VK_NULL_HANDLE);
|
err = vkQueueSubmit(v->Queue, 1, &end_info, VK_NULL_HANDLE);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
|
|
||||||
err = vkDeviceWaitIdle(v->Device);
|
err = vkQueueWaitIdle(v->Queue);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
|
|
||||||
vkDestroyBuffer(v->Device, upload_buffer, v->Allocator);
|
vkDestroyBuffer(v->Device, upload_buffer, v->Allocator);
|
||||||
@@ -937,13 +980,11 @@ static void ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAllocationC
|
|||||||
info.subpass = subpass;
|
info.subpass = subpass;
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
VkPipelineRenderingCreateInfoKHR pipelineRenderingCreateInfo = {};
|
|
||||||
pipelineRenderingCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR;
|
|
||||||
pipelineRenderingCreateInfo.colorAttachmentCount = 1;
|
|
||||||
pipelineRenderingCreateInfo.pColorAttachmentFormats = &bd->VulkanInitInfo.ColorAttachmentFormat;
|
|
||||||
if (bd->VulkanInitInfo.UseDynamicRendering)
|
if (bd->VulkanInitInfo.UseDynamicRendering)
|
||||||
{
|
{
|
||||||
info.pNext = &pipelineRenderingCreateInfo;
|
IM_ASSERT(bd->VulkanInitInfo.PipelineRenderingCreateInfo.sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR && "PipelineRenderingCreateInfo sType must be VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR");
|
||||||
|
IM_ASSERT(bd->VulkanInitInfo.PipelineRenderingCreateInfo.pNext == nullptr && "PipelineRenderingCreateInfo pNext must be NULL");
|
||||||
|
info.pNext = &bd->VulkanInitInfo.PipelineRenderingCreateInfo;
|
||||||
info.renderPass = VK_NULL_HANDLE; // Just make sure it's actually nullptr.
|
info.renderPass = VK_NULL_HANDLE; // Just make sure it's actually nullptr.
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1008,7 +1049,7 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
|||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, v->PipelineCache, bd->RenderPass, v->MSAASamples, &bd->Pipeline, bd->Subpass);
|
ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, v->PipelineCache, v->RenderPass, v->MSAASamples, &bd->Pipeline, v->Subpass);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1017,9 +1058,10 @@ void ImGui_ImplVulkan_DestroyDeviceObjects()
|
|||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
ImGui_ImplVulkanH_DestroyWindowRenderBuffers(v->Device, &bd->MainWindowRenderBuffers, v->Allocator);
|
ImGui_ImplVulkanH_DestroyAllViewportsRenderBuffers(v->Device, v->Allocator);
|
||||||
ImGui_ImplVulkan_DestroyFontsTexture();
|
ImGui_ImplVulkan_DestroyFontsTexture();
|
||||||
|
|
||||||
|
if (bd->FontCommandBuffer) { vkFreeCommandBuffers(v->Device, bd->FontCommandPool, 1, &bd->FontCommandBuffer); bd->FontCommandBuffer = VK_NULL_HANDLE; }
|
||||||
if (bd->FontCommandPool) { vkDestroyCommandPool(v->Device, bd->FontCommandPool, v->Allocator); bd->FontCommandPool = VK_NULL_HANDLE; }
|
if (bd->FontCommandPool) { vkDestroyCommandPool(v->Device, bd->FontCommandPool, v->Allocator); bd->FontCommandPool = VK_NULL_HANDLE; }
|
||||||
if (bd->ShaderModuleVert) { vkDestroyShaderModule(v->Device, bd->ShaderModuleVert, v->Allocator); bd->ShaderModuleVert = VK_NULL_HANDLE; }
|
if (bd->ShaderModuleVert) { vkDestroyShaderModule(v->Device, bd->ShaderModuleVert, v->Allocator); bd->ShaderModuleVert = VK_NULL_HANDLE; }
|
||||||
if (bd->ShaderModuleFrag) { vkDestroyShaderModule(v->Device, bd->ShaderModuleFrag, v->Allocator); bd->ShaderModuleFrag = VK_NULL_HANDLE; }
|
if (bd->ShaderModuleFrag) { vkDestroyShaderModule(v->Device, bd->ShaderModuleFrag, v->Allocator); bd->ShaderModuleFrag = VK_NULL_HANDLE; }
|
||||||
@@ -1057,7 +1099,7 @@ bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const ch
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass)
|
bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
|
||||||
{
|
{
|
||||||
IM_ASSERT(g_FunctionsLoaded && "Need to call ImGui_ImplVulkan_LoadFunctions() if IMGUI_IMPL_VULKAN_NO_PROTOTYPES or VK_NO_PROTOTYPES are set!");
|
IM_ASSERT(g_FunctionsLoaded && "Need to call ImGui_ImplVulkan_LoadFunctions() if IMGUI_IMPL_VULKAN_NO_PROTOTYPES or VK_NO_PROTOTYPES are set!");
|
||||||
|
|
||||||
@@ -1083,6 +1125,7 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass rend
|
|||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_vulkan";
|
io.BackendRendererName = "imgui_impl_vulkan";
|
||||||
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)
|
||||||
|
|
||||||
IM_ASSERT(info->Instance != VK_NULL_HANDLE);
|
IM_ASSERT(info->Instance != VK_NULL_HANDLE);
|
||||||
IM_ASSERT(info->PhysicalDevice != VK_NULL_HANDLE);
|
IM_ASSERT(info->PhysicalDevice != VK_NULL_HANDLE);
|
||||||
@@ -1092,14 +1135,19 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass rend
|
|||||||
IM_ASSERT(info->MinImageCount >= 2);
|
IM_ASSERT(info->MinImageCount >= 2);
|
||||||
IM_ASSERT(info->ImageCount >= info->MinImageCount);
|
IM_ASSERT(info->ImageCount >= info->MinImageCount);
|
||||||
if (info->UseDynamicRendering == false)
|
if (info->UseDynamicRendering == false)
|
||||||
IM_ASSERT(render_pass != VK_NULL_HANDLE);
|
IM_ASSERT(info->RenderPass != VK_NULL_HANDLE);
|
||||||
|
|
||||||
bd->VulkanInitInfo = *info;
|
bd->VulkanInitInfo = *info;
|
||||||
bd->RenderPass = render_pass;
|
|
||||||
bd->Subpass = info->Subpass;
|
|
||||||
|
|
||||||
ImGui_ImplVulkan_CreateDeviceObjects();
|
ImGui_ImplVulkan_CreateDeviceObjects();
|
||||||
|
|
||||||
|
// Our render function expect RendererUserData to be storing the window render buffer we need (for the main viewport we won't use ->Window)
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
main_viewport->RendererUserData = IM_NEW(ImGui_ImplVulkan_ViewportData)();
|
||||||
|
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplVulkan_InitPlatformInterface();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1109,10 +1157,21 @@ void ImGui_ImplVulkan_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();
|
||||||
|
|
||||||
|
// First destroy objects in all viewports
|
||||||
ImGui_ImplVulkan_DestroyDeviceObjects();
|
ImGui_ImplVulkan_DestroyDeviceObjects();
|
||||||
|
|
||||||
|
// Manually delete main viewport render data in-case we haven't initialized for viewports
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
if (ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)main_viewport->RendererUserData)
|
||||||
|
IM_DELETE(vd);
|
||||||
|
main_viewport->RendererUserData = nullptr;
|
||||||
|
|
||||||
|
// Clean up windows
|
||||||
|
ImGui_ImplVulkan_ShutdownPlatformInterface();
|
||||||
|
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1132,10 +1191,12 @@ void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count)
|
|||||||
if (bd->VulkanInitInfo.MinImageCount == min_image_count)
|
if (bd->VulkanInitInfo.MinImageCount == min_image_count)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
IM_ASSERT(0); // FIXME-VIEWPORT: Unsupported. Need to recreate all swap chains!
|
||||||
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
VkResult err = vkDeviceWaitIdle(v->Device);
|
VkResult err = vkDeviceWaitIdle(v->Device);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
ImGui_ImplVulkanH_DestroyWindowRenderBuffers(v->Device, &bd->MainWindowRenderBuffers, v->Allocator);
|
ImGui_ImplVulkanH_DestroyAllViewportsRenderBuffers(v->Device, v->Allocator);
|
||||||
|
|
||||||
bd->VulkanInitInfo.MinImageCount = min_image_count;
|
bd->VulkanInitInfo.MinImageCount = min_image_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1182,6 +1243,26 @@ void ImGui_ImplVulkan_RemoveTexture(VkDescriptorSet descriptor_set)
|
|||||||
vkFreeDescriptorSets(v->Device, v->DescriptorPool, 1, &descriptor_set);
|
vkFreeDescriptorSets(v->Device, v->DescriptorPool, 1, &descriptor_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplVulkan_DestroyFrameRenderBuffers(VkDevice device, ImGui_ImplVulkan_FrameRenderBuffers* buffers, const VkAllocationCallbacks* allocator)
|
||||||
|
{
|
||||||
|
if (buffers->VertexBuffer) { vkDestroyBuffer(device, buffers->VertexBuffer, allocator); buffers->VertexBuffer = VK_NULL_HANDLE; }
|
||||||
|
if (buffers->VertexBufferMemory) { vkFreeMemory(device, buffers->VertexBufferMemory, allocator); buffers->VertexBufferMemory = VK_NULL_HANDLE; }
|
||||||
|
if (buffers->IndexBuffer) { vkDestroyBuffer(device, buffers->IndexBuffer, allocator); buffers->IndexBuffer = VK_NULL_HANDLE; }
|
||||||
|
if (buffers->IndexBufferMemory) { vkFreeMemory(device, buffers->IndexBufferMemory, allocator); buffers->IndexBufferMemory = VK_NULL_HANDLE; }
|
||||||
|
buffers->VertexBufferSize = 0;
|
||||||
|
buffers->IndexBufferSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplVulkan_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulkan_WindowRenderBuffers* buffers, const VkAllocationCallbacks* allocator)
|
||||||
|
{
|
||||||
|
for (uint32_t n = 0; n < buffers->Count; n++)
|
||||||
|
ImGui_ImplVulkan_DestroyFrameRenderBuffers(device, &buffers->FrameRenderBuffers[n], allocator);
|
||||||
|
IM_FREE(buffers->FrameRenderBuffers);
|
||||||
|
buffers->FrameRenderBuffers = nullptr;
|
||||||
|
buffers->Index = 0;
|
||||||
|
buffers->Count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Internal / Miscellaneous Vulkan Helpers
|
// Internal / Miscellaneous Vulkan Helpers
|
||||||
// (Used by example's main.cpp. Used by multi-viewport features. PROBABLY NOT used by your own app.)
|
// (Used by example's main.cpp. Used by multi-viewport features. PROBABLY NOT used by your own app.)
|
||||||
@@ -1269,19 +1350,17 @@ VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_d
|
|||||||
void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator)
|
void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator)
|
||||||
{
|
{
|
||||||
IM_ASSERT(physical_device != VK_NULL_HANDLE && device != VK_NULL_HANDLE);
|
IM_ASSERT(physical_device != VK_NULL_HANDLE && device != VK_NULL_HANDLE);
|
||||||
(void)physical_device;
|
IM_UNUSED(physical_device);
|
||||||
(void)allocator;
|
|
||||||
|
|
||||||
// Create Command Buffers
|
// Create Command Buffers
|
||||||
VkResult err;
|
VkResult err;
|
||||||
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkanH_Frame* fd = &wd->Frames[i];
|
ImGui_ImplVulkanH_Frame* fd = &wd->Frames[i];
|
||||||
ImGui_ImplVulkanH_FrameSemaphores* fsd = &wd->FrameSemaphores[i];
|
|
||||||
{
|
{
|
||||||
VkCommandPoolCreateInfo info = {};
|
VkCommandPoolCreateInfo info = {};
|
||||||
info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||||
info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
|
info.flags = 0;
|
||||||
info.queueFamilyIndex = queue_family;
|
info.queueFamilyIndex = queue_family;
|
||||||
err = vkCreateCommandPool(device, &info, allocator, &fd->CommandPool);
|
err = vkCreateCommandPool(device, &info, allocator, &fd->CommandPool);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
@@ -1302,6 +1381,11 @@ void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_devi
|
|||||||
err = vkCreateFence(device, &info, allocator, &fd->Fence);
|
err = vkCreateFence(device, &info, allocator, &fd->Fence);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < wd->SemaphoreCount; i++)
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkanH_FrameSemaphores* fsd = &wd->FrameSemaphores[i];
|
||||||
{
|
{
|
||||||
VkSemaphoreCreateInfo info = {};
|
VkSemaphoreCreateInfo info = {};
|
||||||
info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
|
info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
|
||||||
@@ -1337,10 +1421,9 @@ void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, V
|
|||||||
// We don't use ImGui_ImplVulkanH_DestroyWindow() because we want to preserve the old swapchain to create the new one.
|
// We don't use ImGui_ImplVulkanH_DestroyWindow() because we want to preserve the old swapchain to create the new one.
|
||||||
// Destroy old Framebuffer
|
// Destroy old Framebuffer
|
||||||
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
||||||
{
|
|
||||||
ImGui_ImplVulkanH_DestroyFrame(device, &wd->Frames[i], allocator);
|
ImGui_ImplVulkanH_DestroyFrame(device, &wd->Frames[i], allocator);
|
||||||
|
for (uint32_t i = 0; i < wd->SemaphoreCount; i++)
|
||||||
ImGui_ImplVulkanH_DestroyFrameSemaphores(device, &wd->FrameSemaphores[i], allocator);
|
ImGui_ImplVulkanH_DestroyFrameSemaphores(device, &wd->FrameSemaphores[i], allocator);
|
||||||
}
|
|
||||||
IM_FREE(wd->Frames);
|
IM_FREE(wd->Frames);
|
||||||
IM_FREE(wd->FrameSemaphores);
|
IM_FREE(wd->FrameSemaphores);
|
||||||
wd->Frames = nullptr;
|
wd->Frames = nullptr;
|
||||||
@@ -1399,11 +1482,12 @@ void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, V
|
|||||||
err = vkGetSwapchainImagesKHR(device, wd->Swapchain, &wd->ImageCount, backbuffers);
|
err = vkGetSwapchainImagesKHR(device, wd->Swapchain, &wd->ImageCount, backbuffers);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
|
|
||||||
IM_ASSERT(wd->Frames == nullptr);
|
IM_ASSERT(wd->Frames == nullptr && wd->FrameSemaphores == nullptr);
|
||||||
|
wd->SemaphoreCount = wd->ImageCount + 1;
|
||||||
wd->Frames = (ImGui_ImplVulkanH_Frame*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_Frame) * wd->ImageCount);
|
wd->Frames = (ImGui_ImplVulkanH_Frame*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_Frame) * wd->ImageCount);
|
||||||
wd->FrameSemaphores = (ImGui_ImplVulkanH_FrameSemaphores*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_FrameSemaphores) * wd->ImageCount);
|
wd->FrameSemaphores = (ImGui_ImplVulkanH_FrameSemaphores*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_FrameSemaphores) * wd->SemaphoreCount);
|
||||||
memset(wd->Frames, 0, sizeof(wd->Frames[0]) * wd->ImageCount);
|
memset(wd->Frames, 0, sizeof(wd->Frames[0]) * wd->ImageCount);
|
||||||
memset(wd->FrameSemaphores, 0, sizeof(wd->FrameSemaphores[0]) * wd->ImageCount);
|
memset(wd->FrameSemaphores, 0, sizeof(wd->FrameSemaphores[0]) * wd->SemaphoreCount);
|
||||||
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
||||||
wd->Frames[i].Backbuffer = backbuffers[i];
|
wd->Frames[i].Backbuffer = backbuffers[i];
|
||||||
}
|
}
|
||||||
@@ -1449,7 +1533,7 @@ void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, V
|
|||||||
|
|
||||||
// We do not create a pipeline by default as this is also used by examples' main.cpp,
|
// We do not create a pipeline by default as this is also used by examples' main.cpp,
|
||||||
// but secondary viewport in multi-viewport mode may want to create one with:
|
// but secondary viewport in multi-viewport mode may want to create one with:
|
||||||
//ImGui_ImplVulkan_CreatePipeline(device, allocator, VK_NULL_HANDLE, wd->RenderPass, VK_SAMPLE_COUNT_1_BIT, &wd->Pipeline, bd->Subpass);
|
//ImGui_ImplVulkan_CreatePipeline(device, allocator, VK_NULL_HANDLE, wd->RenderPass, VK_SAMPLE_COUNT_1_BIT, &wd->Pipeline, v->Subpass);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create The Image Views
|
// Create The Image Views
|
||||||
@@ -1501,6 +1585,7 @@ void ImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevic
|
|||||||
IM_ASSERT(g_FunctionsLoaded && "Need to call ImGui_ImplVulkan_LoadFunctions() if IMGUI_IMPL_VULKAN_NO_PROTOTYPES or VK_NO_PROTOTYPES are set!");
|
IM_ASSERT(g_FunctionsLoaded && "Need to call ImGui_ImplVulkan_LoadFunctions() if IMGUI_IMPL_VULKAN_NO_PROTOTYPES or VK_NO_PROTOTYPES are set!");
|
||||||
(void)instance;
|
(void)instance;
|
||||||
ImGui_ImplVulkanH_CreateWindowSwapChain(physical_device, device, wd, allocator, width, height, min_image_count);
|
ImGui_ImplVulkanH_CreateWindowSwapChain(physical_device, device, wd, allocator, width, height, min_image_count);
|
||||||
|
//ImGui_ImplVulkan_CreatePipeline(device, allocator, VK_NULL_HANDLE, wd->RenderPass, VK_SAMPLE_COUNT_1_BIT, &wd->Pipeline, g_VulkanInitInfo.Subpass);
|
||||||
ImGui_ImplVulkanH_CreateWindowCommandBuffers(physical_device, device, wd, queue_family, allocator);
|
ImGui_ImplVulkanH_CreateWindowCommandBuffers(physical_device, device, wd, queue_family, allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1510,10 +1595,9 @@ void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui
|
|||||||
//vkQueueWaitIdle(bd->Queue);
|
//vkQueueWaitIdle(bd->Queue);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
||||||
{
|
|
||||||
ImGui_ImplVulkanH_DestroyFrame(device, &wd->Frames[i], allocator);
|
ImGui_ImplVulkanH_DestroyFrame(device, &wd->Frames[i], allocator);
|
||||||
|
for (uint32_t i = 0; i < wd->SemaphoreCount; i++)
|
||||||
ImGui_ImplVulkanH_DestroyFrameSemaphores(device, &wd->FrameSemaphores[i], allocator);
|
ImGui_ImplVulkanH_DestroyFrameSemaphores(device, &wd->FrameSemaphores[i], allocator);
|
||||||
}
|
|
||||||
IM_FREE(wd->Frames);
|
IM_FREE(wd->Frames);
|
||||||
IM_FREE(wd->FrameSemaphores);
|
IM_FREE(wd->FrameSemaphores);
|
||||||
wd->Frames = nullptr;
|
wd->Frames = nullptr;
|
||||||
@@ -1546,24 +1630,270 @@ void ImGui_ImplVulkanH_DestroyFrameSemaphores(VkDevice device, ImGui_ImplVulkanH
|
|||||||
fsd->ImageAcquiredSemaphore = fsd->RenderCompleteSemaphore = VK_NULL_HANDLE;
|
fsd->ImageAcquiredSemaphore = fsd->RenderCompleteSemaphore = VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplVulkanH_DestroyFrameRenderBuffers(VkDevice device, ImGui_ImplVulkanH_FrameRenderBuffers* buffers, const VkAllocationCallbacks* allocator)
|
void ImGui_ImplVulkanH_DestroyAllViewportsRenderBuffers(VkDevice device, const VkAllocationCallbacks* allocator)
|
||||||
{
|
{
|
||||||
if (buffers->VertexBuffer) { vkDestroyBuffer(device, buffers->VertexBuffer, allocator); buffers->VertexBuffer = VK_NULL_HANDLE; }
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
if (buffers->VertexBufferMemory) { vkFreeMemory(device, buffers->VertexBufferMemory, allocator); buffers->VertexBufferMemory = VK_NULL_HANDLE; }
|
for (int n = 0; n < platform_io.Viewports.Size; n++)
|
||||||
if (buffers->IndexBuffer) { vkDestroyBuffer(device, buffers->IndexBuffer, allocator); buffers->IndexBuffer = VK_NULL_HANDLE; }
|
if (ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)platform_io.Viewports[n]->RendererUserData)
|
||||||
if (buffers->IndexBufferMemory) { vkFreeMemory(device, buffers->IndexBufferMemory, allocator); buffers->IndexBufferMemory = VK_NULL_HANDLE; }
|
ImGui_ImplVulkan_DestroyWindowRenderBuffers(device, &vd->RenderBuffers, allocator);
|
||||||
buffers->VertexBufferSize = 0;
|
|
||||||
buffers->IndexBufferSize = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplVulkanH_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulkanH_WindowRenderBuffers* buffers, const VkAllocationCallbacks* allocator)
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// 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_ImplVulkan_CreateWindow(ImGuiViewport* viewport)
|
||||||
{
|
{
|
||||||
for (uint32_t n = 0; n < buffers->Count; n++)
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
ImGui_ImplVulkanH_DestroyFrameRenderBuffers(device, &buffers->FrameRenderBuffers[n], allocator);
|
ImGui_ImplVulkan_ViewportData* vd = IM_NEW(ImGui_ImplVulkan_ViewportData)();
|
||||||
IM_FREE(buffers->FrameRenderBuffers);
|
viewport->RendererUserData = vd;
|
||||||
buffers->FrameRenderBuffers = nullptr;
|
ImGui_ImplVulkanH_Window* wd = &vd->Window;
|
||||||
buffers->Index = 0;
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
buffers->Count = 0;
|
|
||||||
|
// Create surface
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
VkResult err = (VkResult)platform_io.Platform_CreateVkSurface(viewport, (ImU64)v->Instance, (const void*)v->Allocator, (ImU64*)&wd->Surface);
|
||||||
|
check_vk_result(err);
|
||||||
|
|
||||||
|
// Check for WSI support
|
||||||
|
VkBool32 res;
|
||||||
|
vkGetPhysicalDeviceSurfaceSupportKHR(v->PhysicalDevice, v->QueueFamily, wd->Surface, &res);
|
||||||
|
if (res != VK_TRUE)
|
||||||
|
{
|
||||||
|
IM_ASSERT(0); // Error: no WSI support on physical device
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select Surface Format
|
||||||
|
ImVector<VkFormat> requestSurfaceImageFormats;
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
for (uint32_t n = 0; n < v->PipelineRenderingCreateInfo.colorAttachmentCount; n++)
|
||||||
|
requestSurfaceImageFormats.push_back(v->PipelineRenderingCreateInfo.pColorAttachmentFormats[n]);
|
||||||
|
#endif
|
||||||
|
const VkFormat defaultFormats[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM };
|
||||||
|
for (VkFormat format : defaultFormats)
|
||||||
|
requestSurfaceImageFormats.push_back(format);
|
||||||
|
|
||||||
|
const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
|
||||||
|
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(v->PhysicalDevice, wd->Surface, requestSurfaceImageFormats.Data, (size_t)requestSurfaceImageFormats.Size, requestSurfaceColorSpace);
|
||||||
|
|
||||||
|
// Select Present Mode
|
||||||
|
// FIXME-VULKAN: Even thought mailbox seems to get us maximum framerate with a single window, it halves framerate with a second window etc. (w/ Nvidia and SDK 1.82.1)
|
||||||
|
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR };
|
||||||
|
wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(v->PhysicalDevice, wd->Surface, &present_modes[0], IM_ARRAYSIZE(present_modes));
|
||||||
|
//printf("[vulkan] Secondary window selected PresentMode = %d\n", wd->PresentMode);
|
||||||
|
|
||||||
|
// Create SwapChain, RenderPass, Framebuffer, etc.
|
||||||
|
wd->ClearEnable = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? false : true;
|
||||||
|
wd->UseDynamicRendering = v->UseDynamicRendering;
|
||||||
|
ImGui_ImplVulkanH_CreateOrResizeWindow(v->Instance, v->PhysicalDevice, v->Device, wd, v->QueueFamily, v->Allocator, (int)viewport->Size.x, (int)viewport->Size.y, v->MinImageCount);
|
||||||
|
vd->WindowOwned = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplVulkan_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_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
|
if (ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)viewport->RendererUserData)
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
|
if (vd->WindowOwned)
|
||||||
|
ImGui_ImplVulkanH_DestroyWindow(v->Instance, v->Device, &vd->Window, v->Allocator);
|
||||||
|
ImGui_ImplVulkan_DestroyWindowRenderBuffers(v->Device, &vd->RenderBuffers, v->Allocator);
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->RendererUserData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplVulkan_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
|
ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)viewport->RendererUserData;
|
||||||
|
if (vd == nullptr) // This is nullptr for the main viewport (which is left to the user/app to handle)
|
||||||
|
return;
|
||||||
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
|
vd->Window.ClearEnable = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? false : true;
|
||||||
|
ImGui_ImplVulkanH_CreateOrResizeWindow(v->Instance, v->PhysicalDevice, v->Device, &vd->Window, v->QueueFamily, v->Allocator, (int)size.x, (int)size.y, v->MinImageCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplVulkan_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
|
ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)viewport->RendererUserData;
|
||||||
|
ImGui_ImplVulkanH_Window* wd = &vd->Window;
|
||||||
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
|
VkResult err;
|
||||||
|
|
||||||
|
ImGui_ImplVulkanH_Frame* fd = &wd->Frames[wd->FrameIndex];
|
||||||
|
ImGui_ImplVulkanH_FrameSemaphores* fsd = &wd->FrameSemaphores[wd->SemaphoreIndex];
|
||||||
|
{
|
||||||
|
{
|
||||||
|
err = vkAcquireNextImageKHR(v->Device, wd->Swapchain, UINT64_MAX, fsd->ImageAcquiredSemaphore, VK_NULL_HANDLE, &wd->FrameIndex);
|
||||||
|
check_vk_result(err);
|
||||||
|
fd = &wd->Frames[wd->FrameIndex];
|
||||||
|
}
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
err = vkWaitForFences(v->Device, 1, &fd->Fence, VK_TRUE, 100);
|
||||||
|
if (err == VK_SUCCESS) break;
|
||||||
|
if (err == VK_TIMEOUT) continue;
|
||||||
|
check_vk_result(err);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
err = vkResetCommandPool(v->Device, fd->CommandPool, 0);
|
||||||
|
check_vk_result(err);
|
||||||
|
VkCommandBufferBeginInfo info = {};
|
||||||
|
info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
|
||||||
|
info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
|
||||||
|
err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
|
||||||
|
check_vk_result(err);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
||||||
|
}
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
if (v->UseDynamicRendering)
|
||||||
|
{
|
||||||
|
// Transition swapchain image to a layout suitable for drawing.
|
||||||
|
VkImageMemoryBarrier barrier = {};
|
||||||
|
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||||
|
barrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||||
|
barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
|
barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||||
|
barrier.image = fd->Backbuffer;
|
||||||
|
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
|
barrier.subresourceRange.levelCount = 1;
|
||||||
|
barrier.subresourceRange.layerCount = 1;
|
||||||
|
vkCmdPipelineBarrier(fd->CommandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier);
|
||||||
|
|
||||||
|
VkRenderingAttachmentInfo attachmentInfo = {};
|
||||||
|
attachmentInfo.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR;
|
||||||
|
attachmentInfo.imageView = fd->BackbufferView;
|
||||||
|
attachmentInfo.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||||
|
attachmentInfo.resolveMode = VK_RESOLVE_MODE_NONE;
|
||||||
|
attachmentInfo.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||||
|
attachmentInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
|
attachmentInfo.clearValue = wd->ClearValue;
|
||||||
|
|
||||||
|
VkRenderingInfo renderingInfo = {};
|
||||||
|
renderingInfo.sType = VK_STRUCTURE_TYPE_RENDERING_INFO_KHR;
|
||||||
|
renderingInfo.renderArea.extent.width = wd->Width;
|
||||||
|
renderingInfo.renderArea.extent.height = wd->Height;
|
||||||
|
renderingInfo.layerCount = 1;
|
||||||
|
renderingInfo.viewMask = 0;
|
||||||
|
renderingInfo.colorAttachmentCount = 1;
|
||||||
|
renderingInfo.pColorAttachments = &attachmentInfo;
|
||||||
|
|
||||||
|
ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR(fd->CommandBuffer, &renderingInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
VkRenderPassBeginInfo info = {};
|
||||||
|
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
||||||
|
info.renderPass = wd->RenderPass;
|
||||||
|
info.framebuffer = fd->Framebuffer;
|
||||||
|
info.renderArea.extent.width = wd->Width;
|
||||||
|
info.renderArea.extent.height = wd->Height;
|
||||||
|
info.clearValueCount = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? 0 : 1;
|
||||||
|
info.pClearValues = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? nullptr : &wd->ClearValue;
|
||||||
|
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui_ImplVulkan_RenderDrawData(viewport->DrawData, fd->CommandBuffer, wd->Pipeline);
|
||||||
|
|
||||||
|
{
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
if (v->UseDynamicRendering)
|
||||||
|
{
|
||||||
|
ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR(fd->CommandBuffer);
|
||||||
|
|
||||||
|
// Transition image to a layout suitable for presentation
|
||||||
|
VkImageMemoryBarrier barrier = {};
|
||||||
|
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||||
|
barrier.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||||
|
barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||||
|
barrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||||
|
barrier.image = fd->Backbuffer;
|
||||||
|
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
|
barrier.subresourceRange.levelCount = 1;
|
||||||
|
barrier.subresourceRange.layerCount = 1;
|
||||||
|
vkCmdPipelineBarrier(fd->CommandBuffer, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
vkCmdEndRenderPass(fd->CommandBuffer);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||||
|
VkSubmitInfo info = {};
|
||||||
|
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
||||||
|
info.waitSemaphoreCount = 1;
|
||||||
|
info.pWaitSemaphores = &fsd->ImageAcquiredSemaphore;
|
||||||
|
info.pWaitDstStageMask = &wait_stage;
|
||||||
|
info.commandBufferCount = 1;
|
||||||
|
info.pCommandBuffers = &fd->CommandBuffer;
|
||||||
|
info.signalSemaphoreCount = 1;
|
||||||
|
info.pSignalSemaphores = &fsd->RenderCompleteSemaphore;
|
||||||
|
|
||||||
|
err = vkEndCommandBuffer(fd->CommandBuffer);
|
||||||
|
check_vk_result(err);
|
||||||
|
err = vkResetFences(v->Device, 1, &fd->Fence);
|
||||||
|
check_vk_result(err);
|
||||||
|
err = vkQueueSubmit(v->Queue, 1, &info, fd->Fence);
|
||||||
|
check_vk_result(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplVulkan_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
|
ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)viewport->RendererUserData;
|
||||||
|
ImGui_ImplVulkanH_Window* wd = &vd->Window;
|
||||||
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
|
|
||||||
|
VkResult err;
|
||||||
|
uint32_t present_index = wd->FrameIndex;
|
||||||
|
|
||||||
|
ImGui_ImplVulkanH_FrameSemaphores* fsd = &wd->FrameSemaphores[wd->SemaphoreIndex];
|
||||||
|
VkPresentInfoKHR info = {};
|
||||||
|
info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
||||||
|
info.waitSemaphoreCount = 1;
|
||||||
|
info.pWaitSemaphores = &fsd->RenderCompleteSemaphore;
|
||||||
|
info.swapchainCount = 1;
|
||||||
|
info.pSwapchains = &wd->Swapchain;
|
||||||
|
info.pImageIndices = &present_index;
|
||||||
|
err = vkQueuePresentKHR(v->Queue, &info);
|
||||||
|
if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR)
|
||||||
|
ImGui_ImplVulkanH_CreateOrResizeWindow(v->Instance, v->PhysicalDevice, v->Device, &vd->Window, v->QueueFamily, v->Allocator, (int)viewport->Size.x, (int)viewport->Size.y, v->MinImageCount);
|
||||||
|
else
|
||||||
|
check_vk_result(err);
|
||||||
|
|
||||||
|
wd->FrameIndex = (wd->FrameIndex + 1) % wd->ImageCount; // This is for the next vkWaitForFences()
|
||||||
|
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->SemaphoreCount; // Now we can use the next set of semaphores
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplVulkan_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
IM_ASSERT(platform_io.Platform_CreateVkSurface != nullptr && "Platform needs to setup the CreateVkSurface handler.");
|
||||||
|
platform_io.Renderer_CreateWindow = ImGui_ImplVulkan_CreateWindow;
|
||||||
|
platform_io.Renderer_DestroyWindow = ImGui_ImplVulkan_DestroyWindow;
|
||||||
|
platform_io.Renderer_SetWindowSize = ImGui_ImplVulkan_SetWindowSize;
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplVulkan_RenderWindow;
|
||||||
|
platform_io.Renderer_SwapBuffers = ImGui_ImplVulkan_SwapBuffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplVulkan_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
// 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.
|
||||||
@@ -46,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
|
||||||
{
|
{
|
||||||
@@ -57,24 +69,31 @@ 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
|
|
||||||
VkSampleCountFlagBits MSAASamples; // >= VK_SAMPLE_COUNT_1_BIT (0 -> default to VK_SAMPLE_COUNT_1_BIT)
|
|
||||||
|
|
||||||
// Dynamic Rendering (Optional)
|
// (Optional) Dynamic Rendering
|
||||||
bool UseDynamicRendering; // Need to explicitly enable VK_KHR_dynamic_rendering extension to use this, even for Vulkan 1.3.
|
// Need to explicitly enable VK_KHR_dynamic_rendering extension to use this, even for Vulkan 1.3.
|
||||||
VkFormat ColorAttachmentFormat; // Required for dynamic rendering
|
bool UseDynamicRendering;
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
VkPipelineRenderingCreateInfoKHR PipelineRenderingCreateInfo;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Allocation, Debugging
|
// (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);
|
||||||
@@ -154,6 +173,7 @@ struct ImGui_ImplVulkanH_Window
|
|||||||
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;
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
// 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.
|
||||||
@@ -16,6 +18,10 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 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-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).
|
||||||
@@ -72,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
|
||||||
@@ -179,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)
|
||||||
@@ -329,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!
|
||||||
@@ -448,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;
|
||||||
|
|
||||||
@@ -557,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] = {};
|
||||||
@@ -646,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;
|
||||||
@@ -676,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;
|
||||||
@@ -697,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!");
|
||||||
@@ -708,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;
|
||||||
@@ -725,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;
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
// 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.
|
||||||
@@ -20,7 +22,24 @@
|
|||||||
|
|
||||||
#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);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
// [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.
|
||||||
@@ -39,6 +40,7 @@ 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-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-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-09-07: Inputs: Added support for keyboard codepage conversion for when application is compiled in MBCS mode and using a non-Unicode window.
|
||||||
@@ -91,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;
|
||||||
@@ -101,6 +108,7 @@ struct ImGui_ImplWin32_Data
|
|||||||
INT64 TicksPerSecond;
|
INT64 TicksPerSecond;
|
||||||
ImGuiMouseCursor LastMouseCursor;
|
ImGuiMouseCursor LastMouseCursor;
|
||||||
UINT32 KeyboardCodePage;
|
UINT32 KeyboardCodePage;
|
||||||
|
bool WantUpdateMonitors;
|
||||||
|
|
||||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
bool HasGamepad;
|
bool HasGamepad;
|
||||||
@@ -150,16 +158,21 @@ static bool ImGui_ImplWin32_InitEx(void* hwnd, bool platform_has_own_dc)
|
|||||||
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();
|
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();
|
||||||
IM_UNUSED(platform_has_own_dc); // Used in 'docking' branch
|
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
|
||||||
@@ -202,6 +215,8 @@ void ImGui_ImplWin32_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_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)
|
||||||
@@ -210,7 +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);
|
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,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
|
||||||
@@ -370,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();
|
||||||
@@ -380,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;
|
||||||
@@ -595,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;
|
||||||
@@ -735,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;
|
||||||
}
|
}
|
||||||
@@ -799,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
|
||||||
@@ -898,6 +980,348 @@ 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
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
// [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.
|
||||||
|
|||||||
@@ -35,11 +35,265 @@ HOW TO UPDATE?
|
|||||||
and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users.
|
and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users.
|
||||||
- Please report any issue!
|
- Please report any issue!
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.90.4 (Released 2024-02-22)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.90.4
|
||||||
|
|
||||||
|
Other changes:
|
||||||
|
|
||||||
|
- Nav: Fixed SetKeyboardFocusHere() or programmatic tabbing API from not working on
|
||||||
|
windows with the ImGuiWindowFlags_NoNavInputs flag (regression in 1.90.2, which
|
||||||
|
among other things broke imgui_memory_editor).
|
||||||
|
- Menus, Popups: Fixed an issue where hovering a parent-menu upward would
|
||||||
|
erroneously close the window. (#7325, #7287, #7063)
|
||||||
|
- Popups: Fixed resizable popup minimum size being too small. Standardized minimum
|
||||||
|
size logic. (#7329).
|
||||||
|
- Modals: Temporary changes of ImGuiCol_ModalWindowDimBg are properly handled by
|
||||||
|
BeginPopupModal(). (#7340)
|
||||||
|
- Tables: Angled headers: fixed support for multi-line labels. (#6917)
|
||||||
|
- Tables: Angled headers: various fixes to accurately handle CellPadding changes. (#6917)
|
||||||
|
- Tables: Angled headers: properly registers horizontal component of angled headers
|
||||||
|
for auto-resizing of columns. (#6917)
|
||||||
|
- Tables: Angled headers: fixed TableAngledHeadersRow() incorrect background fill
|
||||||
|
drawn too low, particularly visible with tables that have no scrolling. (#6917)
|
||||||
|
- ProgressBar: Fixed a minor tesselation issue when rendering rounded progress bars,
|
||||||
|
where in some situations the rounded section wouldn't follow regular tesselation rules.
|
||||||
|
- Debug Tools: Item Picker: Promoted ImGui::DebugStartItemPicker() to public API. (#2673)
|
||||||
|
- Debug Tools: Item Picker: Menu entry visible in Demo->Tools but greyed out unless
|
||||||
|
io.ConfigDebugIsDebuggerPresent is set. (#2673)
|
||||||
|
- Misc: Added optional alpha multiplier parameter to GetColorU32(ImU32) variant.
|
||||||
|
- Demo: Custom Rendering: better demonstrate PathArcTo(), PathBezierQuadraticCurveTo(),
|
||||||
|
PathBezierCubicCurveTo(), PathStroke(), PathFillConvex() functions.
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Backends: GLFW: enable ImGuiBackendFlags_HasMouseHoveredViewport support with GLFW 3.3.x,
|
||||||
|
as required specs for it was relaxed in 1.87. This enable better viewport hovering detection
|
||||||
|
without GLFW 3.4's GLFW_MOUSE_PASSTHROUGH, with less reliance on dear imgui's own heuristic
|
||||||
|
of platform windows order. (#7316)
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.90.3 (Released 2024-02-14)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.90.3
|
||||||
|
|
||||||
|
Breaking changes:
|
||||||
|
|
||||||
|
- Backends: SDL2: Removed obsolete ImGui_ImplSDL2_NewFrame(SDL_Window*) signature which
|
||||||
|
was obsoleted in 1.84. Calling ImGui_ImplSDL2_NewFrame() is fine.
|
||||||
|
- Backends: Vulkan: Moved RenderPass parameter from ImGui_ImplVulkan_Init() function to
|
||||||
|
ImGui_ImplVulkan_InitInfo structure. Not required when using dynamic rendering. (#7308) [@shawnhatori]
|
||||||
|
- Backends: Vulkan: Using dynamic rendering now require filling the PipelineRenderingCreateInfo
|
||||||
|
structure in ImGui_ImplVulkan_InitInfo, allowing to configure color/depth/stencil formats.
|
||||||
|
Removed ColorAttachmentFormat field previously provided for dynamic rendering.
|
||||||
|
(#7166, #6855, #5446, #5037) [@shawnhatori]
|
||||||
|
|
||||||
|
Other changes:
|
||||||
|
|
||||||
|
- Menus, Popups: Fixed menus and popups with ChildWindow flag erroneously not displaying
|
||||||
|
a scrollbar when contents is over parent viewport size. (#7287, #7063) [@ZingBallyhoo]
|
||||||
|
- Backends: SDL2, SDL3: Handle gamepad disconnection + fixed increasing gamepad reference
|
||||||
|
counter continuously. Added support for multiple simultaneous gamepads.
|
||||||
|
Added ImGui_ImplSDL2_SetGamepadMode()) function to select whether to automatically pick
|
||||||
|
first available gamepad, all gamepads, or specific gamepads.
|
||||||
|
(#3884, #6559, #6890, #7180) [@ocornut, @lethal-guitar, @wn2000, @bog-dan-ro]
|
||||||
|
- Backends: SDL3: Fixed gamepad handling. (#7180) [@bog-dan-ro]
|
||||||
|
- Backends: SDLRenderer3: query newly added SDL_RenderViewportSet() to not restore
|
||||||
|
a wrong viewport if none was initially set.
|
||||||
|
- Backends: DirectX9: Using RGBA format when allowed by the driver to avoid CPU side
|
||||||
|
conversion. (#6575) [@Demonese]
|
||||||
|
- Internals: Fixed ImFileOpen not working before context is created, preventing creation
|
||||||
|
of a font atlas before main context creation. (#7314, #7315) [@PathogenDavid, @ocornut]
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.90.2 (Released 2024-02-09)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.90.2
|
||||||
|
|
||||||
|
Breaking changes:
|
||||||
|
|
||||||
|
- Commented out ImGuiIO::ImeWindowHandle obsoleted in 1.87 in favor of writing
|
||||||
|
to 'void* ImGuiViewport::PlatformHandleRaw'.
|
||||||
|
- Backends: WebGPU: ImGui_ImplWGPU_Init() now takes a ImGui_ImplWGPU_InitInfo structure
|
||||||
|
instead of variety of parameters, allowing for easier further changes. (#7240)
|
||||||
|
|
||||||
|
Other changes:
|
||||||
|
|
||||||
|
- Nav: keyboard/gamepad activation mark widgets as held to give better visual feedback.
|
||||||
|
- Nav: tweak to logic marking navigated item as hovered when using keyboard, allowing
|
||||||
|
the hover highlight to stay even while another item is activated.
|
||||||
|
- Nav: Fixed SetKeyboardFocusHere() not working when current nav focus is in different scope,
|
||||||
|
regression from 1.90.1 related to code scoping Tab presses to local scope. (#7226) [@bratpilz]
|
||||||
|
- Nav: Fixed pressing Escape while in a child window with _NavFlattened flag. (#7237)
|
||||||
|
- Nav: Improve handling of Alt key to toggle menu so that key ownership may be claimed on
|
||||||
|
individual left/right alt key without interfering with the other.
|
||||||
|
- Nav, Menus: Fixed click on a BeginMenu() followed by right-arrow from making the child menu
|
||||||
|
reopen and flicker (using ImGuiPopupFlags_NoReopen).
|
||||||
|
- Nav: ImGuiWindowFlags_NoNavInputs is tested during scoring so NavFlattened windows can use it.
|
||||||
|
- Popups: OpenPopup(): added ImGuiPopupFlags_NoReopen flag to specifically not close and reopen
|
||||||
|
a popup when it is already open. (#1497, #1533)
|
||||||
|
(Note that this differs from specific handling we already have in place for the case of calling
|
||||||
|
OpenPopup() repeatedly every frame: we already didn't reopen in that specific situation, otherwise
|
||||||
|
the effect would be very disastrous in term of confusion, as reopening would steal focus).
|
||||||
|
- Popups: Slight change to popup closing logic (e.g. after focusing another window) which skipped
|
||||||
|
over popups that are also child windows.
|
||||||
|
- Combo: Fixed not reusing windows optimally when used inside a popup stack.
|
||||||
|
- Debug Tools: Metrics: Fixed debug break in SetShortcutRouting() not handling ImGuiMod_Shortcut redirect.
|
||||||
|
- Debug Tools: Metrics: Improved Monitors and Viewports minimap display. Highlight on hover.
|
||||||
|
- Debug Tools: Debug Log: Added "Input Routing" logging.
|
||||||
|
- Debug Tools: Added "nop" to IM_DEBUG_BREAK macro on GCC to work around GDB bug (#7266) [@Peter0x44]
|
||||||
|
- Backends: Vulkan: Fixed vkAcquireNextImageKHR() validation errors in VulkanSDK 1.3.275 by
|
||||||
|
allocating one extra semaphore than in-flight frames. (#7236) [@mklefrancois]
|
||||||
|
- Backends: Vulkan: Fixed vkMapMemory() calls unnecessarily using full buffer size. (#3957)
|
||||||
|
- Backends: Vulkan: Fixed handling of ImGui_ImplVulkan_InitInfo::MinAllocationSize field. (#7189, #4238)
|
||||||
|
- Backends: WebGPU: Added ImGui_ImplWGPU_InitInfo::PipelineMultisampleState. (#7240)
|
||||||
|
- Backends: WebGPU: Filling all WGPUDepthStencilState fields explicitly as a recent Dawn
|
||||||
|
update stopped setting default values. (#7232) [@GrigoryGraborenko]
|
||||||
|
- Backends: WebGPU: Fixed pipeline layout leak. (#7245) [@rajveermalviya]
|
||||||
|
- Backends: OpenGL3: Backup and restore GL_PIXEL_UNPACK_BUFFER. (#7253)
|
||||||
|
- Internals: Many improvements related to yet unpublicized shortcut routing and input ownership systems.
|
||||||
|
- Internals: InputText: Added internal helpers to force reload of user-buf when active. (#2890) [@kudaba, @ocornut]
|
||||||
|
Often requested in some form (#6962, #5219, #3290, #4627, #5054, #3878, #2881, #1506, #1216, #968),
|
||||||
|
and useful for interactive completion/suggestions popups (#2057, #718)
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Added ImGuiWindowClass::FocusRouteParentWindowId as a way to connect the focus route between
|
||||||
|
a tool window to a parent document window, so that Shortcuts in the documents are routed when the
|
||||||
|
tool is focused (regardless of whether the tool is docked or in a floating viewport, etc.) (#6798)
|
||||||
|
- Added ImGuiDockNodeFlags_DockedWindowsInFocusRoute to automatically make a dockspace connect
|
||||||
|
the focus route of its docked window. This is provided a convenience in case you have windows
|
||||||
|
where a connection is not explicit. (#6798)
|
||||||
|
- Viewports: Fixed moving accross monitors when io.ConfigWindowsMoveFromTitleBarOnly is set. (#7299, #3071)
|
||||||
|
- Backends: OSX: Fixed not submitting Monitors info when viewports are not enabled, leading to
|
||||||
|
missing e.g. DpiScale info. (#7257) [@actboy168]
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.90.1 (Released 2024-01-10)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.90.1
|
||||||
|
|
||||||
|
Breaking changes:
|
||||||
|
|
||||||
|
- imgui_freetype: commented out ImGuiFreeType::BuildFontAtlas() obsoleted in 1.81.
|
||||||
|
Prefer using #define IMGUI_ENABLE_FREETYPE or see commented code for manual calls.
|
||||||
|
- Removed CalcListClipping() marked obsolete in 1.86. (#3841)
|
||||||
|
Prefer using ImGuiListClipper which can return non-contiguous ranges.
|
||||||
|
- Internals, Columns: commented out legacy ImGuiColumnsFlags_XXX symbols redirecting
|
||||||
|
to ImGuiOldColumnsFlags_XXX, obsoleted from imgui_internal.h in 1.80.
|
||||||
|
- Commented out obsolete ImGuiKey_KeyPadEnter redirection to ImGuiKey_KeypadEnter. (#2625, #7143)
|
||||||
|
|
||||||
|
Other changes:
|
||||||
|
|
||||||
|
- Windows:
|
||||||
|
- BeginChild(): Fixed auto-resizing erroneously limiting size to host viewport
|
||||||
|
minus padding. There are no limit to a child width/height. (#7063) [@Devyre]
|
||||||
|
- BeginChild(): Resize borders rendered even when ImGuiWindowFlags_NoBackground
|
||||||
|
is specified. (#1710, #7194)
|
||||||
|
- Fixed some auto-resizing path using style.WindowMinSize.x (instead of x/y)
|
||||||
|
for both axises since 1.90. (#7106) [@n0bodysec]
|
||||||
|
- Scrolling: internal scrolling value is rounded instead of truncated, as a way to reduce
|
||||||
|
speed asymmetry when (incorrectly) attempting to scroll by non-integer amount. (#6677)
|
||||||
|
- Navigation (Keyboard/gamepad):
|
||||||
|
- Nav, IO: SetNextFrameWantCaptureKeyboard(false) calls are not overridden back to true when
|
||||||
|
navigation is enabled. SetNextFrameWantCaptureKeyboard() is always higher priority. (#6997)
|
||||||
|
- Nav: Activation can also be performed with Keypad Enter. (#5606)
|
||||||
|
- Drag and Drop:
|
||||||
|
- Fixed drop target highlight on items temporarily pushing a widened clip rect
|
||||||
|
(namely Selectables and Treenodes using SpanAllColumn flag) so the highlight properly covers
|
||||||
|
all columns. (#7049, #4281, #3272)
|
||||||
|
- InputText:
|
||||||
|
- InputTextMultiline: Fixed Tab character input not repeating (1.89.4 regression).
|
||||||
|
- InputTextMultiline: Tabbing through a multi-line text editor which allows Tab character inputs
|
||||||
|
(using the ImGuiInputTextFlags_AllowTabInput flag) doesn't automatically activate it, in order
|
||||||
|
to allow passing through multiple widgets easily. (#3092, #5759, #787)
|
||||||
|
- Drags, Sliders, Inputs:
|
||||||
|
- DragScalarN, SliderScalarN, InputScalarN: Fixed incorrect pushes into ItemWidth
|
||||||
|
stack when number of components is 1. [#7095] [@Nahor]
|
||||||
|
- Drags, Sliders, Inputs: removed all attempts to filter non-numerical characters during text
|
||||||
|
editing. Invalid inputs not applied to value, visibly reverted after validation. (#6810, #7096)
|
||||||
|
- Drags, Sliders, Inputs: removal of filter means that "nan" and "inf" values may be input. (#7096)
|
||||||
|
- DragScalarN, SliderScalarN, InputScalarN, PushMultiItemsWidths: improve multi-components
|
||||||
|
width computation to better distribute the error. (#7120, #7121) [@Nahor]
|
||||||
|
- Menus:
|
||||||
|
- Tweaked hover slack logic, adding an extra timeout to avoid situations where a slow vertical
|
||||||
|
movements toward another parent BeginMenu() can keep the wrong child menu open. (#6671, #6926)
|
||||||
|
- Color Editors:
|
||||||
|
- ColorEdit: Layout tweaks for very small sizes. (#7120, #7121)
|
||||||
|
- ColorPicker: Fixed saturation/value cursor radius not scaling properly.
|
||||||
|
- Tabs: Added ImGuiTabItemFlags_NoAssumedClosure to enable app to react on closure attempt,
|
||||||
|
without having to draw an unsaved document marker (ImGuiTabItemFlags_UnsavedDocument sets
|
||||||
|
_NoAssumedClosure automatically). (#7084)
|
||||||
|
- Debug Tools:
|
||||||
|
- Added io.ConfigDebugIsDebuggerPresent option. When enabled, this adds buttons in various
|
||||||
|
locations of Metrics/Debugger to manually request a debugger break:
|
||||||
|
- Request a debug break in a Begin() call.
|
||||||
|
- Request a debug break in a ItemAdd() call via debug log and hovering 0xXXXXXX identifiers.
|
||||||
|
- Request a debug break in a BeginTable() call.
|
||||||
|
- Request a debug break in a SetShortcutRouting()/Shortcut() call. [Internal]
|
||||||
|
- Metrics: Reorganize Tools menu.
|
||||||
|
- Added DebugFlashStyleColor() to identify a style color. Added to Style Editor.
|
||||||
|
- Debug Log: Hide its own clipper log to reduce noise in the output. (#5855)
|
||||||
|
- Debug Log: Clicking any filter with SHIFT held enables it for 2 frames only,
|
||||||
|
making it easier when dealing with spammy logs. (#5855)
|
||||||
|
- Settings: Fixed an issue marking settings as dirty when merely clicking on a border or resize
|
||||||
|
grip without moving it.
|
||||||
|
- Misc: Added IMGUI_USER_H_FILENAME to change the path included when using
|
||||||
|
IMGUI_INCLUDE_IMGUI_USER_H. (#7039) [@bryceberger]
|
||||||
|
- Misc: Rework debug display of texture id in Metrics window to avoid compile-error when
|
||||||
|
ImTextureID is defined to be larger than 64-bits. (#7090)
|
||||||
|
- Misc: Added extra courtesy ==/!= operators when IMGUI_DEFINE_MATH_OPERATORS is defined.
|
||||||
|
- Misc: Fixed text functions fast-path for handling "%s" and "%.*s" to handle null pointers gracefully,
|
||||||
|
like most printf implementations. (#7016, #3466, #6846) [@codefrog2002]
|
||||||
|
- Misc: Renamed some defines in imstb_textedit.h to avoid conflicts when using unity/jumbo builds
|
||||||
|
on a codebase where another copy of the library is used.
|
||||||
|
- Misc: During shutdown, check that io.BackendPlatformUserData and io.BackendRendererUserData are NULL
|
||||||
|
in order to catch cases where backend was not shut down. (#7175)
|
||||||
|
- Misc: Reworked Issue Template to a shinier and better form. (#5927) [@Panquesito7, @PathogenDavid, @ocornut]
|
||||||
|
- Backends:
|
||||||
|
- GLFW, Emscripten: Added ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback() to
|
||||||
|
register canvas selector and auto-resize GLFW window. (#6751) [@Traveller23, @ypujante]
|
||||||
|
- GLFW: Fixed Windows specific hooks to use Unicode version of WndProc even when
|
||||||
|
compiling in MBCS mode. (#7174) [@kimidaisuki22]
|
||||||
|
- OpenGL3: Update GL3W based imgui_impl_opengl3_loader.h to load libGL.so variants in
|
||||||
|
case of missing symlink. Fix 1.90 regression for some distros. (#6983)
|
||||||
|
- Vulkan: Fixed mismatching allocator passed to vkCreateCommandPool() vs
|
||||||
|
vkDestroyCommandPool(). (#7075) [@FoonTheRaccoon]
|
||||||
|
- Vulkan: Added MinAllocationSize field in ImGui_ImplVulkan_InitInfo to workaround zealous
|
||||||
|
"best practice" validation layer. (#7189, #4238) [@philae-ael]
|
||||||
|
- Vulkan: Stopped creating command pools with VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT
|
||||||
|
as we don't reset them.
|
||||||
|
- WebGPU: Fixed wgpuRenderPassEncoderSetScissorRect() crash when rendering modal window's
|
||||||
|
dimming layer, which has an unclipped value in ImDrawCmd::ClipRect. (#7191) [@aparis69]
|
||||||
|
- Examples:
|
||||||
|
- Examples: GLFW+Emscripten: Fixed examples not consistently resizing according to host canvas.
|
||||||
|
(#6751) [@Traveller23, @ypujante]
|
||||||
|
- Examples: SDL3: Minor fixes following recent SDL3 in-progress development.
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Windows: Fixed ImGuiCol_TitleBg/Active alpha being used for viewport-owned windows. (#7181) [@PathogenDavid]
|
||||||
|
- Backends: DX12: Changed swapchain scaling mode to DXGI_SCALING_NONE to reduce artifacts as
|
||||||
|
queued frames aren't synchronized with platform window resizes. (#7152, #7153) [@SuperWangKai]
|
||||||
|
- Backends: OSX: Fixed monitor and window position by correctly transforming Y origin on multi-viewports
|
||||||
|
multi-monitor setups. (#7028, #7101, #6009, #6432) [@dmirty-kuzmenko, @734vin]
|
||||||
|
- Backends: OSX: Fixed IME position in multi-monitor multi-viewports setups. (#7028) [@734vin]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.90.0 (Released 2023-11-15)
|
VERSION 1.90.0 (Released 2023-11-15)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.90
|
||||||
|
|
||||||
Breaking changes:
|
Breaking changes:
|
||||||
|
|
||||||
- BeginChild(): Upgraded 'bool border = false' parameter to 'ImGuiChildFlags flags = 0'.
|
- BeginChild(): Upgraded 'bool border = false' parameter to 'ImGuiChildFlags flags = 0'.
|
||||||
@@ -153,7 +407,7 @@ Other changes:
|
|||||||
with ImGuiDragDropFlags_AcceptNoPreviewTooltip and submitting a tooltip manually.
|
with ImGuiDragDropFlags_AcceptNoPreviewTooltip and submitting a tooltip manually.
|
||||||
- Tables:
|
- Tables:
|
||||||
- Added angled headers support. You need to set ImGuiTableColumnFlags_AngledHeader on selected
|
- Added angled headers support. You need to set ImGuiTableColumnFlags_AngledHeader on selected
|
||||||
columns and call TableAngledHeadersRow(). Added style.TableAngledHeadersAngle style option.
|
columns and call TableAngledHeadersRow(). Added style.TableAngledHeadersAngle style option. (#6917)
|
||||||
- Added ImGuiTableFlags_HighlightHoveredColumn flag, currently highlighting column header.
|
- Added ImGuiTableFlags_HighlightHoveredColumn flag, currently highlighting column header.
|
||||||
- Fixed an edge-case when no columns are visible + table scrollbar is visible + user
|
- Fixed an edge-case when no columns are visible + table scrollbar is visible + user
|
||||||
code is always testing return value of TableSetColumnIndex() to coarse clip. With an active
|
code is always testing return value of TableSetColumnIndex() to coarse clip. With an active
|
||||||
@@ -225,6 +479,8 @@ Other changes:
|
|||||||
Fixed leaks, and added ImGui_ImplVulkan_DestroyFontsTexture() (probably no need to call this directly).
|
Fixed leaks, and added ImGui_ImplVulkan_DestroyFontsTexture() (probably no need to call this directly).
|
||||||
(#6943, #6715, #6327, #3743, #4618)
|
(#6943, #6715, #6327, #3743, #4618)
|
||||||
[@helynranta, @thomasherzog, @guybrush77, @albin-johansson, @MiroKaku, @benbatya-fb, @ocornut]
|
[@helynranta, @thomasherzog, @guybrush77, @albin-johansson, @MiroKaku, @benbatya-fb, @ocornut]
|
||||||
|
- Backends: Vulkan: use specified ColorAttachmentFormat when creating a secondary window when enabling
|
||||||
|
UseDynamicRendering option. (#6999, #5446, #5037) [@raaaviol]
|
||||||
- Backends: GLFW: Clear emscripten's MouseWheel callback before shutdown. (#6790, #6096, #4019) [@halx99]
|
- Backends: GLFW: Clear emscripten's MouseWheel callback before shutdown. (#6790, #6096, #4019) [@halx99]
|
||||||
- Backends: GLFW: Added support for F13 to F24 function keys. (#6891)
|
- Backends: GLFW: Added support for F13 to F24 function keys. (#6891)
|
||||||
- Backends: SDL2, SDL3: Added support for F13 to F24 function keys, AppBack, AppForward. (#6891)
|
- Backends: SDL2, SDL3: Added support for F13 to F24 function keys, AppBack, AppForward. (#6891)
|
||||||
@@ -242,6 +498,31 @@ Other changes:
|
|||||||
- Examples: GLFW+Vulkan, SDL+Vulkan: Simplified and removed code due to backend improvements.
|
- Examples: GLFW+Vulkan, SDL+Vulkan: Simplified and removed code due to backend improvements.
|
||||||
- Internals: Renamed ImFloor() to ImTrunc(). Renamed ImFloorSigned() to ImFloor(). (#6861)
|
- Internals: Renamed ImFloor() to ImTrunc(). Renamed ImFloorSigned() to ImFloor(). (#6861)
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Viewports: Fixed window inner clipping rectangle off by one when window is located on a monitor
|
||||||
|
with negative coordinates. While it is expected that other small issues with arise from this
|
||||||
|
situation, at the moment we are fixing the most noticeable one. (#6861, #2884) [@Vuhdo, @alektron]
|
||||||
|
- Docking: revised undocking to reduce accidental whole-node undocking:
|
||||||
|
- cannot undock a whole node by dragging from empty space in tab-bar.
|
||||||
|
- can undock whole node by dragging from window/collapse menu button.
|
||||||
|
- can undock single window by dragging from its tab.
|
||||||
|
- can still move (but not undock) whole node or whole hierarchy when node is part of a
|
||||||
|
floating hierarchy.
|
||||||
|
- added tooltip when hovering the collapse/window menu button, to faciliate understanding
|
||||||
|
that whole dock node may be undocked or grabbed from here.
|
||||||
|
- Docking: Fixed an issue leading to incorrect restoration of selected tab in dock nodes that
|
||||||
|
don't carry the currently focused window. (#2304)
|
||||||
|
- Docking: added ImGuiDockNodeFlags_NoUndocking. (#2999, #6823, #6780, #3492)
|
||||||
|
- Docking: renamed ImGuiDockNodeFlags_NoSplit to ImGuiDockNodeFlags_NoDockingSplit.
|
||||||
|
- Docking: renamed ImGuiDockNodeFlags_NoDockingInCentralNode to ImGuiDockNodeFlags_NoDockingOverCentralNode.
|
||||||
|
- Docking: Internals: renamed ImGuiDockNodeFlags_NoDockingSplitMe to ImGuiDockNodeFlags_NoDockingSplit.
|
||||||
|
- Docking: Fixed a bug where ClassId compare tests (when using SetNextWindowClass) on success would
|
||||||
|
prevent further filter from running, namely the one that prevent docking over a popup.
|
||||||
|
- Backends: GLFW: Fixed an assertion in situation where the WndProc handler is different between
|
||||||
|
main and secondary viewport (may happen due to third-party hooks). (#6889)
|
||||||
|
- Backends: DX9: Fixed incorrect assert triggering on reopening session with minimized windows. (#3424)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.9 (Released 2023-09-04)
|
VERSION 1.89.9 (Released 2023-09-04)
|
||||||
@@ -299,6 +580,11 @@ Other changes:
|
|||||||
- Examples: Emscripten+WebGPU: Fixed WGPUInstance creation process + use preferred
|
- Examples: Emscripten+WebGPU: Fixed WGPUInstance creation process + use preferred
|
||||||
framebuffer format. (#6640, #6748) [@smileorigin]
|
framebuffer format. (#6640, #6748) [@smileorigin]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: when io.ConfigDockingWithShift is enabled, staying stationary while moving
|
||||||
|
a window displays an help tooltip to increase affordance. (#6709, #4643)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.8 (Released 2023-08-01)
|
VERSION 1.89.8 (Released 2023-08-01)
|
||||||
@@ -367,6 +653,16 @@ Other changes:
|
|||||||
- Examples: Vulkan: Creating minimal descriptor pools to fit only what is needed by
|
- Examples: Vulkan: Creating minimal descriptor pools to fit only what is needed by
|
||||||
example. (#6642) [@SaschaWillem]
|
example. (#6642) [@SaschaWillem]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking, Style: resizing separators use same colors as window borders (ImGuiCol_Border)
|
||||||
|
for consistency. With default styles it doesn't make a big difference. (#2522) [@rmitton]
|
||||||
|
In the future if we promote using thick value for inner/outer docking padding we may
|
||||||
|
need to introduce new colors for it.
|
||||||
|
- Docking: added style.DockingSeparatorSize, ImGuiStyleVar_DockingSeparatorSize. Now
|
||||||
|
also scaled by style.ScaleAllSizes(). (#3481, #4721, #2522) [@PossiblyAShrub, @wobbier]
|
||||||
|
- Docking: fixed rendering of docked-window scrollbar above outer border. (#2522)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.7 (Released 2023-07-04)
|
VERSION 1.89.7 (Released 2023-07-04)
|
||||||
@@ -462,6 +758,23 @@ Other changes:
|
|||||||
- Examples: Win32+OpenGL3: Changed DefWindowProc() to DefWindowProcW() to match other examples
|
- Examples: Win32+OpenGL3: Changed DefWindowProc() to DefWindowProcW() to match other examples
|
||||||
and support the example app being compiled without UNICODE. (#6516, #5725, #5961, #5975) [@yenixing]
|
and support the example app being compiled without UNICODE. (#6516, #5725, #5961, #5975) [@yenixing]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Viewports+Docking: Fixed extraneous viewport+platform-window recreation in various
|
||||||
|
combination of showing or hiding windows, docking with/without split, undocking.
|
||||||
|
While with some backends and without OS decorations, some extraneous window recreation
|
||||||
|
were visibly not noticeable, they would typically become noticeable when enabling
|
||||||
|
OS decorations on those windows (e.g. Windows title bar fade-in/animation).
|
||||||
|
- Viewports: Closing a viewport via OS/platform means (e.g. OS close button or task-bar menu),
|
||||||
|
mark all windows in this viewport as closed.
|
||||||
|
- Docking: Fixed one-frame flickering on reappearing windows binding to a dock node
|
||||||
|
where a later-submitted window was already bound.
|
||||||
|
- Docking: Fixed dragging from title-bar empty space (regression from 1.88 related to
|
||||||
|
keeping ID alive when calling low-level ButtonBehavior() directly). (#5181, #2645)
|
||||||
|
- Docking: [Internal] DockBuilderDockWindow() API calls don't clear docking order
|
||||||
|
if the target node is same as existing one.
|
||||||
|
- Backends: Win32: Added support for changing ParentViewportID after viewport creation.
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.6 (Released 2023-05-31)
|
VERSION 1.89.6 (Released 2023-05-31)
|
||||||
@@ -531,6 +844,23 @@ Other changes:
|
|||||||
- Examples: Added SDL3+SDL_Renderer example. (#6286)
|
- Examples: Added SDL3+SDL_Renderer example. (#6286)
|
||||||
- Examples: Updated all Visual Studio projects and batches to use /utf-8 argument.
|
- Examples: Updated all Visual Studio projects and batches to use /utf-8 argument.
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Viewports: Fixed platform-side focus (e.g. Alt+Tab) from leading to accidental
|
||||||
|
closure of Modal windows. Regression from 1.89.5. (#6357, #6299)
|
||||||
|
- Viewports: Fixed loss of imgui-side focus when dragging a secondary viewport back in
|
||||||
|
main viewport, due to platform-side handling changes. Regression from 1.89.5 (#6299)
|
||||||
|
- Viewports: Avoid applying imgui-side focus when focus change is due to a viewport
|
||||||
|
destruction. Fixes erroneous popup closure on closing a previous popup. (#6462, #6299)
|
||||||
|
- Viewports: Added void* ImGuiPlatformMonitor::PlatformHandle field (backend-dependant),
|
||||||
|
for usage by user code.
|
||||||
|
- Backends: GLFW: Preserve monitor list when there are no monitor, may briefly
|
||||||
|
happen when recovering from macOS sleeping mode. (#5683) [@Guistac]
|
||||||
|
- Backends: SDL2: Update monitor list when receiving a display event. (#6348)
|
||||||
|
Note however that SDL2 currently doesn't have an event for a DPI/Scaling change,
|
||||||
|
so monitor data won't be updated in this situation.
|
||||||
|
- Backends: SDL3: Update monitor list when receiving a display event. (#6348)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.5 (Released 2023-04-13)
|
VERSION 1.89.5 (Released 2023-04-13)
|
||||||
@@ -588,7 +918,6 @@ Other changes:
|
|||||||
is to other IME function such as SDL_SetTextInputRect(). (#6306, #6071, #1953)
|
is to other IME function such as SDL_SetTextInputRect(). (#6306, #6071, #1953)
|
||||||
- Backends: GLFW: Added support on Win32 only for io.AddMouseSourceEvent() to discriminate
|
- Backends: GLFW: Added support on Win32 only for io.AddMouseSourceEvent() to discriminate
|
||||||
Mouse/TouchScreen/Pen. (#2334, #2702)
|
Mouse/TouchScreen/Pen. (#2334, #2702)
|
||||||
- Backends: GLFW: Fixed key modifiers handling on secondary viewports. (#6248, #6034) [@aiekick]
|
|
||||||
- Backends: Android: Added support for io.AddMouseSourceEvent() to discriminate Mouse/TouchScreen/Pen.
|
- Backends: Android: Added support for io.AddMouseSourceEvent() to discriminate Mouse/TouchScreen/Pen.
|
||||||
(#6315) [@PathogenDavid]
|
(#6315) [@PathogenDavid]
|
||||||
- Backends: OSX: Added support for io.AddMouseSourceEvent() to discriminate Mouse/Pen.
|
- Backends: OSX: Added support for io.AddMouseSourceEvent() to discriminate Mouse/Pen.
|
||||||
@@ -604,6 +933,16 @@ Other changes:
|
|||||||
- TestSuite: Added variety of new regression tests and improved/amended existing ones
|
- TestSuite: Added variety of new regression tests and improved/amended existing ones
|
||||||
in imgui_test_engine/ repo. [@PathogenDavid, @ocornut]
|
in imgui_test_engine/ repo. [@PathogenDavid, @ocornut]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Viewports: Setting focus from Platform/OS (e.g. via decoration, or Alt-Tab) sets corresponding
|
||||||
|
focus at Dear ImGui level (generally last focused window in the viewport). (#6299)
|
||||||
|
- Docking: Fixed using GetItemXXX() or IsItemXXX() functions after a DockSpace(). (#6217)
|
||||||
|
- Backends: GLFW: Fixed key modifiers handling on secondary viewports. (#6248, #6034) [@aiekick]
|
||||||
|
- Backends: GLFW: Fixed Emscripten erroneously enabling multi-viewport support, leading to assert. (#5683)
|
||||||
|
- Backends: SDL2/SDL3: Fixed IME text input rectangle position with viewports. (#6071, #1953)
|
||||||
|
- Backends: SDL3: Fixed for compilation with multi-viewports. (#6255) [@P3RK4N]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.4 (Released 2023-03-14)
|
VERSION 1.89.4 (Released 2023-03-14)
|
||||||
@@ -678,7 +1017,6 @@ Other changes:
|
|||||||
and ImGuiConfigFlags_NavEnableGamepad by default. (#787)
|
and ImGuiConfigFlags_NavEnableGamepad by default. (#787)
|
||||||
- Internals: Misc tweaks to facilitate applying an explicit-context patch. (#5856) [@Dragnalith]
|
- Internals: Misc tweaks to facilitate applying an explicit-context patch. (#5856) [@Dragnalith]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.3 (Released 2023-02-14)
|
VERSION 1.89.3 (Released 2023-02-14)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
@@ -779,6 +1117,10 @@ Other changes:
|
|||||||
- Examples: SDL2+SDL_Renderer: Added call to SDL_RenderSetScale() to fix display on a
|
- Examples: SDL2+SDL_Renderer: Added call to SDL_RenderSetScale() to fix display on a
|
||||||
Retina display (albeit lower-res as our other unmodified examples). (#6121, #6065, #5931).
|
Retina display (albeit lower-res as our other unmodified examples). (#6121, #6065, #5931).
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Backends: GLFW: Handle unsupported glfwGetVideoMode() for Emscripten. (#6096)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.2 (Released 2023-01-05)
|
VERSION 1.89.2 (Released 2023-01-05)
|
||||||
@@ -829,6 +1171,17 @@ All changes:
|
|||||||
- Backends: Vulkan: Fixed sampler passed to ImGui_ImplVulkan_AddTexture() not being honored as we were using
|
- Backends: Vulkan: Fixed sampler passed to ImGui_ImplVulkan_AddTexture() not being honored as we were using
|
||||||
an immutable sampler. (#5502, #6001, #914) [@martin-ejdestig, @rytisss]
|
an immutable sampler. (#5502, #6001, #914) [@martin-ejdestig, @rytisss]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Internals: fixed DockBuilderCopyDockSpace() crashing when windows not in the
|
||||||
|
remapping list are docked on the left or top side of a split. (#6035)
|
||||||
|
- Docking: fixed DockSpace() with ImGuiDockNodeFlags_KeepAliveOnly marking current window
|
||||||
|
as written to, even if it doesn't technically submit an item. This allow using KeepAliveOnly
|
||||||
|
from any window location. (#6037)
|
||||||
|
- Backends: OSX: fixed typo in ImGui_ImplOSX_GetWindowSize that would cause issues when resiing
|
||||||
|
from OS decorations, if they are enabled on secondary viewports. (#6009) [@sivu]
|
||||||
|
- Backends: Metal: fixed secondary viewport rendering. (#6015) [@dmirty-kuzmenko]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.1 (Released 2022-11-24)
|
VERSION 1.89.1 (Released 2022-11-24)
|
||||||
@@ -855,6 +1208,13 @@ Other changes:
|
|||||||
- Backends: GLFW: cancel out errors emitted by glfwGetKeyName() when a name is missing. (#5908)
|
- Backends: GLFW: cancel out errors emitted by glfwGetKeyName() when a name is missing. (#5908)
|
||||||
- Backends: WebGPU: fixed validation error with default depth buffer settings. (#5869, #5914) [@kdchambers]
|
- Backends: WebGPU: fixed validation error with default depth buffer settings. (#5869, #5914) [@kdchambers]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Viewports: Fixed collapsed windows setting ImGuiViewportFlags_NoRendererClear without
|
||||||
|
making title bar color opaque, leading to potential texture/fb garbage being visible.
|
||||||
|
Right now as we don't fully support transparent viewports (#2766), so we turn that
|
||||||
|
'TitleBgCollapsed' color opaque just lke we do for 'WindowBG' on uncollapsed windows.
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89 (Released 2022-11-15)
|
VERSION 1.89 (Released 2022-11-15)
|
||||||
@@ -1046,6 +1406,23 @@ Other Changes:
|
|||||||
- Backends: Vulkan: Added experimental ImGui_ImplVulkan_RemoveTexture() for api symetry. (#914, #5738).
|
- Backends: Vulkan: Added experimental ImGui_ImplVulkan_RemoveTexture() for api symetry. (#914, #5738).
|
||||||
- Backends: WebGPU: fixed rendering when a depth buffer is enabled. (#5869) [@brainlag]
|
- Backends: WebGPU: fixed rendering when a depth buffer is enabled. (#5869) [@brainlag]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Fixed incorrect focus highlight on docking node when focusing a menu. (#5702)
|
||||||
|
- Docking, Nav: Fixed using gamepad/keyboard navigation not being able enter menu layer when
|
||||||
|
it only contained the standard Collapse/Close buttons and no actual menu. (#5463, #4792)
|
||||||
|
- Docking: Fixed regression introduced in v1.87 when docked window content not rendered
|
||||||
|
while switching between with CTRL+Tab. [@rokups]
|
||||||
|
- Docking: Fixed amending into an existing tab bar from rendering invisible items. (#5515)
|
||||||
|
- Docking: Made spacing between dock nodes not a dropping gap. When hovering it only
|
||||||
|
outer-docking drop markers are visible.
|
||||||
|
- Docking+Viewports: Fixed undocking window node causing parent viewports to become unresponsive
|
||||||
|
in certain situation (e.g. hidden tab bar). (#5503) [@rokups]
|
||||||
|
- Backends: SDL: Fixed building backend under non-OSX Apple targets (e.g. iPhone). (#5665)
|
||||||
|
- Backends: SDL: Fixed drag'n drop crossing a viewport border losing mouse coordinates. (#5710, #5012)
|
||||||
|
- Backends: GLFW: Fixed leftover static variable preventing from changing or
|
||||||
|
reinitializing backend while application is running. (#4616, #5434) [@rtoumazet]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.88 (Released 2022-06-21)
|
VERSION 1.88 (Released 2022-06-21)
|
||||||
@@ -1180,6 +1557,26 @@ Other Changes:
|
|||||||
- Examples: Emscripten+WebGPU: Fix building for latest WebGPU specs. (#3632)
|
- Examples: Emscripten+WebGPU: Fix building for latest WebGPU specs. (#3632)
|
||||||
- Examples: OSX+Metal, OSX+OpenGL: Removed now-unnecessary calls to ImGui_ImplOSX_HandleEvent(). (#4821)
|
- Examples: OSX+Metal, OSX+OpenGL: Removed now-unnecessary calls to ImGui_ImplOSX_HandleEvent(). (#4821)
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Fixed floating docked nodes not being clamped into viewport workrect to stay reachable
|
||||||
|
when io.ConfigWindowsMoveFromTitleBarOnly is true and multi-viewports are disabled. (#5044)
|
||||||
|
- Docking: Fixed a regression where moving window would be interrupted after undocking a tab
|
||||||
|
when io.ConfigDockingAlwaysTabBar is true. (#5324) [@rokups]
|
||||||
|
- Docking: Fixed incorrect focus highlight on docking node when focusing empty central node
|
||||||
|
or a child window which was manually injected into a dockspace window.
|
||||||
|
- Docking, Modal: Fixed a crash when opening popup from a parent which is being docked on the same frame. (#5401)
|
||||||
|
- Viewports: Fixed an issue where MouseViewport was lagging by a frame when using 1.87 Input Queue.
|
||||||
|
A common side-effect would be that when releasing a window drag the underlying window would highlight
|
||||||
|
for a frame. (#5837, #4921) [@cfillion]
|
||||||
|
- Viewports: Fixed translating a host viewport from briefly altering the size of AlwaysAutoResize windows. (#5057)
|
||||||
|
- Viewports: Fixed main viewport size not matching ImDrawData::DisplaySize for one frame during resize
|
||||||
|
when multi-viewports are disabled. (#4900)
|
||||||
|
- Backends: SDL: Fixed dragging out main viewport broken on some SDL setups. (#5012) [@rokups]
|
||||||
|
- Backends: OSX: Added support for multi-viewports. [@stuartcarnie, @metarutaiga] (#4821, #2778)
|
||||||
|
- Backends: Metal: Added support for multi-viewports. [@stuartcarnie, @metarutaiga] (#4821, #2778)
|
||||||
|
- Examples: OSX+Metal, SDL+Metal, GLFW+Metal: Added support for multi-viewports. [@rokups]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.87 (Released 2022-02-07)
|
VERSION 1.87 (Released 2022-02-07)
|
||||||
@@ -1322,6 +1719,29 @@ Other Changes:
|
|||||||
- Backends: WebGPU: Fixed incorrect size parameters in wgpuRenderPassEncoderSetIndexBuffer() and
|
- Backends: WebGPU: Fixed incorrect size parameters in wgpuRenderPassEncoderSetIndexBuffer() and
|
||||||
wgpuRenderPassEncoderSetVertexBuffer() calls. (#4891) [@FeepsDev]
|
wgpuRenderPassEncoderSetVertexBuffer() calls. (#4891) [@FeepsDev]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Fixed a CTRL+TAB crash when aiming at an empty docked window. (#4792)
|
||||||
|
- Docking: Tabs use their own identifier instead of the Window identifier.
|
||||||
|
(This will invalidate some stored .ini data such as last selected tab, sorry!)
|
||||||
|
- Docking: Fixed size constraints not working on single window holding on a dock id (still doesn't work on docked windows).
|
||||||
|
- Docking: Fixed CTRL+TAB back into a docked window not selecting menu layer when no item are on main layer.
|
||||||
|
- Viewports, IO: Added io.AddMouseViewportEvent() function to queue hovered viewport change (when known by backend).
|
||||||
|
- Viewports: Relaxed specs for backend supporting ImGuiBackendFlags_HasMouseHoveredViewport: it is now _optional_
|
||||||
|
for the backend to have to ignore viewports with the _NoInputs flag when call io.AddMouseViewportEvent(). It is
|
||||||
|
much better if they can (Win32 and GLFW 3.3+ backends can, SDL and GLFW 3.2 backends cannot, they are lacking data).
|
||||||
|
A concrete example is: when dragging a viewport for docking, the viewport is marked with _NoInputs to allow us
|
||||||
|
to pick the target viewports for docking. If the backend reports a viewport with _NoInputs when calling the
|
||||||
|
io.AddMouseViewportEvent() function, then Dear ImGui will revert to its flawed heuristic to find the viewport under.
|
||||||
|
By lowering those specs, we allow the SDL and more backend to support this, only relying on the heuristic in a few
|
||||||
|
drag and drop situations rather that relying on it everywhere.
|
||||||
|
- Viewports: Fixed a CTRL+TAB crash with viewports enabled when the window list needs to appears in
|
||||||
|
its own viewport (regression from 1.86). (#4023, #787)
|
||||||
|
- Viewports: Fixed active InputText() from preventing viewports to merge. (#4212)
|
||||||
|
- Backends: SDL: Added support for ImGuiBackendFlags_HasMouseHoveredViewport now that its specs have been lowered.
|
||||||
|
- (Breaking) Removed ImGuiPlatformIO::Platform_SetImeInputPos() in favor of newly standardized
|
||||||
|
io.SetPlatformImeDataFn() function. Should not affect more than default backends.
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.86 (Released 2021-12-22)
|
VERSION 1.86 (Released 2021-12-22)
|
||||||
@@ -1420,6 +1840,24 @@ Other Changes:
|
|||||||
wgpuRenderPassEncoderSetIndexBuffer() functions as validation layers appears to not do what the
|
wgpuRenderPassEncoderSetIndexBuffer() functions as validation layers appears to not do what the
|
||||||
in-flux specs says. (#4766) [@meshula]
|
in-flux specs says. (#4766) [@meshula]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Revert removal of io.ConfigDockingWithShift config option (removed in 1.83). (#4643)
|
||||||
|
- Docking: Fixed a bug undocking windows docked into a non-visible or _KeepAliveOnly dockspace
|
||||||
|
when unrelated windows submitted before the dockspace have dynamic visibility. (#4757)
|
||||||
|
- Docking, Style: Docked windows honor ImGuiCol_WindowBg. (#2700, #2539)
|
||||||
|
- Docking, Style: Docked windows honor display their border properly. (#2522)
|
||||||
|
- Docking: Fixed incorrectly rounded tab bars for dock node that are not at the top of their dock tree.
|
||||||
|
- Docking: Fixed single-frame node pos/size inconsistencies when window stop or start being submitted.
|
||||||
|
- Docking: Prevent docking any window created above a popup/modal. (#4317)
|
||||||
|
- Viewports: Made it possible to explicitly assign ImGuiWindowClass::ParentViewportId to 0 in order
|
||||||
|
to ensure a window is not parented. Previously this would use the global default (which might be 0,
|
||||||
|
but not always as it would depend on io.ConfigViewportsNoDefaultParent). (#3152, #2871)
|
||||||
|
- Viewports: Fixed tooltip in own viewport over modal from being incorrectly dimmed. (#4729)
|
||||||
|
- Viewports: Fixed CTRL+TAB highlight outline on docked windows not always fitting in host viewport.
|
||||||
|
- Backends: Made it possible to shutdown default Platform Backends before the Renderer backends. (#4656)
|
||||||
|
- Disabled: Fixed nested BeginDisabled()/EndDisabled() bug in Docking branch due to bad merge. (#4655, #4452, #4453, #4462)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.85 (Released 2021-10-12)
|
VERSION 1.85 (Released 2021-10-12)
|
||||||
@@ -1438,6 +1876,10 @@ Breaking Changes:
|
|||||||
Can use 'GetWindowContentRegionMax().x - GetWindowContentRegionMin().x' instead but it's not
|
Can use 'GetWindowContentRegionMax().x - GetWindowContentRegionMin().x' instead but it's not
|
||||||
very useful in practice, and the only use of it in the demo was illfit.
|
very useful in practice, and the only use of it in the demo was illfit.
|
||||||
Using 'GetContentRegionAvail().x' is generally a better choice.
|
Using 'GetContentRegionAvail().x' is generally a better choice.
|
||||||
|
- (Docking branch) IsWindowFocused() and IsWindowHovered() with only the _ChildWindows flag
|
||||||
|
and without the _RootWindow flag used to leak docking hierarchy, so a docked window would
|
||||||
|
return as the child of the window hosting the dockspace. This was inconsistent and incorrect
|
||||||
|
with other behaviors so we fixed it. Added a new _DockHierarchy flag to opt-in this behavior.
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
|
|
||||||
@@ -1511,6 +1953,29 @@ Other Changes:
|
|||||||
- Backends: All renderers: Normalize clipping rect handling across backends. (#4464)
|
- Backends: All renderers: Normalize clipping rect handling across backends. (#4464)
|
||||||
- Examples: Added SDL + SDL_Renderer example in "examples/example_sdl_sdlrenderer/" folder. (#3926) [@1bsyl]
|
- Examples: Added SDL + SDL_Renderer example in "examples/example_sdl_sdlrenderer/" folder. (#3926) [@1bsyl]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- IsWindowFocused: Fixed using ImGuiFocusedFlags_ChildWindows (without _RootWindow) from leaking the
|
||||||
|
docking hierarchy. Added ImGuiFocusedFlags_DockHierarchy flag to consider docking hierarchy in the test.
|
||||||
|
- IsWindowHovered: Fixed using ImGuiHoveredFlags_ChildWindows (without _RootWindow) from leaking the
|
||||||
|
docking hierarchy. Added ImGuiHoveredFlags_DockHierarchy flag to consider docking hierarchy in the test.
|
||||||
|
- Nav: Fixed an issue with losing focus on docked windows when pressing Alt while keyboard navigation
|
||||||
|
is disabled. (#4547, #4439) [@PathogenDavid]
|
||||||
|
- Docking: Fixed IsItemHovered() and functions depending on it (e.g. BeginPopupContextItem()) when
|
||||||
|
called after Begin() on a docked window (broken 2021/03/04). (#3851)
|
||||||
|
- Docking: Improved resizing system so that non-central zone are better at keeping their fixed size.
|
||||||
|
The algorithm is still not handling the allocation of size ideally for nested sibling, but it got better.
|
||||||
|
- Docking: Fixed settings load issue when mouse wheeling. (#4310)
|
||||||
|
- Docking: Fixed manually created floating node with a central node from not hiding when windows are gone.
|
||||||
|
- Docking + Drag and Drop: Fixed using BeginDragDropSource() or BeginDragDropTarget() inside a Begin()
|
||||||
|
that returned false because the window is docked. (#4515)
|
||||||
|
- Viewports: Fixed a crash while a window owning its viewport disappear while being dragged.
|
||||||
|
It would manifest when e.g. reconfiguring dock nodes while dragging.
|
||||||
|
- Viewports: Fixed unnecessary creation of temporary viewports when multiple docked windows
|
||||||
|
got reassigned to a new node (created mid-frame) which already has a HostWindow.
|
||||||
|
- Viewports: Fixed window with viewport ini data immediately merged into a host viewport from
|
||||||
|
leaving a temporary viewport alive for a frame (would leak into backend).
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.84.2 (Released 2021-08-23)
|
VERSION 1.84.2 (Released 2021-08-23)
|
||||||
@@ -1647,6 +2112,25 @@ Other Changes:
|
|||||||
- Examples: Updated all .vcxproj to VS2015 (toolset v140) to facilitate usage with vcpkg.
|
- Examples: Updated all .vcxproj to VS2015 (toolset v140) to facilitate usage with vcpkg.
|
||||||
- Examples: SDL2: Accommodate for vcpkg install having headers in SDL2/SDL.h vs SDL.h.
|
- Examples: SDL2: Accommodate for vcpkg install having headers in SDL2/SDL.h vs SDL.h.
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Clicking on the right-most close button of a docking node closes all windows. (#4186)
|
||||||
|
- Docking: Fix IsWindowAppearing() and ImGuiCond_Appearing on docked windows. (#4177, #3982, #1497, #1061)
|
||||||
|
- Docking: Fix crash using DockBuilderRemoveNode() in some situations. (#3111, #3179, #3203, #4295) [@hsimyu]
|
||||||
|
- Docking: Fix crash when a dock node gets re-qualified as dockspace>floating>dockspace, which tends to happen
|
||||||
|
when incorrectly calling DockBuilderAddNode() without ImGuiDockNodeFlags_Dockspace and using it as a Dockspace
|
||||||
|
on the next frame after the floating window hosting the node has been automatically created. (#3203, #4295)
|
||||||
|
- Docking: Reworked node flags saving/inheritance so that flags enforced by docked windows via the
|
||||||
|
DockNodeFlagsOverrideSet mechanism are are not left in empty dockspace nodes once the windows gets undocked.
|
||||||
|
(#4292, #3834, #3633, #3521, #3492, #3335, #2999, #2648)
|
||||||
|
- Docking: (Internal/Experimental) Removed DockNodeFlagsOverrideClear flags from ImGuiWindowClass as
|
||||||
|
it is ambiguous how to apply them and we haven't got a use out of them yet.
|
||||||
|
- Docking: Fixed ImGuiWindowFlags_UnsavedDocument clipping label in docked windows when there are
|
||||||
|
no close button. (#5745)
|
||||||
|
- Viewports: Fix popup/tooltip created without a parent window from being given a ParentViewportId value
|
||||||
|
from the implicit/fallback window. (#4236, #2409)
|
||||||
|
- Backends: Vulkan: Fix the use of the incorrect fence for secondary viewports. (#4208) [@FunMiles]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.83 (Released 2021-05-24)
|
VERSION 1.83 (Released 2021-05-24)
|
||||||
@@ -1731,6 +2215,22 @@ Other Changes:
|
|||||||
- Docs: Improvements to description of using colored glyphs/emojis. (#4169, #3369)
|
- Docs: Improvements to description of using colored glyphs/emojis. (#4169, #3369)
|
||||||
- Docs: Improvements to minor mistakes in documentation comments (#3923) [@ANF-Studios]
|
- Docs: Improvements to minor mistakes in documentation comments (#3923) [@ANF-Studios]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- [Breaking] Removed io.ConfigDockingWithShift config option. Behavior always equivalent to having the
|
||||||
|
option set to false (dock/undock by default, hold shift to avoid docking). (#2109)
|
||||||
|
- Docking: DockSpace() returns its node ID.
|
||||||
|
- Docking: Dockspace() never draws a background. (#3924)
|
||||||
|
- Docking: Undocking nodes/windows covering most of the monitor max their size down to 90% to ease manipulations.
|
||||||
|
- Docking: Docking node tab bar honors ItemInnerSpacing.x before first tab. (#4130)
|
||||||
|
- Docking: Tweak rendering and alignment of dock node menu marker. (#4130)
|
||||||
|
- Docking: Fixed restoring of tab order within a dockspace or a split node.
|
||||||
|
- Docking: Fixed reappearing docked windows with no close button showing a tab with extraneous space for one frame.
|
||||||
|
- Docking: Fixed multiple simultaneously reappearing window from appearing undocked for one frame.
|
||||||
|
- Viewports: Hotfix for crash in monitor array access, caused by 4b9bc4902. (#3967)
|
||||||
|
- Backends, Viewports: GLFW: Add a workaround for stuck keys after closing a GLFW window (#3837).
|
||||||
|
- Backends, Viewports: Vulkan: Rebuild swapchain on VK_SUBOPTIMAL_KHR. (#3881)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.82 (Released 2021-02-15)
|
VERSION 1.82 (Released 2021-02-15)
|
||||||
@@ -1826,6 +2326,13 @@ Other Changes:
|
|||||||
scheduled builds builds are not required. [@rokups]
|
scheduled builds builds are not required. [@rokups]
|
||||||
- Log/Capture: Added LogTextV, a va_list variant of LogText. [@PathogenDavid]
|
- Log/Capture: Added LogTextV, a va_list variant of LogText. [@PathogenDavid]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Viewports: Fix setting of ImGuiViewportFlags_NoRendererClear. (#3213)
|
||||||
|
- Viewports: Added GetViewportPlatformMonitor() with a safety net to keep code portable.
|
||||||
|
- Viewports, Backends: SDL: Fix missing ImGuiBackendFlags_HasSetMousePos flag in docking branch.
|
||||||
|
- Viewports, Backends: GLFW: Fix application of WantSetMousePos. (#1542, #787)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.81 (Released 2021-02-10)
|
VERSION 1.81 (Released 2021-02-10)
|
||||||
@@ -1907,6 +2414,17 @@ Other Changes:
|
|||||||
- Examples: WebGPU: Added Emscripten+WebGPU example. (#3632) [@bfierz]
|
- Examples: WebGPU: Added Emscripten+WebGPU example. (#3632) [@bfierz]
|
||||||
- Backends: GLFW: Added ImGui_ImplGlfw_InitForOther() initialization call to use with non OpenGL API. (#3632)
|
- Backends: GLFW: Added ImGui_ImplGlfw_InitForOther() initialization call to use with non OpenGL API. (#3632)
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Fix losing docking information on closed windows for which the hosting node was split. (#3716) [@GamingMinds-DanielC]
|
||||||
|
- Docking: Fix gap in hit test hole when using ImGuiDockNodeFlags_PassthruCentralNode touching the edge of a viewport. (#3733)
|
||||||
|
- Viewports: (Breaking) removed ImGuiPlatformIO::MainViewport which is now pretty much unused and duplicate
|
||||||
|
(and misleading as we will evolve the concept).
|
||||||
|
- Viewports: (Breaking) turned ImGuiViewport::GetWorkPos(), ImGuiViewport::GetWorkSize() into regular fields
|
||||||
|
(WorkPos, WorkSize) before exposing in master branch.
|
||||||
|
- Viewports: Fix issue inferring viewport z-order when new popups gets created. (#3734) + Metrics updates.
|
||||||
|
- Viewports, Backends: Vulkan: handle VK_ERROR_OUT_OF_DATE_KHR when resizing secondary viewport (#3766, #3758)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.80 (Released 2021-01-21)
|
VERSION 1.80 (Released 2021-01-21)
|
||||||
@@ -2026,6 +2544,14 @@ Other Changes:
|
|||||||
- Docs: Split examples/README.txt into docs/BACKENDS.md and docs/EXAMPLES.md, and improved them.
|
- Docs: Split examples/README.txt into docs/BACKENDS.md and docs/EXAMPLES.md, and improved them.
|
||||||
- Docs: Consistently renamed all occurrences of "binding" and "back-end" to "backend" in comments and docs.
|
- Docs: Consistently renamed all occurrences of "binding" and "back-end" to "backend" in comments and docs.
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Docked windows honor change of tab and text colors. (#2771)
|
||||||
|
- Docking: Support for appending into existing tab-bar made to work with Docking + internal helper DockNodeBeginAmendTabBar().
|
||||||
|
- Docking: Added experimental TabItemFlagsOverrideSet to ImGuiWindowClass.
|
||||||
|
- Viewports: Fixed incorrect whitening of popups above a modal if both use their own viewport.
|
||||||
|
- Viewports: Backends: Vulkan: Fixed build, removed extraneous pipeline creation. (#3459, #3579)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.79 (Released 2020-10-08)
|
VERSION 1.79 (Released 2020-10-08)
|
||||||
@@ -2120,6 +2646,21 @@ Other Changes:
|
|||||||
- Examples: DX12: Added '#define ImTextureID ImU64' in project and build files to also allow building
|
- Examples: DX12: Added '#define ImTextureID ImU64' in project and build files to also allow building
|
||||||
on 32-bit systems. Added project to default Visual Studio solution file. (#301)
|
on 32-bit systems. Added project to default Visual Studio solution file. (#301)
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: DockSpace() emits ItemSize() properly (useful when not filling all space).
|
||||||
|
- Docking: Fixed docking while hovering a child window. (#3420) broken by 85a661d. Improve metrics debugging.
|
||||||
|
- Docking: Fix honoring payload filter with overlapping nodes (we incorrectly over-relied on g.HoveredDockNode
|
||||||
|
when making change for #3398).
|
||||||
|
- Docking: Fix handling of WindowMenuButtonPosition == ImGuiDir_None in Docking Nodes. (#3499)
|
||||||
|
- Viewports: Fixed a rare edge-case if the window targeted by CTRL+Tab stops being rendered.
|
||||||
|
- Viewports, Backends: DX12: Make secondary viewport format match main viewport one (#3462) {@BeastLe9enD]
|
||||||
|
- Viewports: Backends: Vulkan: Removed unused shader code. Fix leaks. Avoid unnecessary pipeline creation for main
|
||||||
|
viewport. (#3459) + Add ImGui_ImplVulkanH_CreateWindowSwapChain in ImGui_ImplVulkanH_CreateOrResizeWindow().
|
||||||
|
- Viewports: Backends: DirectX9: Recover from D3DERR_DEVICELOST on secondary viewports. (#3424)
|
||||||
|
- Viewports, Backends: Win32: Fix toggling of ImGuiViewportFlags_TopMost (#3477) [@Kodokuna]
|
||||||
|
- Viewports: Backends: GLFW: Workaround for cases where glfwGetMonitorWorkarea fails (#3457) [@dougbinks]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.78 (Released 2020-08-18)
|
VERSION 1.78 (Released 2020-08-18)
|
||||||
@@ -2221,6 +2762,23 @@ Other Changes:
|
|||||||
- Examples: Vulkan: Fixed GLFW+Vulkan and SDL+Vulkan clear color not being set. (#3390) [@RoryO]
|
- Examples: Vulkan: Fixed GLFW+Vulkan and SDL+Vulkan clear color not being set. (#3390) [@RoryO]
|
||||||
- CI: Emscripten has stopped their support for their fastcomp backend, switching to latest sdk [@Xipiryon]
|
- CI: Emscripten has stopped their support for their fastcomp backend, switching to latest sdk [@Xipiryon]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Made DockBuilderAddNode() automatically call DockBuilderRemoveNode(). (#3399, #2109)
|
||||||
|
- Docking: Storing HoveredDockNode in context which can be useful for easily detecting e.g. hovering an
|
||||||
|
empty node. (#3398)
|
||||||
|
- Docking: Fixed docking overlay bits appearing at (0,0), because of 43bd80a. Most typically noticeable
|
||||||
|
when disabling multi-viewport.
|
||||||
|
- Docking: Workaround recovery for node created without the _DockSpace flags later becoming a DockSpace. (#3340)
|
||||||
|
- Docking: Rework size allocations to recover when there's no enough room for nodes + do not hold on
|
||||||
|
_WantLockSizeOnce forever. (#3328)
|
||||||
|
- Docking: Rework size allocation to allow user code to override node sizes. Not all edge cases will be
|
||||||
|
properly handled but this is a step toward toolbar emitting size constraints.
|
||||||
|
- Docking: Added experimental flags to perform more docking filtering and disable resize per axis.
|
||||||
|
Designed for toolbar patterns.
|
||||||
|
- Viewports, Backends, GLFW: Use GLFW_MOUSE_PASSTHROUGH when available.
|
||||||
|
- Viewports, Backends: DX12: Fixed issue on shutdown when viewports are disabled. (#3347)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.77 (Released 2020-06-29)
|
VERSION 1.77 (Released 2020-06-29)
|
||||||
@@ -2312,6 +2870,17 @@ Other Changes:
|
|||||||
- Examples: Apple: Fixed example_apple_metal and example_apple_opengl2 using imgui_impl_osx.mm
|
- Examples: Apple: Fixed example_apple_metal and example_apple_opengl2 using imgui_impl_osx.mm
|
||||||
not forwarding right and center mouse clicks. (#3260) [@nburrus]
|
not forwarding right and center mouse clicks. (#3260) [@nburrus]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Viewports: Don't set ImGuiViewportFlags_NoRendererClear when ImGuiWindowFlags_NoBackground is set. (#3213)
|
||||||
|
- Viewports: Report minimized viewports as zero DisplaySize to be consistent with main branch. (#1542)
|
||||||
|
- Docking, Settings: Allow reload of settings data at runtime. (#2573)
|
||||||
|
- Backends, GLFW: Fix windows resizing incorrectly on Linux due to GLFW firing window positioning
|
||||||
|
callbacks on next frame after window is resized manually. (#2117)
|
||||||
|
- Backends: DX12: Fix OBJECT_DELETED_WHILE_STILL_IN_USE on viewport resizing. (#3210)
|
||||||
|
- Backends: DX12: Fix for crash caused by early resource release. (#3121)
|
||||||
|
- Backends, Win32: Request monitor update when DPI awareness is enabled to make sure they have the correct DPI settings.
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.76 (Released 2020-04-12)
|
VERSION 1.76 (Released 2020-04-12)
|
||||||
@@ -2384,6 +2953,20 @@ Other Changes:
|
|||||||
- Examples: SDL+DX11: Fixed resizing main window. (#3057) [@joeslay]
|
- Examples: SDL+DX11: Fixed resizing main window. (#3057) [@joeslay]
|
||||||
- Examples: Added SDL+Metal example application. (#3017) [@coding-jackalope]
|
- Examples: Added SDL+Metal example application. (#3017) [@coding-jackalope]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Fixed assert preventing dockspace from being created instead a hidden tab. (#3101)
|
||||||
|
- Viewports: Fixed secondary viewports accidentally merging into a minimized host viewport. (#3118)
|
||||||
|
- Viewports, Docking: Added per-viewport work area system for e.g. menu-bars. Fixed DockspaceOverViewport()
|
||||||
|
and demo code (overlay etc) accordingly. (#3035, #2889, #2474, #1542, #2109)
|
||||||
|
- Viewports: Improve menu positioning in multi-monitor setups. [@rokups]
|
||||||
|
- Viewports: Software mouse cursor is also scaled by current DpiScale. (amend #939)
|
||||||
|
- Viewports: Avoid manually clipping resize grips and borders, which messes up with automation ability
|
||||||
|
to locate those items. Also simpler and more standard.
|
||||||
|
- Viewports: Fix for UWP in the imgui_impl_win32.cpp IME handler. (#2895, #2892).
|
||||||
|
- Viewports: Bunch of extra of comments to facilitate setting up multi-viewports.
|
||||||
|
- Viewports, GLFW: Avoid using window positioning workaround for GLFW 3.3+ versions that have it fixed.
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.75 (Released 2020-02-10)
|
VERSION 1.75 (Released 2020-02-10)
|
||||||
@@ -2482,6 +3065,21 @@ Other Changes:
|
|||||||
- Examples: Metal: Wrapped main loop in @autoreleasepool block to ensure allocations get freed
|
- Examples: Metal: Wrapped main loop in @autoreleasepool block to ensure allocations get freed
|
||||||
even if underlying system event loop gets paused due to app nap. (#2910, #2917) [@bear24rw]
|
even if underlying system event loop gets paused due to app nap. (#2910, #2917) [@bear24rw]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking + Nav: Fixed messed up Ctrl+Tab order with docked windows.
|
||||||
|
- Docking + Nav: Fixed failing to restore NavId when refocusing a child within a docked window.
|
||||||
|
- Docking + Nav: Fixed failing to restore NavId when refocusing due to missing nav window (when
|
||||||
|
it stops being submitted).
|
||||||
|
- Docking: Fixed a bug where the tab bar of a hidden dockspace would keep requesting focus. (#2960)
|
||||||
|
- Docking: Added experimental DockNodeFlagsOverrideSet/DockNodeFlagsOverrideClear flags in ImGuiWindowClass
|
||||||
|
(currently experimenting with toolbar idioms).
|
||||||
|
- Viewports: Fix resizing viewport-owning windows when mouse pos is outside the InnerClipRect
|
||||||
|
(can happen with OS decoration enabled).
|
||||||
|
- Viewports: Preserve last known size for minimized main viewport to be consistent with secondary viewports.
|
||||||
|
- Backends: SDL: Honor NoTaskBarIcon flag under non Win32 OS. (#2117)
|
||||||
|
- Backends: GLFW, SDL: Platform monitors declared properly even if multi-viewport is not enabled.
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.74 (Released 2019-11-25)
|
VERSION 1.74 (Released 2019-11-25)
|
||||||
@@ -2561,6 +3159,14 @@ Other Changes:
|
|||||||
- CI: Set up a bunch of continuous-integration tests using GitHub Actions. We now compile many of the example
|
- CI: Set up a bunch of continuous-integration tests using GitHub Actions. We now compile many of the example
|
||||||
applications on Windows, Linux, MacOS, iOS, Emscripten. Removed Travis integration. (#2865) [@rokups]
|
applications on Windows, Linux, MacOS, iOS, Emscripten. Removed Travis integration. (#2865) [@rokups]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Can undock from the small triangle button. (#2109,. #2645)
|
||||||
|
- Docking: Fixed node->HasCloseButton not honoring ImGuiDockNodeFlags_NoCloseButton in a floating node,
|
||||||
|
leading to empty space at the right of tab-bars with those flags. (#2109)
|
||||||
|
- Docking: Made docked windows not use style.ChildRounding.
|
||||||
|
- Multi-viewports: Added multi-viewport support in the DX12 back-end. (#2851) [@obfuscate]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.73 (Released 2019-09-24)
|
VERSION 1.73 (Released 2019-09-24)
|
||||||
@@ -2623,6 +3229,28 @@ Other Changes:
|
|||||||
- Misc: Updated stb_rect_pack.h from 0.99 to 1.00 (fixes by @rygorous: off-by-1 bug in best-fit heuristic,
|
- Misc: Updated stb_rect_pack.h from 0.99 to 1.00 (fixes by @rygorous: off-by-1 bug in best-fit heuristic,
|
||||||
fix handling of rectangles too large to fit inside texture). (#2762) [@tido64]
|
fix handling of rectangles too large to fit inside texture). (#2762) [@tido64]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Fix BeginDocked() path that creates node so that SetNextWindowDockID() doesn't immediately discard the node. (#2109)
|
||||||
|
- Docking: Fix for node created at the same time as windows that are still resizing (typically with
|
||||||
|
io.ConfigDockingAlwaysTabBar) to not be zero/min sized. (#2109). The fix delays their visibility by one frame,
|
||||||
|
which is not ideal but not very problematic as the .ini data gets populated after that.
|
||||||
|
- Docking: Fix a crash that could occur with a malformed ini file (DockNode Parent value pointing to a missing node).
|
||||||
|
- Viewport: Fix modal/popup window being stuck in unowned hidden viewport associated to fallback window without stealing
|
||||||
|
it back. Fix modal reference viewport when opened outside of another window. (#1542)
|
||||||
|
- Viewport: Modals don't need to set ImGuiViewportFlags_NoFocusOnClick, this also mitigate the issue described by #2445,
|
||||||
|
which becomes particularly bad with unfocused modal. (#1542)
|
||||||
|
- Viewport: better case case where host window gets moved and resized simultaneous (toggling maximized state).
|
||||||
|
There's no perfect solution there, than using io.ConfigViewportsNoAutoMerge = false. (#1542)
|
||||||
|
- Viewport, Docking: Fixed incorrect assignment of IsFallbackWindow which would tag dock node host windows created
|
||||||
|
in NewFrame() as such, messing with popup viewport inheritance.
|
||||||
|
- Viewport: Fixed issue where resize grip would display as hovered while mouse is still off the OS bounds so a click
|
||||||
|
would miss it and focus the OS window behind expected one. (#1542)
|
||||||
|
- Viewport: Fix to allow multiple shutdown / calls to DestroyPlatformWindows(). (#2769)
|
||||||
|
- Viewport: Backends: GLFW: Fix setting window size on macOS (#2767, #2117) [@rokups]
|
||||||
|
- Viewport: Backends: GLFW+Linux: Fix window having incorrect size after uncollapse. (#2756, #2117) [@rokups]
|
||||||
|
- Viewport: Backends: DirectX9: Workaround for windows not refreshing when main viewport has no draw call. (#2560)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.72b (Released 2019-07-31)
|
VERSION 1.72b (Released 2019-07-31)
|
||||||
@@ -2725,6 +3353,25 @@ Other Changes:
|
|||||||
(#2482, #2632) [@josiahmanson]
|
(#2482, #2632) [@josiahmanson]
|
||||||
- Examples: Added SDL2+DirectX11 example application. (#2632, #2612, #2482) [@vincenthamm]
|
- Examples: Added SDL2+DirectX11 example application. (#2632, #2612, #2482) [@vincenthamm]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Making it possible to undock a node by clicking on the tab bar / title bar for the node. (#2645).
|
||||||
|
- Docking: Explicitly inhibit constraint when docked for now. Fix clipping issue related to constraints. (#2690).
|
||||||
|
- Docking: Fixed dragging/resizing from OS decoration not marking settings as dirty.
|
||||||
|
- Docking: Renamed io.ConfigDockingTabBarOnSingleWindows to io.ConfigDockingAlwaysTabBar.
|
||||||
|
Added ImGuiWindowClass::DockingAlwaysTabBar to set on individual windows.
|
||||||
|
- Docking: Perform simple check: assert if Docking or Viewport are enabled exactly on frame 1 (instead of frame 0
|
||||||
|
or later), which is a common user error leading to loss of .ini data on load.
|
||||||
|
- Docking: Fix so that an appearing window making a dock node reappear won't have a zero-size on its first frame.
|
||||||
|
- Docking: Fixed using ImGuiDockNodeFlags_AutoHideTabBar with io.ConfigDockingTabBarOnSingleWindows.
|
||||||
|
- Docking: Added ImGuiDockNode to .natvis file.
|
||||||
|
- Docking: Fixed support for large meshes in GetBackgroundDrawList(), GetForegroundDrawList(). (#2638)
|
||||||
|
- Viewport: Fix monitor dpi info not being copied to main viewport when multi-viewports are not enabled. (#2621, #1676)
|
||||||
|
- Viewport: Refactored ImGuiWindowClass's ViewportFlagsOverrideMask + ViewportFlagsOverrideValue into
|
||||||
|
ViewportFlagsOverrideSet + ViewportFlagsOverrideClear which appears easier to grasp. (#1542)
|
||||||
|
- Viewport: Added ImGuiViewportFlags_NoAutoMerge to prevent merging into host viewport in a per-window basis
|
||||||
|
via the ImGuiWindowClass override mechanism. (#1542)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.71 (Released 2019-06-12)
|
VERSION 1.71 (Released 2019-06-12)
|
||||||
@@ -3064,6 +3711,7 @@ Breaking Changes:
|
|||||||
- Renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Kept redirection typedef (will obsolete).
|
- Renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Kept redirection typedef (will obsolete).
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
|
|
||||||
- Added BETA api for Tab Bar/Tabs widgets: (#261, #351)
|
- Added BETA api for Tab Bar/Tabs widgets: (#261, #351)
|
||||||
- Added BeginTabBar(), EndTabBar(), BeginTabItem(), EndTabItem(), SetTabItemClosed() API.
|
- Added BeginTabBar(), EndTabBar(), BeginTabItem(), EndTabItem(), SetTabItemClosed() API.
|
||||||
- Added ImGuiTabBarFlags flags for BeginTabBar().
|
- Added ImGuiTabBarFlags flags for BeginTabBar().
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ Steps:
|
|||||||
- 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 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 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.
|
||||||
|
|||||||
@@ -426,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)
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ All loaded fonts glyphs are rendered into a single texture atlas ahead of time.
|
|||||||
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.
|
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:
|
Some solutions:
|
||||||
- You may reduce oversampling, e.g. `font_config.OversampleH = 1`, this will half your texture size for a quality looss.
|
- 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).
|
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.
|
- 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!
|
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!
|
||||||
@@ -404,16 +404,12 @@ 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.
|
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 char_t*` which doesn't cast to `const char*`.
|
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:
|
Because of type usage of `u8""` in C++20 is a little more tedious:
|
||||||
```cpp
|
```cpp
|
||||||
ImGui::Text((const char*)u8"こんにちは");
|
ImGui::Text((const char*)u8"こんにちは");
|
||||||
```
|
```
|
||||||
We suggest using a macro in your codebase:
|
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.
|
||||||
```cpp
|
|
||||||
#define U8(_S) (const char*)u8##_S
|
|
||||||
ImGui::Text(U8("こんにちは"));
|
|
||||||
```
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
@@ -486,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
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ Dear ImGui is particularly suited to integration in game engines (for tooling),
|
|||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
**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. 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.
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ 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-20230704.zip](https://www.dearimgui.com/binaries/imgui-demo-binaries-20230704.zip) (Windows, 1.89.7, built 2023/07/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)).
|
||||||
|
|
||||||
@@ -139,6 +139,8 @@ Also see [Wiki](https://github.com/ocornut/imgui/wiki) for more links and ideas.
|
|||||||
|
|
||||||
### Gallery
|
### Gallery
|
||||||
|
|
||||||
|
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 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.
|
||||||
@@ -207,7 +209,7 @@ Sponsoring, maintenance/support contracts and other B2B transactions are hosted
|
|||||||
|
|
||||||
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.
|
||||||
|
|||||||
@@ -129,7 +129,35 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- separator: width, thickness, centering (#1643, #2657)
|
- 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)
|
||||||
|
|
||||||
- docking: 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.
|
||||||
@@ -303,6 +331,20 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- 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)
|
||||||
|
|
||||||
|
- 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)
|
||||||
|
|||||||
@@ -40,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();
|
||||||
|
|||||||
@@ -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 */,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -60,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);
|
||||||
|
|
||||||
@@ -195,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
|
||||||
|
|||||||
@@ -47,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();
|
||||||
@@ -136,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.
|
||||||
|
|
||||||
|
|||||||
@@ -11,13 +11,20 @@
|
|||||||
#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;
|
||||||
@@ -27,15 +34,32 @@ static int wgpu_swap_chain_width = 0;
|
|||||||
static int wgpu_swap_chain_height = 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;
|
||||||
|
|
||||||
@@ -43,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())
|
||||||
@@ -66,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, wgpu_preferred_fmt, 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.
|
||||||
@@ -98,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;
|
||||||
}
|
}
|
||||||
@@ -112,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
|
||||||
@@ -127,127 +259,22 @@ static bool InitWGPU()
|
|||||||
wgpu::Surface surface = instance.CreateSurface(&surface_desc);
|
wgpu::Surface surface = instance.CreateSurface(&surface_desc);
|
||||||
wgpu::Adapter adapter = {};
|
wgpu::Adapter adapter = {};
|
||||||
wgpu_preferred_fmt = (WGPUTextureFormat)surface.GetPreferredFormat(adapter);
|
wgpu_preferred_fmt = (WGPUTextureFormat)surface.GetPreferredFormat(adapter);
|
||||||
wgpu_surface = surface.Release();
|
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 = wgpu_preferred_fmt;
|
|
||||||
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)
|
||||||
|
|
||||||
|
|||||||
@@ -33,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.
|
||||||
@@ -69,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);
|
||||||
@@ -157,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];
|
||||||
|
|
||||||
|
|||||||
@@ -52,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();
|
||||||
@@ -150,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)
|
||||||
|
|
||||||
##---------------------------------------------------------------------
|
##---------------------------------------------------------------------
|
||||||
|
|||||||
@@ -77,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
|
||||||
@@ -176,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__
|
||||||
|
|||||||
@@ -31,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
|
||||||
@@ -64,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)
|
||||||
{
|
{
|
||||||
@@ -139,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;
|
||||||
@@ -153,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 = {};
|
||||||
@@ -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.
|
||||||
@@ -531,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
|
||||||
|
|||||||
@@ -61,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();
|
||||||
@@ -78,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.
|
||||||
|
|||||||
@@ -47,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);
|
||||||
@@ -65,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);
|
||||||
@@ -170,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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,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.
|
||||||
@@ -168,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];
|
||||||
|
|
||||||
|
|||||||
@@ -41,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
|
||||||
@@ -51,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();
|
||||||
@@ -149,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,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
|
||||||
@@ -78,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);
|
||||||
@@ -183,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__
|
||||||
|
|||||||
@@ -38,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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,9 +23,9 @@
|
|||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
//#include <vulkan/vulkan_beta.h>
|
//#include <vulkan/vulkan_beta.h>
|
||||||
|
|
||||||
//#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
|
||||||
@@ -52,14 +52,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)
|
||||||
{
|
{
|
||||||
@@ -127,7 +127,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;
|
||||||
@@ -141,7 +141,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 = {};
|
||||||
@@ -246,7 +246,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_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 };
|
||||||
@@ -263,11 +263,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);
|
||||||
@@ -364,7 +364,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
|
||||||
@@ -385,6 +385,11 @@ int main(int, char**)
|
|||||||
// Create window with Vulkan graphics context
|
// Create window with Vulkan graphics context
|
||||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+Vulkan example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+Vulkan example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
|
||||||
|
if (window == nullptr)
|
||||||
|
{
|
||||||
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ImVector<const char*> extensions;
|
ImVector<const char*> extensions;
|
||||||
uint32_t extensions_count = 0;
|
uint32_t extensions_count = 0;
|
||||||
@@ -414,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.ConfigFlags |= ImGuiConfigFlags_ViewportsNoTaskBarIcons;
|
||||||
|
//io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoMerge;
|
||||||
|
|
||||||
// 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_InitForVulkan(window);
|
ImGui_ImplSDL2_InitForVulkan(window);
|
||||||
ImGui_ImplVulkan_InitInfo init_info = {};
|
ImGui_ImplVulkan_InitInfo init_info = {};
|
||||||
@@ -429,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.
|
||||||
@@ -535,17 +553,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
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ int main(int, char**)
|
|||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||||
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_HIDDEN);
|
Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN;
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+OpenGL3 example", 1280, 720, window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+OpenGL3 example", 1280, 720, window_flags);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
@@ -83,11 +83,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_ImplSDL3_InitForOpenGL(window, gl_context);
|
ImGui_ImplSDL3_InitForOpenGL(window, gl_context);
|
||||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||||
@@ -188,6 +200,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__
|
||||||
|
|||||||
@@ -35,19 +35,19 @@ int main(int, char**)
|
|||||||
SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");
|
SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");
|
||||||
|
|
||||||
// Create window with SDL_Renderer graphics context
|
// Create window with SDL_Renderer graphics context
|
||||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN);
|
Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN;
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+SDL_Renderer example", 1280, 720, window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+SDL_Renderer example", 1280, 720, window_flags);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
SDL_Renderer* renderer = SDL_CreateRenderer(window, NULL, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
SDL_Renderer* renderer = SDL_CreateRenderer(window, nullptr, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
||||||
if (renderer == nullptr)
|
if (renderer == nullptr)
|
||||||
{
|
{
|
||||||
SDL_Log("Error: SDL_CreateRenderer(): %s\n", SDL_GetError());
|
SDL_Log("Error: SDL_CreateRenderer(): %s\n", SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||||
SDL_ShowWindow(window);
|
SDL_ShowWindow(window);
|
||||||
|
|
||||||
|
|||||||
@@ -53,11 +53,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_ImplWin32_Init(hwnd);
|
ImGui_ImplWin32_Init(hwnd);
|
||||||
ImGui_ImplDX10_Init(g_pd3dDevice);
|
ImGui_ImplDX10_Init(g_pd3dDevice);
|
||||||
@@ -158,6 +170,13 @@ int main(int, char**)
|
|||||||
g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
|
g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
|
||||||
ImGui_ImplDX10_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplDX10_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
|
||||||
}
|
}
|
||||||
@@ -174,7 +193,6 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
|
|
||||||
bool CreateDeviceD3D(HWND hWnd)
|
bool CreateDeviceD3D(HWND hWnd)
|
||||||
{
|
{
|
||||||
// Setup swap chain
|
// Setup swap chain
|
||||||
|
|||||||
@@ -53,11 +53,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;
|
||||||
|
//io.ConfigViewportsNoDefaultParent = true;
|
||||||
|
//io.ConfigDockingAlwaysTabBar = true;
|
||||||
|
//io.ConfigDockingTransparentPayload = true;
|
||||||
|
//io.ConfigFlags |= ImGuiConfigFlags_DpiEnableScaleFonts; // FIXME-DPI: Experimental. THIS CURRENTLY DOESN'T WORK AS EXPECTED. DON'T USE IN USER APP!
|
||||||
|
//io.ConfigFlags |= ImGuiConfigFlags_DpiEnableScaleViewports; // FIXME-DPI: Experimental.
|
||||||
|
|
||||||
// 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_ImplWin32_Init(hwnd);
|
ImGui_ImplWin32_Init(hwnd);
|
||||||
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
|
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
|
||||||
@@ -158,6 +175,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
|
||||||
}
|
}
|
||||||
@@ -175,7 +199,6 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
|
|
||||||
bool CreateDeviceD3D(HWND hWnd)
|
bool CreateDeviceD3D(HWND hWnd)
|
||||||
{
|
{
|
||||||
// Setup swap chain
|
// Setup swap chain
|
||||||
@@ -230,6 +253,10 @@ void CleanupRenderTarget()
|
|||||||
if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = nullptr; }
|
if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = nullptr; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef WM_DPICHANGED
|
||||||
|
#define WM_DPICHANGED 0x02E0 // From Windows SDK 8.1+ headers
|
||||||
|
#endif
|
||||||
|
|
||||||
// Forward declare message handler from imgui_impl_win32.cpp
|
// Forward declare message handler from imgui_impl_win32.cpp
|
||||||
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
@@ -258,6 +285,15 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
::PostQuitMessage(0);
|
::PostQuitMessage(0);
|
||||||
return 0;
|
return 0;
|
||||||
|
case WM_DPICHANGED:
|
||||||
|
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DpiEnableScaleViewports)
|
||||||
|
{
|
||||||
|
//const int dpi = HIWORD(wParam);
|
||||||
|
//printf("WM_DPICHANGED to %d (%.0f%%)\n", dpi, (float)dpi / 96.0f * 100.0f);
|
||||||
|
const RECT* suggested_rect = (RECT*)lParam;
|
||||||
|
::SetWindowPos(hWnd, nullptr, suggested_rect->left, suggested_rect->top, suggested_rect->right - suggested_rect->left, suggested_rect->bottom - suggested_rect->top, SWP_NOZORDER | SWP_NOACTIVATE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return ::DefWindowProcW(hWnd, msg, wParam, lParam);
|
return ::DefWindowProcW(hWnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,11 +87,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_ImplWin32_Init(hwnd);
|
ImGui_ImplWin32_Init(hwnd);
|
||||||
ImGui_ImplDX12_Init(g_pd3dDevice, NUM_FRAMES_IN_FLIGHT,
|
ImGui_ImplDX12_Init(g_pd3dDevice, NUM_FRAMES_IN_FLIGHT,
|
||||||
@@ -209,6 +221,13 @@ int main(int, char**)
|
|||||||
|
|
||||||
g_pd3dCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&g_pd3dCommandList);
|
g_pd3dCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&g_pd3dCommandList);
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault(nullptr, (void*)g_pd3dCommandList);
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
@@ -233,7 +252,6 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
|
|
||||||
bool CreateDeviceD3D(HWND hWnd)
|
bool CreateDeviceD3D(HWND hWnd)
|
||||||
{
|
{
|
||||||
// Setup swap chain
|
// Setup swap chain
|
||||||
|
|||||||
@@ -51,11 +51,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_ImplWin32_Init(hwnd);
|
ImGui_ImplWin32_Init(hwnd);
|
||||||
ImGui_ImplDX9_Init(g_pd3dDevice);
|
ImGui_ImplDX9_Init(g_pd3dDevice);
|
||||||
@@ -162,6 +174,14 @@ int main(int, char**)
|
|||||||
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
|
||||||
g_pd3dDevice->EndScene();
|
g_pd3dDevice->EndScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT result = g_pd3dDevice->Present(nullptr, nullptr, nullptr, nullptr);
|
HRESULT result = g_pd3dDevice->Present(nullptr, nullptr, nullptr, nullptr);
|
||||||
|
|
||||||
// Handle loss of D3D9 device
|
// Handle loss of D3D9 device
|
||||||
@@ -181,7 +201,6 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
|
|
||||||
bool CreateDeviceD3D(HWND hWnd)
|
bool CreateDeviceD3D(HWND hWnd)
|
||||||
{
|
{
|
||||||
if ((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == nullptr)
|
if ((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == nullptr)
|
||||||
@@ -217,6 +236,10 @@ void ResetDevice()
|
|||||||
ImGui_ImplDX9_CreateDeviceObjects();
|
ImGui_ImplDX9_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef WM_DPICHANGED
|
||||||
|
#define WM_DPICHANGED 0x02E0 // From Windows SDK 8.1+ headers
|
||||||
|
#endif
|
||||||
|
|
||||||
// Forward declare message handler from imgui_impl_win32.cpp
|
// Forward declare message handler from imgui_impl_win32.cpp
|
||||||
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
@@ -245,6 +268,15 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
::PostQuitMessage(0);
|
::PostQuitMessage(0);
|
||||||
return 0;
|
return 0;
|
||||||
|
case WM_DPICHANGED:
|
||||||
|
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DpiEnableScaleViewports)
|
||||||
|
{
|
||||||
|
//const int dpi = HIWORD(wParam);
|
||||||
|
//printf("WM_DPICHANGED to %d (%.0f%%)\n", dpi, (float)dpi / 96.0f * 100.0f);
|
||||||
|
const RECT* suggested_rect = (RECT*)lParam;
|
||||||
|
::SetWindowPos(hWnd, nullptr, suggested_rect->left, suggested_rect->top, suggested_rect->right - suggested_rect->left, suggested_rect->bottom - suggested_rect->top, SWP_NOZORDER | SWP_NOACTIVATE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return ::DefWindowProcW(hWnd, msg, wParam, lParam);
|
return ::DefWindowProcW(hWnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,14 +33,50 @@ void CleanupDeviceWGL(HWND hWnd, WGL_WindowData* data);
|
|||||||
void ResetDeviceWGL();
|
void ResetDeviceWGL();
|
||||||
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
// Support function for multi-viewports
|
||||||
|
// Unlike most other backend combination, we need specific hooks to combine Win32+OpenGL.
|
||||||
|
// We could in theory decide to support Win32-specific code in OpenGL backend via e.g. an hypothetical ImGui_ImplOpenGL3_InitForRawWin32().
|
||||||
|
static void Hook_Renderer_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
assert(viewport->RendererUserData == NULL);
|
||||||
|
|
||||||
|
WGL_WindowData* data = IM_NEW(WGL_WindowData);
|
||||||
|
CreateDeviceWGL((HWND)viewport->PlatformHandle, data);
|
||||||
|
viewport->RendererUserData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Hook_Renderer_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
if (viewport->RendererUserData != NULL)
|
||||||
|
{
|
||||||
|
WGL_WindowData* data = (WGL_WindowData*)viewport->RendererUserData;
|
||||||
|
CleanupDeviceWGL((HWND)viewport->PlatformHandle, data);
|
||||||
|
IM_DELETE(data);
|
||||||
|
viewport->RendererUserData = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Hook_Platform_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
// Activate the platform window DC in the OpenGL rendering context
|
||||||
|
if (WGL_WindowData* data = (WGL_WindowData*)viewport->RendererUserData)
|
||||||
|
wglMakeCurrent(data->hDC, g_hRC);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Hook_Renderer_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
if (WGL_WindowData* data = (WGL_WindowData*)viewport->RendererUserData)
|
||||||
|
::SwapBuffers(data->hDC);
|
||||||
|
}
|
||||||
|
|
||||||
// Main code
|
// Main code
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
// Create application window
|
// Create application window
|
||||||
//ImGui_ImplWin32_EnableDpiAwareness();
|
//ImGui_ImplWin32_EnableDpiAwareness();
|
||||||
WNDCLASSEXW wc = { sizeof(wc), CS_OWNDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, L"ImGui Example", NULL };
|
WNDCLASSEXW wc = { sizeof(wc), CS_OWNDC, WndProc, 0L, 0L, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, L"ImGui Example", nullptr };
|
||||||
::RegisterClassExW(&wc);
|
::RegisterClassExW(&wc);
|
||||||
HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"Dear ImGui Win32+OpenGL3 Example", WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
|
HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"Dear ImGui Win32+OpenGL3 Example", WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, nullptr, nullptr, wc.hInstance, nullptr);
|
||||||
|
|
||||||
// Initialize OpenGL
|
// Initialize OpenGL
|
||||||
if (!CreateDeviceWGL(hwnd, &g_MainWindow))
|
if (!CreateDeviceWGL(hwnd, &g_MainWindow))
|
||||||
@@ -62,19 +98,43 @@ 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 Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsClassic();
|
//ImGui::StyleColorsClassic();
|
||||||
|
|
||||||
|
// 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_ImplWin32_InitForOpenGL(hwnd);
|
ImGui_ImplWin32_InitForOpenGL(hwnd);
|
||||||
ImGui_ImplOpenGL3_Init();
|
ImGui_ImplOpenGL3_Init();
|
||||||
|
|
||||||
|
// Win32+GL needs specific hooks for viewport, as there are specific things needed to tie Win32 and GL api.
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
IM_ASSERT(platform_io.Renderer_CreateWindow == NULL);
|
||||||
|
IM_ASSERT(platform_io.Renderer_DestroyWindow == NULL);
|
||||||
|
IM_ASSERT(platform_io.Renderer_SwapBuffers == NULL);
|
||||||
|
IM_ASSERT(platform_io.Platform_RenderWindow == NULL);
|
||||||
|
platform_io.Renderer_CreateWindow = Hook_Renderer_CreateWindow;
|
||||||
|
platform_io.Renderer_DestroyWindow = Hook_Renderer_DestroyWindow;
|
||||||
|
platform_io.Renderer_SwapBuffers = Hook_Renderer_SwapBuffers;
|
||||||
|
platform_io.Platform_RenderWindow = Hook_Platform_RenderWindow;
|
||||||
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details.
|
||||||
@@ -84,8 +144,8 @@ int main(int, char**)
|
|||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, nullptr, io.Fonts->GetGlyphRangesJapanese());
|
||||||
//IM_ASSERT(font != NULL);
|
//IM_ASSERT(font != nullptr);
|
||||||
|
|
||||||
// Our state
|
// Our state
|
||||||
bool show_demo_window = true;
|
bool show_demo_window = true;
|
||||||
@@ -99,7 +159,7 @@ int main(int, char**)
|
|||||||
// Poll and handle messages (inputs, window resize, etc.)
|
// Poll and handle messages (inputs, window resize, etc.)
|
||||||
// See the WndProc() function below for our to dispatch events to the Win32 backend.
|
// See the WndProc() function below for our to dispatch events to the Win32 backend.
|
||||||
MSG msg;
|
MSG msg;
|
||||||
while (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
|
while (::PeekMessage(&msg, nullptr, 0U, 0U, PM_REMOVE))
|
||||||
{
|
{
|
||||||
::TranslateMessage(&msg);
|
::TranslateMessage(&msg);
|
||||||
::DispatchMessage(&msg);
|
::DispatchMessage(&msg);
|
||||||
@@ -158,6 +218,16 @@ 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
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
|
||||||
|
// Restore the OpenGL rendering context to the main window DC, since platform windows might have changed it.
|
||||||
|
wglMakeCurrent(g_MainWindow.hDC, g_hRC);
|
||||||
|
}
|
||||||
|
|
||||||
// Present
|
// Present
|
||||||
::SwapBuffers(g_MainWindow.hDC);
|
::SwapBuffers(g_MainWindow.hDC);
|
||||||
}
|
}
|
||||||
@@ -200,7 +270,7 @@ bool CreateDeviceWGL(HWND hWnd, WGL_WindowData* data)
|
|||||||
|
|
||||||
void CleanupDeviceWGL(HWND hWnd, WGL_WindowData* data)
|
void CleanupDeviceWGL(HWND hWnd, WGL_WindowData* data)
|
||||||
{
|
{
|
||||||
wglMakeCurrent(NULL, NULL);
|
wglMakeCurrent(nullptr, nullptr);
|
||||||
::ReleaseDC(hWnd, data->hDC);
|
::ReleaseDC(hWnd, data->hDC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,12 +50,14 @@
|
|||||||
//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available
|
//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available
|
||||||
|
|
||||||
//---- Include imgui_user.h at the end of imgui.h as a convenience
|
//---- Include imgui_user.h at the end of imgui.h as a convenience
|
||||||
|
// May be convenient for some users to only explicitly include vanilla imgui.h and have extra stuff included.
|
||||||
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
||||||
|
//#define IMGUI_USER_H_FILENAME "my_folder/my_imgui_user.h"
|
||||||
|
|
||||||
//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
|
//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
|
||||||
//#define IMGUI_USE_BGRA_PACKED_COLOR
|
//#define IMGUI_USE_BGRA_PACKED_COLOR
|
||||||
|
|
||||||
//---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
|
//---- Use 32-bit for ImWchar (default is 16-bit) to support Unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
|
||||||
//#define IMGUI_USE_WCHAR32
|
//#define IMGUI_USE_WCHAR32
|
||||||
|
|
||||||
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
|
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
|
||||||
|
|||||||
537
imgui_demo.cpp
537
imgui_demo.cpp
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.90.0
|
// dear imgui, v1.90.4
|
||||||
// (drawing and font code)
|
// (drawing and font code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -214,6 +214,8 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst)
|
|||||||
colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
|
colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
|
||||||
colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
||||||
colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
|
colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
|
||||||
|
colors[ImGuiCol_DockingPreview] = colors[ImGuiCol_HeaderActive] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
|
||||||
|
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
||||||
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
|
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
|
||||||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
|
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
|
||||||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||||
@@ -274,6 +276,8 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst)
|
|||||||
colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
|
colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
|
||||||
colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
||||||
colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
|
colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
|
||||||
|
colors[ImGuiCol_DockingPreview] = colors[ImGuiCol_Header] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
|
||||||
|
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
||||||
colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
||||||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||||
@@ -335,6 +339,8 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst)
|
|||||||
colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
|
colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
|
||||||
colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
||||||
colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
|
colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
|
||||||
|
colors[ImGuiCol_DockingPreview] = colors[ImGuiCol_Header] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
|
||||||
|
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
||||||
colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
|
colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
|
||||||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
|
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
|
||||||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||||
@@ -641,7 +647,7 @@ void ImDrawList::PrimReserve(int idx_count, int vtx_count)
|
|||||||
_IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size;
|
_IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the a number of reserved vertices/indices from the end of the last reservation made with PrimReserve().
|
// Release the number of reserved vertices/indices from the end of the last reservation made with PrimReserve().
|
||||||
void ImDrawList::PrimUnreserve(int idx_count, int vtx_count)
|
void ImDrawList::PrimUnreserve(int idx_count, int vtx_count)
|
||||||
{
|
{
|
||||||
IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
|
IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
|
||||||
@@ -3881,6 +3887,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, Im
|
|||||||
// - RenderArrow()
|
// - RenderArrow()
|
||||||
// - RenderBullet()
|
// - RenderBullet()
|
||||||
// - RenderCheckMark()
|
// - RenderCheckMark()
|
||||||
|
// - RenderArrowDockMenu()
|
||||||
// - RenderArrowPointingAt()
|
// - RenderArrowPointingAt()
|
||||||
// - RenderRectFilledRangeH()
|
// - RenderRectFilledRangeH()
|
||||||
// - RenderRectFilledWithHole()
|
// - RenderRectFilledWithHole()
|
||||||
@@ -3955,6 +3962,14 @@ void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is less wide than RenderArrow() and we use in dock nodes instead of the regular RenderArrow() to denote a change of functionality,
|
||||||
|
// and because the saved space means that the left-most tab label can stay at exactly the same position as the label of a loose window.
|
||||||
|
void ImGui::RenderArrowDockMenu(ImDrawList* draw_list, ImVec2 p_min, float sz, ImU32 col)
|
||||||
|
{
|
||||||
|
draw_list->AddRectFilled(p_min + ImVec2(sz * 0.20f, sz * 0.15f), p_min + ImVec2(sz * 0.80f, sz * 0.30f), col);
|
||||||
|
RenderArrowPointingAt(draw_list, p_min + ImVec2(sz * 0.50f, sz * 0.85f), ImVec2(sz * 0.30f, sz * 0.40f), ImGuiDir_Down, col);
|
||||||
|
}
|
||||||
|
|
||||||
static inline float ImAcos01(float x)
|
static inline float ImAcos01(float x)
|
||||||
{
|
{
|
||||||
if (x <= 0.0f) return IM_PI * 0.5f;
|
if (x <= 0.0f) return IM_PI * 0.5f;
|
||||||
@@ -3997,8 +4012,8 @@ void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, Im
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
draw_list->PathArcTo(ImVec2(x0, p1.y - rounding), rounding, IM_PI - arc0_e, IM_PI - arc0_b, 3); // BL
|
draw_list->PathArcTo(ImVec2(x0, p1.y - rounding), rounding, IM_PI - arc0_e, IM_PI - arc0_b); // BL
|
||||||
draw_list->PathArcTo(ImVec2(x0, p0.y + rounding), rounding, IM_PI + arc0_b, IM_PI + arc0_e, 3); // TR
|
draw_list->PathArcTo(ImVec2(x0, p0.y + rounding), rounding, IM_PI + arc0_b, IM_PI + arc0_e); // TR
|
||||||
}
|
}
|
||||||
if (p1.x > rect.Min.x + rounding)
|
if (p1.x > rect.Min.x + rounding)
|
||||||
{
|
{
|
||||||
@@ -4017,8 +4032,8 @@ void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, Im
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
draw_list->PathArcTo(ImVec2(x1, p0.y + rounding), rounding, -arc1_e, -arc1_b, 3); // TR
|
draw_list->PathArcTo(ImVec2(x1, p0.y + rounding), rounding, -arc1_e, -arc1_b); // TR
|
||||||
draw_list->PathArcTo(ImVec2(x1, p1.y - rounding), rounding, +arc1_b, +arc1_e, 3); // BR
|
draw_list->PathArcTo(ImVec2(x1, p1.y - rounding), rounding, +arc1_b, +arc1_e); // BR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
draw_list->PathFillConvex(col);
|
draw_list->PathFillConvex(col);
|
||||||
@@ -4040,6 +4055,17 @@ void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, const ImRect& outer,
|
|||||||
if (fill_R && fill_D) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Max.y), ImVec2(outer.Max.x, outer.Max.y), col, rounding, ImDrawFlags_RoundCornersBottomRight);
|
if (fill_R && fill_D) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Max.y), ImVec2(outer.Max.x, outer.Max.y), col, rounding, ImDrawFlags_RoundCornersBottomRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImDrawFlags ImGui::CalcRoundingFlagsForRectInRect(const ImRect& r_in, const ImRect& r_outer, float threshold)
|
||||||
|
{
|
||||||
|
bool round_l = r_in.Min.x <= r_outer.Min.x + threshold;
|
||||||
|
bool round_r = r_in.Max.x >= r_outer.Max.x - threshold;
|
||||||
|
bool round_t = r_in.Min.y <= r_outer.Min.y + threshold;
|
||||||
|
bool round_b = r_in.Max.y >= r_outer.Max.y - threshold;
|
||||||
|
return ImDrawFlags_RoundCornersNone
|
||||||
|
| ((round_t && round_l) ? ImDrawFlags_RoundCornersTopLeft : 0) | ((round_t && round_r) ? ImDrawFlags_RoundCornersTopRight : 0)
|
||||||
|
| ((round_b && round_l) ? ImDrawFlags_RoundCornersBottomLeft : 0) | ((round_b && round_r) ? ImDrawFlags_RoundCornersBottomRight : 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Helper for ColorPicker4()
|
// Helper for ColorPicker4()
|
||||||
// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that.
|
// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that.
|
||||||
// Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding altogether.
|
// Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding altogether.
|
||||||
@@ -4205,8 +4231,8 @@ static unsigned int stb_decompress(unsigned char *output, const unsigned char *i
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// ProggyClean.ttf
|
// ProggyClean.ttf
|
||||||
// Copyright (c) 2004, 2005 Tristan Grimmer
|
// Copyright (c) 2004, 2005 Tristan Grimmer
|
||||||
// MIT license (see License.txt in http://www.upperbounds.net/download/ProggyClean.ttf.zip)
|
// MIT license (see License.txt in http://www.proggyfonts.net/index.php?menu=download)
|
||||||
// Download and more information at http://upperbounds.net
|
// Download and more information at http://www.proggyfonts.net or http://upperboundsinteractive.com/fonts.php
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// File: 'ProggyClean.ttf' (41208 bytes)
|
// File: 'ProggyClean.ttf' (41208 bytes)
|
||||||
// Exported using misc/fonts/binary_to_compressed_c.cpp (with compression + base85 string encoding).
|
// Exported using misc/fonts/binary_to_compressed_c.cpp (with compression + base85 string encoding).
|
||||||
|
|||||||
766
imgui_internal.h
766
imgui_internal.h
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.90.0
|
// dear imgui, v1.90.4
|
||||||
// (tables and columns code)
|
// (tables and columns code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -329,6 +329,10 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// [DEBUG] Debug break requested by user
|
||||||
|
if (g.DebugBreakInTable == id)
|
||||||
|
IM_DEBUG_BREAK();
|
||||||
|
|
||||||
// Acquire storage for the table
|
// Acquire storage for the table
|
||||||
ImGuiTable* table = g.Tables.GetOrAddByKey(id);
|
ImGuiTable* table = g.Tables.GetOrAddByKey(id);
|
||||||
const ImGuiTableFlags table_last_flags = table->Flags;
|
const ImGuiTableFlags table_last_flags = table->Flags;
|
||||||
@@ -494,7 +498,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||||||
table->DeclColumnsCount = table->AngledHeadersCount = 0;
|
table->DeclColumnsCount = table->AngledHeadersCount = 0;
|
||||||
if (previous_frame_active + 1 < g.FrameCount)
|
if (previous_frame_active + 1 < g.FrameCount)
|
||||||
table->IsActiveIdInTable = false;
|
table->IsActiveIdInTable = false;
|
||||||
temp_data->AngledheadersExtraWidth = 0.0f;
|
temp_data->AngledHeadersExtraWidth = 0.0f;
|
||||||
|
|
||||||
// Using opaque colors facilitate overlapping lines of the grid, otherwise we'd need to improve TableDrawBorders()
|
// Using opaque colors facilitate overlapping lines of the grid, otherwise we'd need to improve TableDrawBorders()
|
||||||
table->BorderColorStrong = GetColorU32(ImGuiCol_TableBorderStrong);
|
table->BorderColorStrong = GetColorU32(ImGuiCol_TableBorderStrong);
|
||||||
@@ -1340,7 +1344,7 @@ void ImGui::EndTable()
|
|||||||
max_pos_x = ImMax(max_pos_x, table->Columns[table->RightMostEnabledColumn].WorkMaxX + table->CellPaddingX + table->OuterPaddingX - outer_padding_for_border);
|
max_pos_x = ImMax(max_pos_x, table->Columns[table->RightMostEnabledColumn].WorkMaxX + table->CellPaddingX + table->OuterPaddingX - outer_padding_for_border);
|
||||||
if (table->ResizedColumn != -1)
|
if (table->ResizedColumn != -1)
|
||||||
max_pos_x = ImMax(max_pos_x, table->ResizeLockMinContentsX2);
|
max_pos_x = ImMax(max_pos_x, table->ResizeLockMinContentsX2);
|
||||||
table->InnerWindow->DC.CursorMaxPos.x = max_pos_x + table->TempData->AngledheadersExtraWidth;
|
table->InnerWindow->DC.CursorMaxPos.x = max_pos_x + table->TempData->AngledHeadersExtraWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pop clipping rect
|
// Pop clipping rect
|
||||||
@@ -1458,7 +1462,7 @@ void ImGui::EndTable()
|
|||||||
}
|
}
|
||||||
else if (temp_data->UserOuterSize.x <= 0.0f)
|
else if (temp_data->UserOuterSize.x <= 0.0f)
|
||||||
{
|
{
|
||||||
const float decoration_size = table->TempData->AngledheadersExtraWidth + ((table->Flags & ImGuiTableFlags_ScrollX) ? inner_window->ScrollbarSizes.x : 0.0f);
|
const float decoration_size = table->TempData->AngledHeadersExtraWidth + ((table->Flags & ImGuiTableFlags_ScrollX) ? inner_window->ScrollbarSizes.x : 0.0f);
|
||||||
outer_window->DC.IdealMaxPos.x = ImMax(outer_window->DC.IdealMaxPos.x, table->OuterRect.Min.x + table->ColumnsAutoFitWidth + decoration_size - temp_data->UserOuterSize.x);
|
outer_window->DC.IdealMaxPos.x = ImMax(outer_window->DC.IdealMaxPos.x, table->OuterRect.Min.x + table->ColumnsAutoFitWidth + decoration_size - temp_data->UserOuterSize.x);
|
||||||
outer_window->DC.CursorMaxPos.x = ImMax(backup_outer_max_pos.x, ImMin(table->OuterRect.Max.x, table->OuterRect.Min.x + table->ColumnsAutoFitWidth));
|
outer_window->DC.CursorMaxPos.x = ImMax(backup_outer_max_pos.x, ImMin(table->OuterRect.Max.x, table->OuterRect.Min.x + table->ColumnsAutoFitWidth));
|
||||||
}
|
}
|
||||||
@@ -1563,6 +1567,7 @@ void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, flo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store name (append with zero-terminator in contiguous buffer)
|
// Store name (append with zero-terminator in contiguous buffer)
|
||||||
|
// FIXME: If we recorded the number of \n in names we could compute header row height
|
||||||
column->NameOffset = -1;
|
column->NameOffset = -1;
|
||||||
if (label != NULL && label[0] != 0)
|
if (label != NULL && label[0] != 0)
|
||||||
{
|
{
|
||||||
@@ -2150,6 +2155,8 @@ void ImGui::TableEndCell(ImGuiTable* table)
|
|||||||
// - TableSetColumnWidthAutoAll() [Internal]
|
// - TableSetColumnWidthAutoAll() [Internal]
|
||||||
// - TableUpdateColumnsWeightFromWidth() [Internal]
|
// - TableUpdateColumnsWeightFromWidth() [Internal]
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
// Note that actual columns widths are computed in TableUpdateLayout().
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
// Maximum column content width given current layout. Use column->MinX so this value on a per-column basis.
|
// Maximum column content width given current layout. Use column->MinX so this value on a per-column basis.
|
||||||
float ImGui::TableGetMaxColumnWidth(const ImGuiTable* table, int column_n)
|
float ImGui::TableGetMaxColumnWidth(const ImGuiTable* table, int column_n)
|
||||||
@@ -2923,6 +2930,7 @@ void ImGui::TableSortSpecsBuild(ImGuiTable* table)
|
|||||||
// [SECTION] Tables: Headers
|
// [SECTION] Tables: Headers
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// - TableGetHeaderRowHeight() [Internal]
|
// - TableGetHeaderRowHeight() [Internal]
|
||||||
|
// - TableGetHeaderAngledMaxLabelWidth() [Internal]
|
||||||
// - TableHeadersRow()
|
// - TableHeadersRow()
|
||||||
// - TableHeader()
|
// - TableHeader()
|
||||||
// - TableAngledHeadersRow()
|
// - TableAngledHeadersRow()
|
||||||
@@ -2954,7 +2962,7 @@ float ImGui::TableGetHeaderAngledMaxLabelWidth()
|
|||||||
if (IM_BITARRAY_TESTBIT(table->EnabledMaskByIndex, column_n))
|
if (IM_BITARRAY_TESTBIT(table->EnabledMaskByIndex, column_n))
|
||||||
if (table->Columns[column_n].Flags & ImGuiTableColumnFlags_AngledHeader)
|
if (table->Columns[column_n].Flags & ImGuiTableColumnFlags_AngledHeader)
|
||||||
width = ImMax(width, CalcTextSize(TableGetColumnName(table, column_n), NULL, true).x);
|
width = ImMax(width, CalcTextSize(TableGetColumnName(table, column_n), NULL, true).x);
|
||||||
return width + g.Style.CellPadding.x * 2.0f;
|
return width + g.Style.CellPadding.y * 2.0f; // Swap padding
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Public] This is a helper to output TableHeader() calls based on the column names declared in TableSetupColumn().
|
// [Public] This is a helper to output TableHeader() calls based on the column names declared in TableSetupColumn().
|
||||||
@@ -3078,7 +3086,7 @@ void ImGui::TableHeader(const char* label)
|
|||||||
if ((table->RowFlags & ImGuiTableRowFlags_Headers) == 0)
|
if ((table->RowFlags & ImGuiTableRowFlags_Headers) == 0)
|
||||||
TableSetBgColor(ImGuiTableBgTarget_CellBg, GetColorU32(ImGuiCol_TableHeaderBg), table->CurrentColumn);
|
TableSetBgColor(ImGuiTableBgTarget_CellBg, GetColorU32(ImGuiCol_TableHeaderBg), table->CurrentColumn);
|
||||||
}
|
}
|
||||||
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding);
|
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_Compact | ImGuiNavHighlightFlags_NoRounding);
|
||||||
if (held)
|
if (held)
|
||||||
table->HeldHeaderColumn = (ImGuiTableColumnIdx)column_n;
|
table->HeldHeaderColumn = (ImGuiTableColumnIdx)column_n;
|
||||||
window->DC.CursorPos.y -= g.Style.ItemSpacing.y * 0.5f;
|
window->DC.CursorPos.y -= g.Style.ItemSpacing.y * 0.5f;
|
||||||
@@ -3176,25 +3184,25 @@ void ImGui::TableAngledHeadersRowEx(float angle, float max_label_width)
|
|||||||
|
|
||||||
// Calculate our base metrics and set angled headers data _before_ the first call to TableNextRow()
|
// Calculate our base metrics and set angled headers data _before_ the first call to TableNextRow()
|
||||||
// FIXME-STYLE: Would it be better for user to submit 'max_label_width' or 'row_height' ? One can be derived from the other.
|
// FIXME-STYLE: Would it be better for user to submit 'max_label_width' or 'row_height' ? One can be derived from the other.
|
||||||
const float header_height = table->RowCellPaddingY * 2.0f + g.FontSize;
|
const float header_height = g.FontSize + g.Style.CellPadding.x * 2.0f;
|
||||||
const float row_height = ImFabs(ImRotate(ImVec2(max_label_width, flip_label ? +header_height : -header_height), cos_a, sin_a).y);
|
const float row_height = ImFabs(ImRotate(ImVec2(max_label_width, flip_label ? +header_height : -header_height), cos_a, sin_a).y);
|
||||||
const ImVec2 header_angled_vector = unit_right * (row_height / -sin_a);
|
|
||||||
table->AngledHeadersHeight = row_height;
|
table->AngledHeadersHeight = row_height;
|
||||||
table->AngledHeadersSlope = (sin_a != 0.0f) ? (cos_a / sin_a) : 0.0f;
|
table->AngledHeadersSlope = (sin_a != 0.0f) ? (cos_a / sin_a) : 0.0f;
|
||||||
|
const ImVec2 header_angled_vector = unit_right * (row_height / -sin_a); // vector from bottom-left to top-left, and from bottom-right to top-right
|
||||||
|
|
||||||
// Declare row, override and draw our own background
|
// Declare row, override and draw our own background
|
||||||
TableNextRow(ImGuiTableRowFlags_Headers, row_height);
|
TableNextRow(ImGuiTableRowFlags_Headers, row_height);
|
||||||
TableNextColumn();
|
TableNextColumn();
|
||||||
|
const ImRect row_r(table->WorkRect.Min.x, table->BgClipRect.Min.y, table->WorkRect.Max.x, table->RowPosY2);
|
||||||
table->DrawSplitter->SetCurrentChannel(draw_list, TABLE_DRAW_CHANNEL_BG0);
|
table->DrawSplitter->SetCurrentChannel(draw_list, TABLE_DRAW_CHANNEL_BG0);
|
||||||
float clip_rect_min_x = table->BgClipRect.Min.x;
|
float clip_rect_min_x = table->BgClipRect.Min.x;
|
||||||
if (table->FreezeColumnsCount > 0)
|
if (table->FreezeColumnsCount > 0)
|
||||||
clip_rect_min_x = ImMax(clip_rect_min_x, table->Columns[table->FreezeColumnsCount - 1].MaxX);
|
clip_rect_min_x = ImMax(clip_rect_min_x, table->Columns[table->FreezeColumnsCount - 1].MaxX);
|
||||||
TableSetBgColor(ImGuiTableBgTarget_RowBg0, 0); // Cancel
|
TableSetBgColor(ImGuiTableBgTarget_RowBg0, 0); // Cancel
|
||||||
PushClipRect(table->BgClipRect.Min, table->BgClipRect.Max, false); // Span all columns
|
PushClipRect(table->BgClipRect.Min, table->BgClipRect.Max, false); // Span all columns
|
||||||
draw_list->AddRectFilled(table->BgClipRect.Min, table->BgClipRect.Max, GetColorU32(ImGuiCol_TableHeaderBg, 0.25f)); // FIXME-STYLE: Change row background with an arbitrary color.
|
draw_list->AddRectFilled(ImVec2(table->BgClipRect.Min.x, row_r.Min.y), ImVec2(table->BgClipRect.Max.x, row_r.Max.y), GetColorU32(ImGuiCol_TableHeaderBg, 0.25f)); // FIXME-STYLE: Change row background with an arbitrary color.
|
||||||
PushClipRect(ImVec2(clip_rect_min_x, table->BgClipRect.Min.y), table->BgClipRect.Max, true); // Span all columns
|
PushClipRect(ImVec2(clip_rect_min_x, table->BgClipRect.Min.y), table->BgClipRect.Max, true); // Span all columns
|
||||||
|
|
||||||
const ImRect row_r(table->WorkRect.Min.x, table->BgClipRect.Min.y, table->WorkRect.Max.x, window->DC.CursorPos.y + row_height);
|
|
||||||
const ImGuiID row_id = GetID("##AngledHeaders");
|
const ImGuiID row_id = GetID("##AngledHeaders");
|
||||||
ButtonBehavior(row_r, row_id, NULL, NULL);
|
ButtonBehavior(row_r, row_id, NULL, NULL);
|
||||||
KeepAliveID(row_id);
|
KeepAliveID(row_id);
|
||||||
@@ -3205,7 +3213,9 @@ void ImGui::TableAngledHeadersRowEx(float angle, float max_label_width)
|
|||||||
if (table_instance->HoveredRowLast == 0 && table->HoveredColumnBorder == -1 && (g.ActiveId == 0 || g.ActiveId == row_id || (table->IsActiveIdInTable || g.DragDropActive)))
|
if (table_instance->HoveredRowLast == 0 && table->HoveredColumnBorder == -1 && (g.ActiveId == 0 || g.ActiveId == row_id || (table->IsActiveIdInTable || g.DragDropActive)))
|
||||||
highlight_column_n = table->HoveredColumnBody;
|
highlight_column_n = table->HoveredColumnBody;
|
||||||
|
|
||||||
|
// Draw background and labels in first pass, then all borders.
|
||||||
float max_x = 0.0f;
|
float max_x = 0.0f;
|
||||||
|
ImVec2 padding = g.Style.CellPadding; // We will always use swapped component
|
||||||
for (int pass = 0; pass < 2; pass++)
|
for (int pass = 0; pass < 2; pass++)
|
||||||
for (int order_n = 0; order_n < table->ColumnsCount; order_n++)
|
for (int order_n = 0; order_n < table->ColumnsCount; order_n++)
|
||||||
{
|
{
|
||||||
@@ -3227,25 +3237,45 @@ void ImGui::TableAngledHeadersRowEx(float angle, float max_label_width)
|
|||||||
draw_list->AddQuadFilled(bg_shape[0], bg_shape[1], bg_shape[2], bg_shape[3], GetColorU32(ImGuiCol_TableHeaderBg));
|
draw_list->AddQuadFilled(bg_shape[0], bg_shape[1], bg_shape[2], bg_shape[3], GetColorU32(ImGuiCol_TableHeaderBg));
|
||||||
if (column_n == highlight_column_n)
|
if (column_n == highlight_column_n)
|
||||||
draw_list->AddQuadFilled(bg_shape[0], bg_shape[1], bg_shape[2], bg_shape[3], GetColorU32(ImGuiCol_Header)); // Highlight on hover
|
draw_list->AddQuadFilled(bg_shape[0], bg_shape[1], bg_shape[2], bg_shape[3], GetColorU32(ImGuiCol_Header)); // Highlight on hover
|
||||||
//draw_list->AddQuad(bg_shape[0], bg_shape[1], bg_shape[2], bg_shape[3], GetColorU32(ImGuiCol_TableBorderLight), 1.0f);
|
|
||||||
max_x = ImMax(max_x, bg_shape[3].x);
|
max_x = ImMax(max_x, bg_shape[3].x);
|
||||||
|
|
||||||
// Draw label (first draw at an offset where RenderTextXXX() function won't meddle with applying current ClipRect, then transform to final offset)
|
// Draw label
|
||||||
// FIXME: May be worth tidying up all those operations to make them easier to understand.
|
// - First draw at an offset where RenderTextXXX() function won't meddle with applying current ClipRect, then transform to final offset.
|
||||||
|
// - Handle multiple lines manually, as we want each lines to follow on the horizontal border, rather than see a whole block rotated.
|
||||||
const char* label_name = TableGetColumnName(table, column_n);
|
const char* label_name = TableGetColumnName(table, column_n);
|
||||||
const float clip_width = max_label_width - (sin_a * table->RowCellPaddingY);
|
const char* label_name_end = FindRenderedTextEnd(label_name);
|
||||||
ImRect label_r(window->ClipRect.Min, window->ClipRect.Min + ImVec2(clip_width + (flip_label ? 0.0f : table->CellPaddingX), header_height + table->RowCellPaddingY));
|
const float line_off_step_x = g.FontSize / -sin_a;
|
||||||
ImVec2 label_size = CalcTextSize(label_name, NULL, true);
|
float line_off_curr_x = 0.0f;
|
||||||
ImVec2 label_off = ImVec2(flip_label ? ImMax(0.0f, max_label_width - label_size.x - table->CellPaddingX) : table->CellPaddingX, table->RowCellPaddingY);
|
while (label_name < label_name_end)
|
||||||
int vtx_idx_begin = draw_list->_VtxCurrentIdx;
|
{
|
||||||
RenderTextEllipsis(draw_list, label_r.Min + label_off, label_r.Max, label_r.Max.x, label_r.Max.x, label_name, NULL, &label_size);
|
const char* label_name_eol = strchr(label_name, '\n');
|
||||||
//if (g.IO.KeyShift) { draw_list->AddRect(label_r.Min, label_r.Max, IM_COL32(0, 255, 0, 255), 0.0f, 0, 2.0f); }
|
if (label_name_eol == NULL)
|
||||||
int vtx_idx_end = draw_list->_VtxCurrentIdx;
|
label_name_eol = label_name_end;
|
||||||
|
|
||||||
// Rotate and offset label
|
// FIXME: Individual line clipping for right-most column is broken for negative angles.
|
||||||
ImVec2 pivot_in = label_r.GetBL();
|
ImVec2 label_size = CalcTextSize(label_name, label_name_eol);
|
||||||
ImVec2 pivot_out = ImVec2(column->WorkMinX, row_r.Max.y) + (flip_label ? (unit_right * clip_width) : ImVec2(header_height, 0.0f));
|
float clip_width = max_label_width - padding.y; // Using padding.y*2.0f would be symetrical but hide more text.
|
||||||
ShadeVertsTransformPos(draw_list, vtx_idx_begin, vtx_idx_end, pivot_in, label_cos_a, label_sin_a, pivot_out); // Rotate and offset
|
float clip_height = ImMin(label_size.y, column->ClipRect.Max.x - column->WorkMinX - line_off_curr_x);
|
||||||
|
ImRect clip_r(window->ClipRect.Min, window->ClipRect.Min + ImVec2(clip_width, clip_height));
|
||||||
|
int vtx_idx_begin = draw_list->_VtxCurrentIdx;
|
||||||
|
RenderTextEllipsis(draw_list, clip_r.Min, clip_r.Max, clip_r.Max.x, clip_r.Max.x, label_name, label_name_eol, &label_size);
|
||||||
|
int vtx_idx_end = draw_list->_VtxCurrentIdx;
|
||||||
|
|
||||||
|
// Rotate and offset label
|
||||||
|
ImVec2 pivot_in = ImVec2(window->ClipRect.Min.x, window->ClipRect.Min.y + label_size.y);
|
||||||
|
ImVec2 pivot_out = ImVec2(column->WorkMinX, row_r.Max.y);
|
||||||
|
line_off_curr_x += line_off_step_x;
|
||||||
|
pivot_out += unit_right * padding.y;
|
||||||
|
if (flip_label)
|
||||||
|
pivot_out += unit_right * (clip_width - ImMax(0.0f, clip_width - label_size.x));
|
||||||
|
pivot_out.x += flip_label ? line_off_curr_x - line_off_step_x : line_off_curr_x;
|
||||||
|
ShadeVertsTransformPos(draw_list, vtx_idx_begin, vtx_idx_end, pivot_in, label_cos_a, label_sin_a, pivot_out); // Rotate and offset
|
||||||
|
//if (g.IO.KeyShift) { ImDrawList* fg_dl = GetForegroundDrawList(); vtx_idx_begin = fg_dl->_VtxCurrentIdx; fg_dl->AddRect(clip_r.Min, clip_r.Max, IM_COL32(0, 255, 0, 255), 0.0f, 0, 2.0f); ShadeVertsTransformPos(fg_dl, vtx_idx_begin, fg_dl->_VtxCurrentIdx, pivot_in, label_cos_a, label_sin_a, pivot_out); }
|
||||||
|
|
||||||
|
// Register header width
|
||||||
|
column->ContentMaxXHeadersUsed = column->ContentMaxXHeadersIdeal = column->WorkMinX + ImCeil(line_off_curr_x);
|
||||||
|
label_name = label_name_eol + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (pass == 1)
|
if (pass == 1)
|
||||||
{
|
{
|
||||||
@@ -3255,7 +3285,7 @@ void ImGui::TableAngledHeadersRowEx(float angle, float max_label_width)
|
|||||||
}
|
}
|
||||||
PopClipRect();
|
PopClipRect();
|
||||||
PopClipRect();
|
PopClipRect();
|
||||||
table->TempData->AngledheadersExtraWidth = ImMax(0.0f, max_x - table->Columns[table->RightMostEnabledColumn].MaxX);
|
table->TempData->AngledHeadersExtraWidth = ImMax(0.0f, max_x - table->Columns[table->RightMostEnabledColumn].MaxX);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@@ -3802,7 +3832,8 @@ static const char* DebugNodeTableGetSizingPolicyDesc(ImGuiTableFlags sizing_poli
|
|||||||
|
|
||||||
void ImGui::DebugNodeTable(ImGuiTable* table)
|
void ImGui::DebugNodeTable(ImGuiTable* table)
|
||||||
{
|
{
|
||||||
const bool is_active = (table->LastFrameActive >= GetFrameCount() - 2); // Note that fully clipped early out scrolling tables will appear as inactive here.
|
ImGuiContext& g = *GImGui;
|
||||||
|
const bool is_active = (table->LastFrameActive >= g.FrameCount - 2); // Note that fully clipped early out scrolling tables will appear as inactive here.
|
||||||
if (!is_active) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); }
|
if (!is_active) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); }
|
||||||
bool open = TreeNode(table, "Table 0x%08X (%d columns, in '%s')%s", table->ID, table->ColumnsCount, table->OuterWindow->Name, is_active ? "" : " *Inactive*");
|
bool open = TreeNode(table, "Table 0x%08X (%d columns, in '%s')%s", table->ID, table->ColumnsCount, table->OuterWindow->Name, is_active ? "" : " *Inactive*");
|
||||||
if (!is_active) { PopStyleColor(); }
|
if (!is_active) { PopStyleColor(); }
|
||||||
@@ -3814,6 +3845,13 @@ void ImGui::DebugNodeTable(ImGuiTable* table)
|
|||||||
return;
|
return;
|
||||||
if (table->InstanceCurrent > 0)
|
if (table->InstanceCurrent > 0)
|
||||||
Text("** %d instances of same table! Some data below will refer to last instance.", table->InstanceCurrent + 1);
|
Text("** %d instances of same table! Some data below will refer to last instance.", table->InstanceCurrent + 1);
|
||||||
|
if (g.IO.ConfigDebugIsDebuggerPresent)
|
||||||
|
{
|
||||||
|
if (DebugBreakButton("**DebugBreak**", "in BeginTable()"))
|
||||||
|
g.DebugBreakInTable = table->ID;
|
||||||
|
SameLine();
|
||||||
|
}
|
||||||
|
|
||||||
bool clear_settings = SmallButton("Clear settings");
|
bool clear_settings = SmallButton("Clear settings");
|
||||||
BulletText("OuterRect: Pos: (%.1f,%.1f) Size: (%.1f,%.1f) Sizing: '%s'", table->OuterRect.Min.x, table->OuterRect.Min.y, table->OuterRect.GetWidth(), table->OuterRect.GetHeight(), DebugNodeTableGetSizingPolicyDesc(table->Flags));
|
BulletText("OuterRect: Pos: (%.1f,%.1f) Size: (%.1f,%.1f) Sizing: '%s'", table->OuterRect.Min.x, table->OuterRect.Min.y, table->OuterRect.GetWidth(), table->OuterRect.GetHeight(), DebugNodeTableGetSizingPolicyDesc(table->Flags));
|
||||||
BulletText("ColumnsGivenWidth: %.1f, ColumnsAutoFitWidth: %.1f, InnerWidth: %.1f%s", table->ColumnsGivenWidth, table->ColumnsAutoFitWidth, table->InnerWidth, table->InnerWidth == 0.0f ? " (auto)" : "");
|
BulletText("ColumnsGivenWidth: %.1f, ColumnsAutoFitWidth: %.1f, InnerWidth: %.1f%s", table->ColumnsGivenWidth, table->ColumnsAutoFitWidth, table->InnerWidth, table->InnerWidth == 0.0f ? " (auto)" : "");
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
143
imstb_textedit.h
143
imstb_textedit.h
@@ -4,6 +4,7 @@
|
|||||||
// - Fix in stb_textedit_discard_redo (see https://github.com/nothings/stb/issues/321)
|
// - Fix in stb_textedit_discard_redo (see https://github.com/nothings/stb/issues/321)
|
||||||
// - Fix in stb_textedit_find_charpos to handle last line (see https://github.com/ocornut/imgui/issues/6000 + #6783)
|
// - Fix in stb_textedit_find_charpos to handle last line (see https://github.com/ocornut/imgui/issues/6000 + #6783)
|
||||||
// Grep for [DEAR IMGUI] to find the changes.
|
// Grep for [DEAR IMGUI] to find the changes.
|
||||||
|
// - Also renamed macros used or defined outside of IMSTB_TEXTEDIT_IMPLEMENTATION block from STB_TEXTEDIT_* to IMSTB_TEXTEDIT_*
|
||||||
|
|
||||||
// stb_textedit.h - v1.14 - public domain - Sean Barrett
|
// stb_textedit.h - v1.14 - public domain - Sean Barrett
|
||||||
// Development of this library was sponsored by RAD Game Tools
|
// Development of this library was sponsored by RAD Game Tools
|
||||||
@@ -30,7 +31,7 @@
|
|||||||
// DEPENDENCIES
|
// DEPENDENCIES
|
||||||
//
|
//
|
||||||
// Uses the C runtime function 'memmove', which you can override
|
// Uses the C runtime function 'memmove', which you can override
|
||||||
// by defining STB_TEXTEDIT_memmove before the implementation.
|
// by defining IMSTB_TEXTEDIT_memmove before the implementation.
|
||||||
// Uses no other functions. Performs no runtime allocations.
|
// Uses no other functions. Performs no runtime allocations.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -274,8 +275,8 @@
|
|||||||
////
|
////
|
||||||
////
|
////
|
||||||
|
|
||||||
#ifndef INCLUDE_STB_TEXTEDIT_H
|
#ifndef INCLUDE_IMSTB_TEXTEDIT_H
|
||||||
#define INCLUDE_STB_TEXTEDIT_H
|
#define INCLUDE_IMSTB_TEXTEDIT_H
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@@ -286,33 +287,33 @@
|
|||||||
// and undo state.
|
// and undo state.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef STB_TEXTEDIT_UNDOSTATECOUNT
|
#ifndef IMSTB_TEXTEDIT_UNDOSTATECOUNT
|
||||||
#define STB_TEXTEDIT_UNDOSTATECOUNT 99
|
#define IMSTB_TEXTEDIT_UNDOSTATECOUNT 99
|
||||||
#endif
|
#endif
|
||||||
#ifndef STB_TEXTEDIT_UNDOCHARCOUNT
|
#ifndef IMSTB_TEXTEDIT_UNDOCHARCOUNT
|
||||||
#define STB_TEXTEDIT_UNDOCHARCOUNT 999
|
#define IMSTB_TEXTEDIT_UNDOCHARCOUNT 999
|
||||||
#endif
|
#endif
|
||||||
#ifndef STB_TEXTEDIT_CHARTYPE
|
#ifndef IMSTB_TEXTEDIT_CHARTYPE
|
||||||
#define STB_TEXTEDIT_CHARTYPE int
|
#define IMSTB_TEXTEDIT_CHARTYPE int
|
||||||
#endif
|
#endif
|
||||||
#ifndef STB_TEXTEDIT_POSITIONTYPE
|
#ifndef IMSTB_TEXTEDIT_POSITIONTYPE
|
||||||
#define STB_TEXTEDIT_POSITIONTYPE int
|
#define IMSTB_TEXTEDIT_POSITIONTYPE int
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
// private data
|
// private data
|
||||||
STB_TEXTEDIT_POSITIONTYPE where;
|
IMSTB_TEXTEDIT_POSITIONTYPE where;
|
||||||
STB_TEXTEDIT_POSITIONTYPE insert_length;
|
IMSTB_TEXTEDIT_POSITIONTYPE insert_length;
|
||||||
STB_TEXTEDIT_POSITIONTYPE delete_length;
|
IMSTB_TEXTEDIT_POSITIONTYPE delete_length;
|
||||||
int char_storage;
|
int char_storage;
|
||||||
} StbUndoRecord;
|
} StbUndoRecord;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
// private data
|
// private data
|
||||||
StbUndoRecord undo_rec [STB_TEXTEDIT_UNDOSTATECOUNT];
|
StbUndoRecord undo_rec [IMSTB_TEXTEDIT_UNDOSTATECOUNT];
|
||||||
STB_TEXTEDIT_CHARTYPE undo_char[STB_TEXTEDIT_UNDOCHARCOUNT];
|
IMSTB_TEXTEDIT_CHARTYPE undo_char[IMSTB_TEXTEDIT_UNDOCHARCOUNT];
|
||||||
short undo_point, redo_point;
|
short undo_point, redo_point;
|
||||||
int undo_char_point, redo_char_point;
|
int undo_char_point, redo_char_point;
|
||||||
} StbUndoState;
|
} StbUndoState;
|
||||||
@@ -371,7 +372,7 @@ typedef struct
|
|||||||
float ymin,ymax; // height of row above and below baseline
|
float ymin,ymax; // height of row above and below baseline
|
||||||
int num_chars;
|
int num_chars;
|
||||||
} StbTexteditRow;
|
} StbTexteditRow;
|
||||||
#endif //INCLUDE_STB_TEXTEDIT_H
|
#endif //INCLUDE_IMSTB_TEXTEDIT_H
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -384,11 +385,11 @@ typedef struct
|
|||||||
|
|
||||||
// implementation isn't include-guarded, since it might have indirectly
|
// implementation isn't include-guarded, since it might have indirectly
|
||||||
// included just the "header" portion
|
// included just the "header" portion
|
||||||
#ifdef STB_TEXTEDIT_IMPLEMENTATION
|
#ifdef IMSTB_TEXTEDIT_IMPLEMENTATION
|
||||||
|
|
||||||
#ifndef STB_TEXTEDIT_memmove
|
#ifndef IMSTB_TEXTEDIT_memmove
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#define STB_TEXTEDIT_memmove memmove
|
#define IMSTB_TEXTEDIT_memmove memmove
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -398,7 +399,7 @@ typedef struct
|
|||||||
//
|
//
|
||||||
|
|
||||||
// traverse the layout to locate the nearest character to a display position
|
// traverse the layout to locate the nearest character to a display position
|
||||||
static int stb_text_locate_coord(STB_TEXTEDIT_STRING *str, float x, float y)
|
static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
|
||||||
{
|
{
|
||||||
StbTexteditRow r;
|
StbTexteditRow r;
|
||||||
int n = STB_TEXTEDIT_STRINGLEN(str);
|
int n = STB_TEXTEDIT_STRINGLEN(str);
|
||||||
@@ -458,7 +459,7 @@ static int stb_text_locate_coord(STB_TEXTEDIT_STRING *str, float x, float y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// API click: on mouse down, move the cursor to the clicked location, and reset the selection
|
// API click: on mouse down, move the cursor to the clicked location, and reset the selection
|
||||||
static void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)
|
static void stb_textedit_click(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)
|
||||||
{
|
{
|
||||||
// In single-line mode, just always make y = 0. This lets the drag keep working if the mouse
|
// In single-line mode, just always make y = 0. This lets the drag keep working if the mouse
|
||||||
// goes off the top or bottom of the text
|
// goes off the top or bottom of the text
|
||||||
@@ -476,7 +477,7 @@ static void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *stat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// API drag: on mouse drag, move the cursor and selection endpoint to the clicked location
|
// API drag: on mouse drag, move the cursor and selection endpoint to the clicked location
|
||||||
static void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)
|
static void stb_textedit_drag(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)
|
||||||
{
|
{
|
||||||
int p = 0;
|
int p = 0;
|
||||||
|
|
||||||
@@ -502,11 +503,11 @@ static void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state
|
|||||||
//
|
//
|
||||||
|
|
||||||
// forward declarations
|
// forward declarations
|
||||||
static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state);
|
static void stb_text_undo(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state);
|
||||||
static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state);
|
static void stb_text_redo(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state);
|
||||||
static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length);
|
static void stb_text_makeundo_delete(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length);
|
||||||
static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length);
|
static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length);
|
||||||
static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length);
|
static void stb_text_makeundo_replace(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length);
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -518,7 +519,7 @@ typedef struct
|
|||||||
|
|
||||||
// find the x/y location of a character, and remember info about the previous row in
|
// find the x/y location of a character, and remember info about the previous row in
|
||||||
// case we get a move-up event (for page up, we'll have to rescan)
|
// case we get a move-up event (for page up, we'll have to rescan)
|
||||||
static void stb_textedit_find_charpos(StbFindState *find, STB_TEXTEDIT_STRING *str, int n, int single_line)
|
static void stb_textedit_find_charpos(StbFindState *find, IMSTB_TEXTEDIT_STRING *str, int n, int single_line)
|
||||||
{
|
{
|
||||||
StbTexteditRow r;
|
StbTexteditRow r;
|
||||||
int prev_start = 0;
|
int prev_start = 0;
|
||||||
@@ -569,7 +570,7 @@ static void stb_textedit_find_charpos(StbFindState *find, STB_TEXTEDIT_STRING *s
|
|||||||
#define STB_TEXT_HAS_SELECTION(s) ((s)->select_start != (s)->select_end)
|
#define STB_TEXT_HAS_SELECTION(s) ((s)->select_start != (s)->select_end)
|
||||||
|
|
||||||
// make the selection/cursor state valid if client altered the string
|
// make the selection/cursor state valid if client altered the string
|
||||||
static void stb_textedit_clamp(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
static void stb_textedit_clamp(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||||
{
|
{
|
||||||
int n = STB_TEXTEDIT_STRINGLEN(str);
|
int n = STB_TEXTEDIT_STRINGLEN(str);
|
||||||
if (STB_TEXT_HAS_SELECTION(state)) {
|
if (STB_TEXT_HAS_SELECTION(state)) {
|
||||||
@@ -583,7 +584,7 @@ static void stb_textedit_clamp(STB_TEXTEDIT_STRING *str, STB_TexteditState *stat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// delete characters while updating undo
|
// delete characters while updating undo
|
||||||
static void stb_textedit_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int len)
|
static void stb_textedit_delete(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int len)
|
||||||
{
|
{
|
||||||
stb_text_makeundo_delete(str, state, where, len);
|
stb_text_makeundo_delete(str, state, where, len);
|
||||||
STB_TEXTEDIT_DELETECHARS(str, where, len);
|
STB_TEXTEDIT_DELETECHARS(str, where, len);
|
||||||
@@ -591,7 +592,7 @@ static void stb_textedit_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *sta
|
|||||||
}
|
}
|
||||||
|
|
||||||
// delete the section
|
// delete the section
|
||||||
static void stb_textedit_delete_selection(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
static void stb_textedit_delete_selection(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||||
{
|
{
|
||||||
stb_textedit_clamp(str, state);
|
stb_textedit_clamp(str, state);
|
||||||
if (STB_TEXT_HAS_SELECTION(state)) {
|
if (STB_TEXT_HAS_SELECTION(state)) {
|
||||||
@@ -628,7 +629,7 @@ static void stb_textedit_move_to_first(STB_TexteditState *state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// move cursor to last character of selection
|
// move cursor to last character of selection
|
||||||
static void stb_textedit_move_to_last(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
static void stb_textedit_move_to_last(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||||
{
|
{
|
||||||
if (STB_TEXT_HAS_SELECTION(state)) {
|
if (STB_TEXT_HAS_SELECTION(state)) {
|
||||||
stb_textedit_sortselection(state);
|
stb_textedit_sortselection(state);
|
||||||
@@ -640,13 +641,13 @@ static void stb_textedit_move_to_last(STB_TEXTEDIT_STRING *str, STB_TexteditStat
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef STB_TEXTEDIT_IS_SPACE
|
#ifdef STB_TEXTEDIT_IS_SPACE
|
||||||
static int is_word_boundary( STB_TEXTEDIT_STRING *str, int idx )
|
static int is_word_boundary( IMSTB_TEXTEDIT_STRING *str, int idx )
|
||||||
{
|
{
|
||||||
return idx > 0 ? (STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str,idx-1) ) && !STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str, idx) ) ) : 1;
|
return idx > 0 ? (STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str,idx-1) ) && !STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str, idx) ) ) : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef STB_TEXTEDIT_MOVEWORDLEFT
|
#ifndef STB_TEXTEDIT_MOVEWORDLEFT
|
||||||
static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *str, int c )
|
static int stb_textedit_move_to_word_previous( IMSTB_TEXTEDIT_STRING *str, int c )
|
||||||
{
|
{
|
||||||
--c; // always move at least one character
|
--c; // always move at least one character
|
||||||
while( c >= 0 && !is_word_boundary( str, c ) )
|
while( c >= 0 && !is_word_boundary( str, c ) )
|
||||||
@@ -661,7 +662,7 @@ static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *str, int c )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef STB_TEXTEDIT_MOVEWORDRIGHT
|
#ifndef STB_TEXTEDIT_MOVEWORDRIGHT
|
||||||
static int stb_textedit_move_to_word_next( STB_TEXTEDIT_STRING *str, int c )
|
static int stb_textedit_move_to_word_next( IMSTB_TEXTEDIT_STRING *str, int c )
|
||||||
{
|
{
|
||||||
const int len = STB_TEXTEDIT_STRINGLEN(str);
|
const int len = STB_TEXTEDIT_STRINGLEN(str);
|
||||||
++c; // always move at least one character
|
++c; // always move at least one character
|
||||||
@@ -688,7 +689,7 @@ static void stb_textedit_prep_selection_at_cursor(STB_TexteditState *state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// API cut: delete selection
|
// API cut: delete selection
|
||||||
static int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
static int stb_textedit_cut(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||||
{
|
{
|
||||||
if (STB_TEXT_HAS_SELECTION(state)) {
|
if (STB_TEXT_HAS_SELECTION(state)) {
|
||||||
stb_textedit_delete_selection(str,state); // implicitly clamps
|
stb_textedit_delete_selection(str,state); // implicitly clamps
|
||||||
@@ -699,7 +700,7 @@ static int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// API paste: replace existing selection with passed-in text
|
// API paste: replace existing selection with passed-in text
|
||||||
static int stb_textedit_paste_internal(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE *text, int len)
|
static int stb_textedit_paste_internal(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, IMSTB_TEXTEDIT_CHARTYPE *text, int len)
|
||||||
{
|
{
|
||||||
// if there's a selection, the paste should delete it
|
// if there's a selection, the paste should delete it
|
||||||
stb_textedit_clamp(str, state);
|
stb_textedit_clamp(str, state);
|
||||||
@@ -720,14 +721,14 @@ static int stb_textedit_paste_internal(STB_TEXTEDIT_STRING *str, STB_TexteditSta
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// API key: process a keyboard input
|
// API key: process a keyboard input
|
||||||
static void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_KEYTYPE key)
|
static void stb_textedit_key(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_KEYTYPE key)
|
||||||
{
|
{
|
||||||
retry:
|
retry:
|
||||||
switch (key) {
|
switch (key) {
|
||||||
default: {
|
default: {
|
||||||
int c = STB_TEXTEDIT_KEYTOTEXT(key);
|
int c = STB_TEXTEDIT_KEYTOTEXT(key);
|
||||||
if (c > 0) {
|
if (c > 0) {
|
||||||
STB_TEXTEDIT_CHARTYPE ch = (STB_TEXTEDIT_CHARTYPE) c;
|
IMSTB_TEXTEDIT_CHARTYPE ch = (IMSTB_TEXTEDIT_CHARTYPE) c;
|
||||||
|
|
||||||
// can't add newline in single-line mode
|
// can't add newline in single-line mode
|
||||||
if (c == '\n' && state->single_line)
|
if (c == '\n' && state->single_line)
|
||||||
@@ -892,8 +893,8 @@ retry:
|
|||||||
x = row.x0;
|
x = row.x0;
|
||||||
for (i=0; i < row.num_chars; ++i) {
|
for (i=0; i < row.num_chars; ++i) {
|
||||||
float dx = STB_TEXTEDIT_GETWIDTH(str, start, i);
|
float dx = STB_TEXTEDIT_GETWIDTH(str, start, i);
|
||||||
#ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE
|
#ifdef IMSTB_TEXTEDIT_GETWIDTH_NEWLINE
|
||||||
if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE)
|
if (dx == IMSTB_TEXTEDIT_GETWIDTH_NEWLINE)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
x += dx;
|
x += dx;
|
||||||
@@ -954,8 +955,8 @@ retry:
|
|||||||
x = row.x0;
|
x = row.x0;
|
||||||
for (i=0; i < row.num_chars; ++i) {
|
for (i=0; i < row.num_chars; ++i) {
|
||||||
float dx = STB_TEXTEDIT_GETWIDTH(str, find.prev_first, i);
|
float dx = STB_TEXTEDIT_GETWIDTH(str, find.prev_first, i);
|
||||||
#ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE
|
#ifdef IMSTB_TEXTEDIT_GETWIDTH_NEWLINE
|
||||||
if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE)
|
if (dx == IMSTB_TEXTEDIT_GETWIDTH_NEWLINE)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
x += dx;
|
x += dx;
|
||||||
@@ -1112,8 +1113,8 @@ retry:
|
|||||||
|
|
||||||
static void stb_textedit_flush_redo(StbUndoState *state)
|
static void stb_textedit_flush_redo(StbUndoState *state)
|
||||||
{
|
{
|
||||||
state->redo_point = STB_TEXTEDIT_UNDOSTATECOUNT;
|
state->redo_point = IMSTB_TEXTEDIT_UNDOSTATECOUNT;
|
||||||
state->redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT;
|
state->redo_char_point = IMSTB_TEXTEDIT_UNDOCHARCOUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// discard the oldest entry in the undo list
|
// discard the oldest entry in the undo list
|
||||||
@@ -1125,13 +1126,13 @@ static void stb_textedit_discard_undo(StbUndoState *state)
|
|||||||
int n = state->undo_rec[0].insert_length, i;
|
int n = state->undo_rec[0].insert_length, i;
|
||||||
// delete n characters from all other records
|
// delete n characters from all other records
|
||||||
state->undo_char_point -= n;
|
state->undo_char_point -= n;
|
||||||
STB_TEXTEDIT_memmove(state->undo_char, state->undo_char + n, (size_t) (state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE)));
|
IMSTB_TEXTEDIT_memmove(state->undo_char, state->undo_char + n, (size_t) (state->undo_char_point*sizeof(IMSTB_TEXTEDIT_CHARTYPE)));
|
||||||
for (i=0; i < state->undo_point; ++i)
|
for (i=0; i < state->undo_point; ++i)
|
||||||
if (state->undo_rec[i].char_storage >= 0)
|
if (state->undo_rec[i].char_storage >= 0)
|
||||||
state->undo_rec[i].char_storage -= n; // @OPTIMIZE: get rid of char_storage and infer it
|
state->undo_rec[i].char_storage -= n; // @OPTIMIZE: get rid of char_storage and infer it
|
||||||
}
|
}
|
||||||
--state->undo_point;
|
--state->undo_point;
|
||||||
STB_TEXTEDIT_memmove(state->undo_rec, state->undo_rec+1, (size_t) (state->undo_point*sizeof(state->undo_rec[0])));
|
IMSTB_TEXTEDIT_memmove(state->undo_rec, state->undo_rec+1, (size_t) (state->undo_point*sizeof(state->undo_rec[0])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1141,7 +1142,7 @@ static void stb_textedit_discard_undo(StbUndoState *state)
|
|||||||
// fill up even though the undo buffer didn't
|
// fill up even though the undo buffer didn't
|
||||||
static void stb_textedit_discard_redo(StbUndoState *state)
|
static void stb_textedit_discard_redo(StbUndoState *state)
|
||||||
{
|
{
|
||||||
int k = STB_TEXTEDIT_UNDOSTATECOUNT-1;
|
int k = IMSTB_TEXTEDIT_UNDOSTATECOUNT-1;
|
||||||
|
|
||||||
if (state->redo_point <= k) {
|
if (state->redo_point <= k) {
|
||||||
// if the k'th undo state has characters, clean those up
|
// if the k'th undo state has characters, clean those up
|
||||||
@@ -1149,7 +1150,7 @@ static void stb_textedit_discard_redo(StbUndoState *state)
|
|||||||
int n = state->undo_rec[k].insert_length, i;
|
int n = state->undo_rec[k].insert_length, i;
|
||||||
// move the remaining redo character data to the end of the buffer
|
// move the remaining redo character data to the end of the buffer
|
||||||
state->redo_char_point += n;
|
state->redo_char_point += n;
|
||||||
STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((STB_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE)));
|
IMSTB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((IMSTB_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point)*sizeof(IMSTB_TEXTEDIT_CHARTYPE)));
|
||||||
// adjust the position of all the other records to account for above memmove
|
// adjust the position of all the other records to account for above memmove
|
||||||
for (i=state->redo_point; i < k; ++i)
|
for (i=state->redo_point; i < k; ++i)
|
||||||
if (state->undo_rec[i].char_storage >= 0)
|
if (state->undo_rec[i].char_storage >= 0)
|
||||||
@@ -1157,12 +1158,12 @@ static void stb_textedit_discard_redo(StbUndoState *state)
|
|||||||
}
|
}
|
||||||
// now move all the redo records towards the end of the buffer; the first one is at 'redo_point'
|
// now move all the redo records towards the end of the buffer; the first one is at 'redo_point'
|
||||||
// [DEAR IMGUI]
|
// [DEAR IMGUI]
|
||||||
size_t move_size = (size_t)((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point - 1) * sizeof(state->undo_rec[0]));
|
size_t move_size = (size_t)((IMSTB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point - 1) * sizeof(state->undo_rec[0]));
|
||||||
const char* buf_begin = (char*)state->undo_rec; (void)buf_begin;
|
const char* buf_begin = (char*)state->undo_rec; (void)buf_begin;
|
||||||
const char* buf_end = (char*)state->undo_rec + sizeof(state->undo_rec); (void)buf_end;
|
const char* buf_end = (char*)state->undo_rec + sizeof(state->undo_rec); (void)buf_end;
|
||||||
IM_ASSERT(((char*)(state->undo_rec + state->redo_point)) >= buf_begin);
|
IM_ASSERT(((char*)(state->undo_rec + state->redo_point)) >= buf_begin);
|
||||||
IM_ASSERT(((char*)(state->undo_rec + state->redo_point + 1) + move_size) <= buf_end);
|
IM_ASSERT(((char*)(state->undo_rec + state->redo_point + 1) + move_size) <= buf_end);
|
||||||
STB_TEXTEDIT_memmove(state->undo_rec + state->redo_point+1, state->undo_rec + state->redo_point, move_size);
|
IMSTB_TEXTEDIT_memmove(state->undo_rec + state->redo_point+1, state->undo_rec + state->redo_point, move_size);
|
||||||
|
|
||||||
// now move redo_point to point to the new one
|
// now move redo_point to point to the new one
|
||||||
++state->redo_point;
|
++state->redo_point;
|
||||||
@@ -1176,32 +1177,32 @@ static StbUndoRecord *stb_text_create_undo_record(StbUndoState *state, int numch
|
|||||||
|
|
||||||
// if we have no free records, we have to make room, by sliding the
|
// if we have no free records, we have to make room, by sliding the
|
||||||
// existing records down
|
// existing records down
|
||||||
if (state->undo_point == STB_TEXTEDIT_UNDOSTATECOUNT)
|
if (state->undo_point == IMSTB_TEXTEDIT_UNDOSTATECOUNT)
|
||||||
stb_textedit_discard_undo(state);
|
stb_textedit_discard_undo(state);
|
||||||
|
|
||||||
// if the characters to store won't possibly fit in the buffer, we can't undo
|
// if the characters to store won't possibly fit in the buffer, we can't undo
|
||||||
if (numchars > STB_TEXTEDIT_UNDOCHARCOUNT) {
|
if (numchars > IMSTB_TEXTEDIT_UNDOCHARCOUNT) {
|
||||||
state->undo_point = 0;
|
state->undo_point = 0;
|
||||||
state->undo_char_point = 0;
|
state->undo_char_point = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we don't have enough free characters in the buffer, we have to make room
|
// if we don't have enough free characters in the buffer, we have to make room
|
||||||
while (state->undo_char_point + numchars > STB_TEXTEDIT_UNDOCHARCOUNT)
|
while (state->undo_char_point + numchars > IMSTB_TEXTEDIT_UNDOCHARCOUNT)
|
||||||
stb_textedit_discard_undo(state);
|
stb_textedit_discard_undo(state);
|
||||||
|
|
||||||
return &state->undo_rec[state->undo_point++];
|
return &state->undo_rec[state->undo_point++];
|
||||||
}
|
}
|
||||||
|
|
||||||
static STB_TEXTEDIT_CHARTYPE *stb_text_createundo(StbUndoState *state, int pos, int insert_len, int delete_len)
|
static IMSTB_TEXTEDIT_CHARTYPE *stb_text_createundo(StbUndoState *state, int pos, int insert_len, int delete_len)
|
||||||
{
|
{
|
||||||
StbUndoRecord *r = stb_text_create_undo_record(state, insert_len);
|
StbUndoRecord *r = stb_text_create_undo_record(state, insert_len);
|
||||||
if (r == NULL)
|
if (r == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
r->where = pos;
|
r->where = pos;
|
||||||
r->insert_length = (STB_TEXTEDIT_POSITIONTYPE) insert_len;
|
r->insert_length = (IMSTB_TEXTEDIT_POSITIONTYPE) insert_len;
|
||||||
r->delete_length = (STB_TEXTEDIT_POSITIONTYPE) delete_len;
|
r->delete_length = (IMSTB_TEXTEDIT_POSITIONTYPE) delete_len;
|
||||||
|
|
||||||
if (insert_len == 0) {
|
if (insert_len == 0) {
|
||||||
r->char_storage = -1;
|
r->char_storage = -1;
|
||||||
@@ -1213,7 +1214,7 @@ static STB_TEXTEDIT_CHARTYPE *stb_text_createundo(StbUndoState *state, int pos,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
static void stb_text_undo(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||||
{
|
{
|
||||||
StbUndoState *s = &state->undostate;
|
StbUndoState *s = &state->undostate;
|
||||||
StbUndoRecord u, *r;
|
StbUndoRecord u, *r;
|
||||||
@@ -1240,7 +1241,7 @@ static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
|||||||
// characters stored for *undoing* don't leave room for redo
|
// characters stored for *undoing* don't leave room for redo
|
||||||
// if the last is true, we have to bail
|
// if the last is true, we have to bail
|
||||||
|
|
||||||
if (s->undo_char_point + u.delete_length >= STB_TEXTEDIT_UNDOCHARCOUNT) {
|
if (s->undo_char_point + u.delete_length >= IMSTB_TEXTEDIT_UNDOCHARCOUNT) {
|
||||||
// the undo records take up too much character space; there's no space to store the redo characters
|
// the undo records take up too much character space; there's no space to store the redo characters
|
||||||
r->insert_length = 0;
|
r->insert_length = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -1249,7 +1250,7 @@ static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
|||||||
// there's definitely room to store the characters eventually
|
// there's definitely room to store the characters eventually
|
||||||
while (s->undo_char_point + u.delete_length > s->redo_char_point) {
|
while (s->undo_char_point + u.delete_length > s->redo_char_point) {
|
||||||
// should never happen:
|
// should never happen:
|
||||||
if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT)
|
if (s->redo_point == IMSTB_TEXTEDIT_UNDOSTATECOUNT)
|
||||||
return;
|
return;
|
||||||
// there's currently not enough room, so discard a redo record
|
// there's currently not enough room, so discard a redo record
|
||||||
stb_textedit_discard_redo(s);
|
stb_textedit_discard_redo(s);
|
||||||
@@ -1281,11 +1282,11 @@ static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
|||||||
s->redo_point--;
|
s->redo_point--;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
static void stb_text_redo(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||||
{
|
{
|
||||||
StbUndoState *s = &state->undostate;
|
StbUndoState *s = &state->undostate;
|
||||||
StbUndoRecord *u, r;
|
StbUndoRecord *u, r;
|
||||||
if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT)
|
if (s->redo_point == IMSTB_TEXTEDIT_UNDOSTATECOUNT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// we need to do two things: apply the redo record, and create an undo record
|
// we need to do two things: apply the redo record, and create an undo record
|
||||||
@@ -1337,20 +1338,20 @@ static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int le
|
|||||||
stb_text_createundo(&state->undostate, where, 0, length);
|
stb_text_createundo(&state->undostate, where, 0, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length)
|
static void stb_text_makeundo_delete(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, length, 0);
|
IMSTB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, length, 0);
|
||||||
if (p) {
|
if (p) {
|
||||||
for (i=0; i < length; ++i)
|
for (i=0; i < length; ++i)
|
||||||
p[i] = STB_TEXTEDIT_GETCHAR(str, where+i);
|
p[i] = STB_TEXTEDIT_GETCHAR(str, where+i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length)
|
static void stb_text_makeundo_replace(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, old_length, new_length);
|
IMSTB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, old_length, new_length);
|
||||||
if (p) {
|
if (p) {
|
||||||
for (i=0; i < old_length; ++i)
|
for (i=0; i < old_length; ++i)
|
||||||
p[i] = STB_TEXTEDIT_GETCHAR(str, where+i);
|
p[i] = STB_TEXTEDIT_GETCHAR(str, where+i);
|
||||||
@@ -1362,8 +1363,8 @@ static void stb_textedit_clear_state(STB_TexteditState *state, int is_single_lin
|
|||||||
{
|
{
|
||||||
state->undostate.undo_point = 0;
|
state->undostate.undo_point = 0;
|
||||||
state->undostate.undo_char_point = 0;
|
state->undostate.undo_char_point = 0;
|
||||||
state->undostate.redo_point = STB_TEXTEDIT_UNDOSTATECOUNT;
|
state->undostate.redo_point = IMSTB_TEXTEDIT_UNDOSTATECOUNT;
|
||||||
state->undostate.redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT;
|
state->undostate.redo_char_point = IMSTB_TEXTEDIT_UNDOCHARCOUNT;
|
||||||
state->select_end = state->select_start = 0;
|
state->select_end = state->select_start = 0;
|
||||||
state->cursor = 0;
|
state->cursor = 0;
|
||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
@@ -1386,16 +1387,16 @@ static void stb_textedit_initialize_state(STB_TexteditState *state, int is_singl
|
|||||||
#pragma GCC diagnostic ignored "-Wcast-qual"
|
#pragma GCC diagnostic ignored "-Wcast-qual"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int stb_textedit_paste(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE const *ctext, int len)
|
static int stb_textedit_paste(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, IMSTB_TEXTEDIT_CHARTYPE const *ctext, int len)
|
||||||
{
|
{
|
||||||
return stb_textedit_paste_internal(str, state, (STB_TEXTEDIT_CHARTYPE *) ctext, len);
|
return stb_textedit_paste_internal(str, state, (IMSTB_TEXTEDIT_CHARTYPE *) ctext, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__GNUC__) || defined(__clang__)
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif//STB_TEXTEDIT_IMPLEMENTATION
|
#endif//IMSTB_TEXTEDIT_IMPLEMENTATION
|
||||||
|
|
||||||
/*
|
/*
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -55,4 +55,8 @@ More information at: https://docs.microsoft.com/en-us/visualstudio/debugger/crea
|
|||||||
<DisplayString>{{Name {Name,s} Active {(Active||WasActive)?1:0,d} Child {(Flags & 0x01000000)?1:0,d} Popup {(Flags & 0x04000000)?1:0,d} Hidden {(Hidden)?1:0,d}}</DisplayString>
|
<DisplayString>{{Name {Name,s} Active {(Active||WasActive)?1:0,d} Child {(Flags & 0x01000000)?1:0,d} Popup {(Flags & 0x04000000)?1:0,d} Hidden {(Hidden)?1:0,d}}</DisplayString>
|
||||||
</Type>
|
</Type>
|
||||||
|
|
||||||
|
<Type Name="ImGuiDockNode">
|
||||||
|
<DisplayString>{{ID {ID,x} Pos=({Pos.x,g} {Pos.y,g}) Size=({Size.x,g} {Size.y,g}) Parent {(ParentNode==0)?0:ParentNode->ID,x} Childs {(ChildNodes[0] != 0)+(ChildNodes[1] != 0)} Windows {Windows.Size} }</DisplayString>
|
||||||
|
</Type>
|
||||||
|
|
||||||
</AutoVisualizer>
|
</AutoVisualizer>
|
||||||
|
|||||||
@@ -437,7 +437,7 @@ bool ImFontAtlasBuildWithFreeTypeEx(FT_Library ft_library, ImFontAtlas* atlas, u
|
|||||||
ImFontAtlasBuildInit(atlas);
|
ImFontAtlasBuildInit(atlas);
|
||||||
|
|
||||||
// Clear atlas
|
// Clear atlas
|
||||||
atlas->TexID = (ImTextureID)nullptr;
|
atlas->TexID = 0;
|
||||||
atlas->TexWidth = atlas->TexHeight = 0;
|
atlas->TexWidth = atlas->TexHeight = 0;
|
||||||
atlas->TexUvScale = ImVec2(0.0f, 0.0f);
|
atlas->TexUvScale = ImVec2(0.0f, 0.0f);
|
||||||
atlas->TexUvWhitePixel = ImVec2(0.0f, 0.0f);
|
atlas->TexUvWhitePixel = ImVec2(0.0f, 0.0f);
|
||||||
|
|||||||
@@ -43,9 +43,8 @@ namespace ImGuiFreeType
|
|||||||
IMGUI_API void SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data = nullptr);
|
IMGUI_API void SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data = nullptr);
|
||||||
|
|
||||||
// Obsolete names (will be removed soon)
|
// Obsolete names (will be removed soon)
|
||||||
// Prefer using '#define IMGUI_ENABLE_FREETYPE'
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
static inline bool BuildFontAtlas(ImFontAtlas* atlas, unsigned int flags = 0) { atlas->FontBuilderIO = GetBuilderForFreeType(); atlas->FontBuilderFlags = flags; return atlas->Build(); }
|
//static inline bool BuildFontAtlas(ImFontAtlas* atlas, unsigned int flags = 0) { atlas->FontBuilderIO = GetBuilderForFreeType(); atlas->FontBuilderFlags = flags; return atlas->Build(); } // Prefer using '#define IMGUI_ENABLE_FREETYPE'
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user