Jelajahi Sumber

re-org mods

woelper 4 tahun lalu
induk
melakukan
39c5cc0cb7
8 mengubah file dengan 287 tambahan dan 469 penghapusan
  1. 36 380
      Cargo.lock
  2. 10 8
      Cargo.toml
  3. 20 0
      sampler.ini
  4. 15 12
      src/main.rs
  5. 135 0
      src/support_glium/mod.rs
  6. 0 0
      src/support_ogl/IBMPlexSans-Regular.ttf
  7. 71 69
      src/support/mod.rs
  8. 0 0
      src/support_ogl/mplus-1p-regular.ttf

+ 36 - 380
Cargo.lock

@@ -8,9 +8,9 @@ checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2"
 
 [[package]]
 name = "aho-corasick"
-version = "0.7.8"
+version = "0.7.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "743ad5a418686aad3b87fd14c43badd828cf26e214a00f92a384291cf22e1811"
+checksum = "d5e63fd144e18ba274ae7095c0197a870a7b9468abc801dd62f190d80817d2ec"
 dependencies = [
  "memchr",
 ]
@@ -68,7 +68,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
 dependencies = [
  "hermit-abi",
  "libc",
- "winapi 0.3.8",
+ "winapi",
 ]
 
 [[package]]
@@ -142,17 +142,6 @@ version = "1.3.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
 
-[[package]]
-name = "calloop"
-version = "0.4.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7aa2097be53a00de9e8fc349fea6d76221f398f5c4fa550d420669906962d160"
-dependencies = [
- "mio",
- "mio-extras",
- "nix",
-]
-
 [[package]]
 name = "cc"
 version = "1.0.50"
@@ -184,15 +173,6 @@ dependencies = [
  "libc",
 ]
 
-[[package]]
-name = "cgl"
-version = "0.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff"
-dependencies = [
- "libc",
-]
-
 [[package]]
 name = "clang-sys"
 version = "0.28.1"
@@ -234,21 +214,6 @@ dependencies = [
  "objc",
 ]
 
-[[package]]
-name = "cocoa"
-version = "0.19.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f29f7768b2d1be17b96158e3285951d366b40211320fb30826a76cb7a0da6400"
-dependencies = [
- "bitflags",
- "block",
- "core-foundation",
- "core-graphics",
- "foreign-types",
- "libc",
- "objc",
-]
-
 [[package]]
 name = "color_quant"
 version = "1.0.1"
@@ -283,19 +248,6 @@ dependencies = [
  "libc",
 ]
 
-[[package]]
-name = "core-video-sys"
-version = "0.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8dc065219542086f72d1e9f7aadbbab0989e980263695d129d502082d063a9d0"
-dependencies = [
- "cfg-if",
- "core-foundation-sys",
- "core-graphics",
- "libc",
- "objc",
-]
-
 [[package]]
 name = "coreaudio-rs"
 version = "0.9.1"
@@ -329,7 +281,7 @@ dependencies = [
  "libc",
  "num-traits",
  "stdweb",
- "winapi 0.3.8",
+ "winapi",
 ]
 
 [[package]]
@@ -398,12 +350,6 @@ dependencies = [
  "byteorder",
 ]
 
-[[package]]
-name = "dispatch"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"
-
 [[package]]
 name = "dlib"
 version = "0.4.1"
@@ -469,12 +415,6 @@ dependencies = [
  "synstructure",
 ]
 
-[[package]]
-name = "fnv"
-version = "1.0.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
-
 [[package]]
 name = "foreign-types"
 version = "0.3.2"
@@ -490,22 +430,6 @@ version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
 
-[[package]]
-name = "fuchsia-zircon"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
-dependencies = [
- "bitflags",
- "fuchsia-zircon-sys",
-]
-
-[[package]]
-name = "fuchsia-zircon-sys"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
-
 [[package]]
 name = "gfx"
 version = "0.18.2"
@@ -556,7 +480,7 @@ checksum = "310ff66f08b5a55854b18fea2f48bdbb75c94458207ba574c9723be78e97a646"
 dependencies = [
  "gfx_core",
  "gfx_device_gl",
- "glutin 0.21.2",
+ "glutin",
 ]
 
 [[package]]
@@ -600,22 +524,6 @@ dependencies = [
  "gl_generator 0.13.1",
 ]
 
-[[package]]
-name = "glium"
-version = "0.26.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a46e88b2c64cfa63d54ed54dc2a0d25136470eb1721e10be49d857ab583f8663"
-dependencies = [
- "backtrace",
- "fnv",
- "gl_generator 0.14.0",
- "glutin 0.23.0",
- "lazy_static",
- "memoffset",
- "smallvec 1.2.0",
- "takeable-option",
-]
-
 [[package]]
 name = "glob"
 version = "0.3.0"
@@ -629,8 +537,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "5371b35b309dace06be1b81b5f6adb1c9de578b7dbe1e74bf7e4ef762cf6febd"
 dependencies = [
  "android_glue",
- "cgl 0.2.3",
- "cocoa 0.18.5",
+ "cgl",
+ "cocoa",
  "core-foundation",
  "core-graphics",
  "glutin_egl_sys",
@@ -643,36 +551,9 @@ dependencies = [
  "objc",
  "osmesa-sys",
  "parking_lot 0.9.0",
- "wayland-client 0.21.13",
- "winapi 0.3.8",
- "winit 0.19.5",
-]
-
-[[package]]
-name = "glutin"
-version = "0.23.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cf22d4e90c55d9be9f2ad52410e7a2c0d7e9c99d93a13df73a672e7ef4e8c7f7"
-dependencies = [
- "android_glue",
- "cgl 0.3.2",
- "cocoa 0.19.1",
- "core-foundation",
- "core-graphics",
- "glutin_egl_sys",
- "glutin_emscripten_sys",
- "glutin_gles2_sys",
- "glutin_glx_sys",
- "glutin_wgl_sys",
- "lazy_static",
- "libloading",
- "log",
- "objc",
- "osmesa-sys",
- "parking_lot 0.10.0",
- "wayland-client 0.23.6",
- "winapi 0.3.8",
- "winit 0.21.0",
+ "wayland-client",
+ "winapi",
+ "winit",
 ]
 
 [[package]]
@@ -682,7 +563,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "772edef3b28b8ad41e4ea202748e65eefe8e5ffd1f4535f1219793dbb20b3d4c"
 dependencies = [
  "gl_generator 0.13.1",
- "winapi 0.3.8",
+ "winapi",
 ]
 
 [[package]]
@@ -783,7 +664,7 @@ checksum = "506eae7244a06bc18273634d1c30e070bdf592f5e7fb1f6871d062ad17a4b2ec"
 dependencies = [
  "gfx",
  "imgui",
- "winapi 0.3.8",
+ "winapi",
 ]
 
 [[package]]
@@ -802,7 +683,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a90f2e2a24b82dbd7aa9eb20825cd6421af5d40643d329d8e7bb1ae37a962ffe"
 dependencies = [
  "imgui",
- "winit 0.19.5",
+ "winit",
 ]
 
 [[package]]
@@ -814,21 +695,6 @@ dependencies = [
  "adler32",
 ]
 
-[[package]]
-name = "instant"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6c346c299e3fe8ef94dc10c2c0253d858a69aac1245157a3bf4125915d528caf"
-
-[[package]]
-name = "iovec"
-version = "0.1.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
-dependencies = [
- "libc",
-]
-
 [[package]]
 name = "jpeg-decoder"
 version = "0.1.18"
@@ -839,16 +705,6 @@ dependencies = [
  "rayon",
 ]
 
-[[package]]
-name = "kernel32-sys"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
-dependencies = [
- "winapi 0.2.8",
- "winapi-build",
-]
-
 [[package]]
 name = "khronos_api"
 version = "3.1.0"
@@ -861,12 +717,6 @@ version = "1.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
 
-[[package]]
-name = "lazycell"
-version = "1.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
-
 [[package]]
 name = "lewton"
 version = "0.9.4"
@@ -891,7 +741,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753"
 dependencies = [
  "cc",
- "winapi 0.3.8",
+ "winapi",
 ]
 
 [[package]]
@@ -964,7 +814,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
 dependencies = [
  "libc",
- "winapi 0.3.8",
+ "winapi",
 ]
 
 [[package]]
@@ -1004,60 +854,6 @@ dependencies = [
  "adler32",
 ]
 
-[[package]]
-name = "mio"
-version = "0.6.21"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f"
-dependencies = [
- "cfg-if",
- "fuchsia-zircon",
- "fuchsia-zircon-sys",
- "iovec",
- "kernel32-sys",
- "libc",
- "log",
- "miow",
- "net2",
- "slab",
- "winapi 0.2.8",
-]
-
-[[package]]
-name = "mio-extras"
-version = "2.0.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19"
-dependencies = [
- "lazycell",
- "log",
- "mio",
- "slab",
-]
-
-[[package]]
-name = "miow"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
-dependencies = [
- "kernel32-sys",
- "net2",
- "winapi 0.2.8",
- "ws2_32-sys",
-]
-
-[[package]]
-name = "net2"
-version = "0.2.33"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
-dependencies = [
- "cfg-if",
- "libc",
- "winapi 0.3.8",
-]
-
 [[package]]
 name = "nix"
 version = "0.14.1"
@@ -1201,7 +997,7 @@ dependencies = [
  "redox_syscall",
  "rustc_version",
  "smallvec 0.6.13",
- "winapi 0.3.8",
+ "winapi",
 ]
 
 [[package]]
@@ -1215,7 +1011,7 @@ dependencies = [
  "libc",
  "redox_syscall",
  "smallvec 1.2.0",
- "winapi 0.3.8",
+ "winapi",
 ]
 
 [[package]]
@@ -1420,8 +1216,7 @@ dependencies = [
  "gfx",
  "gfx_device_gl",
  "gfx_window_glutin",
- "glium",
- "glutin 0.21.2",
+ "glutin",
  "image",
  "imgui",
  "imgui-gfx-renderer",
@@ -1474,12 +1269,6 @@ version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
 
-[[package]]
-name = "slab"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
-
 [[package]]
 name = "slice-deque"
 version = "0.3.0"
@@ -1488,7 +1277,7 @@ checksum = "31ef6ee280cdefba6d2d0b4b78a84a1c1a3f3a4cec98c2d4231c8bc225de0f25"
 dependencies = [
  "libc",
  "mach",
- "winapi 0.3.8",
+ "winapi",
 ]
 
 [[package]]
@@ -1518,25 +1307,9 @@ dependencies = [
  "lazy_static",
  "memmap",
  "nix",
- "wayland-client 0.21.13",
- "wayland-commons 0.21.13",
- "wayland-protocols 0.21.13",
-]
-
-[[package]]
-name = "smithay-client-toolkit"
-version = "0.6.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "421c8dc7acf5cb205b88160f8b4cc2c5cfabe210e43b2f80f009f4c1ef910f1d"
-dependencies = [
- "andrew",
- "bitflags",
- "dlib",
- "lazy_static",
- "memmap",
- "nix",
- "wayland-client 0.23.6",
- "wayland-protocols 0.23.6",
+ "wayland-client",
+ "wayland-commons",
+ "wayland-protocols",
 ]
 
 [[package]]
@@ -1577,12 +1350,6 @@ dependencies = [
  "unicode-xid 0.2.0",
 ]
 
-[[package]]
-name = "takeable-option"
-version = "0.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "36ae8932fcfea38b7d3883ae2ab357b0d57a02caaa18ebb4f5ece08beaec4aa0"
-
 [[package]]
 name = "termcolor"
 version = "1.1.0"
@@ -1643,7 +1410,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"
 dependencies = [
  "same-file",
- "winapi 0.3.8",
+ "winapi",
  "winapi-util",
 ]
 
@@ -1657,26 +1424,9 @@ dependencies = [
  "downcast-rs",
  "libc",
  "nix",
- "wayland-commons 0.21.13",
- "wayland-scanner 0.21.13",
- "wayland-sys 0.21.13",
-]
-
-[[package]]
-name = "wayland-client"
-version = "0.23.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "af1080ebe0efabcf12aef2132152f616038f2d7dcbbccf7b2d8c5270fe14bcda"
-dependencies = [
- "bitflags",
- "calloop",
- "downcast-rs",
- "libc",
- "mio",
- "nix",
- "wayland-commons 0.23.6",
- "wayland-scanner 0.23.6",
- "wayland-sys 0.23.6",
+ "wayland-commons",
+ "wayland-scanner",
+ "wayland-sys",
 ]
 
 [[package]]
@@ -1686,17 +1436,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "40c08896768b667e1df195d88a62a53a2d1351a1ed96188be79c196b35bb32ec"
 dependencies = [
  "nix",
- "wayland-sys 0.21.13",
-]
-
-[[package]]
-name = "wayland-commons"
-version = "0.23.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bb66b0d1a27c39bbce712b6372131c6e25149f03ffb0cd017cf8f7de8d66dbdb"
-dependencies = [
- "nix",
- "wayland-sys 0.23.6",
+ "wayland-sys",
 ]
 
 [[package]]
@@ -1706,22 +1446,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "4afde2ea2a428eee6d7d2c8584fdbe8b82eee8b6c353e129a434cd6e07f42145"
 dependencies = [
  "bitflags",
- "wayland-client 0.21.13",
- "wayland-commons 0.21.13",
- "wayland-scanner 0.21.13",
- "wayland-sys 0.21.13",
-]
-
-[[package]]
-name = "wayland-protocols"
-version = "0.23.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6cc286643656742777d55dc8e70d144fa4699e426ca8e9d4ef454f4bf15ffcf9"
-dependencies = [
- "bitflags",
- "wayland-client 0.23.6",
- "wayland-commons 0.23.6",
- "wayland-scanner 0.23.6",
+ "wayland-client",
+ "wayland-commons",
+ "wayland-scanner",
+ "wayland-sys",
 ]
 
 [[package]]
@@ -1735,17 +1463,6 @@ dependencies = [
  "xml-rs",
 ]
 
-[[package]]
-name = "wayland-scanner"
-version = "0.23.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "93b02247366f395b9258054f964fe293ddd019c3237afba9be2ccbe9e1651c3d"
-dependencies = [
- "proc-macro2 0.4.30",
- "quote 0.6.13",
- "xml-rs",
-]
-
 [[package]]
 name = "wayland-sys"
 version = "0.21.13"
@@ -1756,22 +1473,6 @@ dependencies = [
  "lazy_static",
 ]
 
-[[package]]
-name = "wayland-sys"
-version = "0.23.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d94e89a86e6d6d7c7c9b19ebf48a03afaac4af6bc22ae570e9a24124b75358f4"
-dependencies = [
- "dlib",
- "lazy_static",
-]
-
-[[package]]
-name = "winapi"
-version = "0.2.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
-
 [[package]]
 name = "winapi"
 version = "0.3.8"
@@ -1782,12 +1483,6 @@ dependencies = [
  "winapi-x86_64-pc-windows-gnu",
 ]
 
-[[package]]
-name = "winapi-build"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
-
 [[package]]
 name = "winapi-i686-pc-windows-gnu"
 version = "0.4.0"
@@ -1800,7 +1495,7 @@ version = "0.1.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80"
 dependencies = [
- "winapi 0.3.8",
+ "winapi",
 ]
 
 [[package]]
@@ -1818,7 +1513,7 @@ dependencies = [
  "android_glue",
  "backtrace",
  "bitflags",
- "cocoa 0.18.5",
+ "cocoa",
  "core-foundation",
  "core-graphics",
  "lazy_static",
@@ -1828,51 +1523,12 @@ dependencies = [
  "parking_lot 0.9.0",
  "percent-encoding",
  "raw-window-handle",
- "smithay-client-toolkit 0.4.6",
- "wayland-client 0.21.13",
- "winapi 0.3.8",
- "x11-dl",
-]
-
-[[package]]
-name = "winit"
-version = "0.21.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "65a5c1a5ef76ac31cc97ad29489acdbed2178f3fc12ca00ee6cb11d60adb5a3a"
-dependencies = [
- "android_glue",
- "bitflags",
- "cocoa 0.19.1",
- "core-foundation",
- "core-graphics",
- "core-video-sys",
- "dispatch",
- "instant",
- "lazy_static",
- "libc",
- "log",
- "mio",
- "mio-extras",
- "objc",
- "parking_lot 0.10.0",
- "percent-encoding",
- "raw-window-handle",
- "smithay-client-toolkit 0.6.6",
- "wayland-client 0.23.6",
- "winapi 0.3.8",
+ "smithay-client-toolkit",
+ "wayland-client",
+ "winapi",
  "x11-dl",
 ]
 
-[[package]]
-name = "ws2_32-sys"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
-dependencies = [
- "winapi 0.2.8",
- "winapi-build",
-]
-
 [[package]]
 name = "x11-dl"
 version = "2.18.5"

+ 10 - 8
Cargo.toml

@@ -7,22 +7,24 @@ edition = "2018"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 
-[features]
-opengl = ["imgui-gfx-renderer/opengl"]
-directx = ["imgui-gfx-renderer/directx"]
-default = ["opengl"]
-
 [dependencies]
 rodio = "*"
-glium = { version = "0.26", default-features = true }
-image = "0.23"
 imgui = "*"
 log = "*"
 env_logger = "*"
 walkdir = "*"
+image = "0.23"
+
+# GFX / OPENGL
 gfx = "0.18"
 gfx_device_gl = "0.16"
 gfx_window_glutin = "0.31"
 glutin = "0.21"
+imgui-winit-support = { default-features = false, features = ["winit-19"] }
 imgui-gfx-renderer = "*"
-imgui-winit-support = { default-features = false, features = ["winit-19"] }
+
+
+# GLIUM - DISABLE UNTIL THIS WORKS WITH RODIO
+# glium = { version = "0.26", default-features = true }
+# imgui-glium-renderer = "*"
+# imgui-winit-support = "*"

+ 20 - 0
sampler.ini

@@ -0,0 +1,20 @@
+[Window][Debug##Default]
+Pos=60,60
+Size=400,400
+Collapsed=0
+
+[Window][Hello world]
+Pos=41,122
+Size=300,100
+Collapsed=0
+
+[Window][sources]
+Pos=372,27
+Size=339,460
+Collapsed=0
+
+[Window][ImGui Demo]
+Pos=297,1
+Size=550,680
+Collapsed=0
+

+ 15 - 12
src/main.rs

@@ -1,14 +1,14 @@
-use std::io::BufReader;
-use std::path::PathBuf;
-use std::thread;
-use std::time::Duration;
+// use std::io::BufReader;
+// use std::path::PathBuf;
+// use std::thread;
+// use std::time::Duration;
 extern crate rodio;
 mod base;
 use base::*;
-// use rodio::Source;
 use imgui::*;
 use walkdir::WalkDir;
-mod support;
+mod support_ogl;
+// mod support_glium;
 use env_logger;
 use log::*;
 
@@ -33,9 +33,10 @@ fn main() {
     bar.bpm = 160;
     bar.repeat = 2;
 
-    let system = support::init(file!());
+    let system = support_ogl::init(file!());
+    // let system = support_glium::init(file!());
 
-    system.main_loop(|_, ui| {
+    system.main_loop(move |_, ui| {
         Window::new(im_str!("sources"))
             // .resizable(false)
             .position([400.0, 140.0], Condition::Appearing)
@@ -46,6 +47,8 @@ fn main() {
                 // let mut s = ui.clone_style();
                 // ui.show_style_editor(&mut s);
 
+                ui.show_default_style_editor();
+
                 ui.tree_node(im_str!("Tree")).build(|| {
                     for s in &sounds {
                         ui.tree_node(&im_str!("{}", s.name)).build(|| {
@@ -66,10 +69,10 @@ fn main() {
             .build(ui, || {
                 ui.text(im_str!("bars"));
 
-                for i in 0..bar.length {
-                    ui.same_line(0.0);
-                    ui.small_button(&im_str!("{}", i));
-                }
+                // for i in 0..bar.length {
+                //     ui.same_line(0.0);
+                //     ui.small_button(&im_str!("{}", i));
+                // }
             });
     });
 }

+ 135 - 0
src/support_glium/mod.rs

@@ -0,0 +1,135 @@
+use glium::glutin;
+use glium::glutin::event::{Event, WindowEvent};
+use glium::glutin::event_loop::{ControlFlow, EventLoop};
+use glium::glutin::window::WindowBuilder;
+use glium::{Display, Surface};
+use imgui::{Context, FontConfig, FontGlyphRanges, FontSource, Ui};
+use imgui_glium_renderer::Renderer;
+use imgui_winit_support::{HiDpiMode, WinitPlatform};
+use std::time::Instant;
+
+// mod clipboard;
+
+pub struct System {
+    pub event_loop: EventLoop<()>,
+    pub display: glium::Display,
+    pub imgui: Context,
+    pub platform: WinitPlatform,
+    pub renderer: Renderer,
+    pub font_size: f32,
+}
+
+pub fn init(title: &str) -> System {
+    let title = match title.rfind('/') {
+        Some(idx) => title.split_at(idx + 1).1,
+        None => title,
+    };
+    let event_loop = EventLoop::new();
+    let context = glutin::ContextBuilder::new().with_vsync(true);
+    let builder = WindowBuilder::new()
+        .with_title(title.to_owned())
+        .with_inner_size(glutin::dpi::LogicalSize::new(1024f64, 768f64));
+    let display =
+        Display::new(builder, context, &event_loop).expect("Failed to initialize display");
+
+    let mut imgui = Context::create();
+    imgui.set_ini_filename(None);
+
+    // if let Some(backend) = clipboard::init() {
+    //     imgui.set_clipboard_backend(Box::new(backend));
+    // } else {
+    //     eprintln!("Failed to initialize clipboard");
+    // }
+
+    let mut platform = WinitPlatform::init(&mut imgui);
+    {
+        let gl_window = display.gl_window();
+        let window = gl_window.window();
+        platform.attach_window(imgui.io_mut(), &window, HiDpiMode::Rounded);
+    }
+
+    let hidpi_factor = platform.hidpi_factor();
+    let font_size = (13.0 * hidpi_factor) as f32;
+    imgui.fonts().add_font(&[
+        FontSource::DefaultFontData {
+            config: Some(FontConfig {
+                size_pixels: font_size,
+                ..FontConfig::default()
+            }),
+        },
+        FontSource::TtfData {
+            data: include_bytes!("../support/mplus-1p-regular.ttf"),
+            size_pixels: font_size,
+            config: Some(FontConfig {
+                rasterizer_multiply: 1.75,
+                glyph_ranges: FontGlyphRanges::japanese(),
+                ..FontConfig::default()
+            }),
+        },
+    ]);
+
+    imgui.io_mut().font_global_scale = (1.0 / hidpi_factor) as f32;
+
+    let renderer = Renderer::init(&mut imgui, &display).expect("Failed to initialize renderer");
+
+    System {
+        event_loop,
+        display,
+        imgui,
+        platform,
+        renderer,
+        font_size,
+    }
+}
+
+impl System {
+    pub fn main_loop<F: FnMut(&mut bool, &mut Ui) + 'static>(self, mut run_ui: F) {
+        let System {
+            event_loop,
+            display,
+            mut imgui,
+            mut platform,
+            mut renderer,
+            ..
+        } = self;
+        let mut last_frame = Instant::now();
+
+        event_loop.run(move |event, _, control_flow| match event {
+            Event::NewEvents(_) => last_frame = imgui.io_mut().update_delta_time(last_frame),
+            Event::MainEventsCleared => {
+                let gl_window = display.gl_window();
+                platform
+                    .prepare_frame(imgui.io_mut(), &gl_window.window())
+                    .expect("Failed to prepare frame");
+                gl_window.window().request_redraw();
+            }
+            Event::RedrawRequested(_) => {
+                let mut ui = imgui.frame();
+
+                let mut run = true;
+                run_ui(&mut run, &mut ui);
+                if !run {
+                    *control_flow = ControlFlow::Exit;
+                }
+
+                let gl_window = display.gl_window();
+                let mut target = display.draw();
+                target.clear_color_srgb(1.0, 1.0, 1.0, 1.0);
+                platform.prepare_render(&ui, gl_window.window());
+                let draw_data = ui.render();
+                renderer
+                    .render(&mut target, draw_data)
+                    .expect("Rendering failed");
+                target.finish().expect("Failed to swap buffers");
+            }
+            Event::WindowEvent {
+                event: WindowEvent::CloseRequested,
+                ..
+            } => *control_flow = ControlFlow::Exit,
+            event => {
+                let gl_window = display.gl_window();
+                platform.handle_event(imgui.io_mut(), gl_window.window(), &event);
+            }
+        })
+    }
+}

src/support/IBMPlexSans-Regular.ttf → src/support_ogl/IBMPlexSans-Regular.ttf


+ 71 - 69
src/support/mod.rs

@@ -4,6 +4,7 @@ use imgui::{Context, FontConfig, FontGlyphRanges, FontSource, Ui};
 use imgui_gfx_renderer::{Renderer, Shaders};
 use imgui_winit_support::{HiDpiMode, WinitPlatform};
 use std::time::Instant;
+use std::path::PathBuf;
 
 type ColorFormat = gfx::format::Rgba8;
 
@@ -26,32 +27,33 @@ pub fn init(title: &str) -> System {
         .with_dimensions(glutin::dpi::LogicalSize::new(1024f64, 768f64));
 
     let mut imgui = Context::create();
-    imgui.set_ini_filename(None);
+    imgui.set_ini_filename(Some(PathBuf::from("sampler.ini")));
 
     let mut platform = WinitPlatform::init(&mut imgui);
 
     let hidpi_factor = platform.hidpi_factor();
     let font_size = (13.0 * hidpi_factor) as f32;
     imgui.fonts().add_font(&[
-        FontSource::DefaultFontData {
-            config: Some(FontConfig {
-                size_pixels: font_size,
-                ..FontConfig::default()
-            }),
-        },
         FontSource::TtfData {
             data: include_bytes!("IBMPlexSans-Regular.ttf"),
             // data: include_bytes!("mplus-1p-regular.ttf"),
             size_pixels: font_size,
             config: Some(FontConfig {
-                rasterizer_multiply: 1.75,
-                glyph_ranges: FontGlyphRanges::japanese(),
+                glyph_offset: [0.0, -1.5],
+                name: Some("IBM Plex".to_string()),
+                // glyph_ranges: FontGlyphRanges::japanese(),
+                ..FontConfig::default()
+            }),
+        },
+        FontSource::DefaultFontData {
+            config: Some(FontConfig {
+                size_pixels: font_size,
                 ..FontConfig::default()
             }),
         },
     ]);
 
-    imgui.io_mut().font_global_scale = (1.0 / hidpi_factor) as f32;
+    imgui.io_mut().font_global_scale = (0.9 / hidpi_factor) as f32;
 
     let render_sys = RenderSystem::init(&mut imgui, builder, &events_loop);
     platform.attach_window(imgui.io_mut(), render_sys.window(), HiDpiMode::Rounded);
@@ -100,7 +102,7 @@ impl System {
             run_ui(&mut run, &mut ui);
 
             if let Some(main_color) = render_sys.main_color.as_mut() {
-                encoder.clear(main_color, [1.0, 1.0, 1.0, 1.0]);
+                encoder.clear(main_color, [0.01, 0.01, 0.01, 1.0]);
             }
             platform.prepare_render(&ui, render_sys.window());
             let draw_data = ui.render();
@@ -117,14 +119,14 @@ impl System {
     }
 }
 
-#[cfg(feature = "opengl")]
+// #[cfg(feature = "opengl")]
 mod types {
     pub type Device = gfx_device_gl::Device;
     pub type Factory = gfx_device_gl::Factory;
     pub type Resources = gfx_device_gl::Resources;
 }
 
-#[cfg(feature = "opengl")]
+// #[cfg(feature = "opengl")]
 pub struct RenderSystem {
     pub renderer: Renderer<ColorFormat, types::Resources>,
     pub windowed_context: glutin::WindowedContext<glutin::PossiblyCurrent>,
@@ -134,7 +136,7 @@ pub struct RenderSystem {
     pub main_depth: gfx::handle::DepthStencilView<types::Resources, gfx::format::DepthStencil>,
 }
 
-#[cfg(feature = "opengl")]
+// #[cfg(feature = "opengl")]
 impl RenderSystem {
     pub fn init(
         imgui: &mut Context,
@@ -209,60 +211,60 @@ impl RenderSystem {
     }
 }
 
-#[cfg(feature = "directx")]
-mod types {
-    pub type Device = gfx_device_dx11::Device;
-    pub type Factory = gfx_device_dx11::Factory;
-    pub type Resources = gfx_device_dx11::Resources;
-}
+// #[cfg(feature = "directx")]
+// mod types {
+//     pub type Device = gfx_device_dx11::Device;
+//     pub type Factory = gfx_device_dx11::Factory;
+//     pub type Resources = gfx_device_dx11::Resources;
+// }
 
-#[cfg(feature = "directx")]
-pub struct RenderSystem {
-    pub renderer: Renderer<ColorFormat, types::Resources>,
-    pub window: gfx_window_dxgi::Window,
-    pub device: types::Device,
-    pub factory: types::Factory,
-    pub main_color: Option<gfx::handle::RenderTargetView<types::Resources, ColorFormat>>,
-}
+// #[cfg(feature = "directx")]
+// pub struct RenderSystem {
+//     pub renderer: Renderer<ColorFormat, types::Resources>,
+//     pub window: gfx_window_dxgi::Window,
+//     pub device: types::Device,
+//     pub factory: types::Factory,
+//     pub main_color: Option<gfx::handle::RenderTargetView<types::Resources, ColorFormat>>,
+// }
 
-#[cfg(feature = "directx")]
-impl RenderSystem {
-    pub fn init(
-        imgui: &mut Context,
-        builder: glutin::WindowBuilder,
-        events_loop: &glutin::EventsLoop,
-    ) -> RenderSystem {
-        let (window, device, mut factory, main_color) =
-            gfx_window_dxgi::init(builder, &events_loop).expect("Failed to initialize graphics");
-        let renderer = Renderer::init(imgui, &mut factory, Shaders::HlslSm40)
-            .expect("Failed to initialize renderer");
-        RenderSystem {
-            renderer,
-            window,
-            device,
-            factory,
-            main_color: Some(main_color),
-        }
-    }
-    pub fn window(&self) -> &glutin::Window {
-        &self.window.inner
-    }
-    pub fn update_views(&mut self, size: glutin::dpi::LogicalSize) {
-        let physical = size.to_physical(self.window().get_hidpi_factor());
-        let (width, height): (u32, u32) = physical.into();
-        let _ = self.main_color.take(); // we need to drop main_color before calling update_views
-        self.main_color = Some(
-            gfx_window_dxgi::update_views(
-                &mut self.window,
-                &mut self.factory,
-                &mut self.device,
-                width as u16,
-                height as u16,
-            )
-            .expect("Failed to update resize"),
-        );
-    }
-    pub fn swap_buffers(&mut self) {
-        self.window.swap_buffers(1);
-    }
-}
+// #[cfg(feature = "directx")]
+// impl RenderSystem {
+//     pub fn init(
+//         imgui: &mut Context,
+//         builder: glutin::WindowBuilder,
+//         events_loop: &glutin::EventsLoop,
+//     ) -> RenderSystem {
+//         let (window, device, mut factory, main_color) =
+//             gfx_window_dxgi::init(builder, &events_loop).expect("Failed to initialize graphics");
+//         let renderer = Renderer::init(imgui, &mut factory, Shaders::HlslSm40)
+//             .expect("Failed to initialize renderer");
+//         RenderSystem {
+//             renderer,
+//             window,
+//             device,
+//             factory,
+//             main_color: Some(main_color),
+//         }
+//     }
+//     pub fn window(&self) -> &glutin::Window {
+//         &self.window.inner
+//     }
+//     pub fn update_views(&mut self, size: glutin::dpi::LogicalSize) {
+//         let physical = size.to_physical(self.window().get_hidpi_factor());
+//         let (width, height): (u32, u32) = physical.into();
+//         let _ = self.main_color.take(); // we need to drop main_color before calling update_views
+//         self.main_color = Some(
+//             gfx_window_dxgi::update_views(
+//                 &mut self.window,
+//                 &mut self.factory,
+//                 &mut self.device,
+//                 width as u16,
+//                 height as u16,
+//             )
+//             .expect("Failed to update resize"),
+//         );
+//     }
+//     pub fn swap_buffers(&mut self) {
+//         self.window.swap_buffers(1);
+//     }
+// }

src/support/mplus-1p-regular.ttf → src/support_ogl/mplus-1p-regular.ttf