summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty')
-rw-r--r--3rdparty/benchmark/.travis.yml2
-rw-r--r--3rdparty/benchmark/AUTHORS1
-rw-r--r--3rdparty/benchmark/CMakeLists.txt26
-rw-r--r--3rdparty/benchmark/CONTRIBUTORS3
-rw-r--r--3rdparty/benchmark/README.md134
-rw-r--r--3rdparty/benchmark/cmake/posix_regex.cpp4
-rw-r--r--3rdparty/benchmark/include/benchmark/benchmark_api.h40
-rw-r--r--3rdparty/benchmark/include/benchmark/reporter.h10
-rw-r--r--3rdparty/benchmark/src/benchmark.cc93
-rw-r--r--3rdparty/benchmark/src/console_reporter.cc42
-rw-r--r--3rdparty/benchmark/src/csv_reporter.cc9
-rw-r--r--3rdparty/benchmark/src/json_reporter.cc11
-rw-r--r--3rdparty/benchmark/src/reporter.cc12
-rw-r--r--3rdparty/benchmark/test/benchmark_test.cc28
-rw-r--r--3rdparty/benchmark/test/options_test.cc16
-rw-r--r--3rdparty/bgfx/.editorconfig3
-rw-r--r--3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp724
-rw-r--r--3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h53
-rw-r--r--3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_demo.cpp187
-rw-r--r--3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_draw.cpp22
-rw-r--r--3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_internal.h48
-rw-r--r--3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_wm.cpp25
-rw-r--r--3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_wm.h4
-rw-r--r--3rdparty/bgfx/README.md1
-rw-r--r--3rdparty/bgfx/examples/00-helloworld/helloworld.cpp6
-rw-r--r--3rdparty/bgfx/examples/01-cubes/cubes.cpp2
-rw-r--r--3rdparty/bgfx/examples/02-metaballs/metaballs.cpp4
-rw-r--r--3rdparty/bgfx/examples/03-raymarch/raymarch.cpp6
-rw-r--r--3rdparty/bgfx/examples/04-mesh/mesh.cpp4
-rw-r--r--3rdparty/bgfx/examples/05-instancing/instancing.cpp4
-rw-r--r--3rdparty/bgfx/examples/06-bump/bump.cpp4
-rw-r--r--3rdparty/bgfx/examples/08-update/update.cpp6
-rw-r--r--3rdparty/bgfx/examples/10-font/font.cpp2
-rw-r--r--3rdparty/bgfx/examples/16-shadowmaps/shadowmaps.cpp17
-rw-r--r--3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp3
-rw-r--r--3rdparty/bgfx/examples/assets/meshes/build.ninja18
-rw-r--r--3rdparty/bgfx/examples/assets/meshes/makefile40
-rw-r--r--3rdparty/bgfx/examples/assets/textures/build.ninja8
-rw-r--r--3rdparty/bgfx/examples/assets/textures/texture_compression.png (renamed from 3rdparty/bgfx/examples/08-update/texture_compression.png)bin14941 -> 14941 bytes
-rw-r--r--3rdparty/bgfx/examples/common/cube_atlas.cpp25
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry.cpp10
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_windows.cpp2
-rw-r--r--3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp70
-rw-r--r--3rdparty/bgfx/examples/runtime/meshes/bunny.binbin2588410 -> 974323 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/meshes/bunny_decimated.binbin191471 -> 191471 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/meshes/bunny_patched.binbin975611 -> 975611 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/meshes/column.binbin55507 -> 55507 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/meshes/cube.binbin930 -> 930 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/meshes/hollowcube.binbin40281 -> 24144 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/meshes/orb.binbin2485418 -> 1494272 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/meshes/platform.binbin1607 -> 1607 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/meshes/tree.binbin100714 -> 100714 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/meshes/tree1b_lod0_1.binbin63365 -> 63365 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/meshes/tree1b_lod0_2.binbin25719 -> 25719 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/meshes/tree1b_lod1_1.binbin36659 -> 36659 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/meshes/tree1b_lod1_2.binbin27123 -> 27123 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/meshes/tree1b_lod2_1.binbin16061 -> 16061 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/meshes/tree1b_lod2_2.binbin10899 -> 10899 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/textures/texture_compression_bc1.ddsbin11064 -> 0 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/textures/texture_compression_bc1.ktxbin0 -> 11020 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/textures/texture_compression_bc2.ddsbin22000 -> 0 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/textures/texture_compression_bc2.ktxbin0 -> 21948 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/textures/texture_compression_bc3.ddsbin22000 -> 0 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/textures/texture_compression_bc3.ktxbin0 -> 21948 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/textures/texture_compression_etc1.ktxbin8260 -> 11020 bytes
-rw-r--r--3rdparty/bgfx/examples/runtime/textures/texture_compression_etc2.ktxbin8260 -> 11020 bytes
-rw-r--r--3rdparty/bgfx/scripts/common.ninja26
-rw-r--r--3rdparty/bgfx/src/bgfx.cpp6
-rw-r--r--3rdparty/bgfx/src/image.cpp52
-rw-r--r--3rdparty/bgfx/src/renderer_gl.cpp2
-rw-r--r--3rdparty/bgfx/tools/shaderc/shaderc_glsl.cpp4
-rw-r--r--3rdparty/bgfx/tools/texturev/texturev.cpp146
-rw-r--r--3rdparty/bx/include/bx/string.h17
-rw-r--r--3rdparty/bx/scripts/toolchain.lua18
-rwxr-xr-x3rdparty/bx/tools/bin/darwin/geniebin442656 -> 463136 bytes
-rwxr-xr-x3rdparty/bx/tools/bin/linux/geniebin417336 -> 437784 bytes
-rw-r--r--3rdparty/bx/tools/bin/windows/genie.exebin421376 -> 443392 bytes
-rw-r--r--3rdparty/rapidjson/doc/dom.md2
-rw-r--r--3rdparty/rapidjson/doc/encoding.md4
-rw-r--r--3rdparty/rapidjson/doc/encoding.zh-cn.md4
-rw-r--r--3rdparty/rapidjson/include/rapidjson/istreamwrapper.h5
-rw-r--r--3rdparty/rapidjson/include/rapidjson/ostreamwrapper.h5
-rw-r--r--3rdparty/rapidjson/include_dirs.js2
-rw-r--r--3rdparty/rapidjson/package.json25
84 files changed, 1353 insertions, 694 deletions
diff --git a/3rdparty/benchmark/.travis.yml b/3rdparty/benchmark/.travis.yml
index 8b138ce134d..bf26395bcbc 100644
--- a/3rdparty/benchmark/.travis.yml
+++ b/3rdparty/benchmark/.travis.yml
@@ -39,3 +39,5 @@ after_success:
- if [ "${BUILD_TYPE}" == "Coverage" -a "${TRAVIS_OS_NAME}" == "linux" ]; then
coveralls --include src --include include --gcov-options '\-lp' --root .. --build-root .;
fi
+
+sudo: required
diff --git a/3rdparty/benchmark/AUTHORS b/3rdparty/benchmark/AUTHORS
index 5a4b35535e2..9da43c73b47 100644
--- a/3rdparty/benchmark/AUTHORS
+++ b/3rdparty/benchmark/AUTHORS
@@ -17,6 +17,7 @@ Evgeny Safronov <division494@gmail.com>
Felix Homann <linuxaudio@showlabor.de>
Google Inc.
JianXiong Zhou <zhoujianxiong2@gmail.com>
+Jussi Knuuttila <jussi.knuuttila@gmail.com>
Kaito Udagawa <umireon@gmail.com>
Lei Xu <eddyxu@gmail.com>
Matt Clarkson <mattyclarkson@gmail.com>
diff --git a/3rdparty/benchmark/CMakeLists.txt b/3rdparty/benchmark/CMakeLists.txt
index 2c722526216..f340fb35040 100644
--- a/3rdparty/benchmark/CMakeLists.txt
+++ b/3rdparty/benchmark/CMakeLists.txt
@@ -33,15 +33,29 @@ include(CXXFeatureCheck)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# Turn compiler warnings up to 11
- add_cxx_compiler_flag(-W4)
+ string(REGEX REPLACE "[-/]W[1-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
# Link time optimisation
if (BENCHMARK_ENABLE_LTO)
- set(CMAKE_CXX_FLAGS_RELEASE "/GL")
- set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "/LTCG")
- set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/LTCG")
- set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL")
+ set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG")
+ set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG")
+ set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
+
+ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /GL")
+ string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO}")
+ set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
+ string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO}")
+ set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
+ string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
+ set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
+
+ set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /GL")
+ set(CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL "${CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL} /LTCG")
+ set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} /LTCG")
+ set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /LTCG")
endif()
else()
# Try and enable C++11. Don't use C++14 because it doesn't work in some
@@ -57,6 +71,8 @@ else()
add_cxx_compiler_flag(-Wextra)
add_cxx_compiler_flag(-Wshadow)
add_cxx_compiler_flag(-Werror RELEASE)
+ add_cxx_compiler_flag(-Werror RELWITHDEBINFO)
+ add_cxx_compiler_flag(-Werror MINSIZEREL)
add_cxx_compiler_flag(-pedantic)
add_cxx_compiler_flag(-pedantic-errors)
add_cxx_compiler_flag(-Wshorten-64-to-32)
diff --git a/3rdparty/benchmark/CONTRIBUTORS b/3rdparty/benchmark/CONTRIBUTORS
index ed55bcf2767..67ecb280e0b 100644
--- a/3rdparty/benchmark/CONTRIBUTORS
+++ b/3rdparty/benchmark/CONTRIBUTORS
@@ -23,6 +23,7 @@
# Please keep the list sorted.
Arne Beer <arne@twobeer.de>
+Billy Robert O'Neal III <billy.oneal@gmail.com> <bion@microsoft.com>
Chris Kennelly <ckennelly@google.com> <ckennelly@ckennelly.com>
Christopher Seymour <chris.j.seymour@hotmail.com>
David Coeurjolly <david.coeurjolly@liris.cnrs.fr>
@@ -31,7 +32,9 @@ Eugene Zhuk <eugene.zhuk@gmail.com>
Evgeny Safronov <division494@gmail.com>
Felix Homann <linuxaudio@showlabor.de>
JianXiong Zhou <zhoujianxiong2@gmail.com>
+Jussi Knuuttila <jussi.knuuttila@gmail.com>
Kaito Udagawa <umireon@gmail.com>
+Kai Wolf <kai.wolf@gmail.com>
Lei Xu <eddyxu@gmail.com>
Matt Clarkson <mattyclarkson@gmail.com>
Oleksandr Sochka <sasha.sochka@gmail.com>
diff --git a/3rdparty/benchmark/README.md b/3rdparty/benchmark/README.md
index 21ae478b893..051b3011801 100644
--- a/3rdparty/benchmark/README.md
+++ b/3rdparty/benchmark/README.md
@@ -1,5 +1,4 @@
-benchmark
-=========
+# benchmark
[![Build Status](https://travis-ci.org/google/benchmark.svg?branch=master)](https://travis-ci.org/google/benchmark)
[![Build status](https://ci.appveyor.com/api/projects/status/u0qsyp7t1tk7cpxs/branch/master?svg=true)](https://ci.appveyor.com/project/google/benchmark/branch/master)
[![Coverage Status](https://coveralls.io/repos/google/benchmark/badge.svg)](https://coveralls.io/r/google/benchmark)
@@ -10,10 +9,9 @@ Discussion group: https://groups.google.com/d/forum/benchmark-discuss
IRC channel: https://freenode.net #googlebenchmark
-Example usage
--------------
-Define a function that executes the code to be measured a
-specified number of times:
+## Example usage
+### Basic usage
+Define a function that executes the code to be measured.
```c++
static void BM_StringCreation(benchmark::State& state) {
@@ -34,15 +32,16 @@ BENCHMARK(BM_StringCopy);
BENCHMARK_MAIN();
```
-Sometimes a family of microbenchmarks can be implemented with
-just one routine that takes an extra argument to specify which
-one of the family of benchmarks to run. For example, the following
-code defines a family of microbenchmarks for measuring the speed
-of `memcpy()` calls of different lengths:
+### Passing arguments
+Sometimes a family of benchmarks can be implemented with just one routine that
+takes an extra argument to specify which one of the family of benchmarks to
+run. For example, the following code defines a family of benchmarks for
+measuring the speed of `memcpy()` calls of different lengths:
```c++
static void BM_memcpy(benchmark::State& state) {
- char* src = new char[state.range_x()]; char* dst = new char[state.range_x()];
+ char* src = new char[state.range_x()];
+ char* dst = new char[state.range_x()];
memset(src, 'x', state.range_x());
while (state.KeepRunning())
memcpy(dst, src, state.range_x());
@@ -54,18 +53,17 @@ static void BM_memcpy(benchmark::State& state) {
BENCHMARK(BM_memcpy)->Arg(8)->Arg(64)->Arg(512)->Arg(1<<10)->Arg(8<<10);
```
-The preceding code is quite repetitive, and can be replaced with the
-following short-hand. The following invocation will pick a few
-appropriate arguments in the specified range and will generate a
-microbenchmark for each such argument.
+The preceding code is quite repetitive, and can be replaced with the following
+short-hand. The following invocation will pick a few appropriate arguments in
+the specified range and will generate a benchmark for each such argument.
```c++
BENCHMARK(BM_memcpy)->Range(8, 8<<10);
```
-You might have a microbenchmark that depends on two inputs. For
-example, the following code defines a family of microbenchmarks for
-measuring the speed of set insertion.
+You might have a benchmark that depends on two inputs. For example, the
+following code defines a family of benchmarks for measuring the speed of set
+insertion.
```c++
static void BM_SetInsert(benchmark::State& state) {
@@ -88,19 +86,18 @@ BENCHMARK(BM_SetInsert)
->ArgPair(8<<10, 512);
```
-The preceding code is quite repetitive, and can be replaced with
-the following short-hand. The following macro will pick a few
-appropriate arguments in the product of the two specified ranges
-and will generate a microbenchmark for each such pair.
+The preceding code is quite repetitive, and can be replaced with the following
+short-hand. The following macro will pick a few appropriate arguments in the
+product of the two specified ranges and will generate a benchmark for each such
+pair.
```c++
BENCHMARK(BM_SetInsert)->RangePair(1<<10, 8<<10, 1, 512);
```
-For more complex patterns of inputs, passing a custom function
-to Apply allows programmatic specification of an
-arbitrary set of arguments to run the microbenchmark on.
-The following example enumerates a dense range on one parameter,
+For more complex patterns of inputs, passing a custom function to `Apply` allows
+programmatic specification of an arbitrary set of arguments on which to run the
+benchmark. The following example enumerates a dense range on one parameter,
and a sparse range on the second.
```c++
@@ -112,9 +109,10 @@ static void CustomArguments(benchmark::internal::Benchmark* b) {
BENCHMARK(BM_SetInsert)->Apply(CustomArguments);
```
-Templated microbenchmarks work the same way:
-Produce then consume 'size' messages 'iters' times
-Measures throughput in the absence of multiprogramming.
+### Templated benchmarks
+Templated benchmarks work the same way: This example produces and consumes
+messages of size `sizeof(v)` `range_x` times. It also outputs throughput in the
+absence of multiprogramming.
```c++
template <class Q> int BM_Sequential(benchmark::State& state) {
@@ -145,11 +143,12 @@ Three macros are provided for adding benchmark templates.
#define BENCHMARK_TEMPLATE2(func, arg1, arg2)
```
+### Multithreaded benchmarks
In a multithreaded test (benchmark invoked by multiple threads simultaneously),
it is guaranteed that none of the threads will start until all have called
-KeepRunning, and all will have finished before KeepRunning returns false. As
-such, any global setup or teardown you want to do can be
-wrapped in a check against the thread index:
+`KeepRunning`, and all will have finished before KeepRunning returns false. As
+such, any global setup or teardown can be wrapped in a check against the thread
+index:
```c++
static void BM_MultiThreaded(benchmark::State& state) {
@@ -176,6 +175,46 @@ BENCHMARK(BM_test)->Range(8, 8<<10)->UseRealTime();
Without `UseRealTime`, CPU time is used by default.
+
+## Manual timing
+For benchmarking something for which neither CPU time nor real-time are
+correct or accurate enough, completely manual timing is supported using
+the `UseManualTime` function.
+
+When `UseManualTime` is used, the benchmarked code must call
+`SetIterationTime` once per iteration of the `KeepRunning` loop to
+report the manually measured time.
+
+An example use case for this is benchmarking GPU execution (e.g. OpenCL
+or CUDA kernels, OpenGL or Vulkan or Direct3D draw calls), which cannot
+be accurately measured using CPU time or real-time. Instead, they can be
+measured accurately using a dedicated API, and these measurement results
+can be reported back with `SetIterationTime`.
+
+```c++
+static void BM_ManualTiming(benchmark::State& state) {
+ int microseconds = state.range_x();
+ std::chrono::duration<double, std::micro> sleep_duration {
+ static_cast<double>(microseconds)
+ };
+
+ while (state.KeepRunning()) {
+ auto start = std::chrono::high_resolution_clock::now();
+ // Simulate some useful workload with a sleep
+ std::this_thread::sleep_for(sleep_duration);
+ auto end = std::chrono::high_resolution_clock::now();
+
+ auto elapsed_seconds =
+ std::chrono::duration_cast<std::chrono::duration<double>>(
+ end - start);
+
+ state.SetIterationTime(elapsed_seconds.count());
+ }
+}
+BENCHMARK(BM_ManualTiming)->Range(1, 1<<17)->UseManualTime();
+```
+
+### Preventing optimisation
To prevent a value or expression from being optimized away by the compiler
the `benchmark::DoNotOptimize(...)` function can be used.
@@ -190,8 +229,24 @@ static void BM_test(benchmark::State& state) {
}
```
-Benchmark Fixtures
-------------------
+### Set time unit manually
+If a benchmark runs a few milliseconds it may be hard to visually compare the
+measured times, since the output data is given in nanoseconds per default. In
+order to manually set the time unit, you can specify it manually:
+
+```c++
+BENCHMARK(BM_test)->Unit(benchmark::kMillisecond);
+```
+
+## Controlling number of iterations
+In all cases, the number of iterations for which the benchmark is run is
+governed by the amount of time the benchmark takes. Concretely, the number of
+iterations is at least one, not more than 1e9, until CPU time is greater than
+the minimum time, or the wallclock time is 5x minimum time. The minimum time is
+set as a flag `--benchmark_min_time` or per benchmark by calling `MinTime` on
+the registered benchmark object.
+
+## Fixtures
Fixture tests are created by
first defining a type that derives from ::benchmark::Fixture and then
creating/registering the tests using the following macros:
@@ -221,8 +276,7 @@ BENCHMARK_REGISTER_F(MyFixture, BarTest)->Threads(2);
/* BarTest is now registered */
```
-Output Formats
---------------
+## Output Formats
The library supports multiple output formats. Use the
`--benchmark_format=<tabular|json>` flag to set the format type. `tabular` is
the default format.
@@ -290,8 +344,7 @@ name,iterations,real_time,cpu_time,bytes_per_second,items_per_second,label
"BM_SetInsert/1024/10",106365,17238.4,8421.53,4.74973e+06,1.18743e+06,
```
-Debug vs Release
-----------------
+## Debug vs Release
By default, benchmark builds as a debug library. You will see a warning in the output when this is the case. To build it as a release library instead, use:
```
@@ -304,6 +357,5 @@ To enable link-time optimisation, use
cmake -DCMAKE_BUILD_TYPE=Release -DBENCHMARK_ENABLE_LTO=true
```
-Linking against the library
----------------------------
+## Linking against the library
When using gcc, it is necessary to link against pthread to avoid runtime exceptions. This is due to how gcc implements std::thread. See [issue #67](https://github.com/google/benchmark/issues/67) for more details.
diff --git a/3rdparty/benchmark/cmake/posix_regex.cpp b/3rdparty/benchmark/cmake/posix_regex.cpp
index a31af80481a..466dc62560a 100644
--- a/3rdparty/benchmark/cmake/posix_regex.cpp
+++ b/3rdparty/benchmark/cmake/posix_regex.cpp
@@ -7,6 +7,8 @@ int main() {
if (ec != 0) {
return ec;
}
- return regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0;
+ int ret = regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0;
+ regfree(&re);
+ return ret;
}
diff --git a/3rdparty/benchmark/include/benchmark/benchmark_api.h b/3rdparty/benchmark/include/benchmark/benchmark_api.h
index 7a42025a457..ef7eca5313d 100644
--- a/3rdparty/benchmark/include/benchmark/benchmark_api.h
+++ b/3rdparty/benchmark/include/benchmark/benchmark_api.h
@@ -137,6 +137,13 @@ static void BM_MultiThreaded(benchmark::State& state) {
}
}
BENCHMARK(BM_MultiThreaded)->Threads(4);
+
+
+If a benchmark runs a few milliseconds it may be hard to visually compare the
+measured times, since the output data is given in nanoseconds per default. In
+order to manually set the time unit, you can specify it manually:
+
+BENCHMARK(BM_test)->Unit(benchmark::kMillisecond);
*/
#ifndef BENCHMARK_BENCHMARK_API_H_
@@ -216,6 +223,13 @@ inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const& value) {
}
#endif
+// TimeUnit is passed to a benchmark in order to specify the order of magnitude
+// for the measured time.
+enum TimeUnit {
+ kNanosecond,
+ kMicrosecond,
+ kMillisecond
+};
// State is passed to a running Benchmark and contains state for the
// benchmark to use.
@@ -269,6 +283,17 @@ public:
// within each benchmark iteration, if possible.
void ResumeTiming();
+ // REQUIRES: called exactly once per iteration of the KeepRunning loop.
+ // Set the manually measured time for this benchmark iteration, which
+ // is used instead of automatically measured time if UseManualTime() was
+ // specified.
+ //
+ // For threaded benchmarks the SetIterationTime() function acts
+ // like a barrier. I.e., the ith call by a particular thread to this
+ // function will block until all threads have made their ith call.
+ // The time will be set by the last thread to call this function.
+ void SetIterationTime(double seconds);
+
// Set the number of bytes processed by the current benchmark
// execution. This routine is typically called once at the end of a
// throughput oriented benchmark. If this routine is called with a
@@ -305,10 +330,10 @@ public:
// If this routine is called, the specified label is printed at the
// end of the benchmark report line for the currently executing
// benchmark. Example:
- // static void BM_Compress(int iters) {
+ // static void BM_Compress(benchmark::State& state) {
// ...
// double compress = input_size / output_size;
- // benchmark::SetLabel(StringPrintf("compress:%.1f%%", 100.0*compression));
+ // state.SetLabel(StringPrintf("compress:%.1f%%", 100.0*compression));
// }
// Produces output that looks like:
// BM_Compress 50 50 14115038 compress:27.3%
@@ -390,6 +415,9 @@ public:
// REQUIRES: The function passed to the constructor must accept an arg1.
Benchmark* Arg(int x);
+ // Run this benchmark with the given time unit for the generated output report
+ Benchmark* Unit(TimeUnit unit);
+
// Run this benchmark once for a number of values picked from the
// range [start..limit]. (start and limit are always picked.)
// REQUIRES: The function passed to the constructor must accept an arg1.
@@ -427,6 +455,13 @@ public:
// called, the cpu time used by the benchmark will be used.
Benchmark* UseRealTime();
+ // If a benchmark must measure time manually (e.g. if GPU execution time is being
+ // measured), call this method. If called, each benchmark iteration should call
+ // SetIterationTime(seconds) to report the measured time, which will be used
+ // to control how many iterations are run, and in the printing of items/second
+ // or MB/second values.
+ Benchmark* UseManualTime();
+
// Support for running multiple copies of the same benchmark concurrently
// in multiple threads. This may be useful when measuring the scaling
// of some piece of code.
@@ -534,6 +569,7 @@ protected:
// Old-style macros
#define BENCHMARK_WITH_ARG(n, a) BENCHMARK(n)->Arg((a))
#define BENCHMARK_WITH_ARG2(n, a1, a2) BENCHMARK(n)->ArgPair((a1), (a2))
+#define BENCHMARK_WITH_UNIT(n, t) BENCHMARK(n)->Unit((t))
#define BENCHMARK_RANGE(n, lo, hi) BENCHMARK(n)->Range((lo), (hi))
#define BENCHMARK_RANGE2(n, l1, h1, l2, h2) \
BENCHMARK(n)->RangePair((l1), (h1), (l2), (h2))
diff --git a/3rdparty/benchmark/include/benchmark/reporter.h b/3rdparty/benchmark/include/benchmark/reporter.h
index d23ab6574d7..aaf5fbff2d2 100644
--- a/3rdparty/benchmark/include/benchmark/reporter.h
+++ b/3rdparty/benchmark/include/benchmark/reporter.h
@@ -22,6 +22,8 @@
namespace benchmark {
+typedef std::pair<const char*,double> TimeUnitMultiplier;
+
// Interface for custom benchmark result printers.
// By default, benchmark reports are printed to stdout. However an application
// can control the destination of the reports by calling
@@ -41,6 +43,7 @@ class BenchmarkReporter {
struct Run {
Run() :
iterations(1),
+ time_unit(kNanosecond),
real_accumulated_time(0),
cpu_accumulated_time(0),
bytes_per_second(0),
@@ -50,6 +53,7 @@ class BenchmarkReporter {
std::string benchmark_name;
std::string report_label; // Empty if not set by benchmark.
int64_t iterations;
+ TimeUnit time_unit;
double real_accumulated_time;
double cpu_accumulated_time;
@@ -81,7 +85,8 @@ class BenchmarkReporter {
virtual ~BenchmarkReporter();
protected:
- static void ComputeStats(std::vector<Run> const& reports, Run* mean, Run* stddev);
+ static void ComputeStats(std::vector<Run> const& reports, Run* mean, Run* stddev);
+ static TimeUnitMultiplier GetTimeUnitAndMultiplier(TimeUnit unit);
};
// Simple reporter that outputs benchmark data to the console. This is the
@@ -90,7 +95,8 @@ class ConsoleReporter : public BenchmarkReporter {
public:
virtual bool ReportContext(const Context& context);
virtual void ReportRuns(const std::vector<Run>& reports);
-protected:
+
+ protected:
virtual void PrintRunData(const Run& report);
size_t name_field_width_;
diff --git a/3rdparty/benchmark/src/benchmark.cc b/3rdparty/benchmark/src/benchmark.cc
index 08b180e37e6..1a836eb4abc 100644
--- a/3rdparty/benchmark/src/benchmark.cc
+++ b/3rdparty/benchmark/src/benchmark.cc
@@ -64,9 +64,9 @@ DEFINE_int32(benchmark_repetitions, 1,
"The number of runs of each benchmark. If greater than 1, the "
"mean and standard deviation of the runs will be reported.");
-DEFINE_string(benchmark_format, "tabular",
+DEFINE_string(benchmark_format, "console",
"The format to use for console output. Valid values are "
- "'tabular', 'json', or 'csv'.");
+ "'console', 'json', or 'csv'.");
DEFINE_bool(color_print, true, "Enables colorized logging.");
@@ -130,6 +130,7 @@ class TimerManager {
running_(false),
real_time_used_(0),
cpu_time_used_(0),
+ manual_time_used_(0),
num_finalized_(0),
phase_number_(0),
entered_(0) {
@@ -170,6 +171,21 @@ class TimerManager {
}
// Called by each thread
+ void SetIterationTime(double seconds) EXCLUDES(lock_) {
+ bool last_thread = false;
+ {
+ MutexLock ml(lock_);
+ last_thread = Barrier(ml);
+ if (last_thread) {
+ manual_time_used_ += seconds;
+ }
+ }
+ if (last_thread) {
+ phase_condition_.notify_all();
+ }
+ }
+
+ // Called by each thread
void Finalize() EXCLUDES(lock_) {
MutexLock l(lock_);
num_finalized_++;
@@ -194,6 +210,13 @@ class TimerManager {
return cpu_time_used_;
}
+ // REQUIRES: timer is not running
+ double manual_time_used() EXCLUDES(lock_) {
+ MutexLock l(lock_);
+ CHECK(!running_);
+ return manual_time_used_;
+ }
+
private:
Mutex lock_;
Condition phase_condition_;
@@ -207,6 +230,8 @@ class TimerManager {
// Accumulated time so far (does not contain current slice if running_)
double real_time_used_;
double cpu_time_used_;
+ // Manually set iteration time. User sets this with SetIterationTime(seconds).
+ double manual_time_used_;
// How many threads have called Finalize()
int num_finalized_;
@@ -261,7 +286,9 @@ struct Benchmark::Instance {
int arg1;
bool has_arg2;
int arg2;
+ TimeUnit time_unit;
bool use_real_time;
+ bool use_manual_time;
double min_time;
int threads; // Number of concurrent threads to use
bool multithreaded; // Is benchmark multi-threaded?
@@ -294,12 +321,14 @@ public:
~BenchmarkImp();
void Arg(int x);
+ void Unit(TimeUnit unit);
void Range(int start, int limit);
void DenseRange(int start, int limit);
void ArgPair(int start, int limit);
void RangePair(int lo1, int hi1, int lo2, int hi2);
void MinTime(double n);
void UseRealTime();
+ void UseManualTime();
void Threads(int t);
void ThreadRange(int min_threads, int max_threads);
void ThreadPerCpu();
@@ -313,8 +342,10 @@ private:
std::string name_;
int arg_count_;
std::vector< std::pair<int, int> > args_; // Args for all benchmark runs
+ TimeUnit time_unit_;
double min_time_;
bool use_real_time_;
+ bool use_manual_time_;
std::vector<int> thread_counts_;
BenchmarkImp& operator=(BenchmarkImp const&);
@@ -372,8 +403,10 @@ bool BenchmarkFamilies::FindBenchmarks(
instance.arg1 = args.first;
instance.has_arg2 = family->arg_count_ == 2;
instance.arg2 = args.second;
+ instance.time_unit = family->time_unit_;
instance.min_time = family->min_time_;
instance.use_real_time = family->use_real_time_;
+ instance.use_manual_time = family->use_manual_time_;
instance.threads = num_threads;
instance.multithreaded = !(family->thread_counts_.empty());
@@ -387,7 +420,9 @@ bool BenchmarkFamilies::FindBenchmarks(
if (!IsZero(family->min_time_)) {
instance.name += StringPrintF("/min_time:%0.3f", family->min_time_);
}
- if (family->use_real_time_) {
+ if (family->use_manual_time_) {
+ instance.name += "/manual_time";
+ } else if (family->use_real_time_) {
instance.name += "/real_time";
}
@@ -406,8 +441,9 @@ bool BenchmarkFamilies::FindBenchmarks(
}
BenchmarkImp::BenchmarkImp(const char* name)
- : name_(name), arg_count_(-1),
- min_time_(0.0), use_real_time_(false) {
+ : name_(name), arg_count_(-1), time_unit_(kNanosecond),
+ min_time_(0.0), use_real_time_(false),
+ use_manual_time_(false) {
}
BenchmarkImp::~BenchmarkImp() {
@@ -419,6 +455,10 @@ void BenchmarkImp::Arg(int x) {
args_.emplace_back(x, -1);
}
+void BenchmarkImp::Unit(TimeUnit unit) {
+ time_unit_ = unit;
+}
+
void BenchmarkImp::Range(int start, int limit) {
CHECK(arg_count_ == -1 || arg_count_ == 1);
arg_count_ = 1;
@@ -466,9 +506,15 @@ void BenchmarkImp::MinTime(double t) {
}
void BenchmarkImp::UseRealTime() {
+ CHECK(!use_manual_time_) << "Cannot set UseRealTime and UseManualTime simultaneously.";
use_real_time_ = true;
}
+void BenchmarkImp::UseManualTime() {
+ CHECK(!use_real_time_) << "Cannot set UseRealTime and UseManualTime simultaneously.";
+ use_manual_time_ = true;
+}
+
void BenchmarkImp::Threads(int t) {
CHECK_GT(t, 0);
thread_counts_.push_back(t);
@@ -531,6 +577,11 @@ Benchmark* Benchmark::Arg(int x) {
return this;
}
+Benchmark* Benchmark::Unit(TimeUnit unit) {
+ imp_->Unit(unit);
+ return this;
+}
+
Benchmark* Benchmark::Range(int start, int limit) {
imp_->Range(start, limit);
return this;
@@ -566,6 +617,11 @@ Benchmark* Benchmark::UseRealTime() {
return this;
}
+Benchmark* Benchmark::UseManualTime() {
+ imp_->UseManualTime();
+ return this;
+}
+
Benchmark* Benchmark::Threads(int t) {
imp_->Threads(t);
return this;
@@ -647,7 +703,7 @@ void RunBenchmark(const benchmark::internal::Benchmark::Instance& b,
thread.join();
}
for (std::size_t ti = 0; ti < pool.size(); ++ti) {
- pool[ti] = std::thread(&RunInThread, &b, iters, ti, &total);
+ pool[ti] = std::thread(&RunInThread, &b, iters, static_cast<int>(ti), &total);
}
} else {
// Run directly in this thread
@@ -658,6 +714,7 @@ void RunBenchmark(const benchmark::internal::Benchmark::Instance& b,
const double cpu_accumulated_time = timer_manager->cpu_time_used();
const double real_accumulated_time = timer_manager->real_time_used();
+ const double manual_accumulated_time = timer_manager->manual_time_used();
timer_manager.reset();
VLOG(2) << "Ran in " << cpu_accumulated_time << "/"
@@ -665,7 +722,9 @@ void RunBenchmark(const benchmark::internal::Benchmark::Instance& b,
// Base decisions off of real time if requested by this benchmark.
double seconds = cpu_accumulated_time;
- if (b.use_real_time) {
+ if (b.use_manual_time) {
+ seconds = manual_accumulated_time;
+ } else if (b.use_real_time) {
seconds = real_accumulated_time;
}
@@ -699,7 +758,12 @@ void RunBenchmark(const benchmark::internal::Benchmark::Instance& b,
report.report_label = label;
// Report the total iterations across all threads.
report.iterations = static_cast<int64_t>(iters) * b.threads;
- report.real_accumulated_time = real_accumulated_time;
+ report.time_unit = b.time_unit;
+ if (b.use_manual_time) {
+ report.real_accumulated_time = manual_accumulated_time;
+ } else {
+ report.real_accumulated_time = real_accumulated_time;
+ }
report.cpu_accumulated_time = cpu_accumulated_time;
report.bytes_per_second = bytes_per_second;
report.items_per_second = items_per_second;
@@ -760,6 +824,12 @@ void State::ResumeTiming() {
timer_manager->StartTimer();
}
+void State::SetIterationTime(double seconds)
+{
+ CHECK(running_benchmark);
+ timer_manager->SetIterationTime(seconds);
+}
+
void State::SetLabel(const char* label) {
CHECK(running_benchmark);
MutexLock l(GetBenchmarkLock());
@@ -814,7 +884,7 @@ void RunMatchingBenchmarks(const std::string& spec,
std::unique_ptr<BenchmarkReporter> GetDefaultReporter() {
typedef std::unique_ptr<BenchmarkReporter> PtrType;
- if (FLAGS_benchmark_format == "tabular") {
+ if (FLAGS_benchmark_format == "console") {
return PtrType(new ConsoleReporter);
} else if (FLAGS_benchmark_format == "json") {
return PtrType(new JSONReporter);
@@ -860,7 +930,7 @@ void PrintUsageAndExit() {
" [--benchmark_filter=<regex>]\n"
" [--benchmark_min_time=<min_time>]\n"
" [--benchmark_repetitions=<num_repetitions>]\n"
- " [--benchmark_format=<tabular|json|csv>]\n"
+ " [--benchmark_format=<console|json|csv>]\n"
" [--color_print={true|false}]\n"
" [--v=<verbosity>]\n");
exit(0);
@@ -891,7 +961,8 @@ void ParseCommandLineFlags(int* argc, char** argv) {
PrintUsageAndExit();
}
}
- if (FLAGS_benchmark_format != "tabular" &&
+
+ if (FLAGS_benchmark_format != "console" &&
FLAGS_benchmark_format != "json" &&
FLAGS_benchmark_format != "csv") {
PrintUsageAndExit();
diff --git a/3rdparty/benchmark/src/console_reporter.cc b/3rdparty/benchmark/src/console_reporter.cc
index 092936d5935..56bd3ced05b 100644
--- a/3rdparty/benchmark/src/console_reporter.cc
+++ b/3rdparty/benchmark/src/console_reporter.cc
@@ -18,6 +18,7 @@
#include <cstdio>
#include <iostream>
#include <string>
+#include <tuple>
#include <vector>
#include "check.h"
@@ -46,9 +47,9 @@ bool ConsoleReporter::ReportContext(const Context& context) {
"affected.\n";
#endif
- int output_width = fprintf(stdout, "%-*s %10s %10s %10s\n",
+ int output_width = fprintf(stdout, "%-*s %13s %13s %10s\n",
static_cast<int>(name_field_width_), "Benchmark",
- "Time(ns)", "CPU(ns)", "Iterations");
+ "Time", "CPU", "Iterations");
std::cout << std::string(output_width - 1, '-') << "\n";
return true;
@@ -92,25 +93,44 @@ void ConsoleReporter::PrintRunData(const Run& result) {
" items/s");
}
- double const multiplier = 1e9; // nano second multiplier
+ double multiplier;
+ const char* timeLabel;
+ std::tie(timeLabel, multiplier) = GetTimeUnitAndMultiplier(result.time_unit);
+
ColorPrintf(COLOR_GREEN, "%-*s ",
name_field_width_, result.benchmark_name.c_str());
+
if (result.iterations == 0) {
- ColorPrintf(COLOR_YELLOW, "%10.0f %10.0f ",
+ ColorPrintf(COLOR_YELLOW, "%10.0f %s %10.0f %s ",
result.real_accumulated_time * multiplier,
- result.cpu_accumulated_time * multiplier);
+ timeLabel,
+ result.cpu_accumulated_time * multiplier,
+ timeLabel);
} else {
- ColorPrintf(COLOR_YELLOW, "%10.0f %10.0f ",
+ ColorPrintf(COLOR_YELLOW, "%10.0f %s %10.0f %s ",
(result.real_accumulated_time * multiplier) /
(static_cast<double>(result.iterations)),
+ timeLabel,
(result.cpu_accumulated_time * multiplier) /
- (static_cast<double>(result.iterations)));
+ (static_cast<double>(result.iterations)),
+ timeLabel);
}
+
ColorPrintf(COLOR_CYAN, "%10lld", result.iterations);
- ColorPrintf(COLOR_DEFAULT, "%*s %*s %s\n",
- 13, rate.c_str(),
- 18, items.c_str(),
- result.report_label.c_str());
+
+ if (!rate.empty()) {
+ ColorPrintf(COLOR_DEFAULT, " %*s", 13, rate.c_str());
+ }
+
+ if (!items.empty()) {
+ ColorPrintf(COLOR_DEFAULT, " %*s", 18, items.c_str());
+ }
+
+ if (!result.report_label.empty()) {
+ ColorPrintf(COLOR_DEFAULT, " %s", result.report_label.c_str());
+ }
+
+ ColorPrintf(COLOR_DEFAULT, "\n");
}
} // end namespace benchmark
diff --git a/3rdparty/benchmark/src/csv_reporter.cc b/3rdparty/benchmark/src/csv_reporter.cc
index d78a9dfb267..3f67d1de1e6 100644
--- a/3rdparty/benchmark/src/csv_reporter.cc
+++ b/3rdparty/benchmark/src/csv_reporter.cc
@@ -17,6 +17,7 @@
#include <cstdint>
#include <iostream>
#include <string>
+#include <tuple>
#include <vector>
#include "string_util.h"
@@ -42,7 +43,7 @@ bool CSVReporter::ReportContext(const Context& context) {
std::cerr << "***WARNING*** Library was built as DEBUG. Timings may be "
"affected.\n";
#endif
- std::cout << "name,iterations,real_time,cpu_time,bytes_per_second,"
+ std::cout << "name,iterations,real_time,cpu_time,time_unit,bytes_per_second,"
"items_per_second,label\n";
return true;
}
@@ -66,7 +67,10 @@ void CSVReporter::ReportRuns(std::vector<Run> const& reports) {
}
void CSVReporter::PrintRunData(Run const& run) {
- double const multiplier = 1e9; // nano second multiplier
+ double multiplier;
+ const char* timeLabel;
+ std::tie(timeLabel, multiplier) = GetTimeUnitAndMultiplier(run.time_unit);
+
double cpu_time = run.cpu_accumulated_time * multiplier;
double real_time = run.real_accumulated_time * multiplier;
if (run.iterations != 0) {
@@ -83,6 +87,7 @@ void CSVReporter::PrintRunData(Run const& run) {
std::cout << run.iterations << ",";
std::cout << real_time << ",";
std::cout << cpu_time << ",";
+ std::cout << timeLabel << ",";
if (run.bytes_per_second > 0.0) {
std::cout << run.bytes_per_second;
diff --git a/3rdparty/benchmark/src/json_reporter.cc b/3rdparty/benchmark/src/json_reporter.cc
index def50ac49cf..7ed141fc179 100644
--- a/3rdparty/benchmark/src/json_reporter.cc
+++ b/3rdparty/benchmark/src/json_reporter.cc
@@ -17,6 +17,7 @@
#include <cstdint>
#include <iostream>
#include <string>
+#include <tuple>
#include <vector>
#include "string_util.h"
@@ -120,7 +121,10 @@ void JSONReporter::Finalize() {
}
void JSONReporter::PrintRunData(Run const& run) {
- double const multiplier = 1e9; // nano second multiplier
+ double multiplier;
+ const char* timeLabel;
+ std::tie(timeLabel, multiplier) = GetTimeUnitAndMultiplier(run.time_unit);
+
double cpu_time = run.cpu_accumulated_time * multiplier;
double real_time = run.real_accumulated_time * multiplier;
if (run.iterations != 0) {
@@ -140,7 +144,10 @@ void JSONReporter::PrintRunData(Run const& run) {
<< FormatKV("real_time", RoundDouble(real_time))
<< ",\n";
out << indent
- << FormatKV("cpu_time", RoundDouble(cpu_time));
+ << FormatKV("cpu_time", RoundDouble(cpu_time))
+ << ",\n";
+ out << indent
+ << FormatKV("time_unit", timeLabel);
if (run.bytes_per_second > 0.0) {
out << ",\n" << indent
<< FormatKV("bytes_per_second", RoundDouble(run.bytes_per_second));
diff --git a/3rdparty/benchmark/src/reporter.cc b/3rdparty/benchmark/src/reporter.cc
index 4b47e3d556c..036546e7669 100644
--- a/3rdparty/benchmark/src/reporter.cc
+++ b/3rdparty/benchmark/src/reporter.cc
@@ -77,6 +77,18 @@ void BenchmarkReporter::ComputeStats(
stddev_data->items_per_second = items_per_second_stat.StdDev();
}
+TimeUnitMultiplier BenchmarkReporter::GetTimeUnitAndMultiplier(TimeUnit unit) {
+ switch (unit) {
+ case kMillisecond:
+ return std::make_pair("ms", 1e3);
+ case kMicrosecond:
+ return std::make_pair("us", 1e6);
+ case kNanosecond:
+ default:
+ return std::make_pair("ns", 1e9);
+ }
+}
+
void BenchmarkReporter::Finalize() {
}
diff --git a/3rdparty/benchmark/test/benchmark_test.cc b/3rdparty/benchmark/test/benchmark_test.cc
index 97abb68fdb8..252602a75f8 100644
--- a/3rdparty/benchmark/test/benchmark_test.cc
+++ b/3rdparty/benchmark/test/benchmark_test.cc
@@ -14,6 +14,8 @@
#include <sstream>
#include <string>
#include <vector>
+#include <chrono>
+#include <thread>
#if defined(__GNUC__)
# define BENCHMARK_NOINLINE __attribute__((noinline))
@@ -174,5 +176,31 @@ static void BM_ParallelMemset(benchmark::State& state) {
}
BENCHMARK(BM_ParallelMemset)->Arg(10 << 20)->ThreadRange(1, 4);
+static void BM_ManualTiming(benchmark::State& state) {
+ size_t slept_for = 0;
+ int microseconds = state.range_x();
+ std::chrono::duration<double, std::micro> sleep_duration {
+ static_cast<double>(microseconds)
+ };
+
+ while (state.KeepRunning()) {
+ auto start = std::chrono::high_resolution_clock::now();
+ // Simulate some useful workload with a sleep
+ std::this_thread::sleep_for(std::chrono::duration_cast<
+ std::chrono::nanoseconds>(sleep_duration));
+ auto end = std::chrono::high_resolution_clock::now();
+
+ auto elapsed =
+ std::chrono::duration_cast<std::chrono::duration<double>>(
+ end - start);
+
+ state.SetIterationTime(elapsed.count());
+ slept_for += microseconds;
+ }
+ state.SetItemsProcessed(slept_for);
+}
+BENCHMARK(BM_ManualTiming)->Range(1, 1 << 14)->UseRealTime();
+BENCHMARK(BM_ManualTiming)->Range(1, 1 << 14)->UseManualTime();
+
BENCHMARK_MAIN()
diff --git a/3rdparty/benchmark/test/options_test.cc b/3rdparty/benchmark/test/options_test.cc
index d4c682d4ece..4737caa2e4c 100644
--- a/3rdparty/benchmark/test/options_test.cc
+++ b/3rdparty/benchmark/test/options_test.cc
@@ -1,11 +1,27 @@
#include "benchmark/benchmark_api.h"
+#include <chrono>
+#include <thread>
+
void BM_basic(benchmark::State& state) {
while (state.KeepRunning()) {
}
}
+
+void BM_basic_slow(benchmark::State& state) {
+ std::chrono::milliseconds sleep_duration(state.range_x());
+ while (state.KeepRunning()) {
+ std::this_thread::sleep_for(
+ std::chrono::duration_cast<std::chrono::nanoseconds>(sleep_duration)
+ );
+ }
+}
+
BENCHMARK(BM_basic);
BENCHMARK(BM_basic)->Arg(42);
+BENCHMARK(BM_basic_slow)->Arg(10)->Unit(benchmark::kNanosecond);
+BENCHMARK(BM_basic_slow)->Arg(100)->Unit(benchmark::kMicrosecond);
+BENCHMARK(BM_basic_slow)->Arg(1000)->Unit(benchmark::kMillisecond);
BENCHMARK(BM_basic)->Range(1, 8);
BENCHMARK(BM_basic)->DenseRange(10, 15);
BENCHMARK(BM_basic)->ArgPair(42, 42);
diff --git a/3rdparty/bgfx/.editorconfig b/3rdparty/bgfx/.editorconfig
index 350f2a6e82c..4fa189592fd 100644
--- a/3rdparty/bgfx/.editorconfig
+++ b/3rdparty/bgfx/.editorconfig
@@ -11,6 +11,9 @@ trim_trailing_whitespace = true
[include/bgfx/c99/*.h]
indent_style = space
+[*.ninja]
+indent_style = space
+
[*.md]
trim_trailing_whitespace = false
max_line_length = 80
diff --git a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp
index 51d5acb4d3b..9a89ac21186 100644
--- a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp
+++ b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp
@@ -20,12 +20,14 @@
- How can I help?
- How do I update to a newer version of ImGui?
- What is ImTextureID and how do I display an image?
- - Can I have multiple widgets with the same label? Can I have widget without a label? (Yes) / A primer on the use of labels/IDs in ImGui.
- I integrated ImGui in my engine and the text or lines are blurry..
- I integrated ImGui in my engine and some elements are clipping or disappearing when I move windows around..
+ - How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on the purpose of labels/IDs.
+ - How can I tell when ImGui wants my mouse/keyboard inputs and when I can pass them to my application?
- How can I load a different font than the default?
- How can I load multiple fonts?
- How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?
+ - How can I use the drawing facilities without an ImGui window? (using ImDrawList API)
- ISSUES & TODO-LIST
- CODE
@@ -53,7 +55,7 @@
==============
- double-click title bar to collapse window
- - click upper right corner to close a window, available when 'bool* p_opened' is passed to ImGui::Begin()
+ - click upper right corner to close a window, available when 'bool* p_open' is passed to ImGui::Begin()
- click and drag on lower right corner to resize window
- click and drag on any empty space to move window
- double-click/double-tap on lower right corner grip to auto-fit to content
@@ -78,7 +80,7 @@
- read the FAQ below this section!
- your code creates the UI, if your code doesn't run the UI is gone! == very dynamic UI, no construction/destructions steps, less data retention on your side, no state duplication, less sync, less bugs.
- call and read ImGui::ShowTestWindow() for demo code demonstrating most features.
- - see examples/ folder for standalone sample applications. Prefer reading examples/opengl_example/ first at it is the simplest.
+ - see examples/ folder for standalone sample applications. Prefer reading examples/opengl_example/ first as it is the simplest.
you may be able to grab and copy a ready made imgui_impl_*** file from the examples/.
- customization: PushStyleColor()/PushStyleVar() or the style editor to tweak the look of the interface (e.g. if you want a more compact UI or a different color scheme).
@@ -140,9 +142,8 @@
SwapBuffers();
}
- - after calling ImGui::NewFrame() you can read back flags from the IO structure to tell how ImGui intends to use your inputs.
- When 'io.WantCaptureMouse' or 'io.WantCaptureKeyboard' flags are set you may want to discard/hide the inputs from the rest of your application.
- When 'io.WantInputsCharacters' is set to may want to notify your OS to popup an on-screen keyboard, if available.
+ - You can read back 'io.WantCaptureMouse', 'io.WantCaptureKeybord' etc. flags from the IO structure to tell how ImGui intends to use your
+ inputs and to know if you should share them or hide them from the rest of your application. Read the FAQ below for more information.
API BREAKING CHANGES
@@ -152,6 +153,8 @@
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
+ - 2016/05/07 (1.49) - removed confusing set of GetInternalState(), GetInternalStateSize(), SetInternalState() functions. Now using CreateContext(), DestroyContext(), GetCurrentContext(), SetCurrentContext().
+ - 2016/05/02 (1.49) - renamed SetNextTreeNodeOpened() to SetNextTreeNodeOpen(), no redirection.
- 2016/05/01 (1.49) - obsoleted old signature of CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false) as extra parameters were badly designed and rarely used. You can replace the "default_open = true" flag in new API with CollapsingHeader(label, ImGuiTreeNodeFlags_DefaultOpen).
- 2016/04/26 (1.49) - changed ImDrawList::PushClipRect(ImVec4 rect) to ImDraw::PushClipRect(Imvec2 min,ImVec2 max,bool intersect_with_current_clip_rect=false). Note that higher-level ImGui::PushClipRect() is preferable because it will clip at logic/widget level, whereas ImDrawList::PushClipRect() only affect your renderer.
- 2016/04/03 (1.48) - removed style.WindowFillAlphaDefault setting which was redundant. Bake default BG alpha inside style.Colors[ImGuiCol_WindowBg] and all other Bg color values. (ref github issue #337).
@@ -196,7 +199,7 @@
- 2015/05/31 (1.40) - renamed GetWindowCollapsed() to IsWindowCollapsed() for consistency. Kept inline redirection function (will obsolete).
- 2015/05/31 (1.40) - renamed IsRectClipped() to IsRectVisible() for consistency. Note that return value is opposite! Kept inline redirection function (will obsolete).
- 2015/05/27 (1.40) - removed the third 'repeat_if_held' parameter from Button() - sorry! it was rarely used and inconsistent. Use PushButtonRepeat(true) / PopButtonRepeat() to enable repeat on desired buttons.
- - 2015/05/11 (1.40) - changed BeginPopup() API, takes a string identifier instead of a bool. ImGui needs to manage the open/closed state of popups. Call OpenPopup() to actually set the "opened" state of a popup. BeginPopup() returns true if the popup is opened.
+ - 2015/05/11 (1.40) - changed BeginPopup() API, takes a string identifier instead of a bool. ImGui needs to manage the open/closed state of popups. Call OpenPopup() to actually set the "open" state of a popup. BeginPopup() returns true if the popup is opened.
- 2015/05/03 (1.40) - removed style.AutoFitPadding, using style.WindowPadding makes more sense (the default values were already the same).
- 2015/04/13 (1.38) - renamed IsClipped() to IsRectClipped(). Kept inline redirection function (will obsolete).
- 2015/04/09 (1.38) - renamed ImDrawList::AddArc() to ImDrawList::AddArcFast() for compatibility with future API
@@ -277,6 +280,13 @@
ImGui will generate the geometry and draw calls using the ImTextureID that you passed and which your renderer can use.
It is your responsibility to get textures uploaded to your GPU.
+ Q: I integrated ImGui in my engine and the text or lines are blurry..
+ A: In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f).
+ Also make sure your orthographic projection matrix and io.DisplaySize matches your actual framebuffer dimension.
+
+ Q: I integrated ImGui in my engine and some elements are clipping or disappearing when I move windows around..
+ A: Most likely you are mishandling the clipping rectangles in your render function. Rectangles provided by ImGui are defined as (x1,y1,x2,y2) and NOT as (x1,y1,width,height).
+
Q: Can I have multiple widgets with the same label? Can I have widget without a label? (Yes)
A: Yes. A primer on the use of labels/IDs in ImGui..
@@ -365,17 +375,16 @@
TreePop();
}
- - When working with trees, ID are used to preserve the opened/closed state of each tree node.
+ - When working with trees, ID are used to preserve the open/close state of each tree node.
Depending on your use cases you may want to use strings, indices or pointers as ID.
e.g. when displaying a single object that may change over time (1-1 relationship), using a static string as ID will preserve your node open/closed state when the targeted object change.
e.g. when displaying a list of objects, using indices or pointers as ID will preserve the node open/closed state differently. experiment and see what makes more sense!
- Q: I integrated ImGui in my engine and the text or lines are blurry..
- A: In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f).
- Also make sure your orthographic projection matrix and io.DisplaySize matches your actual framebuffer dimension.
-
- Q: I integrated ImGui in my engine and some elements are clipping or disappearing when I move windows around..
- A: Most likely you are mishandling the clipping rectangles in your render function. Rectangles provided by ImGui are defined as (x1,y1,x2,y2) and NOT as (x1,y1,width,height).
+ Q: How can I tell when ImGui wants my mouse/keyboard inputs and when I can pass them to my application?
+ A: You can read the 'io.WantCaptureXXX' flags in the ImGuiIO structure. Preferably read them after calling ImGui::NewFrame() to avoid those flags lagging by one frame.
+ When 'io.WantCaptureMouse' or 'io.WantCaptureKeyboard' flags are set you may want to discard/hide the inputs from the rest of your application.
+ When 'io.WantInputsCharacters' is set to may want to notify your OS to popup an on-screen keyboard, if available.
+ ImGui is tracking dragging and widget activity that may occur outside the boundary of a window, so 'io.WantCaptureMouse' is a more accurate and complete than testing for ImGui::IsMouseHoveringAnyWindow().
Q: How can I load a different font than the default? (default is an embedded version of ProggyClean.ttf, rendered at size 13)
A: Use the font atlas to load the TTF file you want:
@@ -413,7 +422,7 @@
Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic?
A: When loading a font, pass custom Unicode ranges to specify the glyphs to load.
- All strings passed need to use UTF-8 encoding. Specifying literal in your source code using a local code page (such as CP-923 for Japanese CP-1251 for Cyrillic) will not work.
+ All your strings needs to use UTF-8 encoding. Specifying literal in your source code using a local code page (such as CP-923 for Japanese or CP-1251 for Cyrillic) will not work.
In C++11 you can encode a string literal in UTF-8 by using the u8"hello" syntax. Otherwise you can convert yourself to UTF-8 or load text data from file already saved as UTF-8.
You can also try to remap your local codepage characters to their Unicode codepoint using font->AddRemapChar(), but international users may have problems reading/editing your source code.
@@ -423,6 +432,10 @@
As for text input, depends on you passing the right character code to io.AddInputCharacter(). The example applications do that.
+ Q: How can I use the drawing facilities without an ImGui window? (using ImDrawList API)
+ A: The easiest way is to create a dummy window. Call Begin() with NoTitleBar|NoResize|NoMove|NoScrollbar|NoSavedSettings|NoInputs flag, zero background alpha,
+ then retrieve the ImDrawList* via GetWindowDrawList() and draw to it in any way you like.
+
- tip: the construct 'IMGUI_ONCE_UPON_A_FRAME { ... }' will run the block of code only once a frame. You can use it to quickly add custom UI in the middle of a deep nested inner loop in your code.
- tip: you can create widgets without a Begin()/End() block, they will go in an implicit window called "Debug"
- tip: you can call Begin() multiple times with the same name during the same frame, it will keep appending to the same window. this is also useful to set yourself in the context of another window (to get/set other settings)
@@ -444,7 +457,7 @@
- window: background options for child windows, border option (disable rounding)
- window: add a way to clear an existing window instead of appending (e.g. for tooltip override using a consistent api rather than the deferred tooltip)
- window: resizing from any sides? + mouse cursor directives for app.
-!- window: begin with *p_opened == false should return false.
+!- window: begin with *p_open == false should return false.
- window: get size/pos helpers given names (see discussion in #249)
- window: a collapsed window can be stuck behind the main menu bar?
- window: when window is small, prioritize resize button over close button.
@@ -564,6 +577,7 @@
- style editor: have a more global HSV setter (e.g. alter hue on all elements). consider replacing active/hovered by offset in HSV space? (#438)
- style editor: color child window height expressed in multiple of line height.
- remote: make a system like RemoteImGui first-class citizen/project (#75)
+ - drawlist: move Font, FontSize, FontTexUvWhitePixel inside ImDrawList and make it self-contained (apart from drawing settings?)
- drawlist: end-user probably can't call Clear() directly because we expect a texture to be pushed in the stack.
- examples: directx9: save/restore device state more thoroughly.
- examples: window minimize, maximize (#583)
@@ -596,7 +610,6 @@
#pragma warning (disable: 4127) // condition expression is constant
#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
-#define snprintf _snprintf
#endif
// Clang warnings with -Weverything
@@ -611,10 +624,13 @@
#pragma clang diagnostic ignored "-Wdeprecated-declarations"// warning : 'xx' is deprecated: The POSIX name for this item.. // for strdup used in demo code (so user can copy & paste the code)
#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int'
#pragma clang diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
-#endif
-#ifdef __GNUC__
+#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int' //
+#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size
+#pragma GCC diagnostic ignored "-Wformat" // warning: format '%p' expects argument of type 'void*', but argument 6 has type 'ImGuiWindow*'
+#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
+#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
#endif
//-------------------------------------------------------------------------
@@ -634,7 +650,6 @@ static void SetWindowScrollY(ImGuiWindow* window, float new_scroll_y
static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiSetCond cond);
static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiSetCond cond);
static void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiSetCond cond);
-ImGuiWindow* FindWindowByName(const char* name);
static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs);
static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags);
static inline bool IsWindowContentHoverable(ImGuiWindow* window);
@@ -684,15 +699,15 @@ static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y);
// Context
//-----------------------------------------------------------------------------
-// We access everything through this pointer (always assumed to be != NULL)
-// You can swap the pointer to a different context by calling ImGui::SetInternalState()
-static ImGuiState GImDefaultState;
-ImGuiState* GImGui = &GImDefaultState;
-
-// Statically allocated default font atlas. This is merely a maneuver to keep ImFontAtlas definition at the bottom of the .h file (otherwise it'd be inside ImGuiIO)
-// Also we wouldn't be able to new() one at this point, before users may define IO.MemAllocFn.
+// Default context, default font atlas.
+// New contexts always point by default to this font atlas. It can be changed by reassigning the GetIO().Fonts variable.
+static ImGuiContext GImDefaultContext;
static ImFontAtlas GImDefaultFontAtlas;
+// Current context pointer. Implicitely used by all ImGui functions. Always assumed to be != NULL. Change to a different context by calling ImGui::SetCurrentContext()
+// ImGui is currently not thread-safe because of this variable. If you want thread-safety to allow N threads to access N different contexts, you might work around it by (A) having two instances of the ImGui code under different namespaces or (B) change this variable to be TLS. Further development aim to make this context pointer explicit to all calls. Also read https://github.com/ocornut/imgui/issues/586
+ImGuiContext* GImGui = &GImDefaultContext;
+
//-----------------------------------------------------------------------------
// User facing structures
//-----------------------------------------------------------------------------
@@ -1304,6 +1319,11 @@ int ImGuiStorage::GetInt(ImU32 key, int default_val) const
return it->val_i;
}
+bool ImGuiStorage::GetBool(ImU32 key, bool default_val) const
+{
+ return GetInt(key, default_val ? 1 : 0) != 0;
+}
+
float ImGuiStorage::GetFloat(ImU32 key, float default_val) const
{
ImVector<Pair>::iterator it = LowerBound(const_cast<ImVector<ImGuiStorage::Pair>&>(Data), key);
@@ -1329,6 +1349,11 @@ int* ImGuiStorage::GetIntRef(ImGuiID key, int default_val)
return &it->val_i;
}
+bool* ImGuiStorage::GetBoolRef(ImGuiID key, bool default_val)
+{
+ return (bool*)GetIntRef(key, default_val ? 1 : 0);
+}
+
float* ImGuiStorage::GetFloatRef(ImGuiID key, float default_val)
{
ImVector<Pair>::iterator it = LowerBound(Data, key);
@@ -1357,6 +1382,11 @@ void ImGuiStorage::SetInt(ImU32 key, int val)
it->val_i = val;
}
+void ImGuiStorage::SetBool(ImU32 key, bool val)
+{
+ SetInt(key, val ? 1 : 0);
+}
+
void ImGuiStorage::SetFloat(ImU32 key, float val)
{
ImVector<Pair>::iterator it = LowerBound(Data, key);
@@ -1615,6 +1645,7 @@ ImGuiWindow::ImGuiWindow(const char* name)
DrawList->_OwnerName = Name;
RootWindow = NULL;
RootNonPopupWindow = NULL;
+ ParentWindow = NULL;
FocusIdxAllCounter = FocusIdxTabCounter = -1;
FocusIdxAllRequestCurrent = FocusIdxTabRequestCurrent = IM_INT_MAX;
@@ -1652,7 +1683,7 @@ ImGuiID ImGuiWindow::GetID(const void* ptr)
static void SetCurrentWindow(ImGuiWindow* window)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
g.CurrentWindow = window;
if (window)
g.FontSize = window->CalcFontSize();
@@ -1660,14 +1691,14 @@ static void SetCurrentWindow(ImGuiWindow* window)
ImGuiWindow* ImGui::GetParentWindow()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
IM_ASSERT(g.CurrentWindowStack.Size >= 2);
return g.CurrentWindowStack[(unsigned int)g.CurrentWindowStack.Size - 2];
}
void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window = NULL)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
g.ActiveId = id;
g.ActiveIdAllowOverlap = false;
g.ActiveIdIsJustActivated = true;
@@ -1676,14 +1707,14 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window = NULL)
void ImGui::SetHoveredID(ImGuiID id)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
g.HoveredId = id;
g.HoveredIdAllowOverlap = false;
}
void ImGui::KeepAliveID(ImGuiID id)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (g.ActiveId == id)
g.ActiveIdIsAlive = true;
}
@@ -1696,7 +1727,7 @@ void ImGui::ItemSize(const ImVec2& size, float text_offset_y)
return;
// Always align ourselves on pixel boundaries
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const float line_height = ImMax(window->DC.CurrentLineHeight, size.y);
const float text_base_offset = ImMax(window->DC.CurrentLineTextBaseOffset, text_offset_y);
window->DC.CursorPosPrevLine = ImVec2(window->DC.CursorPos.x + size.x, window->DC.CursorPos.y);
@@ -1729,7 +1760,7 @@ bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id)
return false;
// This is a sensible default, but widgets are free to override it after calling ItemAdd()
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (IsMouseHoveringRect(bb.Min, bb.Max))
{
// Matching the behavior of IsHovered() but allow if ActiveId==window->MoveID (we clicked on the window background)
@@ -1746,7 +1777,7 @@ bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id)
bool ImGui::IsClippedEx(const ImRect& bb, const ImGuiID* id, bool clip_even_when_logged)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindowRead();
if (!bb.Overlaps(window->ClipRect))
@@ -1759,7 +1790,7 @@ bool ImGui::IsClippedEx(const ImRect& bb, const ImGuiID* id, bool clip_even_when
// NB: This is an internal helper. The user-facing IsItemHovered() is using data emitted from ItemAdd(), with a slightly different logic.
bool ImGui::IsHovered(const ImRect& bb, ImGuiID id, bool flatten_childs)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (g.HoveredId == 0 || g.HoveredId == id || g.HoveredIdAllowOverlap)
{
ImGuiWindow* window = GetCurrentWindowRead();
@@ -1773,7 +1804,7 @@ bool ImGui::IsHovered(const ImRect& bb, ImGuiID id, bool flatten_childs)
bool ImGui::FocusableItemRegister(ImGuiWindow* window, bool is_active, bool tab_stop)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const bool allow_keyboard_focus = window->DC.AllowKeyboardFocus;
window->FocusIdxAllCounter++;
@@ -1806,7 +1837,7 @@ void ImGui::FocusableItemUnregister(ImGuiWindow* window)
ImVec2 ImGui::CalcItemSize(ImVec2 size, float default_x, float default_y)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImVec2 content_max;
if (size.x < 0.0f || size.y < 0.0f)
content_max = g.CurrentWindow->Pos + ImGui::GetContentRegionMax();
@@ -1864,21 +1895,33 @@ const char* ImGui::GetVersion()
// Internal state access - if you want to share ImGui state between modules (e.g. DLL) or allocate it yourself
// Note that we still point to some static data and members (such as GFontAtlas), so the state instance you end up using will point to the static data within its module
-void* ImGui::GetInternalState()
+ImGuiContext* ImGui::GetCurrentContext()
{
return GImGui;
}
-size_t ImGui::GetInternalStateSize()
+void ImGui::SetCurrentContext(ImGuiContext* ctx)
{
- return sizeof(ImGuiState);
+ GImGui = ctx;
}
-void ImGui::SetInternalState(void* state, bool construct)
+ImGuiContext* ImGui::CreateContext(void* (*malloc_fn)(size_t), void (*free_fn)(void*))
{
- if (construct)
- IM_PLACEMENT_NEW(state) ImGuiState();
- GImGui = (ImGuiState*)state;
+ if (!malloc_fn) malloc_fn = malloc;
+ ImGuiContext* ctx = (ImGuiContext*)malloc_fn(sizeof(ImGuiContext));
+ IM_PLACEMENT_NEW(ctx) ImGuiContext();
+ ctx->IO.MemAllocFn = malloc_fn;
+ ctx->IO.MemFreeFn = free_fn ? free_fn : free;
+ return ctx;
+}
+
+void ImGui::DestroyContext(ImGuiContext* ctx)
+{
+ void (*free_fn)(void*) = ctx->IO.MemFreeFn;
+ ctx->~ImGuiContext();
+ free_fn(ctx);
+ if (GImGui == ctx)
+ GImGui = NULL;
}
ImGuiIO& ImGui::GetIO()
@@ -1909,7 +1952,7 @@ int ImGui::GetFrameCount()
void ImGui::NewFrame()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
// Check user data
IM_ASSERT(g.IO.DeltaTime >= 0.0f); // Need a positive DeltaTime (zero is tolerated but will cause some timing issues)
@@ -1998,8 +2041,35 @@ void ImGui::NewFrame()
g.ActiveIdPreviousFrame = g.ActiveId;
g.ActiveIdIsAlive = false;
g.ActiveIdIsJustActivated = false;
- if (!g.ActiveId)
+
+ // Handle user moving window (at the beginning of the frame to avoid input lag or sheering). Only valid for root windows.
+ if (g.MovedWindowMoveId && g.MovedWindowMoveId == g.ActiveId)
+ {
+ KeepAliveID(g.MovedWindowMoveId);
+ IM_ASSERT(g.MovedWindow && g.MovedWindow->RootWindow);
+ IM_ASSERT(g.MovedWindow->RootWindow->MoveID == g.MovedWindowMoveId);
+ if (g.IO.MouseDown[0])
+ {
+ if (!(g.MovedWindow->Flags & ImGuiWindowFlags_NoMove))
+ {
+ g.MovedWindow->PosFloat += g.IO.MouseDelta;
+ if (!(g.MovedWindow->Flags & ImGuiWindowFlags_NoSavedSettings))
+ MarkSettingsDirty();
+ }
+ FocusWindow(g.MovedWindow);
+ }
+ else
+ {
+ SetActiveID(0);
+ g.MovedWindow = NULL;
+ g.MovedWindowMoveId = 0;
+ }
+ }
+ else
+ {
g.MovedWindow = NULL;
+ g.MovedWindowMoveId = 0;
+ }
// Delay saving settings so we don't spam disk too much
if (g.SettingsDirtyTimer > 0.0f)
@@ -2010,16 +2080,19 @@ void ImGui::NewFrame()
}
// Find the window we are hovering. Child windows can extend beyond the limit of their parent so we need to derive HoveredRootWindow from HoveredWindow
- g.HoveredWindow = FindHoveredWindow(g.IO.MousePos, false);
+ g.HoveredWindow = g.MovedWindow ? g.MovedWindow : FindHoveredWindow(g.IO.MousePos, false);
if (g.HoveredWindow && (g.HoveredWindow->Flags & ImGuiWindowFlags_ChildWindow))
g.HoveredRootWindow = g.HoveredWindow->RootWindow;
else
- g.HoveredRootWindow = FindHoveredWindow(g.IO.MousePos, true);
+ g.HoveredRootWindow = g.MovedWindow ? g.MovedWindow->RootWindow : FindHoveredWindow(g.IO.MousePos, true);
if (ImGuiWindow* modal_window = GetFrontMostModalRootWindow())
{
g.ModalWindowDarkeningRatio = ImMin(g.ModalWindowDarkeningRatio + g.IO.DeltaTime * 6.0f, 1.0f);
- if (g.HoveredRootWindow != modal_window)
+ ImGuiWindow* window = g.HoveredRootWindow;
+ while (window && window != modal_window)
+ window = window->ParentWindow;
+ if (!window)
g.HoveredRootWindow = g.HoveredWindow = NULL;
}
else
@@ -2034,7 +2107,7 @@ void ImGui::NewFrame()
for (int i = 0; i < IM_ARRAYSIZE(g.IO.MouseDown); i++)
{
if (g.IO.MouseClicked[i])
- g.IO.MouseDownOwned[i] = (g.HoveredWindow != NULL) || (!g.OpenedPopupStack.empty());
+ g.IO.MouseDownOwned[i] = (g.HoveredWindow != NULL) || (!g.OpenPopupStack.empty());
mouse_any_down |= g.IO.MouseDown[i];
if (g.IO.MouseDown[i])
if (mouse_earliest_button_down == -1 || g.IO.MouseClickedTime[mouse_earliest_button_down] > g.IO.MouseClickedTime[i])
@@ -2044,7 +2117,7 @@ void ImGui::NewFrame()
if (g.CaptureMouseNextFrame != -1)
g.IO.WantCaptureMouse = (g.CaptureMouseNextFrame != 0);
else
- g.IO.WantCaptureMouse = (mouse_avail_to_imgui && (g.HoveredWindow != NULL || mouse_any_down)) || (g.ActiveId != 0) || (!g.OpenedPopupStack.empty());
+ g.IO.WantCaptureMouse = (mouse_avail_to_imgui && (g.HoveredWindow != NULL || mouse_any_down)) || (g.ActiveId != 0) || (!g.OpenPopupStack.empty());
g.IO.WantCaptureKeyboard = (g.CaptureKeyboardNextFrame != -1) ? (g.CaptureKeyboardNextFrame != 0) : (g.ActiveId != 0);
g.IO.WantTextInput = (g.ActiveId != 0 && g.InputTextState.Id == g.ActiveId);
g.MouseCursor = ImGuiMouseCursor_Arrow;
@@ -2114,7 +2187,7 @@ void ImGui::NewFrame()
// NB: behavior of ImGui after Shutdown() is not tested/guaranteed at the moment. This function is merely here to free heap allocations.
void ImGui::Shutdown()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
// The fonts atlas can be used prior to calling NewFrame(), so we clear it even if g.Initialized is FALSE (which would happen if we never called NewFrame)
if (g.IO.Fonts) // Testing for NULL to allow user to NULLify in case of running Shutdown() on multiple contexts. Bit hacky.
@@ -2143,7 +2216,7 @@ void ImGui::Shutdown()
g.ColorModifiers.clear();
g.StyleModifiers.clear();
g.FontStack.clear();
- g.OpenedPopupStack.clear();
+ g.OpenPopupStack.clear();
g.CurrentPopupStack.clear();
for (int i = 0; i < IM_ARRAYSIZE(g.RenderDrawLists); i++)
g.RenderDrawLists[i].clear();
@@ -2174,7 +2247,7 @@ void ImGui::Shutdown()
static ImGuiIniData* FindWindowSettings(const char* name)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiID id = ImHash(name, 0);
for (int i = 0; i != g.Settings.Size; i++)
{
@@ -2201,7 +2274,7 @@ static ImGuiIniData* AddWindowSettings(const char* name)
// FIXME: Write something less rubbish
static void LoadSettings()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const char* filename = g.IO.IniFilename;
if (!filename)
return;
@@ -2247,7 +2320,7 @@ static void LoadSettings()
static void SaveSettings()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const char* filename = g.IO.IniFilename;
if (!filename)
return;
@@ -2289,7 +2362,7 @@ static void SaveSettings()
static void MarkSettingsDirty()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (g.SettingsDirtyTimer <= 0.0f)
g.SettingsDirtyTimer = g.IO.IniSavingRate;
}
@@ -2385,7 +2458,7 @@ void ImGui::PopClipRect()
// This is normally called by Render(). You may want to call it directly if you want to avoid calling Render() but the gain will be very minimal.
void ImGui::EndFrame()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
IM_ASSERT(g.Initialized); // Forgot to call ImGui::NewFrame()
IM_ASSERT(g.FrameCountEnded != g.FrameCount); // ImGui::EndFrame() called multiple times, or forgot to call ImGui::NewFrame() again
@@ -2411,8 +2484,6 @@ void ImGui::EndFrame()
ImGui::End();
// Click to focus window and start moving (after we're done with all our widgets)
- if (!g.ActiveId)
- g.MovedWindow = NULL;
if (g.ActiveId == 0 && g.HoveredId == 0 && g.IO.MouseClicked[0])
{
if (!(g.FocusedWindow && !g.FocusedWindow->WasActive && g.FocusedWindow->Active)) // Unless we just made a popup appear
@@ -2423,7 +2494,8 @@ void ImGui::EndFrame()
if (!(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove))
{
g.MovedWindow = g.HoveredWindow;
- SetActiveID(g.HoveredRootWindow->MoveID, g.HoveredRootWindow);
+ g.MovedWindowMoveId = g.HoveredRootWindow->MoveID;
+ SetActiveID(g.MovedWindowMoveId, g.HoveredRootWindow);
}
}
else if (g.FocusedWindow != NULL && GetFrontMostModalRootWindow() == NULL)
@@ -2457,7 +2529,7 @@ void ImGui::EndFrame()
void ImGui::Render()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
IM_ASSERT(g.Initialized); // Forgot to call ImGui::NewFrame()
if (g.FrameCountEnded != g.FrameCount)
@@ -2547,7 +2619,7 @@ const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end)
// Pass text data straight to log (without being displayed)
void ImGui::LogText(const char* fmt, ...)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (!g.LogEnabled)
return;
@@ -2568,7 +2640,7 @@ void ImGui::LogText(const char* fmt, ...)
// We split text into individual lines to add current tree level padding
static void LogRenderedText(const ImVec2& ref_pos, const char* text, const char* text_end)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = ImGui::GetCurrentWindowRead();
if (!text_end)
@@ -2619,7 +2691,7 @@ static void LogRenderedText(const ImVec2& ref_pos, const char* text, const char*
// RenderText***() functions calls ImDrawList::AddText() calls ImBitmapFont::RenderText()
void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool hide_text_after_hash)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
// Hide anything after a '##' string
@@ -2646,7 +2718,7 @@ void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool
void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
if (!text_end)
@@ -2670,7 +2742,7 @@ void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, cons
if (text_len == 0)
return;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
// Perform CPU side clipping for single clipped element to avoid using scissor state
@@ -2714,9 +2786,9 @@ void ImGui::RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border,
}
// Render a triangle to denote expanded/collapsed state
-void ImGui::RenderCollapseTriangle(ImVec2 p_min, bool opened, float scale, bool shadow)
+void ImGui::RenderCollapseTriangle(ImVec2 p_min, bool is_open, float scale, bool shadow)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
const float h = g.FontSize * 1.00f;
@@ -2724,7 +2796,7 @@ void ImGui::RenderCollapseTriangle(ImVec2 p_min, bool opened, float scale, bool
ImVec2 center = p_min + ImVec2(h*0.50f, h*0.50f*scale);
ImVec2 a, b, c;
- if (opened)
+ if (is_open)
{
center.y -= r*0.25f;
a = center + ImVec2(0,1)*r;
@@ -2751,7 +2823,7 @@ void ImGui::RenderBullet(ImVec2 pos)
void ImGui::RenderCheckMark(ImVec2 pos, ImU32 col)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
ImVec2 a, b, c;
@@ -2774,7 +2846,7 @@ void ImGui::RenderCheckMark(ImVec2 pos, ImU32 col)
// CalcTextSize("") should return ImVec2(0.0f, GImGui->FontSize)
ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const char* text_display_end;
if (hide_text_after_double_hash)
@@ -2813,7 +2885,7 @@ ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_tex
// }
void ImGui::CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindowRead();
if (g.LogEnabled)
{
@@ -2833,9 +2905,10 @@ void ImGui::CalcListClipping(int items_count, float items_height, int* out_items
}
// Find window given position, search front-to-back
+// FIXME: Note that we have a lag here because WindowRectClipped is updated in Begin() so windows moved by user via SetWindowPos() and not SetNextWindowPos() will have that rectangle lagging by a frame at the time FindHoveredWindow() is called, aka before the next Begin(). Moving window thankfully isn't affected.
static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
for (int i = g.Windows.Size-1; i >= 0; i--)
{
ImGuiWindow* window = g.Windows[i];
@@ -2847,7 +2920,7 @@ static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs)
continue;
// Using the clipped AABB so a child window will typically be clipped by its parent.
- ImRect bb(window->ClippedWindowRect.Min - g.Style.TouchExtraPadding, window->ClippedWindowRect.Max + g.Style.TouchExtraPadding);
+ ImRect bb(window->WindowRectClipped.Min - g.Style.TouchExtraPadding, window->WindowRectClipped.Max + g.Style.TouchExtraPadding);
if (bb.Contains(pos))
return window;
}
@@ -2859,7 +2932,7 @@ static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs)
// NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding)
bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindowRead();
// Clip
@@ -2874,13 +2947,13 @@ bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool c
bool ImGui::IsMouseHoveringWindow()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
return g.HoveredWindow == g.CurrentWindow;
}
bool ImGui::IsMouseHoveringAnyWindow()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
return g.HoveredWindow != NULL;
}
@@ -2910,7 +2983,7 @@ bool ImGui::IsKeyDown(int key_index)
bool ImGui::IsKeyPressed(int key_index, bool repeat)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (key_index < 0) return false;
IM_ASSERT(key_index >= 0 && key_index < IM_ARRAYSIZE(g.IO.KeysDown));
const float t = g.IO.KeysDownDuration[key_index];
@@ -2928,7 +3001,7 @@ bool ImGui::IsKeyPressed(int key_index, bool repeat)
bool ImGui::IsKeyReleased(int key_index)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (key_index < 0) return false;
IM_ASSERT(key_index >= 0 && key_index < IM_ARRAYSIZE(g.IO.KeysDown));
if (g.IO.KeysDownDurationPrev[key_index] >= 0.0f && !g.IO.KeysDown[key_index])
@@ -2938,14 +3011,14 @@ bool ImGui::IsKeyReleased(int key_index)
bool ImGui::IsMouseDown(int button)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
return g.IO.MouseDown[button];
}
bool ImGui::IsMouseClicked(int button, bool repeat)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
const float t = g.IO.MouseDownDuration[button];
if (t == 0.0f)
@@ -2963,21 +3036,21 @@ bool ImGui::IsMouseClicked(int button, bool repeat)
bool ImGui::IsMouseReleased(int button)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
return g.IO.MouseReleased[button];
}
bool ImGui::IsMouseDoubleClicked(int button)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
return g.IO.MouseDoubleClicked[button];
}
bool ImGui::IsMouseDragging(int button, float lock_threshold)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
if (!g.IO.MouseDown[button])
return false;
@@ -2994,15 +3067,15 @@ ImVec2 ImGui::GetMousePos()
// NB: prefer to call right after BeginPopup(). At the time Selectable/MenuItem is activated, the popup is already closed!
ImVec2 ImGui::GetMousePosOnOpeningCurrentPopup()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (g.CurrentPopupStack.Size > 0)
- return g.OpenedPopupStack[g.CurrentPopupStack.Size-1].MousePosOnOpen;
+ return g.OpenPopupStack[g.CurrentPopupStack.Size-1].MousePosOnOpen;
return g.IO.MousePos;
}
ImVec2 ImGui::GetMouseDragDelta(int button, float lock_threshold)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
if (lock_threshold < 0.0f)
lock_threshold = g.IO.MouseDragThreshold;
@@ -3014,7 +3087,7 @@ ImVec2 ImGui::GetMouseDragDelta(int button, float lock_threshold)
void ImGui::ResetMouseDragDelta(int button)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
// NB: We don't need to reset g.IO.MouseDragMaxDistanceSqr
g.IO.MouseClickedPos[button] = g.IO.MousePos;
@@ -3054,7 +3127,7 @@ bool ImGui::IsItemHoveredRect()
bool ImGui::IsItemActive()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (g.ActiveId)
{
ImGuiWindow* window = GetCurrentWindowRead();
@@ -3088,7 +3161,7 @@ bool ImGui::IsItemVisible()
// Allow last item to be overlapped by a subsequent item. Both may be activated during the same frame before the later one takes priority.
void ImGui::SetItemAllowOverlap()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (g.HoveredId == g.CurrentWindow->DC.LastItemID)
g.HoveredIdAllowOverlap = true;
if (g.ActiveId == g.CurrentWindow->DC.LastItemID)
@@ -3124,7 +3197,7 @@ ImVec2 ImGui::CalcItemRectClosestPoint(const ImVec2& pos, bool on_edge, float ou
// Tooltip is stored and turned into a BeginTooltip()/EndTooltip() sequence at the end of the frame. Each call override previous value.
void ImGui::SetTooltipV(const char* fmt, va_list args)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImFormatStringV(g.Tooltip, IM_ARRAYSIZE(g.Tooltip), fmt, args);
}
@@ -3138,7 +3211,7 @@ void ImGui::SetTooltip(const char* fmt, ...)
static ImRect GetVisibleRect()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (g.IO.DisplayVisibleMin.x != g.IO.DisplayVisibleMax.x && g.IO.DisplayVisibleMin.y != g.IO.DisplayVisibleMax.y)
return ImRect(g.IO.DisplayVisibleMin, g.IO.DisplayVisibleMax);
return ImRect(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y);
@@ -3158,9 +3231,9 @@ void ImGui::EndTooltip()
static bool IsPopupOpen(ImGuiID id)
{
- ImGuiState& g = *GImGui;
- const bool opened = g.OpenedPopupStack.Size > g.CurrentPopupStack.Size && g.OpenedPopupStack[g.CurrentPopupStack.Size].PopupID == id;
- return opened;
+ ImGuiContext& g = *GImGui;
+ const bool is_open = g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].PopupID == id;
+ return is_open;
}
// Mark popup as open (toggle toward open state).
@@ -3169,17 +3242,17 @@ static bool IsPopupOpen(ImGuiID id)
// One open popup per level of the popup hierarchy (NB: when assigning we reset the Window member of ImGuiPopupRef to NULL)
void ImGui::OpenPopupEx(const char* str_id, bool reopen_existing)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
ImGuiID id = window->GetID(str_id);
int current_stack_size = g.CurrentPopupStack.Size;
ImGuiPopupRef popup_ref = ImGuiPopupRef(id, window, window->GetID("##menus"), g.IO.MousePos); // Tagged as new ref because constructor sets Window to NULL (we are passing the ParentWindow info here)
- if (g.OpenedPopupStack.Size < current_stack_size + 1)
- g.OpenedPopupStack.push_back(popup_ref);
- else if (reopen_existing || g.OpenedPopupStack[current_stack_size].PopupID != id)
+ if (g.OpenPopupStack.Size < current_stack_size + 1)
+ g.OpenPopupStack.push_back(popup_ref);
+ else if (reopen_existing || g.OpenPopupStack[current_stack_size].PopupID != id)
{
- g.OpenedPopupStack.resize(current_stack_size+1);
- g.OpenedPopupStack[current_stack_size] = popup_ref;
+ g.OpenPopupStack.resize(current_stack_size+1);
+ g.OpenPopupStack[current_stack_size] = popup_ref;
}
}
@@ -3190,8 +3263,8 @@ void ImGui::OpenPopup(const char* str_id)
static void CloseInactivePopups()
{
- ImGuiState& g = *GImGui;
- if (g.OpenedPopupStack.empty())
+ ImGuiContext& g = *GImGui;
+ if (g.OpenPopupStack.empty())
return;
// When popups are stacked, clicking on a lower level popups puts focus back to it and close popups above it.
@@ -3199,9 +3272,9 @@ static void CloseInactivePopups()
int n = 0;
if (g.FocusedWindow)
{
- for (n = 0; n < g.OpenedPopupStack.Size; n++)
+ for (n = 0; n < g.OpenPopupStack.Size; n++)
{
- ImGuiPopupRef& popup = g.OpenedPopupStack[n];
+ ImGuiPopupRef& popup = g.OpenPopupStack[n];
if (!popup.Window)
continue;
IM_ASSERT((popup.Window->Flags & ImGuiWindowFlags_Popup) != 0);
@@ -3209,21 +3282,21 @@ static void CloseInactivePopups()
continue;
bool has_focus = false;
- for (int m = n; m < g.OpenedPopupStack.Size && !has_focus; m++)
- has_focus = (g.OpenedPopupStack[m].Window && g.OpenedPopupStack[m].Window->RootWindow == g.FocusedWindow->RootWindow);
+ for (int m = n; m < g.OpenPopupStack.Size && !has_focus; m++)
+ has_focus = (g.OpenPopupStack[m].Window && g.OpenPopupStack[m].Window->RootWindow == g.FocusedWindow->RootWindow);
if (!has_focus)
break;
}
}
- if (n < g.OpenedPopupStack.Size) // This test is not required but it allows to set a useful breakpoint on the line below
- g.OpenedPopupStack.resize(n);
+ if (n < g.OpenPopupStack.Size) // This test is not required but it allows to set a useful breakpoint on the line below
+ g.OpenPopupStack.resize(n);
}
static ImGuiWindow* GetFrontMostModalRootWindow()
{
- ImGuiState& g = *GImGui;
- for (int n = g.OpenedPopupStack.Size-1; n >= 0; n--)
- if (ImGuiWindow* front_most_popup = g.OpenedPopupStack.Data[n].Window)
+ ImGuiContext& g = *GImGui;
+ for (int n = g.OpenPopupStack.Size-1; n >= 0; n--)
+ if (ImGuiWindow* front_most_popup = g.OpenPopupStack.Data[n].Window)
if (front_most_popup->Flags & ImGuiWindowFlags_Modal)
return front_most_popup;
return NULL;
@@ -3231,44 +3304,44 @@ static ImGuiWindow* GetFrontMostModalRootWindow()
static void ClosePopupToLevel(int remaining)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (remaining > 0)
- ImGui::FocusWindow(g.OpenedPopupStack[remaining-1].Window);
+ ImGui::FocusWindow(g.OpenPopupStack[remaining-1].Window);
else
- ImGui::FocusWindow(g.OpenedPopupStack[0].ParentWindow);
- g.OpenedPopupStack.resize(remaining);
+ ImGui::FocusWindow(g.OpenPopupStack[0].ParentWindow);
+ g.OpenPopupStack.resize(remaining);
}
static void ClosePopup(ImGuiID id)
{
if (!IsPopupOpen(id))
return;
- ImGuiState& g = *GImGui;
- ClosePopupToLevel(g.OpenedPopupStack.Size - 1);
+ ImGuiContext& g = *GImGui;
+ ClosePopupToLevel(g.OpenPopupStack.Size - 1);
}
// Close the popup we have begin-ed into.
void ImGui::CloseCurrentPopup()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
int popup_idx = g.CurrentPopupStack.Size - 1;
- if (popup_idx < 0 || popup_idx > g.OpenedPopupStack.Size || g.CurrentPopupStack[popup_idx].PopupID != g.OpenedPopupStack[popup_idx].PopupID)
+ if (popup_idx < 0 || popup_idx > g.OpenPopupStack.Size || g.CurrentPopupStack[popup_idx].PopupID != g.OpenPopupStack[popup_idx].PopupID)
return;
- while (popup_idx > 0 && g.OpenedPopupStack[popup_idx].Window && (g.OpenedPopupStack[popup_idx].Window->Flags & ImGuiWindowFlags_ChildMenu))
+ while (popup_idx > 0 && g.OpenPopupStack[popup_idx].Window && (g.OpenPopupStack[popup_idx].Window->Flags & ImGuiWindowFlags_ChildMenu))
popup_idx--;
ClosePopupToLevel(popup_idx);
}
static inline void ClearSetNextWindowData()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
g.SetNextWindowPosCond = g.SetNextWindowSizeCond = g.SetNextWindowContentSizeCond = g.SetNextWindowCollapsedCond = 0;
g.SetNextWindowFocus = false;
}
static bool BeginPopupEx(const char* str_id, ImGuiWindowFlags extra_flags)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
const ImGuiID id = window->GetID(str_id);
if (!IsPopupOpen(id))
@@ -3286,18 +3359,18 @@ static bool BeginPopupEx(const char* str_id, ImGuiWindowFlags extra_flags)
else
ImFormatString(name, 20, "##popup_%08x", id); // Not recycling, so we can close/open during the same frame
- bool opened = ImGui::Begin(name, NULL, flags);
+ bool is_open = ImGui::Begin(name, NULL, flags);
if (!(window->Flags & ImGuiWindowFlags_ShowBorders))
g.CurrentWindow->Flags &= ~ImGuiWindowFlags_ShowBorders;
- if (!opened) // opened can be 'false' when the popup is completely clipped (e.g. zero size display)
+ if (!is_open) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
ImGui::EndPopup();
- return opened;
+ return is_open;
}
bool ImGui::BeginPopup(const char* str_id)
{
- if (GImGui->OpenedPopupStack.Size <= GImGui->CurrentPopupStack.Size) // Early out for performance
+ if (GImGui->OpenPopupStack.Size <= GImGui->CurrentPopupStack.Size) // Early out for performance
{
ClearSetNextWindowData(); // We behave like Begin() and need to consume those values
return false;
@@ -3305,9 +3378,9 @@ bool ImGui::BeginPopup(const char* str_id)
return BeginPopupEx(str_id, ImGuiWindowFlags_ShowBorders);
}
-bool ImGui::BeginPopupModal(const char* name, bool* p_opened, ImGuiWindowFlags extra_flags)
+bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags extra_flags)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
const ImGuiID id = window->GetID(name);
if (!IsPopupOpen(id))
@@ -3317,16 +3390,16 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_opened, ImGuiWindowFlags e
}
ImGuiWindowFlags flags = extra_flags|ImGuiWindowFlags_Popup|ImGuiWindowFlags_Modal|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoSavedSettings;
- bool opened = ImGui::Begin(name, p_opened, flags);
- if (!opened || (p_opened && !*p_opened)) // Opened can be 'false' when the popup is completely clipped (e.g. zero size display)
+ bool is_open = ImGui::Begin(name, p_open, flags);
+ if (!is_open || (p_open && !*p_open)) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
{
ImGui::EndPopup();
- if (opened)
+ if (is_open)
ClosePopup(id);
return false;
}
- return opened;
+ return is_open;
}
void ImGui::EndPopup()
@@ -3443,7 +3516,7 @@ void ImGui::EndChild()
// Helper to create a child window / scrolling region that looks like a normal widget frame.
bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
ImGui::PushStyleColor(ImGuiCol_ChildWindowBg, style.Colors[ImGuiCol_FrameBg]);
ImGui::PushStyleVar(ImGuiStyleVar_ChildWindowRounding, style.FrameRounding);
@@ -3462,7 +3535,7 @@ void ImGui::EndChildFrame()
static void CheckStacksSize(ImGuiWindow* window, bool write)
{
// NOT checking: DC.ItemWidth, DC.AllowKeyboardFocus, DC.ButtonRepeat, DC.TextWrapPos (per window) to allow user to conveniently push once and not pop (they are cleared on Begin)
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
int* p_backup = &window->DC.StackSizesBackup[0];
{ int current = window->IDStack.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current); p_backup++; } // User forgot PopID()
{ int current = window->DC.GroupStack.Size; if (write) *p_backup = current; else IM_ASSERT(*p_backup == current); p_backup++; } // User forgot EndGroup()
@@ -3504,7 +3577,7 @@ static ImVec2 FindBestPopupWindowPos(const ImVec2& base_pos, const ImVec2& size,
ImGuiWindow* ImGui::FindWindowByName(const char* name)
{
// FIXME-OPT: Store sorted hashes -> pointers so we can do a bissection in a contiguous block
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiID id = ImHash(name, 0);
for (int i = 0; i < g.Windows.Size; i++)
if (g.Windows[i]->ID == id)
@@ -3514,7 +3587,7 @@ ImGuiWindow* ImGui::FindWindowByName(const char* name)
static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
// Create window the first time
ImGuiWindow* window = (ImGuiWindow*)ImGui::MemAlloc(sizeof(ImGuiWindow));
@@ -3585,16 +3658,16 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
// - The window name is used as a unique identifier to preserve window information across frames (and save rudimentary information to the .ini file).
// You can use the "##" or "###" markers to use the same label with different id, or same id with different label. See documentation at the top of this file.
// - Return false when window is collapsed, so you can early out in your code. You always need to call ImGui::End() even if false is returned.
-// - Passing 'bool* p_opened' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed.
+// - Passing 'bool* p_open' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed.
// - Passing non-zero 'size' is roughly equivalent to calling SetNextWindowSize(size, ImGuiSetCond_FirstUseEver) prior to calling Begin().
-bool ImGui::Begin(const char* name, bool* p_opened, ImGuiWindowFlags flags)
+bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
{
- return ImGui::Begin(name, p_opened, ImVec2(0.f, 0.f), -1.0f, flags);
+ return ImGui::Begin(name, p_open, ImVec2(0.f, 0.f), -1.0f, flags);
}
-bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_use, float bg_alpha, ImGuiWindowFlags flags)
+bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha, ImGuiWindowFlags flags)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
IM_ASSERT(name != NULL); // Window name required
IM_ASSERT(g.Initialized); // Forgot to call ImGui::NewFrame()
@@ -3629,7 +3702,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
bool window_was_active = (window->LastFrameActive == current_frame - 1); // Not using !WasActive because the implicit "Debug" window would always toggle off->on
if (flags & ImGuiWindowFlags_Popup)
{
- ImGuiPopupRef& popup_ref = g.OpenedPopupStack[g.CurrentPopupStack.Size];
+ ImGuiPopupRef& popup_ref = g.OpenPopupStack[g.CurrentPopupStack.Size];
window_was_active &= (window->PopupID == popup_ref.PopupID);
window_was_active &= (window == popup_ref.Window);
popup_ref.Window = window;
@@ -3694,6 +3767,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
for (root_non_popup_idx = root_idx; root_non_popup_idx > 0; root_non_popup_idx--)
if (!(g.CurrentWindowStack[root_non_popup_idx]->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)))
break;
+ window->ParentWindow = parent_window;
window->RootWindow = g.CurrentWindowStack[root_idx];
window->RootNonPopupWindow = g.CurrentWindowStack[root_non_popup_idx]; // This is merely for displaying the TitleBgActive color.
@@ -3875,28 +3949,6 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
window->PosFloat = g.IO.MousePos + ImVec2(2,2); // If there's not enough room, for tooltip we prefer avoiding the cursor at all cost even if it means that part of the tooltip won't be visible.
}
- // User moving window (at the beginning of the frame to avoid input lag or sheering). Only valid for root windows.
- KeepAliveID(window->MoveID);
- if (g.ActiveId == window->MoveID)
- {
- if (g.IO.MouseDown[0])
- {
- if (!(flags & ImGuiWindowFlags_NoMove))
- {
- window->PosFloat += g.IO.MouseDelta;
- if (!(flags & ImGuiWindowFlags_NoSavedSettings))
- MarkSettingsDirty();
- }
- IM_ASSERT(g.MovedWindow != NULL);
- FocusWindow(g.MovedWindow);
- }
- else
- {
- SetActiveID(0);
- g.MovedWindow = NULL; // Not strictly necessary but doing it for sanity.
- }
- }
-
// Clamp position so it stays visible
if (!(flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Tooltip))
{
@@ -4087,12 +4139,12 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
// Title bar
if (!(flags & ImGuiWindowFlags_NoTitleBar))
{
- if (p_opened != NULL)
+ if (p_open != NULL)
{
const float pad = 2.0f;
const float rad = (window->TitleBarHeight() - pad*2.0f) * 0.5f;
if (CloseButton(window->GetID("#CLOSE"), window->Rect().GetTR() + ImVec2(-pad - rad, pad + rad), rad))
- *p_opened = false;
+ *p_open = false;
}
const ImVec2 text_size = CalcTextSize(name, NULL, true);
@@ -4101,9 +4153,9 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
ImVec2 text_min = window->Pos + style.FramePadding;
ImVec2 text_max = window->Pos + ImVec2(window->Size.x - style.FramePadding.x, style.FramePadding.y*2 + text_size.y);
- ImVec2 clip_max = ImVec2(window->Pos.x + window->Size.x - (p_opened ? title_bar_rect.GetHeight() - 3 : style.FramePadding.x), text_max.y); // Match the size of CloseWindowButton()
+ ImVec2 clip_max = ImVec2(window->Pos.x + window->Size.x - (p_open ? title_bar_rect.GetHeight() - 3 : style.FramePadding.x), text_max.y); // Match the size of CloseWindowButton()
bool pad_left = (flags & ImGuiWindowFlags_NoCollapse) == 0;
- bool pad_right = (p_opened != NULL);
+ bool pad_right = (p_open != NULL);
if (style.WindowTitleAlign & ImGuiAlign_Center) pad_right = pad_left;
if (pad_left) text_min.x += g.FontSize + style.ItemInnerSpacing.x;
if (pad_right) text_max.x -= g.FontSize + style.ItemInnerSpacing.x;
@@ -4111,8 +4163,8 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
}
// Save clipped aabb so we can access it in constant-time in FindHoveredWindow()
- window->ClippedWindowRect = window->Rect();
- window->ClippedWindowRect.Clip(window->ClipRect);
+ window->WindowRectClipped = window->Rect();
+ window->WindowRectClipped.Clip(window->ClipRect);
// Pressing CTRL+C while holding on a window copy its content to the clipboard
// This works but 1. doesn't handle multiple Begin/End pairs, 2. recursing into another Begin/End pair - so we need to work that out and add better logging scope.
@@ -4149,7 +4201,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
window->Collapsed = parent_window && parent_window->Collapsed;
if (!(flags & ImGuiWindowFlags_AlwaysAutoResize) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0)
- window->Collapsed |= (window->ClippedWindowRect.Min.x >= window->ClippedWindowRect.Max.x || window->ClippedWindowRect.Min.y >= window->ClippedWindowRect.Max.y);
+ window->Collapsed |= (window->WindowRectClipped.Min.x >= window->WindowRectClipped.Max.x || window->WindowRectClipped.Min.y >= window->WindowRectClipped.Max.y);
// We also hide the window from rendering because we've already added its border to the command list.
// (we could perform the check earlier in the function but it is simpler at this point)
@@ -4166,7 +4218,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
void ImGui::End()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
ImGui::Columns(1, "#CloseColumns");
@@ -4192,7 +4244,7 @@ void ImGui::End()
// - We handle both horizontal and vertical scrollbars, which makes the terminology not ideal.
static void Scrollbar(ImGuiWindow* window, bool horizontal)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(horizontal ? "#SCROLLX" : "#SCROLLY");
@@ -4290,7 +4342,7 @@ static void Scrollbar(ImGuiWindow* window, bool horizontal)
// Moving window to front of display (which happens to be back of our sorted list)
void ImGui::FocusWindow(ImGuiWindow* window)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
// Always mark the window we passed as focused. This is used for keyboard interactions such as tabbing.
g.FocusedWindow = window;
@@ -4364,7 +4416,7 @@ float ImGui::CalcItemWidth()
static void SetCurrentFont(ImFont* font)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
IM_ASSERT(font && font->IsLoaded()); // Font Atlas not created. Did you call io.Fonts->GetTexDataAsRGBA32 / GetTexDataAsAlpha8 ?
IM_ASSERT(font->Scale > 0.0f);
g.Font = font;
@@ -4375,7 +4427,7 @@ static void SetCurrentFont(ImFont* font)
void ImGui::PushFont(ImFont* font)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (!font)
font = g.IO.Fonts->Fonts[0];
SetCurrentFont(font);
@@ -4385,7 +4437,7 @@ void ImGui::PushFont(ImFont* font)
void ImGui::PopFont()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
g.CurrentWindow->DrawList->PopTextureID();
g.FontStack.pop_back();
SetCurrentFont(g.FontStack.empty() ? g.IO.Fonts->Fonts[0] : g.FontStack.back());
@@ -4435,7 +4487,7 @@ void ImGui::PopTextWrapPos()
void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4& col)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiColMod backup;
backup.Col = idx;
backup.PreviousValue = g.Style.Colors[idx];
@@ -4445,7 +4497,7 @@ void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4& col)
void ImGui::PopStyleColor(int count)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
while (count > 0)
{
ImGuiColMod& backup = g.ColorModifiers.back();
@@ -4457,7 +4509,7 @@ void ImGui::PopStyleColor(int count)
static float* GetStyleVarFloatAddr(ImGuiStyleVar idx)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
switch (idx)
{
case ImGuiStyleVar_Alpha: return &g.Style.Alpha;
@@ -4473,7 +4525,7 @@ static float* GetStyleVarFloatAddr(ImGuiStyleVar idx)
static ImVec2* GetStyleVarVec2Addr(ImGuiStyleVar idx)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
switch (idx)
{
case ImGuiStyleVar_WindowPadding: return &g.Style.WindowPadding;
@@ -4487,7 +4539,7 @@ static ImVec2* GetStyleVarVec2Addr(ImGuiStyleVar idx)
void ImGui::PushStyleVar(ImGuiStyleVar idx, float val)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
float* pvar = GetStyleVarFloatAddr(idx);
IM_ASSERT(pvar != NULL); // Called function with wrong-type? Variable is not a float.
ImGuiStyleMod backup;
@@ -4500,7 +4552,7 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, float val)
void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImVec2* pvar = GetStyleVarVec2Addr(idx);
IM_ASSERT(pvar != NULL); // Called function with wrong-type? Variable is not a ImVec2.
ImGuiStyleMod backup;
@@ -4512,7 +4564,7 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val)
void ImGui::PopStyleVar(int count)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
while (count > 0)
{
ImGuiStyleMod& backup = g.StyleModifiers.back();
@@ -4580,31 +4632,31 @@ const char* ImGui::GetStyleColName(ImGuiCol idx)
bool ImGui::IsWindowHovered()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
return g.HoveredWindow == g.CurrentWindow && IsWindowContentHoverable(g.HoveredRootWindow);
}
bool ImGui::IsWindowFocused()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
return g.FocusedWindow == g.CurrentWindow;
}
bool ImGui::IsRootWindowFocused()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
return g.FocusedWindow == g.CurrentWindow->RootWindow;
}
bool ImGui::IsRootWindowOrAnyChildFocused()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
return g.FocusedWindow && g.FocusedWindow->RootWindow == g.CurrentWindow->RootWindow;
}
bool ImGui::IsRootWindowOrAnyChildHovered()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
return g.HoveredRootWindow && (g.HoveredRootWindow == g.CurrentWindow->RootWindow) && IsWindowContentHoverable(g.HoveredRootWindow);
}
@@ -4622,7 +4674,7 @@ float ImGui::GetWindowHeight()
ImVec2 ImGui::GetWindowPos()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
return window->Pos;
}
@@ -4760,49 +4812,49 @@ void ImGui::SetWindowFocus(const char* name)
void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiSetCond cond)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
g.SetNextWindowPosVal = pos;
g.SetNextWindowPosCond = cond ? cond : ImGuiSetCond_Always;
}
void ImGui::SetNextWindowPosCenter(ImGuiSetCond cond)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
g.SetNextWindowPosVal = ImVec2(-FLT_MAX, -FLT_MAX);
g.SetNextWindowPosCond = cond ? cond : ImGuiSetCond_Always;
}
void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
g.SetNextWindowSizeVal = size;
g.SetNextWindowSizeCond = cond ? cond : ImGuiSetCond_Always;
}
void ImGui::SetNextWindowContentSize(const ImVec2& size)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
g.SetNextWindowContentSizeVal = size;
g.SetNextWindowContentSizeCond = ImGuiSetCond_Always;
}
void ImGui::SetNextWindowContentWidth(float width)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
g.SetNextWindowContentSizeVal = ImVec2(width, g.SetNextWindowContentSizeCond ? g.SetNextWindowContentSizeVal.y : 0.0f);
g.SetNextWindowContentSizeCond = ImGuiSetCond_Always;
}
void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
g.SetNextWindowCollapsedVal = collapsed;
g.SetNextWindowCollapsedCond = cond ? cond : ImGuiSetCond_Always;
}
void ImGui::SetNextWindowFocus()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
g.SetNextWindowFocus = true;
}
@@ -4811,7 +4863,7 @@ void ImGui::SetNextWindowFocus()
ImVec2 ImGui::GetContentRegionMax()
{
ImGuiWindow* window = GetCurrentWindowRead();
- ImVec2 content_region_size = ImVec2(window->SizeContentsExplicit.x ? window->SizeContentsExplicit.x : window->Size.x - window->ScrollbarSizes.x, window->SizeContentsExplicit.y ? window->SizeContentsExplicit.y : window->Size.y - window->ScrollbarSizes.y);
+ ImVec2 content_region_size = ImVec2(window->SizeContentsExplicit.x != 0.0f ? window->SizeContentsExplicit.x : window->Size.x - window->ScrollbarSizes.x, window->SizeContentsExplicit.y != 0.0f ? window->SizeContentsExplicit.y : window->Size.y - window->ScrollbarSizes.y);
ImVec2 mx = content_region_size - window->Scroll - window->WindowPadding;
if (window->DC.ColumnsCount != 1)
mx.x = ImGui::GetColumnOffset(window->DC.ColumnsCurrent + 1) - window->WindowPadding.x;
@@ -4839,7 +4891,7 @@ ImVec2 ImGui::GetWindowContentRegionMin()
ImVec2 ImGui::GetWindowContentRegionMax()
{
ImGuiWindow* window = GetCurrentWindowRead();
- ImVec2 content_region_size = ImVec2(window->SizeContentsExplicit.x ? window->SizeContentsExplicit.x : window->Size.x, window->SizeContentsExplicit.y ? window->SizeContentsExplicit.y : window->Size.y);
+ ImVec2 content_region_size = ImVec2(window->SizeContentsExplicit.x != 0.0f ? window->SizeContentsExplicit.x : window->Size.x, window->SizeContentsExplicit.y != 0.0f ? window->SizeContentsExplicit.y : window->Size.y);
ImVec2 m = content_region_size - window->Scroll - window->WindowPadding - window->ScrollbarSizes;
return m;
}
@@ -4851,19 +4903,19 @@ float ImGui::GetWindowContentRegionWidth()
float ImGui::GetTextLineHeight()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
return g.FontSize;
}
float ImGui::GetTextLineHeightWithSpacing()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
return g.FontSize + g.Style.ItemSpacing.y;
}
float ImGui::GetItemsLineHeightWithSpacing()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
return g.FontSize + g.Style.FramePadding.y * 2.0f + g.Style.ItemSpacing.y;
}
@@ -4890,7 +4942,7 @@ ImVec2 ImGui::GetFontTexUvWhitePixel()
void ImGui::SetWindowFontScale(float scale)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
window->FontWindowScale = scale;
g.FontSize = window->CalcFontSize();
@@ -5035,7 +5087,7 @@ void ImGui::TextV(const char* fmt, va_list args)
if (window->SkipItems)
return;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const char* text_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
TextUnformatted(g.TempBuffer, text_end);
}
@@ -5099,7 +5151,7 @@ void ImGui::TextUnformatted(const char* text, const char* text_end)
if (window->SkipItems)
return;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
IM_ASSERT(text != NULL);
const char* text_begin = text;
if (text_end == NULL)
@@ -5209,7 +5261,7 @@ void ImGui::AlignFirstTextHeightToWidgets()
return;
// Declare a dummy item size to that upcoming items that are smaller will center-align on the newly expanded line height.
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ItemSize(ImVec2(0, g.FontSize + g.Style.FramePadding.y*2), g.Style.FramePadding.y);
ImGui::SameLine(0, 0);
}
@@ -5221,7 +5273,7 @@ void ImGui::LabelTextV(const char* label, const char* fmt, va_list args)
if (window->SkipItems)
return;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const float w = CalcItemWidth();
@@ -5251,7 +5303,7 @@ void ImGui::LabelText(const char* label, const char* fmt, ...)
static inline bool IsWindowContentHoverable(ImGuiWindow* window)
{
// An active popup disable hovering on other windows (apart from its own children)
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (ImGuiWindow* focused_window = g.FocusedWindow)
if (ImGuiWindow* focused_root_window = focused_window->RootWindow)
if ((focused_root_window->Flags & ImGuiWindowFlags_Popup) != 0 && focused_root_window->WasActive && focused_root_window != window->RootWindow)
@@ -5262,7 +5314,7 @@ static inline bool IsWindowContentHoverable(ImGuiWindow* window)
bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
if (flags & ImGuiButtonFlags_Disabled)
@@ -5335,7 +5387,7 @@ bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label);
const ImVec2 label_size = CalcTextSize(label, NULL, true);
@@ -5374,7 +5426,7 @@ bool ImGui::Button(const char* label, const ImVec2& size_arg)
// Small buttons fits within text without additional vertical spacing.
bool ImGui::SmallButton(const char* label)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
float backup_padding_y = g.Style.FramePadding.y;
g.Style.FramePadding.y = 0.0f;
bool pressed = ButtonEx(label, ImVec2(0,0), ImGuiButtonFlags_AlignTextBaseLine);
@@ -5462,7 +5514,7 @@ bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const I
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
// Default to using texture ID as ID. User can still push string/integer prefixes.
@@ -5494,7 +5546,7 @@ bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const I
// Start logging ImGui output to TTY
void ImGui::LogToTTY(int max_depth)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (g.LogEnabled)
return;
ImGuiWindow* window = GetCurrentWindowRead();
@@ -5509,7 +5561,7 @@ void ImGui::LogToTTY(int max_depth)
// Start logging ImGui output to given file
void ImGui::LogToFile(int max_depth, const char* filename)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (g.LogEnabled)
return;
ImGuiWindow* window = GetCurrentWindowRead();
@@ -5536,7 +5588,7 @@ void ImGui::LogToFile(int max_depth, const char* filename)
// Start logging ImGui output to clipboard
void ImGui::LogToClipboard(int max_depth)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (g.LogEnabled)
return;
ImGuiWindow* window = GetCurrentWindowRead();
@@ -5550,7 +5602,7 @@ void ImGui::LogToClipboard(int max_depth)
void ImGui::LogFinish()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (!g.LogEnabled)
return;
@@ -5575,7 +5627,7 @@ void ImGui::LogFinish()
// Helper to display logging buttons
void ImGui::LogButtons()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGui::PushID("LogButtons");
const bool log_to_tty = ImGui::Button("Log To TTY");
@@ -5601,23 +5653,23 @@ void ImGui::LogButtons()
LogToClipboard(g.LogAutoExpandMaxDepth);
}
-bool ImGui::TreeNodeBehaviorIsOpened(ImGuiID id, ImGuiTreeNodeFlags flags)
+bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags)
{
if (flags & ImGuiTreeNodeFlags_AlwaysOpen)
return true;
// We only write to the tree storage if the user clicks (or explicitely use SetNextTreeNode*** functions)
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
ImGuiStorage* storage = window->DC.StateStorage;
- bool opened;
- if (g.SetNextTreeNodeOpenedCond != 0)
+ bool is_open;
+ if (g.SetNextTreeNodeOpenCond != 0)
{
- if (g.SetNextTreeNodeOpenedCond & ImGuiSetCond_Always)
+ if (g.SetNextTreeNodeOpenCond & ImGuiSetCond_Always)
{
- opened = g.SetNextTreeNodeOpenedVal;
- storage->SetInt(id, opened);
+ is_open = g.SetNextTreeNodeOpenVal;
+ storage->SetInt(id, is_open);
}
else
{
@@ -5625,27 +5677,27 @@ bool ImGui::TreeNodeBehaviorIsOpened(ImGuiID id, ImGuiTreeNodeFlags flags)
const int stored_value = storage->GetInt(id, -1);
if (stored_value == -1)
{
- opened = g.SetNextTreeNodeOpenedVal;
- storage->SetInt(id, opened);
+ is_open = g.SetNextTreeNodeOpenVal;
+ storage->SetInt(id, is_open);
}
else
{
- opened = stored_value != 0;
+ is_open = stored_value != 0;
}
}
- g.SetNextTreeNodeOpenedCond = 0;
+ g.SetNextTreeNodeOpenCond = 0;
}
else
{
- opened = storage->GetInt(id, (flags & ImGuiTreeNodeFlags_DefaultOpen) ? 1 : 0) != 0;
+ is_open = storage->GetInt(id, (flags & ImGuiTreeNodeFlags_DefaultOpen) ? 1 : 0) != 0;
}
// When logging is enabled, we automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior).
// NB- If we are above max depth we still allow manually opened nodes to be logged.
if (g.LogEnabled && !(flags & ImGuiTreeNodeFlags_NoAutoOpenOnLog) && window->DC.TreeDepth < g.LogAutoExpandMaxDepth)
- opened = true;
+ is_open = true;
- return opened;
+ return is_open;
}
bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end)
@@ -5654,7 +5706,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const bool display_frame = (flags & ImGuiTreeNodeFlags_Framed) != 0;
const ImVec2 padding = display_frame ? style.FramePadding : ImVec2(style.FramePadding.x, 0.0f);
@@ -5681,12 +5733,12 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
// For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing
// (Ideally we'd want to add a flag for the user to specify we want want the hit test to be done up to the right side of the content or not)
const ImRect interact_bb = display_frame ? bb : ImRect(bb.Min.x, bb.Min.y, bb.Min.x + text_width + style.ItemSpacing.x*2, bb.Max.y);
- bool opened = TreeNodeBehaviorIsOpened(id, flags);
+ bool is_open = TreeNodeBehaviorIsOpen(id, flags);
if (!ItemAdd(interact_bb, &id))
{
- if (opened && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
+ if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
TreePushRawID(id);
- return opened;
+ return is_open;
}
// Flags that affects opening behavior:
@@ -5707,8 +5759,8 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
toggled |= g.IO.MouseDoubleClicked[0];
if (toggled)
{
- opened = !opened;
- window->DC.StateStorage->SetInt(id, opened);
+ is_open = !is_open;
+ window->DC.StateStorage->SetInt(id, is_open);
}
}
if (flags & ImGuiTreeNodeFlags_AllowOverlapMode)
@@ -5721,7 +5773,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
{
// Framed type
RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding);
- RenderCollapseTriangle(bb.Min + padding + ImVec2(0.0f, text_base_offset_y), opened, 1.0f, true);
+ RenderCollapseTriangle(bb.Min + padding + ImVec2(0.0f, text_base_offset_y), is_open, 1.0f, true);
if (g.LogEnabled)
{
// NB: '##' is normally used to hide text (as a library-wide feature), so we need to specify the text range to make sure the ## aren't stripped out here.
@@ -5745,15 +5797,15 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
if (flags & ImGuiTreeNodeFlags_AlwaysOpen)
RenderBullet(bb.Min + ImVec2(text_offset_x * 0.5f, g.FontSize*0.50f + text_base_offset_y));
else
- RenderCollapseTriangle(bb.Min + ImVec2(padding.x, g.FontSize*0.15f + text_base_offset_y), opened, 0.70f, false);
+ RenderCollapseTriangle(bb.Min + ImVec2(padding.x, g.FontSize*0.15f + text_base_offset_y), is_open, 0.70f, false);
if (g.LogEnabled)
LogRenderedText(text_pos, ">");
RenderText(text_pos, label, label_end, false);
}
- if (opened && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
+ if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
TreePushRawID(id);
- return opened;
+ return is_open;
}
bool ImGui::CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags)
@@ -5775,17 +5827,17 @@ bool ImGui::CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags
return false;
ImGuiID id = window->GetID(label);
- bool opened = TreeNodeBehavior(id, flags | ImGuiTreeNodeFlags_CollapsingHeader | ImGuiTreeNodeFlags_NoTreePushOnOpen | (p_open ? ImGuiTreeNodeFlags_AllowOverlapMode : 0), label);
+ bool is_open = TreeNodeBehavior(id, flags | ImGuiTreeNodeFlags_CollapsingHeader | ImGuiTreeNodeFlags_NoTreePushOnOpen | (p_open ? ImGuiTreeNodeFlags_AllowOverlapMode : 0), label);
if (p_open)
{
// Create a small overlapping close button // FIXME: We can evolve this into user accessible helpers to add extra buttons on title bars, headers, etc.
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
float button_sz = g.FontSize * 0.5f;
if (CloseButton(window->GetID((void*)(intptr_t)(id+1)), ImVec2(window->DC.LastItemRect.Max.x - g.Style.FramePadding.x - button_sz, window->DC.LastItemRect.Min.y + g.Style.FramePadding.y + button_sz), button_sz))
*p_open = false;
}
- return opened;
+ return is_open;
}
bool ImGui::TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags)
@@ -5803,7 +5855,7 @@ bool ImGui::TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const char* label_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
return TreeNodeBehavior(window->GetID(str_id), flags, g.TempBuffer, label_end);
}
@@ -5814,7 +5866,7 @@ bool ImGui::TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const char* label_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
return TreeNodeBehavior(window->GetID(ptr_id), flags, g.TempBuffer, label_end);
}
@@ -5833,36 +5885,36 @@ bool ImGui::TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char*
{
va_list args;
va_start(args, fmt);
- bool opened = TreeNodeExV(str_id, flags, fmt, args);
+ bool is_open = TreeNodeExV(str_id, flags, fmt, args);
va_end(args);
- return opened;
+ return is_open;
}
bool ImGui::TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
- bool opened = TreeNodeExV(ptr_id, flags, fmt, args);
+ bool is_open = TreeNodeExV(ptr_id, flags, fmt, args);
va_end(args);
- return opened;
+ return is_open;
}
bool ImGui::TreeNode(const char* str_id, const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
- bool opened = TreeNodeExV(str_id, 0, fmt, args);
+ bool is_open = TreeNodeExV(str_id, 0, fmt, args);
va_end(args);
- return opened;
+ return is_open;
}
bool ImGui::TreeNode(const void* ptr_id, const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
- bool opened = TreeNodeExV(ptr_id, 0, fmt, args);
+ bool is_open = TreeNodeExV(ptr_id, 0, fmt, args);
va_end(args);
- return opened;
+ return is_open;
}
bool ImGui::TreeNode(const char* label)
@@ -5876,7 +5928,7 @@ bool ImGui::TreeNode(const char* label)
float ImGui::GetTreeNodeToLabelSpacing(ImGuiTreeNodeFlags flags)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
float off_from_start;
if (flags & ImGuiTreeNodeFlags_Framed)
off_from_start = g.FontSize + (g.Style.FramePadding.x * 3.0f) - ((float)(int)(g.CurrentWindow->WindowPadding.x*0.5f) - 1);
@@ -5885,11 +5937,11 @@ float ImGui::GetTreeNodeToLabelSpacing(ImGuiTreeNodeFlags flags)
return off_from_start;
}
-void ImGui::SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond)
+void ImGui::SetNextTreeNodeOpen(bool is_open, ImGuiSetCond cond)
{
- ImGuiState& g = *GImGui;
- g.SetNextTreeNodeOpenedVal = opened;
- g.SetNextTreeNodeOpenedCond = cond ? cond : ImGuiSetCond_Always;
+ ImGuiContext& g = *GImGui;
+ g.SetNextTreeNodeOpenVal = is_open;
+ g.SetNextTreeNodeOpenCond = cond ? cond : ImGuiSetCond_Always;
}
void ImGui::PushID(const char* str_id)
@@ -5944,7 +5996,7 @@ void ImGui::Bullet()
if (window->SkipItems)
return;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const float line_height = ImMax(ImMin(window->DC.CurrentLineHeight, g.FontSize + g.Style.FramePadding.y*2), g.FontSize);
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize, line_height));
@@ -5967,7 +6019,7 @@ void ImGui::BulletTextV(const char* fmt, va_list args)
if (window->SkipItems)
return;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const char* text_begin = g.TempBuffer;
@@ -6103,7 +6155,7 @@ static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
// Create text input in place of a slider (when CTRL+Clicking on slider)
bool ImGui::InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label, ImGuiDataType data_type, void* data_ptr, ImGuiID id, int decimal_precision)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
// Our replacement widget will override the focus ID (registered previously to allow for a TAB focus to happen)
@@ -6171,7 +6223,7 @@ float ImGui::RoundScalar(float value, int decimal_precision)
bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_min, float v_max, float power, int decimal_precision, ImGuiSliderFlags flags)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
const ImGuiStyle& style = g.Style;
@@ -6233,7 +6285,7 @@ bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v
{
// Positive: rescale to the positive range before powering
float a;
- if (fabsf(linear_zero_pos - 1.0f) > 1.e-6)
+ if (fabsf(linear_zero_pos - 1.0f) > 1.e-6f)
a = (normalized_pos - linear_zero_pos) / (1.0f - linear_zero_pos);
else
a = normalized_pos;
@@ -6308,7 +6360,7 @@ bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, c
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label);
const float w = CalcItemWidth();
@@ -6371,7 +6423,7 @@ bool ImGui::VSliderFloat(const char* label, const ImVec2& size, float* v, float
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label);
@@ -6446,7 +6498,7 @@ bool ImGui::SliderFloatN(const char* label, float* v, int components, float v_mi
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
bool value_changed = false;
ImGui::BeginGroup();
ImGui::PushID(label);
@@ -6488,7 +6540,7 @@ bool ImGui::SliderIntN(const char* label, int* v, int components, int v_min, int
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
bool value_changed = false;
ImGui::BeginGroup();
ImGui::PushID(label);
@@ -6526,7 +6578,7 @@ bool ImGui::SliderInt4(const char* label, int v[4], int v_min, int v_max, const
bool ImGui::DragBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_speed, float v_min, float v_max, int decimal_precision, float power)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
// Draw frame
@@ -6605,7 +6657,7 @@ bool ImGui::DragFloat(const char* label, float* v, float v_speed, float v_min, f
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label);
const float w = CalcItemWidth();
@@ -6668,7 +6720,7 @@ bool ImGui::DragFloatN(const char* label, float* v, int components, float v_spee
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
bool value_changed = false;
ImGui::BeginGroup();
ImGui::PushID(label);
@@ -6710,7 +6762,7 @@ bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_cu
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGui::PushID(label);
ImGui::BeginGroup();
PushMultiItemsWidths(2);
@@ -6746,7 +6798,7 @@ bool ImGui::DragIntN(const char* label, int* v, int components, float v_speed, i
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
bool value_changed = false;
ImGui::BeginGroup();
ImGui::PushID(label);
@@ -6788,7 +6840,7 @@ bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGui::PushID(label);
ImGui::BeginGroup();
PushMultiItemsWidths(2);
@@ -6813,7 +6865,7 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
if (window->SkipItems)
return;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImVec2 label_size = CalcTextSize(label, NULL, true);
@@ -6955,7 +7007,7 @@ void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* over
if (window->SkipItems)
return;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
ImVec2 pos = window->DC.CursorPos;
@@ -6990,7 +7042,7 @@ bool ImGui::Checkbox(const char* label, bool* v)
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label);
const ImVec2 label_size = CalcTextSize(label, NULL, true);
@@ -7053,7 +7105,7 @@ bool ImGui::RadioButton(const char* label, bool active)
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label);
const ImVec2 label_size = CalcTextSize(label, NULL, true);
@@ -7377,7 +7429,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackHistory) && (flags & ImGuiInputTextFlags_Multiline))); // Can't use both together (they both use up/down keys)
IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackCompletion) && (flags & ImGuiInputTextFlags_AllowTabInput))); // Can't use both together (they both use tab key)
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiIO& io = g.IO;
const ImGuiStyle& style = g.Style;
@@ -7951,7 +8003,7 @@ bool ImGui::InputScalarEx(const char* label, ImGuiDataType data_type, void* data
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImVec2 label_size = CalcTextSize(label, NULL, true);
@@ -8024,7 +8076,7 @@ bool ImGui::InputFloatN(const char* label, float* v, int components, int decimal
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
bool value_changed = false;
ImGui::BeginGroup();
ImGui::PushID(label);
@@ -8067,7 +8119,7 @@ bool ImGui::InputIntN(const char* label, int* v, int components, ImGuiInputTextF
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
bool value_changed = false;
ImGui::BeginGroup();
ImGui::PushID(label);
@@ -8160,7 +8212,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label);
const float w = CalcItemWidth();
@@ -8174,12 +8226,12 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
const float arrow_size = (g.FontSize + style.FramePadding.x * 2.0f);
const bool hovered = IsHovered(frame_bb, id);
- bool popup_opened = IsPopupOpen(id);
+ bool popup_open = IsPopupOpen(id);
bool popup_opened_now = false;
const ImRect value_bb(frame_bb.Min, frame_bb.Max - ImVec2(arrow_size, 0.0f));
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
- RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32(popup_opened || hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding); // FIXME-ROUNDING
+ RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32(popup_open || hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding); // FIXME-ROUNDING
RenderCollapseTriangle(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y) + style.FramePadding, true);
if (*current_item >= 0 && *current_item < items_count)
@@ -8206,7 +8258,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
{
FocusWindow(window);
OpenPopup(label);
- popup_opened = popup_opened_now = true;
+ popup_open = popup_opened_now = true;
}
}
}
@@ -8269,7 +8321,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsCount > 1)
@@ -8450,7 +8502,7 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, boo
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImVec2 pos = window->DC.CursorPos;
ImVec2 label_size = CalcTextSize(label, NULL, true);
ImVec2 shortcut_size = shortcut ? CalcTextSize(shortcut, NULL) : ImVec2(0.0f, 0.0f);
@@ -8484,7 +8536,7 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool* p_selected,
bool ImGui::BeginMainMenuBar()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f));
ImGui::SetNextWindowSize(ImVec2(g.IO.DisplaySize.x, g.FontBaseSize + g.Style.FramePadding.y * 2.0f));
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
@@ -8550,7 +8602,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label);
@@ -8558,9 +8610,9 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
ImGuiWindow* backed_focused_window = g.FocusedWindow;
bool pressed;
- bool opened = IsPopupOpen(id);
- bool menuset_opened = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenedPopupStack.Size > g.CurrentPopupStack.Size && g.OpenedPopupStack[g.CurrentPopupStack.Size].ParentMenuSet == window->GetID("##menus"));
- if (menuset_opened)
+ bool menu_is_open = IsPopupOpen(id);
+ bool menuset_is_open = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].ParentMenuSet == window->GetID("##menus"));
+ if (menuset_is_open)
g.FocusedWindow = window;
ImVec2 popup_pos, pos = window->DC.CursorPos;
@@ -8570,7 +8622,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * 0.5f);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing * 2.0f);
float w = label_size.x;
- pressed = ImGui::Selectable(label, opened, ImGuiSelectableFlags_Menu | ImGuiSelectableFlags_DontClosePopups | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f));
+ pressed = ImGui::Selectable(label, menu_is_open, ImGuiSelectableFlags_Menu | ImGuiSelectableFlags_DontClosePopups | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f));
ImGui::PopStyleVar();
ImGui::SameLine();
window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * 0.5f);
@@ -8580,14 +8632,14 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
popup_pos = ImVec2(pos.x, pos.y - style.WindowPadding.y);
float w = window->MenuColumns.DeclColumns(label_size.x, 0.0f, (float)(int)(g.FontSize * 1.20f)); // Feedback to next frame
float extra_w = ImMax(0.0f, ImGui::GetContentRegionAvail().x - w);
- pressed = ImGui::Selectable(label, opened, ImGuiSelectableFlags_Menu | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_DrawFillAvailWidth | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f));
+ pressed = ImGui::Selectable(label, menu_is_open, ImGuiSelectableFlags_Menu | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_DrawFillAvailWidth | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f));
if (!enabled) ImGui::PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]);
RenderCollapseTriangle(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.20f, 0.0f), false);
if (!enabled) ImGui::PopStyleColor();
}
bool hovered = enabled && IsHovered(window->DC.LastItemRect, id);
- if (menuset_opened)
+ if (menuset_is_open)
g.FocusedWindow = backed_focused_window;
bool want_open = false, want_close = false;
@@ -8595,9 +8647,9 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
{
// Implement http://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown to avoid using timers, so menus feels more reactive.
bool moving_within_opened_triangle = false;
- if (g.HoveredWindow == window && g.OpenedPopupStack.Size > g.CurrentPopupStack.Size && g.OpenedPopupStack[g.CurrentPopupStack.Size].ParentWindow == window)
+ if (g.HoveredWindow == window && g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].ParentWindow == window)
{
- if (ImGuiWindow* next_window = g.OpenedPopupStack[g.CurrentPopupStack.Size].Window)
+ if (ImGuiWindow* next_window = g.OpenPopupStack[g.CurrentPopupStack.Size].Window)
{
ImRect next_window_rect = next_window->Rect();
ImVec2 ta = g.IO.MousePos - g.IO.MouseDelta;
@@ -8612,39 +8664,39 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
}
}
- want_close = (opened && !hovered && g.HoveredWindow == window && g.HoveredIdPreviousFrame != 0 && g.HoveredIdPreviousFrame != id && !moving_within_opened_triangle);
- want_open = (!opened && hovered && !moving_within_opened_triangle) || (!opened && hovered && pressed);
+ want_close = (menu_is_open && !hovered && g.HoveredWindow == window && g.HoveredIdPreviousFrame != 0 && g.HoveredIdPreviousFrame != id && !moving_within_opened_triangle);
+ want_open = (!menu_is_open && hovered && !moving_within_opened_triangle) || (!menu_is_open && hovered && pressed);
}
- else if (opened && pressed && menuset_opened) // menu-bar: click open menu to close
+ else if (menu_is_open && pressed && menuset_is_open) // menu-bar: click open menu to close
{
want_close = true;
- want_open = opened = false;
+ want_open = menu_is_open = false;
}
- else if (pressed || (hovered && menuset_opened && !opened)) // menu-bar: first click to open, then hover to open others
+ else if (pressed || (hovered && menuset_is_open && !menu_is_open)) // menu-bar: first click to open, then hover to open others
want_open = true;
if (want_close && IsPopupOpen(id))
ClosePopupToLevel(GImGui->CurrentPopupStack.Size);
- if (!opened && want_open && g.OpenedPopupStack.Size > g.CurrentPopupStack.Size)
+ if (!menu_is_open && want_open && g.OpenPopupStack.Size > g.CurrentPopupStack.Size)
{
// Don't recycle same menu level in the same frame, first close the other menu and yield for a frame.
ImGui::OpenPopup(label);
return false;
}
- opened |= want_open;
+ menu_is_open |= want_open;
if (want_open)
ImGui::OpenPopup(label);
- if (opened)
+ if (menu_is_open)
{
ImGui::SetNextWindowPos(popup_pos, ImGuiSetCond_Always);
ImGuiWindowFlags flags = ImGuiWindowFlags_ShowBorders | ((window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu)) ? ImGuiWindowFlags_ChildMenu|ImGuiWindowFlags_ChildWindow : ImGuiWindowFlags_ChildMenu);
- opened = BeginPopupEx(label, flags); // opened can be 'false' when the popup is completely clipped (e.g. zero size display)
+ menu_is_open = BeginPopupEx(label, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
}
- return opened;
+ return menu_is_open;
}
void ImGui::EndMenu()
@@ -8660,7 +8712,7 @@ bool ImGui::ColorButton(const ImVec4& col, bool small_height, bool outline_borde
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID("#colorbutton");
const float square_size = g.FontSize;
@@ -8701,7 +8753,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], bool alpha)
if (window->SkipItems)
return false;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label);
const float w_full = CalcItemWidth();
@@ -8862,7 +8914,7 @@ void ImGui::Separator()
window->DrawList->AddLine(bb.Min, bb.Max, GetColorU32(ImGuiCol_Border));
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (g.LogEnabled)
ImGui::LogText(IM_NEWLINE "--------------------------------");
@@ -8913,7 +8965,7 @@ void ImGui::BeginGroup()
group_data.BackupLogLinePosY = window->DC.LogLinePosY;
group_data.AdvanceCursor = true;
- window->DC.IndentX = window->DC.CursorPos.x - window->Pos.x;
+ window->DC.IndentX = window->DC.CursorPos.x - window->Pos.x - window->DC.ColumnsOffsetX;
window->DC.CursorMaxPos = window->DC.CursorPos;
window->DC.CurrentLineHeight = 0.0f;
window->DC.LogLinePosY = window->DC.CursorPos.y - 9999.0f;
@@ -8962,7 +9014,7 @@ void ImGui::SameLine(float pos_x, float spacing_w)
if (window->SkipItems)
return;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (pos_x != 0.0f)
{
if (spacing_w < 0.0f) spacing_w = 0.0f;
@@ -8985,7 +9037,7 @@ void ImGui::NextColumn()
if (window->SkipItems)
return;
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (window->DC.ColumnsCount > 1)
{
ImGui::PopItemWidth();
@@ -9031,7 +9083,7 @@ static float GetDraggedColumnOffset(int column_index)
{
// Active (dragged) column always follow mouse. The reason we need this is that dragging a column to the right edge of an auto-resizing
// window creates a feedback loop because we store normalized positions. So while dragging we enforce absolute positioning.
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = ImGui::GetCurrentWindowRead();
IM_ASSERT(column_index > 0); // We cannot drag column 0. If you get this assert you may have a conflict between the ID of your columns and another widgets.
IM_ASSERT(g.ActiveId == window->DC.ColumnsSetID + ImGuiID(column_index));
@@ -9044,7 +9096,7 @@ static float GetDraggedColumnOffset(int column_index)
float ImGui::GetColumnOffset(int column_index)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindowRead();
if (column_index < 0)
column_index = window->DC.ColumnsCurrent;
@@ -9099,7 +9151,7 @@ static void PushColumnClipRect(int column_index)
void ImGui::Columns(int columns_count, const char* id, bool border)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
IM_ASSERT(columns_count >= 1);
@@ -9159,7 +9211,7 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
window->DC.ColumnsCount = columns_count;
window->DC.ColumnsShowBorders = border;
- const float content_region_width = window->SizeContentsExplicit.x ? window->SizeContentsExplicit.x : window->Size.x;
+ const float content_region_width = (window->SizeContentsExplicit.x != 0.0f) ? window->SizeContentsExplicit.x : window->Size.x;
window->DC.ColumnsMinX = window->DC.IndentX; // Lock our horizontal range
window->DC.ColumnsMaxX = content_region_width - window->Scroll.x - ((window->Flags & ImGuiWindowFlags_NoScrollbar) ? 0 : g.Style.ScrollbarSize);// - window->WindowPadding().x;
window->DC.ColumnsStartPosY = window->DC.CursorPos.y;
@@ -9191,7 +9243,7 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
void ImGui::Indent()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
window->DC.IndentX += g.Style.IndentSpacing;
window->DC.CursorPos.x = window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX;
@@ -9199,7 +9251,7 @@ void ImGui::Indent()
void ImGui::Unindent()
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
window->DC.IndentX -= g.Style.IndentSpacing;
window->DC.CursorPos.x = window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX;
@@ -9356,7 +9408,7 @@ static const char* GetClipboardTextFn_DefaultImpl()
// Local ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers
static void SetClipboardTextFn_DefaultImpl(const char* text)
{
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (g.PrivateClipboard)
{
ImGui::MemFree(g.PrivateClipboard);
@@ -9402,9 +9454,9 @@ static void ImeSetInputScreenPosFn_DefaultImpl(int, int) {}
// HELP
//-----------------------------------------------------------------------------
-void ImGui::ShowMetricsWindow(bool* opened)
+void ImGui::ShowMetricsWindow(bool* p_open)
{
- if (ImGui::Begin("ImGui Metrics", opened))
+ if (ImGui::Begin("ImGui Metrics", p_open))
{
ImGui::Text("ImGui %s", ImGui::GetVersion());
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
@@ -9418,15 +9470,15 @@ void ImGui::ShowMetricsWindow(bool* opened)
{
static void NodeDrawList(ImDrawList* draw_list, const char* label)
{
- bool node_opened = ImGui::TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->_OwnerName ? draw_list->_OwnerName : "", draw_list->VtxBuffer.Size, draw_list->IdxBuffer.Size, draw_list->CmdBuffer.Size);
+ bool node_open = ImGui::TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->_OwnerName ? draw_list->_OwnerName : "", draw_list->VtxBuffer.Size, draw_list->IdxBuffer.Size, draw_list->CmdBuffer.Size);
if (draw_list == ImGui::GetWindowDrawList())
{
ImGui::SameLine();
ImGui::TextColored(ImColor(255,100,100), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered)
- if (node_opened) ImGui::TreePop();
+ if (node_open) ImGui::TreePop();
return;
}
- if (!node_opened)
+ if (!node_open)
return;
ImDrawList* overlay_draw_list = &GImGui->OverlayDrawList; // Render additional visuals into the top-most draw list
@@ -9439,7 +9491,7 @@ void ImGui::ShowMetricsWindow(bool* opened)
ImGui::BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData);
continue;
}
- bool draw_opened = ImGui::TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "Draw %-4d %s vtx, tex = %p, clip_rect = (%.0f,%.0f)..(%.0f,%.0f)", pcmd->ElemCount, draw_list->IdxBuffer.Size > 0 ? "indexed" : "non-indexed", pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
+ bool pcmd_node_open = ImGui::TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "Draw %-4d %s vtx, tex = %p, clip_rect = (%.0f,%.0f)..(%.0f,%.0f)", pcmd->ElemCount, draw_list->IdxBuffer.Size > 0 ? "indexed" : "non-indexed", pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
if (show_clip_rects && ImGui::IsItemHovered())
{
ImRect clip_rect = pcmd->ClipRect;
@@ -9450,7 +9502,7 @@ void ImGui::ShowMetricsWindow(bool* opened)
clip_rect.Floor(); overlay_draw_list->AddRect(clip_rect.Min, clip_rect.Max, IM_COL32(255,255,0,255));
vtxs_rect.Floor(); overlay_draw_list->AddRect(vtxs_rect.Min, vtxs_rect.Max, IM_COL32(255,0,255,255));
}
- if (!draw_opened)
+ if (!pcmd_node_open)
continue;
for (int i = elem_offset; i+2 < elem_offset + (int)pcmd->ElemCount; i += 3)
{
@@ -9493,7 +9545,7 @@ void ImGui::ShowMetricsWindow(bool* opened)
}
};
- ImGuiState& g = *GImGui; // Access private state
+ ImGuiContext& g = *GImGui; // Access private state
Funcs::NodeWindows(g.Windows, "Windows");
if (ImGui::TreeNode("DrawList", "Active DrawLists (%d)", g.RenderDrawLists[0].Size))
{
@@ -9501,12 +9553,12 @@ void ImGui::ShowMetricsWindow(bool* opened)
Funcs::NodeDrawList(g.RenderDrawLists[0][i], "DrawList");
ImGui::TreePop();
}
- if (ImGui::TreeNode("Popups", "Opened Popups Stack (%d)", g.OpenedPopupStack.Size))
+ if (ImGui::TreeNode("Popups", "Open Popups Stack (%d)", g.OpenPopupStack.Size))
{
- for (int i = 0; i < g.OpenedPopupStack.Size; i++)
+ for (int i = 0; i < g.OpenPopupStack.Size; i++)
{
- ImGuiWindow* window = g.OpenedPopupStack[i].Window;
- ImGui::BulletText("PopupID: %08x, Window: '%s'%s%s", g.OpenedPopupStack[i].PopupID, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? " ChildWindow" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? " ChildMenu" : "");
+ ImGuiWindow* window = g.OpenPopupStack[i].Window;
+ ImGui::BulletText("PopupID: %08x, Window: '%s'%s%s", g.OpenPopupStack[i].PopupID, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? " ChildWindow" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? " ChildMenu" : "");
}
ImGui::TreePop();
}
diff --git a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h
index 887cc068876..063b8334bd8 100644
--- a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h
+++ b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h
@@ -54,6 +54,7 @@ struct ImGuiTextFilter; // Parse and apply text filters. In format "
struct ImGuiTextBuffer; // Text buffer for logging/accumulating text
struct ImGuiTextEditCallbackData; // Shared state of ImGui::InputText() when using custom callbacks (advanced)
struct ImGuiListClipper; // Helper to manually clip large list of items
+struct ImGuiContext; // ImGui context (opaque)
// Enumerations (declared as int for compatibility and to not pollute the top of this file)
typedef unsigned int ImU32;
@@ -110,15 +111,15 @@ namespace ImGui
IMGUI_API void Shutdown();
IMGUI_API void ShowUserGuide(); // help block
IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // style editor block
- IMGUI_API void ShowTestWindow(bool* opened = NULL); // test window demonstrating ImGui features
- IMGUI_API void ShowMetricsWindow(bool* opened = NULL); // metrics window for debugging ImGui
+ IMGUI_API void ShowTestWindow(bool* p_open = NULL); // test window demonstrating ImGui features
+ IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // metrics window for debugging ImGui
// Window
- IMGUI_API bool Begin(const char* name, bool* p_opened = NULL, ImGuiWindowFlags flags = 0); // push window to the stack and start appending to it. see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_opened' creates a widget on the upper-right to close the window (which sets your bool to false).
- IMGUI_API bool Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_use, float bg_alpha = -1.0f, ImGuiWindowFlags flags = 0); // OBSOLETE. this is the older/longer API. the extra parameters aren't very relevant. call SetNextWindowSize() instead if you want to set a window size. For regular windows, 'size_on_first_use' only applies to the first time EVER the window is created and probably not what you want! might obsolete this API eventually.
- IMGUI_API void End(); // finish appending to current window, pop it off the window stack.
- IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // begin a scrolling region. size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). size>0.0f: fixed size. each axis can use a different mode, e.g. ImVec2(0,400).
- IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // "
+ IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // push window to the stack and start appending to it. see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_open' creates a widget on the upper-right to close the window (which sets your bool to false).
+ IMGUI_API bool Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha = -1.0f, ImGuiWindowFlags flags = 0); // OBSOLETE. this is the older/longer API. the extra parameters aren't very relevant. call SetNextWindowSize() instead if you want to set a window size. For regular windows, 'size_on_first_use' only applies to the first time EVER the window is created and probably not what you want! might obsolete this API eventually.
+ IMGUI_API void End(); // finish appending to current window, pop it off the window stack.
+ IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // begin a scrolling region. size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). size>0.0f: fixed size. each axis can use a different mode, e.g. ImVec2(0,400).
+ IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // "
IMGUI_API void EndChild();
IMGUI_API ImVec2 GetContentRegionMax(); // current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates
IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos()
@@ -158,7 +159,7 @@ namespace ImGui
IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()]
IMGUI_API void SetScrollHere(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom.
IMGUI_API void SetScrollFromPosY(float pos_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position valid. use GetCursorPos() or GetCursorStartPos()+offset to get valid positions.
- IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget
+ IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use negative 'offset' to access previous widgets.
IMGUI_API void SetStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it)
IMGUI_API ImGuiStorage* GetStateStorage();
@@ -320,7 +321,7 @@ namespace ImGui
IMGUI_API void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layout purpose
IMGUI_API void TreePush(const void* ptr_id = NULL); // "
IMGUI_API void TreePop();
- IMGUI_API void SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond = 0); // set next tree node/collapsing header to be opened.
+ IMGUI_API void SetNextTreeNodeOpen(bool is_open, ImGuiSetCond cond = 0); // set next TreeNode/CollapsingHeader open state.
IMGUI_API float GetTreeNodeToLabelSpacing(ImGuiTreeNodeFlags flags = 0); // return horizontal distance between cursor and text label due to collapsing node. == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode
IMGUI_API bool CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags = 0); // if returning 'true' the header is open. user doesn't have to call TreePop().
IMGUI_API bool CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags flags = 0); // when 'p_open' isn't NULL, display an additional small close button on upper right of the header
@@ -360,15 +361,15 @@ namespace ImGui
// Popups
IMGUI_API void OpenPopup(const char* str_id); // mark popup as open. popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
- IMGUI_API bool BeginPopup(const char* str_id); // return true if popup if opened and start outputting to it. only call EndPopup() if BeginPopup() returned true!
- IMGUI_API bool BeginPopupModal(const char* name, bool* p_opened = NULL, ImGuiWindowFlags extra_flags = 0); // modal dialog (can't close them by clicking outside)
+ IMGUI_API bool BeginPopup(const char* str_id); // return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returned true!
+ IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags extra_flags = 0); // modal dialog (can't close them by clicking outside)
IMGUI_API bool BeginPopupContextItem(const char* str_id, int mouse_button = 1); // helper to open and begin popup when clicked on last item. read comments in .cpp!
IMGUI_API bool BeginPopupContextWindow(bool also_over_items = true, const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked on current window.
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked in void (no window).
IMGUI_API void EndPopup();
IMGUI_API void CloseCurrentPopup(); // close the popup we have begin-ed into. clicking on a MenuItem or Selectable automatically close the current popup.
- // Logging: all text output from interface is redirected to tty/file/clipboard. Tree nodes are automatically opened.
+ // Logging: all text output from interface is redirected to tty/file/clipboard. By default, tree nodes are automatically opened during logging.
IMGUI_API void LogToTTY(int max_depth = -1); // start logging to tty
IMGUI_API void LogToFile(int max_depth = -1, const char* filename = NULL); // start logging to file
IMGUI_API void LogToClipboard(int max_depth = -1); // start logging to OS clipboard
@@ -442,18 +443,20 @@ namespace ImGui
IMGUI_API const char* GetClipboardText();
IMGUI_API void SetClipboardText(const char* text);
- // Internal state/context access - if you want to use multiple ImGui context, or share context between modules (e.g. DLL), or allocate the memory yourself
+ // Internal context access - if you want to use multiple context, share context between modules (e.g. DLL). There is a default context created and active by default.
+ // All contexts share a same ImFontAtlas by default. If you want different font atlas, you can new() them and overwrite the GetIO().Fonts variable of an ImGui context.
IMGUI_API const char* GetVersion();
- IMGUI_API void* GetInternalState();
- IMGUI_API size_t GetInternalStateSize();
- IMGUI_API void SetInternalState(void* state, bool construct = false);
+ IMGUI_API ImGuiContext* CreateContext(void* (*malloc_fn)(size_t) = NULL, void (*free_fn)(void*) = NULL);
+ IMGUI_API void DestroyContext(ImGuiContext* ctx);
+ IMGUI_API ImGuiContext* GetCurrentContext();
+ IMGUI_API void SetCurrentContext(ImGuiContext* ctx);
// Obsolete (will be removed)
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
static inline bool CollapsingHeader(const char* label, const char* str_id, bool display_frame = true, bool default_open = false) { (void)str_id; (void)display_frame; ImGuiTreeNodeFlags default_open_flags = 1<<5; return CollapsingHeader(label, (default_open ? default_open_flags : 0)); } // OBSOLETE 1.49+
static inline ImFont* GetWindowFont() { return GetFont(); } // OBSOLETE 1.48+
static inline float GetWindowFontSize() { return GetFontSize(); } // OBSOLETE 1.48+
- static inline void OpenNextNode(bool open) { ImGui::SetNextTreeNodeOpened(open, 0); } // OBSOLETE 1.34+
+ static inline void OpenNextNode(bool open) { ImGui::SetNextTreeNodeOpen(open, 0); } // OBSOLETE 1.34+
static inline bool GetWindowIsFocused() { return ImGui::IsWindowFocused(); } // OBSOLETE 1.36+
static inline bool GetWindowCollapsed() { return ImGui::IsWindowCollapsed(); } // OBSOLETE 1.39+
static inline ImVec2 GetItemBoxMin() { return GetItemRectMin(); } // OBSOLETE 1.36+
@@ -528,15 +531,15 @@ enum ImGuiTreeNodeFlags_
ImGuiTreeNodeFlags_Selected = 1 << 0, // Draw as selected
ImGuiTreeNodeFlags_Framed = 1 << 1, // Full colored frame (e.g. for CollapsingHeader)
ImGuiTreeNodeFlags_AllowOverlapMode = 1 << 2, // Hit testing to allow subsequent widgets to overlap this one
- ImGuiTreeNodeFlags_NoTreePushOnOpen = 1 << 3, // Don't do a TreePush() when opened (e.g. for CollapsingHeader) = no extra indent nor pushing on ID stack
+ ImGuiTreeNodeFlags_NoTreePushOnOpen = 1 << 3, // Don't do a TreePush() when open (e.g. for CollapsingHeader) = no extra indent nor pushing on ID stack
ImGuiTreeNodeFlags_NoAutoOpenOnLog = 1 << 4, // Don't automatically and temporarily open node when Logging is active (by default logging will automatically open tree nodes)
- ImGuiTreeNodeFlags_DefaultOpen = 1 << 5, // Default node to be opened
+ ImGuiTreeNodeFlags_DefaultOpen = 1 << 5, // Default node to be open
ImGuiTreeNodeFlags_OpenOnDoubleClick = 1 << 6, // Need double-click to open node
ImGuiTreeNodeFlags_OpenOnArrow = 1 << 7, // Only open when clicking on the arrow part. If ImGuiTreeNodeFlags_OpenOnDoubleClick is also set, single-click arrow or double-click all box to open.
ImGuiTreeNodeFlags_AlwaysOpen = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes).
//ImGuiTreeNodeFlags_UnindentArrow = 1 << 9, // FIXME: TODO: Unindent tree so that Label is aligned to current X position
//ImGuITreeNodeFlags_SpanAllAvailWidth = 1 << 10, // FIXME: TODO: Extend hit box horizontally even if not framed
- //ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 11, // FIXME: TODO: Automatically scroll on TreePop() if node got just opened and contents is not visible
+ //ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 11, // FIXME: TODO: Automatically scroll on TreePop() if node got just open and contents is not visible
ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoAutoOpenOnLog
};
@@ -950,7 +953,7 @@ struct ImGuiTextBuffer
IMGUI_API void appendv(const char* fmt, va_list args);
};
-// Helper: Key->value storage
+// Helper: Simple Key->value storage
// - Store collapse state for a tree (Int 0/1)
// - Store color edit options (Int using values in ImGuiColorEditMode enum).
// - Custom user storage for temporary values.
@@ -958,6 +961,7 @@ struct ImGuiTextBuffer
// Declare your own storage if:
// - You want to manipulate the open/close state of a particular sub-tree in your interface (tree node uses Int 0/1 to store their state).
// - You want to store custom debug data easily without adding or editing structures in your code.
+// Types are NOT stored, so it is up to you to make sure your Key don't collide with different types.
struct ImGuiStorage
{
struct Pair
@@ -972,10 +976,12 @@ struct ImGuiStorage
// - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N)
// - Set***() functions find pair, insertion on demand if missing.
- // - Sorted insertion is costly but should amortize. A typical frame shouldn't need to insert any new pair.
+ // - Sorted insertion is costly, paid once. A typical frame shouldn't need to insert any new pair.
IMGUI_API void Clear();
IMGUI_API int GetInt(ImGuiID key, int default_val = 0) const;
IMGUI_API void SetInt(ImGuiID key, int val);
+ IMGUI_API bool GetBool(ImGuiID key, bool default_val = false) const;
+ IMGUI_API void SetBool(ImGuiID key, bool val);
IMGUI_API float GetFloat(ImGuiID key, float default_val = 0.0f) const;
IMGUI_API void SetFloat(ImGuiID key, float val);
IMGUI_API void* GetVoidPtr(ImGuiID key) const; // default_val is NULL
@@ -987,7 +993,8 @@ struct ImGuiStorage
// float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar;
// - You can also use this to quickly create temporary editable values during a session of using Edit&Continue, without restarting your application.
IMGUI_API int* GetIntRef(ImGuiID key, int default_val = 0);
- IMGUI_API float* GetFloatRef(ImGuiID key, float default_val = 0);
+ IMGUI_API bool* GetBoolRef(ImGuiID key, bool default_val = false);
+ IMGUI_API float* GetFloatRef(ImGuiID key, float default_val = 0.0f);
IMGUI_API void** GetVoidPtrRef(ImGuiID key, void* default_val = NULL);
// Use on your own storage if you know only integer are being stored (open/close all tree nodes)
diff --git a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_demo.cpp b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_demo.cpp
index 794eb4e2c9b..3a2296e6780 100644
--- a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_demo.cpp
+++ b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_demo.cpp
@@ -25,13 +25,17 @@
#define snprintf _snprintf
#endif
#ifdef __clang__
+#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // warning : 'xx' is deprecated: The POSIX name for this item.. // for strdup used in demo code (so user can copy & paste the code)
#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int'
#pragma clang diagnostic ignored "-Wformat-security" // warning : warning: format string is not a string literal
-#endif
-#ifdef __GNUC__
+#pragma clang diagnostic ignored "-Wexit-time-destructors" // warning : declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals.
+#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning : macro name is a reserved identifier //
+#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size
#pragma GCC diagnostic ignored "-Wformat-security" // warning : format string is not a string literal (potentially insecure)
+#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
+#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
#endif
// Play it nice with Windows users. Notepad in 2015 still doesn't display text data with Unix-style \n.
@@ -49,15 +53,15 @@
#ifndef IMGUI_DISABLE_TEST_WINDOWS
-static void ShowExampleAppConsole(bool* opened);
-static void ShowExampleAppLog(bool* opened);
-static void ShowExampleAppLayout(bool* opened);
-static void ShowExampleAppPropertyEditor(bool* opened);
-static void ShowExampleAppLongText(bool* opened);
-static void ShowExampleAppAutoResize(bool* opened);
-static void ShowExampleAppFixedOverlay(bool* opened);
-static void ShowExampleAppManipulatingWindowTitle(bool* opened);
-static void ShowExampleAppCustomRendering(bool* opened);
+static void ShowExampleAppConsole(bool* p_open);
+static void ShowExampleAppLog(bool* p_open);
+static void ShowExampleAppLayout(bool* p_open);
+static void ShowExampleAppPropertyEditor(bool* p_open);
+static void ShowExampleAppLongText(bool* p_open);
+static void ShowExampleAppAutoResize(bool* p_open);
+static void ShowExampleAppFixedOverlay(bool* p_open);
+static void ShowExampleAppManipulatingWindowTitle(bool* p_open);
+static void ShowExampleAppCustomRendering(bool* p_open);
static void ShowExampleAppMainMenuBar();
static void ShowExampleMenuFile();
@@ -91,7 +95,7 @@ void ImGui::ShowUserGuide()
}
// Demonstrate most ImGui features (big function!)
-void ImGui::ShowTestWindow(bool* p_opened)
+void ImGui::ShowTestWindow(bool* p_open)
{
// Examples apps
static bool show_app_main_menu_bar = false;
@@ -150,7 +154,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
if (no_collapse) window_flags |= ImGuiWindowFlags_NoCollapse;
if (!no_menu) window_flags |= ImGuiWindowFlags_MenuBar;
ImGui::SetNextWindowSize(ImVec2(550,680), ImGuiSetCond_FirstUseEver);
- if (!ImGui::Begin("ImGui Demo", p_opened, window_flags))
+ if (!ImGui::Begin("ImGui Demo", p_open, window_flags))
{
// Early out if the window is collapsed, as an optimization.
ImGui::End();
@@ -217,47 +221,6 @@ void ImGui::ShowTestWindow(bool* p_opened)
ImGui::TreePop();
}
- if (ImGui::TreeNode("Fonts", "Fonts (%d)", ImGui::GetIO().Fonts->Fonts.Size))
- {
- ImGui::SameLine(); ShowHelpMarker("Tip: Load fonts with io.Fonts->AddFontFromFileTTF()\nbefore calling io.Fonts->GetTex* functions.");
- ImFontAtlas* atlas = ImGui::GetIO().Fonts;
- if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
- {
- ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0,0), ImVec2(1,1), ImColor(255,255,255,255), ImColor(255,255,255,128));
- ImGui::TreePop();
- }
- ImGui::PushItemWidth(100);
- for (int i = 0; i < atlas->Fonts.Size; i++)
- {
- ImFont* font = atlas->Fonts[i];
- ImGui::BulletText("Font %d: \'%s\', %.2f px, %d glyphs", i, font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size);
- ImGui::TreePush((void*)(intptr_t)i);
- if (i > 0) { ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) { atlas->Fonts[i] = atlas->Fonts[0]; atlas->Fonts[0] = font; } }
- ImGui::PushFont(font);
- ImGui::Text("The quick brown fox jumps over the lazy dog");
- ImGui::PopFont();
- if (ImGui::TreeNode("Details"))
- {
- ImGui::DragFloat("font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); // scale only this font
- ImGui::Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent);
- ImGui::Text("Fallback character: '%c' (%d)", font->FallbackChar, font->FallbackChar);
- for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
- {
- ImFontConfig* cfg = &font->ConfigData[config_i];
- ImGui::BulletText("Input %d: \'%s\'\nOversample: (%d,%d), PixelSnapH: %d", config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH);
- }
- ImGui::TreePop();
- }
- ImGui::TreePop();
- }
- static float window_scale = 1.0f;
- ImGui::DragFloat("this window scale", &window_scale, 0.005f, 0.3f, 2.0f, "%.1f"); // scale only this window
- ImGui::DragFloat("global scale", &ImGui::GetIO().FontGlobalScale, 0.005f, 0.3f, 2.0f, "%.1f"); // scale everything
- ImGui::PopItemWidth();
- ImGui::SetWindowFontScale(window_scale);
- ImGui::TreePop();
- }
-
if (ImGui::TreeNode("Logging"))
{
ImGui::TextWrapped("The logging API redirects all text output so you can easily capture the content of a window or a block. Tree nodes can be automatically expanded. You can also call ImGui::LogText() to output directly to the log without a visual output.");
@@ -293,12 +256,12 @@ void ImGui::ShowTestWindow(bool* p_opened)
ImGuiTreeNodeFlags node_flags = ((selection_mask & (1 << i)) ? ImGuiTreeNodeFlags_Selected : 0) | ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick;
if (i >= 3)
node_flags |= ImGuiTreeNodeFlags_AlwaysOpen;
- bool opened = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable %s %d", (i >= 3) ? "Leaf" : "Node", i);
+ bool node_open = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable %s %d", (i >= 3) ? "Leaf" : "Node", i);
if (ImGui::IsItemClicked())
node_clicked = i;
- if (opened)
+ if (node_open)
{
- ImGui::Text("Blah blah");
+ ImGui::Text("Selectable Blah blah");
ImGui::Text("Blah blah");
ImGui::TreePop();
}
@@ -1046,9 +1009,9 @@ void ImGui::ShowTestWindow(bool* p_opened)
if (ImGui::TreeNode("Node##1")) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
ImGui::AlignFirstTextHeightToWidgets(); // Vertically align text node a bit lower so it'll be vertically centered with upcoming widget. Otherwise you can use SmallButton (smaller fit).
- bool tree_opened = ImGui::TreeNode("Node##2"); // Common mistake to avoid: if we want to SameLine after TreeNode we need to do it before we add child content.
+ bool node_open = ImGui::TreeNode("Node##2"); // Common mistake to avoid: if we want to SameLine after TreeNode we need to do it before we add child content.
ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##2");
- if (tree_opened) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
+ if (node_open) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
// Bullet
ImGui::Button("Button##3");
@@ -1068,9 +1031,11 @@ void ImGui::ShowTestWindow(bool* p_opened)
static bool track = true;
static int track_line = 50, scroll_to_px = 200;
ImGui::Checkbox("Track", &track);
+ ImGui::PushItemWidth(100);
ImGui::SameLine(130); track |= ImGui::DragInt("##line", &track_line, 0.25f, 0, 99, "Line %.0f");
bool scroll_to = ImGui::Button("Scroll To");
ImGui::SameLine(130); scroll_to |= ImGui::DragInt("##pos_y", &scroll_to_px, 1.00f, 0, 9999, "y = %.0f px");
+ ImGui::PopItemWidth();
if (scroll_to) track = false;
for (int i = 0; i < 5; i++)
@@ -1279,6 +1244,9 @@ void ImGui::ShowTestWindow(bool* p_opened)
ImGui::Text("All those beautiful files will be deleted.\nThis operation cannot be undone!\n\n");
ImGui::Separator();
+ //static int dummy_i = 0;
+ //ImGui::Combo("Combo", &dummy_i, "Delete\0Delete harder\0");
+
static bool dont_ask_me_next_time = false;
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0,0));
ImGui::Checkbox("Don't ask me next time", &dont_ask_me_next_time);
@@ -1437,9 +1405,9 @@ void ImGui::ShowTestWindow(bool* p_opened)
ImGui::TreePop();
}
- bool node_opened = ImGui::TreeNode("Tree within single cell");
+ bool node_open = ImGui::TreeNode("Tree within single cell");
ImGui::SameLine(); ShowHelpMarker("NB: Tree node must be poped before ending the cell.\nThere's no storage of state per-cell.");
- if (node_opened)
+ if (node_open)
{
ImGui::Columns(2, "tree items");
ImGui::Separator();
@@ -1685,6 +1653,47 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
ImGui::TreePop();
}
+ if (ImGui::TreeNode("Fonts", "Fonts (%d)", ImGui::GetIO().Fonts->Fonts.Size))
+ {
+ ImGui::SameLine(); ShowHelpMarker("Tip: Load fonts with io.Fonts->AddFontFromFileTTF()\nbefore calling io.Fonts->GetTex* functions.");
+ ImFontAtlas* atlas = ImGui::GetIO().Fonts;
+ if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
+ {
+ ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0,0), ImVec2(1,1), ImColor(255,255,255,255), ImColor(255,255,255,128));
+ ImGui::TreePop();
+ }
+ ImGui::PushItemWidth(100);
+ for (int i = 0; i < atlas->Fonts.Size; i++)
+ {
+ ImFont* font = atlas->Fonts[i];
+ ImGui::BulletText("Font %d: \'%s\', %.2f px, %d glyphs", i, font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size);
+ ImGui::TreePush((void*)(intptr_t)i);
+ if (i > 0) { ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) { atlas->Fonts[i] = atlas->Fonts[0]; atlas->Fonts[0] = font; } }
+ ImGui::PushFont(font);
+ ImGui::Text("The quick brown fox jumps over the lazy dog");
+ ImGui::PopFont();
+ if (ImGui::TreeNode("Details"))
+ {
+ ImGui::DragFloat("font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); // scale only this font
+ ImGui::Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent);
+ ImGui::Text("Fallback character: '%c' (%d)", font->FallbackChar, font->FallbackChar);
+ for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
+ {
+ ImFontConfig* cfg = &font->ConfigData[config_i];
+ ImGui::BulletText("Input %d: \'%s\'\nOversample: (%d,%d), PixelSnapH: %d", config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH);
+ }
+ ImGui::TreePop();
+ }
+ ImGui::TreePop();
+ }
+ static float window_scale = 1.0f;
+ ImGui::DragFloat("this window scale", &window_scale, 0.005f, 0.3f, 2.0f, "%.1f"); // scale only this window
+ ImGui::DragFloat("global scale", &ImGui::GetIO().FontGlobalScale, 0.005f, 0.3f, 2.0f, "%.1f"); // scale everything
+ ImGui::PopItemWidth();
+ ImGui::SetWindowFontScale(window_scale);
+ ImGui::TreePop();
+ }
+
ImGui::PopItemWidth();
}
@@ -1766,9 +1775,9 @@ static void ShowExampleMenuFile()
if (ImGui::MenuItem("Quit", "Alt+F4")) {}
}
-static void ShowExampleAppAutoResize(bool* opened)
+static void ShowExampleAppAutoResize(bool* p_open)
{
- if (!ImGui::Begin("Example: Auto-resizing window", opened, ImGuiWindowFlags_AlwaysAutoResize))
+ if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize))
{
ImGui::End();
return;
@@ -1782,10 +1791,10 @@ static void ShowExampleAppAutoResize(bool* opened)
ImGui::End();
}
-static void ShowExampleAppFixedOverlay(bool* opened)
+static void ShowExampleAppFixedOverlay(bool* p_open)
{
ImGui::SetNextWindowPos(ImVec2(10,10));
- if (!ImGui::Begin("Example: Fixed Overlay", opened, ImVec2(0,0), 0.3f, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoSavedSettings))
+ if (!ImGui::Begin("Example: Fixed Overlay", p_open, ImVec2(0,0), 0.3f, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoSavedSettings))
{
ImGui::End();
return;
@@ -1796,9 +1805,9 @@ static void ShowExampleAppFixedOverlay(bool* opened)
ImGui::End();
}
-static void ShowExampleAppManipulatingWindowTitle(bool* opened)
+static void ShowExampleAppManipulatingWindowTitle(bool* p_open)
{
- (void)opened;
+ (void)p_open;
// By default, Windows are uniquely identified by their title.
// You can use the "##" and "###" markers to manipulate the display/ID. Read FAQ at the top of this file!
@@ -1823,10 +1832,10 @@ static void ShowExampleAppManipulatingWindowTitle(bool* opened)
ImGui::End();
}
-static void ShowExampleAppCustomRendering(bool* opened)
+static void ShowExampleAppCustomRendering(bool* p_open)
{
ImGui::SetNextWindowSize(ImVec2(350,560), ImGuiSetCond_FirstUseEver);
- if (!ImGui::Begin("Example: Custom rendering", opened))
+ if (!ImGui::Begin("Example: Custom rendering", p_open))
{
ImGui::End();
return;
@@ -1975,10 +1984,10 @@ struct ExampleAppConsole
ScrollToBottom = true;
}
- void Draw(const char* title, bool* opened)
+ void Draw(const char* title, bool* p_open)
{
ImGui::SetNextWindowSize(ImVec2(520,600), ImGuiSetCond_FirstUseEver);
- if (!ImGui::Begin(title, opened))
+ if (!ImGui::Begin(title, p_open))
{
ImGui::End();
return;
@@ -2182,7 +2191,7 @@ struct ExampleAppConsole
// A better implementation would preserve the data on the current input line along with cursor position.
if (prev_history_pos != HistoryPos)
{
- data->CursorPos = data->SelectionStart = data->SelectionEnd = data->BufTextLen = (int)snprintf(data->Buf, data->BufSize, "%s", (HistoryPos >= 0) ? History[HistoryPos] : "");
+ data->CursorPos = data->SelectionStart = data->SelectionEnd = data->BufTextLen = (int)snprintf(data->Buf, (size_t)data->BufSize, "%s", (HistoryPos >= 0) ? History[HistoryPos] : "");
data->BufDirty = true;
}
}
@@ -2191,10 +2200,10 @@ struct ExampleAppConsole
}
};
-static void ShowExampleAppConsole(bool* opened)
+static void ShowExampleAppConsole(bool* p_open)
{
static ExampleAppConsole console;
- console.Draw("Example: Console", opened);
+ console.Draw("Example: Console", p_open);
}
// Usage:
@@ -2223,10 +2232,10 @@ struct ExampleAppLog
ScrollToBottom = true;
}
- void Draw(const char* title, bool* p_opened = NULL)
+ void Draw(const char* title, bool* p_open = NULL)
{
ImGui::SetNextWindowSize(ImVec2(500,400), ImGuiSetCond_FirstUseEver);
- ImGui::Begin(title, p_opened);
+ ImGui::Begin(title, p_open);
if (ImGui::Button("Clear")) Clear();
ImGui::SameLine();
bool copy = ImGui::Button("Copy");
@@ -2261,7 +2270,7 @@ struct ExampleAppLog
}
};
-static void ShowExampleAppLog(bool* opened)
+static void ShowExampleAppLog(bool* p_open)
{
static ExampleAppLog log;
@@ -2275,19 +2284,19 @@ static void ShowExampleAppLog(bool* opened)
last_time = time;
}
- log.Draw("Example: Log", opened);
+ log.Draw("Example: Log", p_open);
}
-static void ShowExampleAppLayout(bool* opened)
+static void ShowExampleAppLayout(bool* p_open)
{
ImGui::SetNextWindowSize(ImVec2(500, 440), ImGuiSetCond_FirstUseEver);
- if (ImGui::Begin("Example: Layout", opened, ImGuiWindowFlags_MenuBar))
+ if (ImGui::Begin("Example: Layout", p_open, ImGuiWindowFlags_MenuBar))
{
if (ImGui::BeginMenuBar())
{
if (ImGui::BeginMenu("File"))
{
- if (ImGui::MenuItem("Close")) *opened = false;
+ if (ImGui::MenuItem("Close")) *p_open = false;
ImGui::EndMenu();
}
ImGui::EndMenuBar();
@@ -2323,10 +2332,10 @@ static void ShowExampleAppLayout(bool* opened)
ImGui::End();
}
-static void ShowExampleAppPropertyEditor(bool* p_opened)
+static void ShowExampleAppPropertyEditor(bool* p_open)
{
ImGui::SetNextWindowSize(ImVec2(430,450), ImGuiSetCond_FirstUseEver);
- if (!ImGui::Begin("Example: Property editor", p_opened))
+ if (!ImGui::Begin("Example: Property editor", p_open))
{
ImGui::End();
return;
@@ -2340,16 +2349,16 @@ static void ShowExampleAppPropertyEditor(bool* p_opened)
struct funcs
{
- static void ShowDummyObject(const char* prefix, ImU32 uid)
+ static void ShowDummyObject(const char* prefix, int uid)
{
ImGui::PushID(uid); // Use object uid as identifier. Most commonly you could also use the object pointer as a base ID.
ImGui::AlignFirstTextHeightToWidgets(); // Text and Tree nodes are less high than regular widgets, here we add vertical spacing to make the tree lines equal high.
- bool is_opened = ImGui::TreeNode("Object", "%s_%u", prefix, uid);
+ bool node_open = ImGui::TreeNode("Object", "%s_%u", prefix, uid);
ImGui::NextColumn();
ImGui::AlignFirstTextHeightToWidgets();
ImGui::Text("my sailor is rich");
ImGui::NextColumn();
- if (is_opened)
+ if (node_open)
{
static float dummy_members[8] = { 0.0f,0.0f,1.0f,3.1416f,100.0f,999.0f };
for (int i = 0; i < 8; i++)
@@ -2357,7 +2366,7 @@ static void ShowExampleAppPropertyEditor(bool* p_opened)
ImGui::PushID(i); // Use field index as identifier.
if (i < 2)
{
- ShowDummyObject("Child", ImGui::GetID("foo"));
+ ShowDummyObject("Child", 424242);
}
else
{
@@ -2395,10 +2404,10 @@ static void ShowExampleAppPropertyEditor(bool* p_opened)
ImGui::End();
}
-static void ShowExampleAppLongText(bool* opened)
+static void ShowExampleAppLongText(bool* p_open)
{
ImGui::SetNextWindowSize(ImVec2(520,600), ImGuiSetCond_FirstUseEver);
- if (!ImGui::Begin("Example: Long text display", opened))
+ if (!ImGui::Begin("Example: Long text display", p_open))
{
ImGui::End();
return;
diff --git a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_draw.cpp b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_draw.cpp
index 4f3fe3a228a..28e4a985f40 100644
--- a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_draw.cpp
+++ b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_draw.cpp
@@ -37,10 +37,11 @@
#pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants ok.
#pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference it.
#pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness //
-//#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning : macro name is a reserved identifier //
-#endif
-#ifdef __GNUC__
+#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning : macro name is a reserved identifier //
+#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
+#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
+#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
#endif
//-------------------------------------------------------------------------
@@ -58,7 +59,7 @@ namespace IMGUI_STB_NAMESPACE
#ifdef _MSC_VER
#pragma warning (push)
-#pragma warning (disable: 4456) // declaration of 'xx' hides previous local declaration
+#pragma warning (disable: 4456) // declaration of 'xx' hides previous local declaration
#endif
#ifdef __clang__
@@ -68,6 +69,11 @@ namespace IMGUI_STB_NAMESPACE
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#endif
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtype-limits" // warning: comparison is always true due to limited range of data type [-Wtype-limits]
+#endif
+
#define STBRP_ASSERT(x) IM_ASSERT(x)
#ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
#define STBRP_STATIC
@@ -86,6 +92,10 @@ namespace IMGUI_STB_NAMESPACE
#endif
#include "stb_truetype.h"
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
#ifdef __clang__
#pragma clang diagnostic pop
#endif
@@ -237,7 +247,7 @@ void ImDrawList::PushClipRect(ImVec2 cr_min, ImVec2 cr_max, bool intersect_with_
void ImDrawList::PushClipRectFullScreen()
{
PushClipRect(ImVec2(GNullClipRect.x, GNullClipRect.y), ImVec2(GNullClipRect.z, GNullClipRect.w));
- //PushClipRect(GetVisibleRect()); // FIXME-OPT: This would be more correct but we're not supposed to access ImGuiState from here?
+ //PushClipRect(GetVisibleRect()); // FIXME-OPT: This would be more correct but we're not supposed to access ImGuiContext from here?
}
void ImDrawList::PopClipRect()
@@ -1658,7 +1668,7 @@ ImFont::~ImFont()
// If you want to delete fonts you need to do it between Render() and NewFrame().
// FIXME-CLEANUP
/*
- ImGuiState& g = *GImGui;
+ ImGuiContext& g = *GImGui;
if (g.Font == this)
g.Font = NULL;
*/
diff --git a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_internal.h b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_internal.h
index 0ef0b8478e7..6c90e53a6b8 100644
--- a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_internal.h
+++ b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_internal.h
@@ -33,7 +33,6 @@ struct ImGuiTextEditState;
struct ImGuiIniData;
struct ImGuiMouseCursorData;
struct ImGuiPopupRef;
-struct ImGuiState;
struct ImGuiWindow;
typedef int ImGuiLayoutType; // enum ImGuiLayoutType_
@@ -71,7 +70,7 @@ namespace ImGuiStb
// Context
//-----------------------------------------------------------------------------
-extern IMGUI_API ImGuiState* GImGui;
+extern IMGUI_API ImGuiContext* GImGui; // current implicit ImGui context pointer
//-----------------------------------------------------------------------------
// Helpers
@@ -144,7 +143,7 @@ static inline ImVec2 ImFloor(ImVec2 v)
struct ImPlacementNewDummy {};
inline void* operator new(size_t, ImPlacementNewDummy, void* ptr) { return ptr; }
inline void operator delete(void*, ImPlacementNewDummy, void*) {}
-#define IM_PLACEMENT_NEW(_PTR) new(ImPlacementNewDummy() ,_PTR)
+#define IM_PLACEMENT_NEW(_PTR) new(ImPlacementNewDummy(), _PTR)
#endif
//-----------------------------------------------------------------------------
@@ -274,7 +273,7 @@ struct ImGuiColumnData
//float IndentX;
};
-// Simple column measurement currently used for MenuItem() only. This is very short-sighted for now and NOT a generic helper.
+// Simple column measurement currently used for MenuItem() only. This is very short-sighted/throw-away code and NOT a generic helper.
struct IMGUI_API ImGuiSimpleColumns
{
int Count;
@@ -283,9 +282,9 @@ struct IMGUI_API ImGuiSimpleColumns
float Pos[8], NextWidths[8];
ImGuiSimpleColumns();
- void Update(int count, float spacing, bool clear);
- float DeclColumns(float w0, float w1, float w2);
- float CalcExtraSpace(float avail_w);
+ void Update(int count, float spacing, bool clear);
+ float DeclColumns(float w0, float w1, float w2);
+ float CalcExtraSpace(float avail_w);
};
// Internal state of the currently focused/edited text input box
@@ -345,7 +344,7 @@ struct ImGuiPopupRef
};
// Main state for ImGui
-struct ImGuiState
+struct ImGuiContext
{
bool Initialized;
ImGuiIO IO;
@@ -375,13 +374,14 @@ struct ImGuiState
bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
bool ActiveIdAllowOverlap; // Set only by active widget
ImGuiWindow* ActiveIdWindow;
- ImGuiWindow* MovedWindow; // Track the child window we clicked on to move a window. Pointer is only valid if ActiveID is the "#MOVE" identifier of a window.
+ ImGuiWindow* MovedWindow; // Track the child window we clicked on to move a window.
+ ImGuiID MovedWindowMoveId; // == MovedWindow->RootWindow->MoveId
ImVector<ImGuiIniData> Settings; // .ini Settings
- float SettingsDirtyTimer; // Save .ini settinngs on disk when time reaches zero
+ float SettingsDirtyTimer; // Save .ini Settings on disk when time reaches zero
ImVector<ImGuiColMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar()
ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont()
- ImVector<ImGuiPopupRef> OpenedPopupStack; // Which popups are open (persistent)
+ ImVector<ImGuiPopupRef> OpenPopupStack; // Which popups are open (persistent)
ImVector<ImGuiPopupRef> CurrentPopupStack; // Which level of BeginPopup() we are in (reset every frame)
// Storage for SetNexWindow** and SetNextTreeNode*** functions
@@ -394,8 +394,8 @@ struct ImGuiState
ImGuiSetCond SetNextWindowContentSizeCond;
ImGuiSetCond SetNextWindowCollapsedCond;
bool SetNextWindowFocus;
- bool SetNextTreeNodeOpenedVal;
- ImGuiSetCond SetNextTreeNodeOpenedCond;
+ bool SetNextTreeNodeOpenVal;
+ ImGuiSetCond SetNextTreeNodeOpenCond;
// Render
ImDrawData RenderDrawData; // Main ImDrawData instance to pass render information to the user
@@ -416,7 +416,7 @@ struct ImGuiState
float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
float DragSpeedScaleSlow;
float DragSpeedScaleFast;
- ImVec2 ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
+ ImVec2 ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
char Tooltip[1024];
char* PrivateClipboard; // If no custom clipboard handler is defined
ImVec2 OsImePosRequest, OsImePosSet; // Cursor position request & last passed to the OS Input Method Editor
@@ -436,7 +436,7 @@ struct ImGuiState
int CaptureKeyboardNextFrame;
char TempBuffer[1024*3+1]; // temporary text buffer
- ImGuiState()
+ ImGuiContext()
{
Initialized = false;
Font = NULL;
@@ -460,6 +460,7 @@ struct ImGuiState
ActiveIdAllowOverlap = false;
ActiveIdWindow = NULL;
MovedWindow = NULL;
+ MovedWindowMoveId = 0;
SettingsDirtyTimer = 0.0f;
SetNextWindowPosVal = ImVec2(0.0f, 0.0f);
@@ -470,8 +471,8 @@ struct ImGuiState
SetNextWindowContentSizeCond = 0;
SetNextWindowCollapsedCond = 0;
SetNextWindowFocus = false;
- SetNextTreeNodeOpenedVal = false;
- SetNextTreeNodeOpenedCond = 0;
+ SetNextTreeNodeOpenVal = false;
+ SetNextTreeNodeOpenCond = 0;
ScalarAsInputTextId = 0;
ActiveClickDeltaToCenter = ImVec2(0.0f, 0.0f);
@@ -627,7 +628,7 @@ struct IMGUI_API ImGuiWindow
ImGuiDrawContext DC; // Temporary per-window data, reset at the beginning of the frame
ImVector<ImGuiID> IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack
ImRect ClipRect; // = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
- ImRect ClippedWindowRect; // = ClipRect just after setup in Begin()
+ ImRect WindowRectClipped; // = WindowRect just after setup in Begin(). == window->Rect() for root window.
int LastFrameActive;
float ItemWidthDefault;
ImGuiSimpleColumns MenuColumns; // Simplified columns storage for menu items
@@ -635,7 +636,8 @@ struct IMGUI_API ImGuiWindow
float FontWindowScale; // Scale multiplier per-window
ImDrawList* DrawList;
ImGuiWindow* RootWindow; // If we are a child window, this is pointing to the first non-child parent window. Else point to ourself.
- ImGuiWindow* RootNonPopupWindow; // If we are a child widnow, this is pointing to the first non-child non-popup parent window. Else point to ourself.
+ ImGuiWindow* RootNonPopupWindow; // If we are a child window, this is pointing to the first non-child non-popup parent window. Else point to ourself.
+ ImGuiWindow* ParentWindow; // If we are a child window, this is pointing to our parent window. Else point to NULL.
// Focus
int FocusIdxAllCounter; // Start at -1 and increase as assigned via FocusItemRegister()
@@ -671,8 +673,8 @@ namespace ImGui
// If this ever crash because g.CurrentWindow is NULL it means that either
// - ImGui::NewFrame() has never been called, which is illegal.
// - You are calling ImGui functions after ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
- inline ImGuiWindow* GetCurrentWindowRead() { ImGuiState& g = *GImGui; return g.CurrentWindow; }
- inline ImGuiWindow* GetCurrentWindow() { ImGuiState& g = *GImGui; g.CurrentWindow->Accessed = true; return g.CurrentWindow; }
+ inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; }
+ inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->Accessed = true; return g.CurrentWindow; }
IMGUI_API ImGuiWindow* GetParentWindow();
IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
IMGUI_API void FocusWindow(ImGuiWindow* window);
@@ -705,7 +707,7 @@ namespace ImGui
IMGUI_API void RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width);
IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, ImGuiAlign align = ImGuiAlign_Default, const ImVec2* clip_min = NULL, const ImVec2* clip_max = NULL);
IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
- IMGUI_API void RenderCollapseTriangle(ImVec2 pos, bool opened, float scale = 1.0f, bool shadow = false);
+ IMGUI_API void RenderCollapseTriangle(ImVec2 pos, bool is_open, float scale = 1.0f, bool shadow = false);
IMGUI_API void RenderBullet(ImVec2 pos);
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col);
IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
@@ -729,7 +731,7 @@ namespace ImGui
IMGUI_API bool InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label, ImGuiDataType data_type, void* data_ptr, ImGuiID id, int decimal_precision);
IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
- IMGUI_API bool TreeNodeBehaviorIsOpened(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextTreeNodeOpened() data, if any. May return true when logging
+ IMGUI_API bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextTreeNodeOpened() data, if any. May return true when logging
IMGUI_API void TreePushRawID(ImGuiID id);
IMGUI_API void PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size);
diff --git a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_wm.cpp b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_wm.cpp
index 8551bc3da58..ac584ce110c 100644
--- a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_wm.cpp
+++ b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_wm.cpp
@@ -915,14 +915,11 @@ namespace ImGuiWM
m_bMain = bMain;
m_bIsDragWindow = bIsDragWindow;
m_pContainer = IMGUI_NEW(Container)(this);
- m_pState = NULL;
m_pPreviousState = NULL;
- void* pTemp = ImGui::GetInternalState();
- m_pState = ImGui::MemAlloc(ImGui::GetInternalStateSize());
- ImGui::SetInternalState(m_pState, false);
ImGui::GetIO().IniFilename = NULL;
- ImGui::SetInternalState(pTemp);
+
+ m_pState = ImGui::CreateContext();
}
PlatformWindow::~PlatformWindow()
@@ -936,7 +933,8 @@ namespace ImGuiWM
}
RestoreState();
- ImGui::MemFree(m_pState);
+ ImGui::DestroyContext(m_pState);
+ m_pState = NULL;
}
void PlatformWindow::OnClose()
@@ -955,22 +953,22 @@ namespace ImGuiWM
{
IM_ASSERT(s_bStatePush == false);
s_bStatePush = true;
- m_pPreviousState = ImGui::GetInternalState();
- ImGui::SetInternalState(m_pState);
- memcpy(&((ImGuiState*)m_pState)->Style, &((ImGuiState*)m_pPreviousState)->Style, sizeof(ImGuiStyle));
+ m_pPreviousState = ImGui::GetCurrentContext();
+ ImGui::SetCurrentContext(m_pState);
+ memcpy(&m_pState->Style, &m_pPreviousState->Style, sizeof(ImGuiStyle) );
}
void PlatformWindow::RestoreState()
{
IM_ASSERT(s_bStatePush == true);
s_bStatePush = false;
- memcpy(&((ImGuiState*)m_pPreviousState)->Style, &((ImGuiState*)m_pState)->Style, sizeof(ImGuiStyle));
- ImGui::SetInternalState(m_pPreviousState);
+ memcpy(&m_pPreviousState->Style, &m_pState->Style, sizeof(ImGuiStyle) );
+ ImGui::SetCurrentContext(m_pPreviousState);
}
void PlatformWindow::OnLoseFocus()
{
- ImGuiState& g = *((ImGuiState*)m_pState);
+ ImGuiContext& g = *m_pState;
g.SetNextWindowPosCond = g.SetNextWindowSizeCond = g.SetNextWindowContentSizeCond = g.SetNextWindowCollapsedCond = g.SetNextWindowFocus = 0;
}
@@ -1444,7 +1442,7 @@ namespace ImGuiWM
m_lPlatformWindowActions.push_back(pAction);
Dock(pWindow, E_DOCK_ORIENTATION_CENTER, m_pDragPlatformWindow);
- ((ImGuiState*)m_pDragPlatformWindow->m_pState)->IO.MouseDown[0] = true;
+ m_pDragPlatformWindow->m_pState->IO.MouseDown[0] = true;
}
}
@@ -1486,7 +1484,6 @@ namespace ImGuiWM
DrawWindowArea(pBestContainer->GetPlatformWindowParent(), oHightlightPos, oHightlightSize, m_oConfig.m_oHightlightAreaColor);
}
- //if (!((ImGuiState*)m_pDragPlatformWindow->m_pState)->IO.MouseDown[0])
ImGuiIO& io = ImGui::GetIO();
if (!io.MouseDown[0])
{
diff --git a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_wm.h b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_wm.h
index ac8bf001a77..e191339e1d7 100644
--- a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_wm.h
+++ b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_wm.h
@@ -172,8 +172,8 @@ namespace ImGuiWM
bool m_bMain;
bool m_bIsDragWindow;
Container* m_pContainer;
- void* m_pState;
- void* m_pPreviousState;
+ ImGuiContext* m_pState;
+ ImGuiContext* m_pPreviousState;
};
typedef ImwList<PlatformWindow*> PlatformWindowList;
diff --git a/3rdparty/bgfx/README.md b/3rdparty/bgfx/README.md
index fbd958eaac4..beaeb068b38 100644
--- a/3rdparty/bgfx/README.md
+++ b/3rdparty/bgfx/README.md
@@ -61,6 +61,7 @@ Languages:
* [Lua language API bindings](https://github.com/excessive/lua-bgfx)
* [Python language API bindings](https://github.com/jnadro/pybgfx#pybgf)
* [Rust language API bindings](https://github.com/rhoot/bgfx-rs)
+ * [Swift language API bindings](https://github.com/stuartcarnie/SwiftBGFX)
[Building](https://bkaradzic.github.io/bgfx/build.html)
----------------------------------------------------
diff --git a/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp b/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp
index 92996ae0314..987ec881b8e 100644
--- a/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp
+++ b/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp
@@ -47,7 +47,7 @@ class ExampleHelloWorld : public entry::AppI
if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
{
// Set view 0 default viewport.
- bgfx::setViewRect(0, 0, 0, m_width, m_height);
+ bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
// This dummy draw call is here to make sure that view 0 is cleared
// if no other draw calls are submitted to view 0.
@@ -55,8 +55,8 @@ class ExampleHelloWorld : public entry::AppI
// Use debug font to print information about this example.
bgfx::dbgTextClear();
- bgfx::dbgTextImage(bx::uint16_max(m_width /2/8, 20)-20
- , bx::uint16_max(m_height/2/16, 6)-6
+ bgfx::dbgTextImage(bx::uint16_max(uint16_t(m_width /2/8 ), 20)-20
+ , bx::uint16_max(uint16_t(m_height/2/16), 6)-6
, 40
, 12
, s_logo
diff --git a/3rdparty/bgfx/examples/01-cubes/cubes.cpp b/3rdparty/bgfx/examples/01-cubes/cubes.cpp
index b0e580647ea..c44b74f04a1 100644
--- a/3rdparty/bgfx/examples/01-cubes/cubes.cpp
+++ b/3rdparty/bgfx/examples/01-cubes/cubes.cpp
@@ -161,7 +161,7 @@ class ExampleCubes : public entry::AppI
bgfx::setViewTransform(0, view, proj);
// Set view 0 default viewport.
- bgfx::setViewRect(0, 0, 0, m_width, m_height);
+ bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
}
// This dummy draw call is here to make sure that view 0 is cleared
diff --git a/3rdparty/bgfx/examples/02-metaballs/metaballs.cpp b/3rdparty/bgfx/examples/02-metaballs/metaballs.cpp
index 882b18b59b0..e40142cb7c3 100644
--- a/3rdparty/bgfx/examples/02-metaballs/metaballs.cpp
+++ b/3rdparty/bgfx/examples/02-metaballs/metaballs.cpp
@@ -549,7 +549,7 @@ class ExampleMetaballs : public entry::AppI
if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
{
// Set view 0 default viewport.
- bgfx::setViewRect(0, 0, 0, m_width, m_height);
+ bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
// This dummy draw call is here to make sure that view 0 is cleared
// if no other draw calls are submitted to view 0.
@@ -595,7 +595,7 @@ class ExampleMetaballs : public entry::AppI
bgfx::setViewTransform(0, view, proj);
// Set view 0 default viewport.
- bgfx::setViewRect(0, 0, 0, m_width, m_height);
+ bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
}
// Stats.
diff --git a/3rdparty/bgfx/examples/03-raymarch/raymarch.cpp b/3rdparty/bgfx/examples/03-raymarch/raymarch.cpp
index 0e4a84c3dc9..9ca8c55e7f7 100644
--- a/3rdparty/bgfx/examples/03-raymarch/raymarch.cpp
+++ b/3rdparty/bgfx/examples/03-raymarch/raymarch.cpp
@@ -37,7 +37,7 @@ inline void mtxProj(float* _result, float _fovy, float _aspect, float _near, flo
bx::mtxProj(_result, _fovy, _aspect, _near, _far, s_oglNdc);
}
-void renderScreenSpaceQuad(uint32_t _view, bgfx::ProgramHandle _program, float _x, float _y, float _width, float _height)
+void renderScreenSpaceQuad(uint8_t _view, bgfx::ProgramHandle _program, float _x, float _y, float _width, float _height)
{
bgfx::TransientVertexBuffer tvb;
bgfx::TransientIndexBuffer tib;
@@ -161,10 +161,10 @@ class ExampleRaymarch : public entry::AppI
if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
{
// Set view 0 default viewport.
- bgfx::setViewRect(0, 0, 0, m_width, m_height);
+ bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
// Set view 1 default viewport.
- bgfx::setViewRect(1, 0, 0, m_width, m_height);
+ bgfx::setViewRect(1, 0, 0, uint16_t(m_width), uint16_t(m_height) );
// This dummy draw call is here to make sure that view 0 is cleared
// if no other draw calls are submitted to viewZ 0.
diff --git a/3rdparty/bgfx/examples/04-mesh/mesh.cpp b/3rdparty/bgfx/examples/04-mesh/mesh.cpp
index 3ae361d9549..89754b59bc8 100644
--- a/3rdparty/bgfx/examples/04-mesh/mesh.cpp
+++ b/3rdparty/bgfx/examples/04-mesh/mesh.cpp
@@ -61,7 +61,7 @@ class ExampleMesh : public entry::AppI
if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
{
// Set view 0 default viewport.
- bgfx::setViewRect(0, 0, 0, m_width, m_height);
+ bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
// This dummy draw call is here to make sure that view 0 is cleared
// if no other draw calls are submitted to view 0.
@@ -109,7 +109,7 @@ class ExampleMesh : public entry::AppI
bgfx::setViewTransform(0, view, proj);
// Set view 0 default viewport.
- bgfx::setViewRect(0, 0, 0, m_width, m_height);
+ bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
}
float mtx[16];
diff --git a/3rdparty/bgfx/examples/05-instancing/instancing.cpp b/3rdparty/bgfx/examples/05-instancing/instancing.cpp
index 34268762948..f4073f68c51 100644
--- a/3rdparty/bgfx/examples/05-instancing/instancing.cpp
+++ b/3rdparty/bgfx/examples/05-instancing/instancing.cpp
@@ -118,7 +118,7 @@ class ExampleInstancing : public entry::AppI
if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
{
// Set view 0 default viewport.
- bgfx::setViewRect(0, 0, 0, m_width, m_height);
+ bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
// This dummy draw call is here to make sure that view 0 is cleared
// if no other draw calls are submitted to view 0.
@@ -178,7 +178,7 @@ class ExampleInstancing : public entry::AppI
bgfx::setViewTransform(0, view, proj);
// Set view 0 default viewport.
- bgfx::setViewRect(0, 0, 0, m_width, m_height);
+ bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
}
const uint16_t instanceStride = 80;
diff --git a/3rdparty/bgfx/examples/06-bump/bump.cpp b/3rdparty/bgfx/examples/06-bump/bump.cpp
index 15952012b01..c6497336423 100644
--- a/3rdparty/bgfx/examples/06-bump/bump.cpp
+++ b/3rdparty/bgfx/examples/06-bump/bump.cpp
@@ -195,7 +195,7 @@ class ExampleBump : public entry::AppI
if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
{
// Set view 0 default viewport.
- bgfx::setViewRect(0, 0, 0, m_width, m_height);
+ bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
// This dummy draw call is here to make sure that view 0 is cleared
// if no other draw calls are submitted to view 0.
@@ -243,7 +243,7 @@ class ExampleBump : public entry::AppI
bgfx::setViewTransform(0, view, proj);
// Set view 0 default viewport.
- bgfx::setViewRect(0, 0, 0, m_width, m_height);
+ bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
}
float lightPosRadius[4][4];
diff --git a/3rdparty/bgfx/examples/08-update/update.cpp b/3rdparty/bgfx/examples/08-update/update.cpp
index 17ce20a44a1..3d2918d703f 100644
--- a/3rdparty/bgfx/examples/08-update/update.cpp
+++ b/3rdparty/bgfx/examples/08-update/update.cpp
@@ -149,9 +149,9 @@ public:
// Create vertex stream declaration.
PosTexcoordVertex::init();
- m_textures[0] = loadTexture("textures/texture_compression_bc1.dds", BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP);
- m_textures[1] = loadTexture("textures/texture_compression_bc2.dds", BGFX_TEXTURE_U_CLAMP);
- m_textures[2] = loadTexture("textures/texture_compression_bc3.dds", BGFX_TEXTURE_V_CLAMP);
+ m_textures[0] = loadTexture("textures/texture_compression_bc1.ktx", BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP);
+ m_textures[1] = loadTexture("textures/texture_compression_bc2.ktx", BGFX_TEXTURE_U_CLAMP);
+ m_textures[2] = loadTexture("textures/texture_compression_bc3.ktx", BGFX_TEXTURE_V_CLAMP);
m_textures[3] = loadTexture("textures/texture_compression_etc1.ktx", BGFX_TEXTURE_U_BORDER|BGFX_TEXTURE_V_BORDER|BGFX_TEXTURE_BORDER_COLOR(1) );
m_textures[4] = loadTexture("textures/texture_compression_etc2.ktx");
m_textures[5] = loadTexture("textures/texture_compression_ptc12.pvr");
diff --git a/3rdparty/bgfx/examples/10-font/font.cpp b/3rdparty/bgfx/examples/10-font/font.cpp
index a15cef4baae..6b95fdafae2 100644
--- a/3rdparty/bgfx/examples/10-font/font.cpp
+++ b/3rdparty/bgfx/examples/10-font/font.cpp
@@ -250,7 +250,7 @@ int _main_(int _argc, char** _argv)
float ortho[16];
bx::mtxOrtho(ortho, centering, width + centering, height + centering, centering, -1.0f, 1.0f);
bgfx::setViewTransform(0, view, ortho);
- bgfx::setViewRect(0, 0, 0, width, height);
+ bgfx::setViewRect(0, 0, 0, uint16_t(width), uint16_t(height) );
}
// Submit the debug text.
diff --git a/3rdparty/bgfx/examples/16-shadowmaps/shadowmaps.cpp b/3rdparty/bgfx/examples/16-shadowmaps/shadowmaps.cpp
index 76e6278045e..e782f3c8d22 100644
--- a/3rdparty/bgfx/examples/16-shadowmaps/shadowmaps.cpp
+++ b/3rdparty/bgfx/examples/16-shadowmaps/shadowmaps.cpp
@@ -771,14 +771,14 @@ static RenderState s_renderStates[RenderState::Count] =
struct ViewState
{
- ViewState(uint32_t _width = 1280, uint32_t _height = 720)
+ ViewState(uint16_t _width = 1280, uint16_t _height = 720)
: m_width(_width)
, m_height(_height)
{
}
- uint32_t m_width;
- uint32_t m_height;
+ uint16_t m_width;
+ uint16_t m_height;
float m_view[16];
float m_proj[16];
@@ -1971,8 +1971,13 @@ int _main_(int _argc, char** _argv)
float timeAccumulatorScene = 0.0f;
entry::MouseState mouseState;
- while (!entry::processEvents(viewState.m_width, viewState.m_height, debug, reset, &mouseState) )
+ uint32_t width;
+ uint32_t height;
+ while (!entry::processEvents(width, height, debug, reset, &mouseState) )
{
+ viewState.m_width = uint16_t(width);
+ viewState.m_height = uint16_t(height);
+
// Imgui.
imguiBeginFrame(mouseState.m_mx
, mouseState.m_my
@@ -2451,7 +2456,7 @@ int _main_(int _argc, char** _argv)
// Reset render targets.
const bgfx::FrameBufferHandle invalidRt = BGFX_INVALID_HANDLE;
- for (uint32_t ii = 0; ii < RENDERVIEW_DRAWDEPTH_3_ID+1; ++ii)
+ for (uint8_t ii = 0; ii < RENDERVIEW_DRAWDEPTH_3_ID+1; ++ii)
{
bgfx::setViewFrameBuffer(ii, invalidRt);
}
@@ -2767,7 +2772,7 @@ int _main_(int _argc, char** _argv)
uint8_t renderStateIndex = RenderState::ShadowMap_PackDepth;
if(LightType::PointLight == settings.m_lightType && settings.m_stencilPack)
{
- renderStateIndex = (ii < 2) ? RenderState::ShadowMap_PackDepthHoriz : RenderState::ShadowMap_PackDepthVert;
+ renderStateIndex = uint8_t( (ii < 2) ? RenderState::ShadowMap_PackDepthHoriz : RenderState::ShadowMap_PackDepthVert);
}
// Floor.
diff --git a/3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp b/3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp
index f0950a205d5..4efcd80b882 100644
--- a/3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp
+++ b/3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp
@@ -7,12 +7,11 @@
#include "bgfx_utils.h"
#include <entry/cmd.h>
#include <entry/input.h>
+#include <debugdraw/debugdraw.h>
#include "camera.h"
#include <bx/uint32_t.h>
-#include "../common/debugdraw/debugdraw.h"
-
class DebugDrawApp : public entry::AppI
{
void init(int _argc, char** _argv) BX_OVERRIDE
diff --git a/3rdparty/bgfx/examples/assets/meshes/build.ninja b/3rdparty/bgfx/examples/assets/meshes/build.ninja
new file mode 100644
index 00000000000..232ba6b6216
--- /dev/null
+++ b/3rdparty/bgfx/examples/assets/meshes/build.ninja
@@ -0,0 +1,18 @@
+include ../../../scripts/common.ninja
+meshes = ../../runtime/meshes
+
+build $meshes/bunny.bin: geometryc_pack_normal bunny.obj
+build $meshes/bunny_decimated.bin: geometryc_pack_normal bunny_decimated.obj
+build $meshes/bunny_patched.bin: geometryc_pack_normal bunny_patched.obj
+build $meshes/column.bin: geometryc_pack_normal column.obj
+build $meshes/cube.bin: geometryc_pack_normal cube.obj
+build $meshes/hollowcube.bin: geometryc_pack_normal hollowcube.obj
+build $meshes/orb.bin: geometryc_pack_normal orb.obj
+build $meshes/platform.bin: geometryc_pack_normal platform.obj
+build $meshes/tree.bin: geometryc_pack_normal tree.obj
+build $meshes/tree1b_lod0_1.bin: geometryc_pack_normal tree1b_lod0_1.obj
+build $meshes/tree1b_lod0_2.bin: geometryc_pack_normal tree1b_lod0_2.obj
+build $meshes/tree1b_lod1_1.bin: geometryc_pack_normal tree1b_lod1_1.obj
+build $meshes/tree1b_lod1_2.bin: geometryc_pack_normal tree1b_lod1_2.obj
+build $meshes/tree1b_lod2_1.bin: geometryc_pack_normal tree1b_lod2_1.obj
+build $meshes/tree1b_lod2_2.bin: geometryc_pack_normal tree1b_lod2_2.obj
diff --git a/3rdparty/bgfx/examples/assets/meshes/makefile b/3rdparty/bgfx/examples/assets/meshes/makefile
deleted file mode 100644
index c171432ebd0..00000000000
--- a/3rdparty/bgfx/examples/assets/meshes/makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
-#
-
-BGFX_DIR=../../..
-RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
-BUILD_DIR=../../.build
-
-include $(BGFX_DIR)/scripts/tools.mk
-
-GEOMETRY_SRC= \
- bunny \
- bunny_decimated \
- bunny_patched \
- column \
- cube \
- hollowcube \
- orb \
- platform \
- tree \
- tree1b_lod0_1 \
- tree1b_lod0_2 \
- tree1b_lod1_1 \
- tree1b_lod1_2 \
- tree1b_lod2_1 \
- tree1b_lod2_2
-
-GEOMETRY_BIN=$(addprefix $(RUNTIME_DIR)/meshes/, $(addsuffix .bin, $(basename $(GEOMETRY_SRC))))
-
-all: $(GEOMETRY_BIN)
-
-clean:
- @echo Cleaning...
- @-rm -vf $(GEOMETRY_BIN)
-
-rebuild: clean all
-
-$(RUNTIME_DIR)/meshes/%.bin : %.obj
- $(SILENT) $(GEOMETRYC) -f $(<) -o $(@) --packnormal 1
diff --git a/3rdparty/bgfx/examples/assets/textures/build.ninja b/3rdparty/bgfx/examples/assets/textures/build.ninja
new file mode 100644
index 00000000000..019e5f868a8
--- /dev/null
+++ b/3rdparty/bgfx/examples/assets/textures/build.ninja
@@ -0,0 +1,8 @@
+include ../../../scripts/common.ninja
+textures = ../../runtime/textures
+
+build $textures/texture_compression_bc1.ktx: texturec_bc1 texture_compression.png
+build $textures/texture_compression_bc2.ktx: texturec_bc2 texture_compression.png
+build $textures/texture_compression_bc3.ktx: texturec_bc3 texture_compression.png
+build $textures/texture_compression_etc1.ktx: texturec_etc1 texture_compression.png
+build $textures/texture_compression_etc2.ktx: texturec_etc2 texture_compression.png
diff --git a/3rdparty/bgfx/examples/08-update/texture_compression.png b/3rdparty/bgfx/examples/assets/textures/texture_compression.png
index fb8386afadb..fb8386afadb 100644
--- a/3rdparty/bgfx/examples/08-update/texture_compression.png
+++ b/3rdparty/bgfx/examples/assets/textures/texture_compression.png
Binary files differ
diff --git a/3rdparty/bgfx/examples/common/cube_atlas.cpp b/3rdparty/bgfx/examples/common/cube_atlas.cpp
index ac7343b9b21..7b83f6f7518 100644
--- a/3rdparty/bgfx/examples/common/cube_atlas.cpp
+++ b/3rdparty/bgfx/examples/common/cube_atlas.cpp
@@ -81,7 +81,7 @@ RectanglePacker::RectanglePacker(uint32_t _width, uint32_t _height)
{
// We want a one pixel border around the whole atlas to avoid any artefact when
// sampling texture
- m_skyline.push_back(Node(1, 1, _width - 2) );
+ m_skyline.push_back(Node(1, 1, uint16_t(_width - 2) ) );
}
void RectanglePacker::init(uint32_t _width, uint32_t _height)
@@ -95,38 +95,35 @@ void RectanglePacker::init(uint32_t _width, uint32_t _height)
m_skyline.clear();
// We want a one pixel border around the whole atlas to avoid any artifact when
// sampling texture
- m_skyline.push_back(Node(1, 1, _width - 2) );
+ m_skyline.push_back(Node(1, 1, uint16_t(_width - 2) ) );
}
bool RectanglePacker::addRectangle(uint16_t _width, uint16_t _height, uint16_t& _outX, uint16_t& _outY)
{
- int yy, best_height, best_index;
+ int best_height, best_index;
int32_t best_width;
Node* node;
Node* prev;
_outX = 0;
_outY = 0;
- uint32_t ii;
-
best_height = INT_MAX;
best_index = -1;
best_width = INT_MAX;
- for (ii = 0; ii < m_skyline.size(); ++ii)
+ for (uint16_t ii = 0, num = uint16_t(m_skyline.size() ); ii < num; ++ii)
{
- yy = fit(ii, _width, _height);
+ int32_t yy = fit(ii, _width, _height);
if (yy >= 0)
{
node = &m_skyline[ii];
if ( ( (yy + _height) < best_height)
- || ( ( (yy + _height) == best_height)
- && (node->width < best_width) ) )
+ || ( ( (yy + _height) == best_height) && (node->width < best_width) ) )
{
- best_height = yy + _height;
+ best_height = uint16_t(yy) + _height;
best_index = ii;
best_width = node->width;
_outX = node->x;
- _outY = yy;
+ _outY = uint16_t(yy);
}
}
}
@@ -139,13 +136,13 @@ bool RectanglePacker::addRectangle(uint16_t _width, uint16_t _height, uint16_t&
Node newNode(_outX, _outY + _height, _width);
m_skyline.insert(m_skyline.begin() + best_index, newNode);
- for (ii = best_index + 1; ii < m_skyline.size(); ++ii)
+ for (uint16_t ii = uint16_t(best_index + 1), num = uint16_t(m_skyline.size() ); ii < num; ++ii)
{
node = &m_skyline[ii];
prev = &m_skyline[ii - 1];
if (node->x < (prev->x + prev->width) )
{
- int shrink = prev->x + prev->width - node->x;
+ uint16_t shrink = uint16_t(prev->x + prev->width - node->x);
node->x += shrink;
node->width -= shrink;
if (node->width <= 0)
@@ -187,7 +184,7 @@ void RectanglePacker::clear()
// We want a one pixel border around the whole atlas to avoid any artefact when
// sampling texture
- m_skyline.push_back(Node(1, 1, m_width - 2) );
+ m_skyline.push_back(Node(1, 1, uint16_t(m_width - 2) ) );
}
int32_t RectanglePacker::fit(uint32_t _skylineNodeIndex, uint16_t _width, uint16_t _height)
diff --git a/3rdparty/bgfx/examples/common/entry/entry.cpp b/3rdparty/bgfx/examples/common/entry/entry.cpp
index 919a783c9dc..0e03876a17e 100644
--- a/3rdparty/bgfx/examples/common/entry/entry.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry.cpp
@@ -188,7 +188,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
const bool isNumber = (Key::Key0 <= _key && _key <= Key::Key9);
if (isNumber)
{
- return '0' + (_key - Key::Key0);
+ return '0' + char(_key - Key::Key0);
}
const bool isChar = (Key::KeyA <= _key && _key <= Key::KeyZ);
@@ -197,7 +197,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
enum { ShiftMask = Modifier::LeftShift|Modifier::RightShift };
const bool shift = !!(_modifiers&ShiftMask);
- return (shift ? 'A' : 'a') + (_key - Key::KeyA);
+ return (shift ? 'A' : 'a') + char(_key - Key::KeyA);
}
switch (_key)
@@ -538,7 +538,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{
_reset = s_reset;
bgfx::reset(_width, _height, _reset);
- inputSetMouseResolution(_width, _height);
+ inputSetMouseResolution(uint16_t(_width), uint16_t(_height) );
}
_debug = s_debug;
@@ -692,7 +692,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
if (handle.idx == 0)
{
- inputSetMouseResolution(win.m_width, win.m_height);
+ inputSetMouseResolution(uint16_t(win.m_width), uint16_t(win.m_height) );
}
}
@@ -700,7 +700,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{
_reset = s_reset;
bgfx::reset(s_window[0].m_width, s_window[0].m_height, _reset);
- inputSetMouseResolution(s_window[0].m_width, s_window[0].m_height);
+ inputSetMouseResolution(uint16_t(s_window[0].m_width), uint16_t(s_window[0].m_height) );
}
_debug = s_debug;
diff --git a/3rdparty/bgfx/examples/common/entry/entry_windows.cpp b/3rdparty/bgfx/examples/common/entry/entry_windows.cpp
index 37f403ee480..9d0308e9617 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_windows.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry_windows.cpp
@@ -823,7 +823,7 @@ namespace entry
WindowHandle findHandle(HWND _hwnd)
{
bx::LwMutexScope scope(m_lock);
- for (uint32_t ii = 0, num = m_windowAlloc.getNumHandles(); ii < num; ++ii)
+ for (uint16_t ii = 0, num = m_windowAlloc.getNumHandles(); ii < num; ++ii)
{
uint16_t idx = m_windowAlloc.getHandleAt(ii);
if (_hwnd == m_hwnd[idx])
diff --git a/3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp b/3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp
index f6f0a4e2bdd..5c320d5227a 100644
--- a/3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp
+++ b/3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp
@@ -364,6 +364,8 @@ struct OcornutImguiContext
io.DeltaTime = 1.0f / 60.0f;
io.IniFilename = NULL;
+ setupStyle(true);
+
#if defined(SCI_NAMESPACE)
io.KeyMap[ImGuiKey_Tab] = (int)entry::Key::Tab;
io.KeyMap[ImGuiKey_LeftArrow] = (int)entry::Key::Left;
@@ -509,6 +511,74 @@ struct OcornutImguiContext
m_allocator = NULL;
}
+ void setupStyle(bool _dark)
+ {
+ // Doug Binks' color scheme
+ // https://gist.github.com/dougbinks/8089b4bbaccaaf6fa204236978d165a9
+ ImGuiStyle& style = ImGui::GetStyle();
+
+ style.FrameRounding = 3.0f;
+ style.Colors[ImGuiCol_Text] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
+ style.Colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
+ style.Colors[ImGuiCol_WindowBg] = ImVec4(0.94f, 0.94f, 0.94f, 1.00f);
+ style.Colors[ImGuiCol_ChildWindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
+ style.Colors[ImGuiCol_Border] = ImVec4(0.00f, 0.00f, 0.00f, 0.39f);
+ style.Colors[ImGuiCol_BorderShadow] = ImVec4(1.00f, 1.00f, 1.00f, 0.10f);
+ style.Colors[ImGuiCol_FrameBg] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
+ style.Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
+ style.Colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
+ style.Colors[ImGuiCol_TitleBg] = ImVec4(0.96f, 0.96f, 0.96f, 1.00f);
+ style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(1.00f, 1.00f, 1.00f, 0.51f);
+ style.Colors[ImGuiCol_TitleBgActive] = ImVec4(0.82f, 0.82f, 0.82f, 1.00f);
+ style.Colors[ImGuiCol_MenuBarBg] = ImVec4(0.86f, 0.86f, 0.86f, 1.00f);
+ style.Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.98f, 0.98f, 0.98f, 0.53f);
+ style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.69f, 0.69f, 0.69f, 0.80f);
+ style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.49f, 0.49f, 0.49f, 0.80f);
+ style.Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.49f, 0.49f, 0.49f, 1.00f);
+ style.Colors[ImGuiCol_ComboBg] = ImVec4(0.86f, 0.86f, 0.86f, 0.99f);
+ style.Colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
+ style.Colors[ImGuiCol_SliderGrab] = ImVec4(0.26f, 0.59f, 0.98f, 0.78f);
+ style.Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
+ style.Colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
+ style.Colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
+ style.Colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f);
+ style.Colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f);
+ style.Colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
+ style.Colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
+ style.Colors[ImGuiCol_Column] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
+ style.Colors[ImGuiCol_ColumnHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.78f);
+ style.Colors[ImGuiCol_ColumnActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
+ style.Colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.50f);
+ style.Colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
+ style.Colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
+ style.Colors[ImGuiCol_CloseButton] = ImVec4(0.59f, 0.59f, 0.59f, 0.50f);
+ style.Colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f);
+ style.Colors[ImGuiCol_CloseButtonActive] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f);
+ style.Colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
+ style.Colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
+ style.Colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
+ style.Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
+ style.Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
+ style.Colors[ImGuiCol_PopupBg] = ImVec4(1.00f, 1.00f, 1.00f, 0.94f);
+ style.Colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
+
+ if (_dark)
+ {
+ for (int i = 0; i <= ImGuiCol_COUNT; i++)
+ {
+ ImVec4& col = style.Colors[i];
+ float H, S, V;
+ ImGui::ColorConvertRGBtoHSV( col.x, col.y, col.z, H, S, V );
+
+ if( S < 0.1f )
+ {
+ V = 1.0f - V;
+ }
+ ImGui::ColorConvertHSVtoRGB( H, S, V, col.x, col.y, col.z );
+ }
+ }
+ }
+
void beginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, int _width, int _height, char _inputChar, uint8_t _viewId)
{
m_viewId = _viewId;
diff --git a/3rdparty/bgfx/examples/runtime/meshes/bunny.bin b/3rdparty/bgfx/examples/runtime/meshes/bunny.bin
index 794ec22c7fe..adcca877ef8 100644
--- a/3rdparty/bgfx/examples/runtime/meshes/bunny.bin
+++ b/3rdparty/bgfx/examples/runtime/meshes/bunny.bin
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/meshes/bunny_decimated.bin b/3rdparty/bgfx/examples/runtime/meshes/bunny_decimated.bin
index d2f2f07e3f6..74810680ee5 100644
--- a/3rdparty/bgfx/examples/runtime/meshes/bunny_decimated.bin
+++ b/3rdparty/bgfx/examples/runtime/meshes/bunny_decimated.bin
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/meshes/bunny_patched.bin b/3rdparty/bgfx/examples/runtime/meshes/bunny_patched.bin
index 217bffeb5ab..4031761a56f 100644
--- a/3rdparty/bgfx/examples/runtime/meshes/bunny_patched.bin
+++ b/3rdparty/bgfx/examples/runtime/meshes/bunny_patched.bin
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/meshes/column.bin b/3rdparty/bgfx/examples/runtime/meshes/column.bin
index 2d1d1dc5dd3..a58c780d121 100644
--- a/3rdparty/bgfx/examples/runtime/meshes/column.bin
+++ b/3rdparty/bgfx/examples/runtime/meshes/column.bin
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/meshes/cube.bin b/3rdparty/bgfx/examples/runtime/meshes/cube.bin
index 874c9408e58..9395fc6a3f6 100644
--- a/3rdparty/bgfx/examples/runtime/meshes/cube.bin
+++ b/3rdparty/bgfx/examples/runtime/meshes/cube.bin
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/meshes/hollowcube.bin b/3rdparty/bgfx/examples/runtime/meshes/hollowcube.bin
index 0ea300901e5..3234750e081 100644
--- a/3rdparty/bgfx/examples/runtime/meshes/hollowcube.bin
+++ b/3rdparty/bgfx/examples/runtime/meshes/hollowcube.bin
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/meshes/orb.bin b/3rdparty/bgfx/examples/runtime/meshes/orb.bin
index ac9455a25a5..336f3680565 100644
--- a/3rdparty/bgfx/examples/runtime/meshes/orb.bin
+++ b/3rdparty/bgfx/examples/runtime/meshes/orb.bin
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/meshes/platform.bin b/3rdparty/bgfx/examples/runtime/meshes/platform.bin
index 27b604341e2..de63c2457b8 100644
--- a/3rdparty/bgfx/examples/runtime/meshes/platform.bin
+++ b/3rdparty/bgfx/examples/runtime/meshes/platform.bin
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/meshes/tree.bin b/3rdparty/bgfx/examples/runtime/meshes/tree.bin
index 6daa0cef736..93aaea0bc92 100644
--- a/3rdparty/bgfx/examples/runtime/meshes/tree.bin
+++ b/3rdparty/bgfx/examples/runtime/meshes/tree.bin
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod0_1.bin b/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod0_1.bin
index dcce8a7aaa4..66b672664b1 100644
--- a/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod0_1.bin
+++ b/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod0_1.bin
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod0_2.bin b/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod0_2.bin
index c7cdb1dd67b..8cb6e5f9e5a 100644
--- a/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod0_2.bin
+++ b/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod0_2.bin
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod1_1.bin b/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod1_1.bin
index d27ea1f0e45..8d69ed81a0c 100644
--- a/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod1_1.bin
+++ b/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod1_1.bin
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod1_2.bin b/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod1_2.bin
index 08d57375fc2..2c903cb9fea 100644
--- a/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod1_2.bin
+++ b/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod1_2.bin
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod2_1.bin b/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod2_1.bin
index 4b8d4b7d275..5a172df2a48 100644
--- a/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod2_1.bin
+++ b/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod2_1.bin
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod2_2.bin b/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod2_2.bin
index 821151e0d9d..8b44cb32297 100644
--- a/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod2_2.bin
+++ b/3rdparty/bgfx/examples/runtime/meshes/tree1b_lod2_2.bin
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc1.dds b/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc1.dds
deleted file mode 100644
index 68fa18230d4..00000000000
--- a/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc1.dds
+++ /dev/null
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc1.ktx b/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc1.ktx
new file mode 100644
index 00000000000..6dfe1108cc6
--- /dev/null
+++ b/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc1.ktx
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc2.dds b/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc2.dds
deleted file mode 100644
index 4a92b37c282..00000000000
--- a/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc2.dds
+++ /dev/null
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc2.ktx b/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc2.ktx
new file mode 100644
index 00000000000..5b191d2b2f1
--- /dev/null
+++ b/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc2.ktx
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc3.dds b/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc3.dds
deleted file mode 100644
index 9a3919889ce..00000000000
--- a/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc3.dds
+++ /dev/null
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc3.ktx b/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc3.ktx
new file mode 100644
index 00000000000..ed4ae91eec2
--- /dev/null
+++ b/3rdparty/bgfx/examples/runtime/textures/texture_compression_bc3.ktx
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/textures/texture_compression_etc1.ktx b/3rdparty/bgfx/examples/runtime/textures/texture_compression_etc1.ktx
index a818345a202..b5006848dbc 100644
--- a/3rdparty/bgfx/examples/runtime/textures/texture_compression_etc1.ktx
+++ b/3rdparty/bgfx/examples/runtime/textures/texture_compression_etc1.ktx
Binary files differ
diff --git a/3rdparty/bgfx/examples/runtime/textures/texture_compression_etc2.ktx b/3rdparty/bgfx/examples/runtime/textures/texture_compression_etc2.ktx
index 5f9738eddb8..0d14cf29da5 100644
--- a/3rdparty/bgfx/examples/runtime/textures/texture_compression_etc2.ktx
+++ b/3rdparty/bgfx/examples/runtime/textures/texture_compression_etc2.ktx
Binary files differ
diff --git a/3rdparty/bgfx/scripts/common.ninja b/3rdparty/bgfx/scripts/common.ninja
new file mode 100644
index 00000000000..0cde35fa310
--- /dev/null
+++ b/3rdparty/bgfx/scripts/common.ninja
@@ -0,0 +1,26 @@
+builddir = ../.build
+
+rule geometryc_pack_normal
+ command = geometryc -f $in -o $out --packnormal 1
+ description = Converting geometry $in...
+
+rule texturec_bc1
+ command = texturec -f $in -o $out -t bc1 -m
+
+rule texturec_bc2
+ command = texturec -f $in -o $out -t bc2 -m
+
+rule texturec_bc3
+ command = texturec -f $in -o $out -t bc3 -m
+
+rule texturec_bc4
+ command = texturec -f $in -o $out -t bc4 -m
+
+rule texturec_bc5
+ command = texturec -f $in -o $out -t bc5 -m
+
+rule texturec_etc1
+ command = texturec -f $in -o $out -t etc1 -m
+
+rule texturec_etc2
+ command = texturec -f $in -o $out -t etc2 -m
diff --git a/3rdparty/bgfx/src/bgfx.cpp b/3rdparty/bgfx/src/bgfx.cpp
index 5da3c5609b7..a6c60aaa499 100644
--- a/3rdparty/bgfx/src/bgfx.cpp
+++ b/3rdparty/bgfx/src/bgfx.cpp
@@ -2905,9 +2905,13 @@ namespace bgfx
_height = bx::uint16_max(1, _height);
}
- TextureHandle createTexture2D(BackbufferRatio::Enum _ratio, uint16_t _width, uint16_t _height, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags, const Memory* _mem)
+ static TextureHandle createTexture2D(BackbufferRatio::Enum _ratio, uint16_t _width, uint16_t _height, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags, const Memory* _mem)
{
BGFX_CHECK_MAIN_THREAD();
+
+ BX_CHECK(0 == (_flags & BGFX_TEXTURE_RT_MASK) || 0 == (_flags & BGFX_TEXTURE_READ_BACK)
+ , "Can't create render target with BGFX_TEXTURE_READ_BACK flag."
+ );
BX_CHECK(0 != (g_caps.formats[_format] & (BGFX_CAPS_FORMAT_TEXTURE_2D|BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED|BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB) )
, "Format %s is not supported for 2D texture. Use bgfx::getCaps to check available texture formats."
, getName(_format)
diff --git a/3rdparty/bgfx/src/image.cpp b/3rdparty/bgfx/src/image.cpp
index 2aa69de0a8d..96923f0be3b 100644
--- a/3rdparty/bgfx/src/image.cpp
+++ b/3rdparty/bgfx/src/image.cpp
@@ -1420,7 +1420,7 @@ namespace bgfx
UnpackFn unpack;
};
- static PackUnpack s_packUnpack[] =
+ static const PackUnpack s_packUnpack[] =
{
{ NULL, NULL }, // BC1
{ NULL, NULL }, // BC2
@@ -2498,7 +2498,7 @@ namespace bgfx
bool m_srgb;
};
- static TranslateDdsFormat s_translateDdsFourccFormat[] =
+ static const TranslateDdsFormat s_translateDdsFourccFormat[] =
{
{ DDS_DXT1, TextureFormat::BC1, false },
{ DDS_DXT2, TextureFormat::BC2, false },
@@ -2531,7 +2531,7 @@ namespace bgfx
{ DDS_A2B10G10R10, TextureFormat::RGB10A2, false },
};
- static TranslateDdsFormat s_translateDxgiFormat[] =
+ static const TranslateDdsFormat s_translateDxgiFormat[] =
{
{ DDS_FORMAT_BC1_UNORM, TextureFormat::BC1, false },
{ DDS_FORMAT_BC1_UNORM_SRGB, TextureFormat::BC1, true },
@@ -2578,13 +2578,14 @@ namespace bgfx
TextureFormat::Enum m_textureFormat;
};
- static TranslateDdsPixelFormat s_translateDdsPixelFormat[] =
+ static const TranslateDdsPixelFormat s_translateDdsPixelFormat[] =
{
{ 8, { 0x000000ff, 0x00000000, 0x00000000, 0x00000000 }, TextureFormat::R8 },
{ 16, { 0x0000ffff, 0x00000000, 0x00000000, 0x00000000 }, TextureFormat::R16U },
{ 16, { 0x00000f00, 0x000000f0, 0x0000000f, 0x0000f000 }, TextureFormat::RGBA4 },
{ 16, { 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000 }, TextureFormat::R5G6B5 },
{ 16, { 0x00007c00, 0x000003e0, 0x0000001f, 0x00008000 }, TextureFormat::RGB5A1 },
+ { 24, { 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 }, TextureFormat::RGB8 },
{ 32, { 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }, TextureFormat::BGRA8 },
{ 32, { 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 }, TextureFormat::BGRA8 },
{ 32, { 0x000003ff, 0x000ffc00, 0x3ff00000, 0xc0000000 }, TextureFormat::RGB10A2 },
@@ -2871,7 +2872,7 @@ namespace bgfx
uint32_t m_type;
};
- static KtxFormatInfo s_translateKtxFormat[] =
+ static const KtxFormatInfo s_translateKtxFormat[] =
{
{ KTX_COMPRESSED_RGBA_S3TC_DXT1_EXT, KTX_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, KTX_COMPRESSED_RGBA_S3TC_DXT1_EXT, KTX_ZERO, }, // BC1
{ KTX_COMPRESSED_RGBA_S3TC_DXT3_EXT, KTX_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, KTX_COMPRESSED_RGBA_S3TC_DXT3_EXT, KTX_ZERO, }, // BC2
@@ -2943,6 +2944,18 @@ namespace bgfx
};
BX_STATIC_ASSERT(TextureFormat::UnknownDepth == BX_COUNTOF(s_translateKtxFormat) );
+ struct KtxFormatInfo2
+ {
+ uint32_t m_internalFmt;
+ TextureFormat::Enum m_format;
+ };
+
+ static const KtxFormatInfo2 s_translateKtxFormat2[] =
+ {
+ { KTX_RED, TextureFormat::R8 },
+ { KTX_RGB, TextureFormat::RGB8 },
+ };
+
bool imageParseKtx(ImageContainer& _imageContainer, bx::ReaderSeekerI* _reader)
{
uint8_t identifier[8];
@@ -3010,6 +3023,18 @@ namespace bgfx
}
}
+ if (TextureFormat::Unknown == format)
+ {
+ for (uint32_t ii = 0; ii < BX_COUNTOF(s_translateKtxFormat2); ++ii)
+ {
+ if (s_translateKtxFormat2[ii].m_internalFmt == glInternalFormat)
+ {
+ format = s_translateKtxFormat2[ii].m_format;
+ break;
+ }
+ }
+ }
+
_imageContainer.m_data = NULL;
_imageContainer.m_size = 0;
_imageContainer.m_offset = (uint32_t)offset;
@@ -3017,7 +3042,7 @@ namespace bgfx
_imageContainer.m_height = height;
_imageContainer.m_depth = depth;
_imageContainer.m_format = format;
- _imageContainer.m_numMips = uint8_t(numMips);
+ _imageContainer.m_numMips = uint8_t(bx::uint32_max(numMips, 1) );
_imageContainer.m_hasAlpha = hasAlpha;
_imageContainer.m_cubeMap = numFaces > 1;
_imageContainer.m_ktx = true;
@@ -3064,13 +3089,14 @@ namespace bgfx
#define PVR3_CHANNEL_TYPE_ANY UINT32_MAX
#define PVR3_CHANNEL_TYPE_FLOAT UINT32_C(12)
- static struct TranslatePvr3Format
+ struct TranslatePvr3Format
{
uint64_t m_format;
uint32_t m_channelTypeMask;
TextureFormat::Enum m_textureFormat;
+ };
- } s_translatePvr3Format[] =
+ static const TranslatePvr3Format s_translatePvr3Format[] =
{
{ PVR3_PVRTC1_2BPP_RGB, PVR3_CHANNEL_TYPE_ANY, TextureFormat::PTC12 },
{ PVR3_PVRTC1_2BPP_RGBA, PVR3_CHANNEL_TYPE_ANY, TextureFormat::PTC12A },
@@ -3432,10 +3458,14 @@ namespace bgfx
break;
default:
- if (!imageConvert(_dst, TextureFormat::BGRA8, _src, _format, _width, _height, _pitch) )
{
- // Failed to convert, just make ugly red-yellow checkerboard texture.
- imageCheckerboard(_width, _height, 16, UINT32_C(0xffff0000), UINT32_C(0xffffff00), _dst);
+ const uint32_t srcBpp = s_imageBlockInfo[_format].bitsPerPixel;
+ const uint32_t srcPitch = _width * srcBpp / 8;
+ if (!imageConvert(_dst, TextureFormat::BGRA8, _src, _format, _width, _height, srcPitch) )
+ {
+ // Failed to convert, just make ugly red-yellow checkerboard texture.
+ imageCheckerboard(_width, _height, 16, UINT32_C(0xffff0000), UINT32_C(0xffffff00), _dst);
+ }
}
break;
}
diff --git a/3rdparty/bgfx/src/renderer_gl.cpp b/3rdparty/bgfx/src/renderer_gl.cpp
index d560f65d926..86c67ac4246 100644
--- a/3rdparty/bgfx/src/renderer_gl.cpp
+++ b/3rdparty/bgfx/src/renderer_gl.cpp
@@ -5090,7 +5090,7 @@ namespace bgfx { namespace gl
uint32_t version =
usesIUsamplers || usesTexelFetch ? 130
: usesTextureLod ? 120
- : 0
+ : 120
;
if (0 != version)
diff --git a/3rdparty/bgfx/tools/shaderc/shaderc_glsl.cpp b/3rdparty/bgfx/tools/shaderc/shaderc_glsl.cpp
index 78328cffbbd..5e1e5a28fe9 100644
--- a/3rdparty/bgfx/tools/shaderc/shaderc_glsl.cpp
+++ b/3rdparty/bgfx/tools/shaderc/shaderc_glsl.cpp
@@ -10,7 +10,7 @@ namespace bgfx
{
bool compileGLSLShader(bx::CommandLine& _cmdLine, uint32_t _gles, const std::string& _code, bx::WriterI* _writer)
{
- char ch = tolower(_cmdLine.findOption('\0', "type")[0]);
+ char ch = char(tolower(_cmdLine.findOption('\0', "type")[0]) );
const glslopt_shader_type type = ch == 'f'
? kGlslOptShaderFragment
: (ch == 'c' ? kGlslOptShaderCompute : kGlslOptShaderVertex);
@@ -152,7 +152,7 @@ namespace bgfx
char arraySize[32];
const char* end = bx::strnstr(array, "]", eol-array);
bx::strlcpy(arraySize, array+1, end-array);
- num = atoi(arraySize);
+ num = uint8_t(atoi(arraySize) );
}
else
{
diff --git a/3rdparty/bgfx/tools/texturev/texturev.cpp b/3rdparty/bgfx/tools/texturev/texturev.cpp
index 28e298acbf7..f4704de0153 100644
--- a/3rdparty/bgfx/tools/texturev/texturev.cpp
+++ b/3rdparty/bgfx/tools/texturev/texturev.cpp
@@ -5,6 +5,7 @@
#include "common.h"
#include <bgfx/bgfx.h>
+#include <bx/commandline.h>
#include <bx/os.h>
#include <bx/string.h>
#include <bx/uint32_t.h>
@@ -30,6 +31,18 @@ namespace stl = tinystl;
#include "image.h"
+static const char* s_supportedExt[] =
+{
+ "dds",
+ "jpg",
+ "jpeg",
+ "hdr",
+ "ktx",
+ "png",
+ "pvr",
+ "tga",
+};
+
struct Binding
{
enum Enum
@@ -208,15 +221,18 @@ struct View
const char* ext = strrchr(item->d_name, '.');
if (NULL != ext)
{
- if (0 == bx::stricmp(ext, ".dds")
- || 0 == bx::stricmp(ext, ".jpg")
- || 0 == bx::stricmp(ext, ".jpeg")
- || 0 == bx::stricmp(ext, ".hdr")
- || 0 == bx::stricmp(ext, ".ktx")
- || 0 == bx::stricmp(ext, ".png")
- || 0 == bx::stricmp(ext, ".pvr")
- || 0 == bx::stricmp(ext, ".tga")
- )
+ ext += 1;
+ bool supported = false;
+ for (uint32_t ii = 0; ii < BX_COUNTOF(s_supportedExt); ++ii)
+ {
+ if (0 == bx::stricmp(ext, s_supportedExt[ii]) )
+ {
+ supported = true;
+ break;
+ }
+ }
+
+ if (supported)
{
if (0 == strcmp(_fileName, item->d_name) )
{
@@ -411,12 +427,124 @@ void help(const char* _error = NULL)
fprintf(stderr
, "Usage: texturev <file path>\n"
"\n"
+ "Supported input file types:\n"
+ );
+
+ for (uint32_t ii = 0; ii < BX_COUNTOF(s_supportedExt); ++ii)
+ {
+ fprintf(stderr, " *.%s\n", s_supportedExt[ii]);
+ }
+
+ fprintf(stderr
+ , "\n"
+ "Options:\n"
+ " --associate Associate file extensions with texturev.\n"
+ "\n"
"For additional information, see https://github.com/bkaradzic/bgfx\n"
);
}
+void associate()
+{
+#if BX_PLATFORM_WINDOWS
+ std::string str;
+
+ char exec[MAX_PATH];
+ GetModuleFileNameA(GetModuleHandleA(NULL), exec, MAX_PATH);
+
+ std::string strExec = bx::replaceAll<std::string>(exec, "\\", "\\\\");
+
+ std::string value;
+ bx::stringPrintf(value, "@=\"\\\"%s\\\" \\\"%%1\\\"\"\r\n\r\n", strExec.c_str() );
+
+ str += "Windows Registry Editor Version 5.00\r\n\r\n";
+
+ str += "[HKEY_CLASSES_ROOT\\texturev\\shell\\open\\command]\r\n";
+ str += value;
+
+ str += "[HKEY_CLASSES_ROOT\\Applications\\texturev.exe\\shell\\open\\command]\r\n";
+ str += value;
+
+ for (uint32_t ii = 0; ii < BX_COUNTOF(s_supportedExt); ++ii)
+ {
+ const char* ext = s_supportedExt[ii];
+
+ bx::stringPrintf(str, "[-HKEY_CLASSES_ROOT\\.%s]\r\n\r\n", ext);
+ bx::stringPrintf(str, "[-HKEY_CURRENT_USER\\Software\\Classes\\.%s]\r\n\r\n", ext);
+
+ bx::stringPrintf(str, "[HKEY_CLASSES_ROOT\\.%s]\r\n@=\"texturev\"\r\n\r\n", ext);
+ bx::stringPrintf(str, "[HKEY_CURRENT_USER\\Software\\Classes\\.%s]\r\n@=\"texturev\"\r\n\r\n", ext);
+ }
+
+ char temp[MAX_PATH];
+ GetTempPathA(MAX_PATH, temp);
+ strcat(temp, "\\texturev.reg");
+
+ bx::CrtFileWriter writer;
+ bx::Error err;
+ if (bx::open(&writer, temp, false, &err) )
+ {
+ bx::write(&writer, str.c_str(), str.length(), &err);
+ bx::close(&writer);
+
+ if (err.isOk() )
+ {
+ std::string cmd;
+ bx::stringPrintf(cmd, "regedit.exe /s %s", temp);
+
+ bx::ProcessReader reader;
+ if (bx::open(&reader, cmd.c_str(), &err) )
+ {
+ bx::close(&reader);
+ }
+ }
+ }
+#elif BX_PLATFORM_LINUX
+ std::string str;
+ str += "#/bin/bash\n\n";
+
+ for (uint32_t ii = 0; ii < BX_COUNTOF(s_supportedExt); ++ii)
+ {
+ const char* ext = s_supportedExt[ii];
+ bx::stringPrintf(str, "xdg-mime default texturev.desktop image/%s\n", ext);
+ }
+
+ str += "\n";
+
+ bx::CrtFileWriter writer;
+ bx::Error err;
+ if (bx::open(&writer, "/tmp/texturev.sh", false, &err) )
+ {
+ bx::write(&writer, str.c_str(), str.length(), &err);
+ bx::close(&writer);
+
+ if (err.isOk() )
+ {
+ bx::ProcessReader reader;
+ if (bx::open(&reader, "/bin/bash /tmp/texturev.sh", &err) )
+ {
+ bx::close(&reader);
+ }
+ }
+ }
+#endif // BX_PLATFORM_WINDOWS
+}
+
int _main_(int _argc, char** _argv)
{
+ bx::CommandLine cmdLine(_argc, _argv);
+
+ if (cmdLine.hasArg('h', "help") )
+ {
+ help();
+ return EXIT_FAILURE;
+ }
+ else if (cmdLine.hasArg("associate") )
+ {
+ associate();
+ return EXIT_FAILURE;
+ }
+
uint32_t width = 1280;
uint32_t height = 720;
uint32_t debug = BGFX_DEBUG_TEXT;
diff --git a/3rdparty/bx/include/bx/string.h b/3rdparty/bx/include/bx/string.h
index 640de064910..937f15d1def 100644
--- a/3rdparty/bx/include/bx/string.h
+++ b/3rdparty/bx/include/bx/string.h
@@ -386,6 +386,23 @@ namespace bx
va_end(argList);
}
+ /// Replace all instances of substring.
+ template <typename Ty>
+ inline Ty replaceAll(const Ty& _str, const char* _from, const char* _to)
+ {
+ Ty str = _str;
+ size_t startPos = 0;
+ const size_t fromLen = strlen(_from);
+ const size_t toLen = strlen(_to);
+ while ( (startPos = str.find(_from, startPos) ) != Ty::npos)
+ {
+ str.replace(startPos, fromLen, _to);
+ startPos += toLen;
+ }
+
+ return str;
+ }
+
/// Extract base file name from file path.
inline const char* baseName(const char* _filePath)
{
diff --git a/3rdparty/bx/scripts/toolchain.lua b/3rdparty/bx/scripts/toolchain.lua
index 77e7132d30a..d7d1ec8f189 100644
--- a/3rdparty/bx/scripts/toolchain.lua
+++ b/3rdparty/bx/scripts/toolchain.lua
@@ -168,9 +168,9 @@ function toolchain(_buildDir, _libDir)
print("Set EMSCRIPTEN enviroment variable.")
end
- premake.gcc.cc = "$(EMSCRIPTEN)/emcc"
- premake.gcc.cxx = "$(EMSCRIPTEN)/em++"
- premake.gcc.ar = "$(EMSCRIPTEN)/emar"
+ premake.gcc.cc = "\"$(EMSCRIPTEN)/emcc\""
+ premake.gcc.cxx = "\"$(EMSCRIPTEN)/em++\""
+ premake.gcc.ar = "\"$(EMSCRIPTEN)/emar\""
premake.gcc.llvm = true
location (path.join(_buildDir, "projects", _ACTION .. "-asmjs"))
@@ -428,6 +428,7 @@ function toolchain(_buildDir, _libDir)
"NoRTTI",
"NoExceptions",
"NoEditAndContinue",
+ "NoFramePointer",
"Symbols",
}
@@ -466,8 +467,9 @@ function toolchain(_buildDir, _libDir)
"_CRT_SECURE_NO_DEPRECATE",
}
buildoptions {
- "/Oy-", -- Suppresses creation of frame pointers on the call stack.
- "/Ob2", -- The Inline Function Expansion
+ "/wd4201", -- warning C4201: nonstandard extension used: nameless struct/union
+ "/wd4324", -- warning C4324: '': structure was padded due to alignment specifier
+ "/Ob2", -- The Inline Function Expansion
}
linkoptions {
"/ignore:4221", -- LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
@@ -840,8 +842,8 @@ function toolchain(_buildDir, _libDir)
objdir (path.join(_buildDir, "asmjs/obj"))
libdirs { path.join(_libDir, "lib/asmjs") }
buildoptions {
- "-isystem$(EMSCRIPTEN)/system/include",
- "-isystem$(EMSCRIPTEN)/system/include/libc",
+ "-i\"system$(EMSCRIPTEN)/system/include\"",
+ "-i\"system$(EMSCRIPTEN)/system/include/libc\"",
"-Wunused-value",
"-Wundef",
}
@@ -1223,7 +1225,7 @@ function strip()
configuration { "asmjs" }
postbuildcommands {
"$(SILENT) echo Running asmjs finalize.",
- "$(SILENT) $(EMSCRIPTEN)/emcc -O2 "
+ "$(SILENT) \"$(EMSCRIPTEN)/emcc\" -O2 "
-- .. "-s EMTERPRETIFY=1 "
-- .. "-s EMTERPRETIFY_ASYNC=1 "
.. "-s TOTAL_MEMORY=268435456 "
diff --git a/3rdparty/bx/tools/bin/darwin/genie b/3rdparty/bx/tools/bin/darwin/genie
index 76ea0372048..54b5fcd9ca5 100755
--- a/3rdparty/bx/tools/bin/darwin/genie
+++ b/3rdparty/bx/tools/bin/darwin/genie
Binary files differ
diff --git a/3rdparty/bx/tools/bin/linux/genie b/3rdparty/bx/tools/bin/linux/genie
index 910b28098e0..2a498c42bf1 100755
--- a/3rdparty/bx/tools/bin/linux/genie
+++ b/3rdparty/bx/tools/bin/linux/genie
Binary files differ
diff --git a/3rdparty/bx/tools/bin/windows/genie.exe b/3rdparty/bx/tools/bin/windows/genie.exe
index 356155ae32a..85f9260c388 100644
--- a/3rdparty/bx/tools/bin/windows/genie.exe
+++ b/3rdparty/bx/tools/bin/windows/genie.exe
Binary files differ
diff --git a/3rdparty/rapidjson/doc/dom.md b/3rdparty/rapidjson/doc/dom.md
index 6cccf085046..60480c318ca 100644
--- a/3rdparty/rapidjson/doc/dom.md
+++ b/3rdparty/rapidjson/doc/dom.md
@@ -163,7 +163,7 @@ Document d;
if (d.Parse(json).HasParseError()) {
fprintf(stderr, "\nError(offset %u): %s\n",
(unsigned)d.GetErrorOffset(),
- GetParseError_En(d.GetParseErrorCode()));
+ GetParseError_En(d.GetParseError()));
// ...
}
~~~~~~~~~~
diff --git a/3rdparty/rapidjson/doc/encoding.md b/3rdparty/rapidjson/doc/encoding.md
index e9ebe8f2149..8f8ff7f45aa 100644
--- a/3rdparty/rapidjson/doc/encoding.md
+++ b/3rdparty/rapidjson/doc/encoding.md
@@ -131,8 +131,8 @@ StringStream source(s);
GenericStringBuffer<UTF16<> > target;
bool hasError = false;
-while (source.Peak() != '\0')
- if (!Transcoder::Transcode<UTF8<>, UTF16<> >(source, target)) {
+while (source.Peek() != '\0')
+ if (!Transcoder<UTF8<>, UTF16<> >::Transcode(source, target)) {
hasError = true;
break;
}
diff --git a/3rdparty/rapidjson/doc/encoding.zh-cn.md b/3rdparty/rapidjson/doc/encoding.zh-cn.md
index 4858bae16c3..163eadec551 100644
--- a/3rdparty/rapidjson/doc/encoding.zh-cn.md
+++ b/3rdparty/rapidjson/doc/encoding.zh-cn.md
@@ -137,8 +137,8 @@ StringStream source(s);
GenericStringBuffer<UTF16<> > target;
bool hasError = false;
-while (source.Peak() != '\0')
- if (!Transcoder::Transcode<UTF8<>, UTF16<> >(source, target)) {
+while (source.Peek() != '\0')
+ if (!Transcoder<UTF8<>, UTF16<> >::Transcode(source, target)) {
hasError = true;
break;
}
diff --git a/3rdparty/rapidjson/include/rapidjson/istreamwrapper.h b/3rdparty/rapidjson/include/rapidjson/istreamwrapper.h
index c73586e6005..f5fe28977eb 100644
--- a/3rdparty/rapidjson/include/rapidjson/istreamwrapper.h
+++ b/3rdparty/rapidjson/include/rapidjson/istreamwrapper.h
@@ -12,6 +12,9 @@
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
+#ifndef RAPIDJSON_ISTREAMWRAPPER_H_
+#define RAPIDJSON_ISTREAMWRAPPER_H_
+
#include "stream.h"
#include <iosfwd>
@@ -108,3 +111,5 @@ RAPIDJSON_DIAG_POP
#endif
RAPIDJSON_NAMESPACE_END
+
+#endif // RAPIDJSON_ISTREAMWRAPPER_H_
diff --git a/3rdparty/rapidjson/include/rapidjson/ostreamwrapper.h b/3rdparty/rapidjson/include/rapidjson/ostreamwrapper.h
index 8bf36dcd04c..6f4667c08ad 100644
--- a/3rdparty/rapidjson/include/rapidjson/ostreamwrapper.h
+++ b/3rdparty/rapidjson/include/rapidjson/ostreamwrapper.h
@@ -12,6 +12,9 @@
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
+#ifndef RAPIDJSON_OSTREAMWRAPPER_H_
+#define RAPIDJSON_OSTREAMWRAPPER_H_
+
#include "stream.h"
#include <iosfwd>
@@ -74,3 +77,5 @@ RAPIDJSON_DIAG_POP
#endif
RAPIDJSON_NAMESPACE_END
+
+#endif // RAPIDJSON_OSTREAMWRAPPER_H_
diff --git a/3rdparty/rapidjson/include_dirs.js b/3rdparty/rapidjson/include_dirs.js
new file mode 100644
index 00000000000..b373e85f5ae
--- /dev/null
+++ b/3rdparty/rapidjson/include_dirs.js
@@ -0,0 +1,2 @@
+var path = require('path');
+console.log(path.join(path.relative('.', __dirname), 'include'));
diff --git a/3rdparty/rapidjson/package.json b/3rdparty/rapidjson/package.json
new file mode 100644
index 00000000000..9e5e4f23ce6
--- /dev/null
+++ b/3rdparty/rapidjson/package.json
@@ -0,0 +1,25 @@
+{
+ "name": "rapidjson",
+ "version": "1.0.3",
+ "description": "![](doc/logo/rapidjson.png)",
+ "main": "index.js",
+ "directories": {
+ "doc": "doc",
+ "example": "example",
+ "test": "test"
+ },
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/miloyip/rapidjson.git"
+ },
+ "author": "",
+ "license": "ISC",
+ "bugs": {
+ "url": "https://github.com/miloyip/rapidjson/issues"
+ },
+ "homepage": "https://github.com/miloyip/rapidjson#readme",
+ "main": "include_dirs.js"
+}