From 52afe0f43345c886348501329f4908a40c2dfd33 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Wed, 6 Aug 2014 07:51:16 +0100 Subject: [PATCH 1/9] Using imguiCollapse instead of imguiButton for imguiColorWheel. --- examples/common/imgui/imgui.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index c965aba79..ac7cf986d 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -2298,14 +2298,13 @@ void imguiColorWheel(float _rgb[3], bool _respectIndentation, bool _enabled) void imguiColorWheel(const char* _text, float _rgb[3], bool& _activated, bool _enabled) { char buf[128]; - bx::snprintf(buf, sizeof(buf), "%s [RGB %-2.2f %-2.2f %-2.2f]" - , _text + bx::snprintf(buf, sizeof(buf), "[RGB %-2.2f %-2.2f %-2.2f]" , _rgb[0] , _rgb[1] , _rgb[2] ); - if (imguiButton(buf, true) ) + if (imguiCollapse(_text, buf, _activated, _enabled) ) { _activated = !_activated; } From 13919391515c6eea6ae27c23f88bee179bd54b3f Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Wed, 6 Aug 2014 08:23:54 +0100 Subject: [PATCH 2/9] Fixed drawText() to handle NULL or empty string. --- examples/common/imgui/imgui.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index ac7cf986d..5577a7086 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -1635,6 +1635,12 @@ struct Imgui void drawText(float _x, float _y, const char* _text, ImguiTextAlign::Enum _align, uint32_t _abgr) { + if (NULL == _text + || '\0' == _text[0]) + { + return; + } + #if USE_NANOVG_FONT static uint32_t textAlign[ImguiTextAlign::Count] = { From 1f884a588e013be5ea79da68f33862009f049277 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Wed, 6 Aug 2014 09:01:41 +0100 Subject: [PATCH 3/9] Added imguiImageSwizzle(). --- examples/common/imgui/fs_imgui_image.bin.h | 67 ++++---- .../common/imgui/fs_imgui_image_swizz.bin.h | 146 ++++++++++++++++++ examples/common/imgui/fs_imgui_image_swizz.sc | 18 +++ examples/common/imgui/fs_imgui_texture.bin.h | 29 ++-- examples/common/imgui/imgui.cpp | 110 ++++++++++--- examples/common/imgui/imgui.h | 4 +- 6 files changed, 305 insertions(+), 69 deletions(-) create mode 100644 examples/common/imgui/fs_imgui_image_swizz.bin.h create mode 100644 examples/common/imgui/fs_imgui_image_swizz.sc diff --git a/examples/common/imgui/fs_imgui_image.bin.h b/examples/common/imgui/fs_imgui_image.bin.h index 574b91713..a96cf483a 100644 --- a/examples/common/imgui/fs_imgui_image.bin.h +++ b/examples/common/imgui/fs_imgui_image.bin.h @@ -46,46 +46,45 @@ static const uint8_t fs_imgui_image_dx9[342] = 0x80, 0x00, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x08, 0x80, 0x01, 0x00, 0x00, // ................ 0xa0, 0xff, 0xff, 0x00, 0x00, 0x00, // ...... }; -static const uint8_t fs_imgui_image_dx11[1335] = +static const uint8_t fs_imgui_image_dx11[1319] = { 0x46, 0x53, 0x48, 0x02, 0x6f, 0x1e, 0x3e, 0x3c, 0x01, 0x00, 0x0a, 0x75, 0x5f, 0x69, 0x6d, 0x61, // FSH.o.><...u_ima - 0x67, 0x65, 0x4c, 0x6f, 0x64, 0x14, 0x00, 0x24, 0x0a, 0x01, 0x00, 0x08, 0x05, 0x44, 0x58, 0x42, // geLod..$.....DXB - 0x43, 0x75, 0xb5, 0x78, 0x5b, 0xc0, 0x89, 0x74, 0xe3, 0xd1, 0x10, 0xe5, 0x87, 0x5e, 0x12, 0xcb, // Cu.x[..t.....^.. - 0x02, 0x01, 0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, // .............4.. - 0x00, 0x48, 0x03, 0x00, 0x00, 0xa0, 0x03, 0x00, 0x00, 0xd4, 0x03, 0x00, 0x00, 0x8c, 0x04, 0x00, // .H.............. - 0x00, 0x52, 0x44, 0x45, 0x46, 0x0c, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, // .RDEF........... + 0x67, 0x65, 0x4c, 0x6f, 0x64, 0x14, 0x00, 0x24, 0x0a, 0x01, 0x00, 0xf8, 0x04, 0x44, 0x58, 0x42, // geLod..$.....DXB + 0x43, 0x81, 0x72, 0x6a, 0x6b, 0x91, 0x2b, 0xbb, 0x35, 0x1d, 0xd7, 0x8a, 0xc7, 0x03, 0xf3, 0x8b, // C.rjk.+.5....... + 0x88, 0x01, 0x00, 0x00, 0x00, 0xf8, 0x04, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, // .............4.. + 0x00, 0x38, 0x03, 0x00, 0x00, 0x90, 0x03, 0x00, 0x00, 0xc4, 0x03, 0x00, 0x00, 0x7c, 0x04, 0x00, // .8...........|.. + 0x00, 0x52, 0x44, 0x45, 0x46, 0xfc, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, // .RDEF........... 0x00, 0x03, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0xff, 0x00, 0x91, 0x00, // ................ - 0x00, 0xdb, 0x02, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .....|.......... + 0x00, 0xcb, 0x02, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .....|.......... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ................ - 0x00, 0x01, 0x00, 0x00, 0x00, 0x97, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, // ................ + 0x00, 0x01, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, // ................ 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ................ - 0x00, 0x0d, 0x00, 0x00, 0x00, 0xb2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ + 0x00, 0x0d, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ................ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x75, // .....u_texColoru - 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, // _texColorampler. - 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, // u_texColoru_texC - 0x6f, 0x6c, 0x6f, 0x72, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, // olorexture.$Glob - 0x61, 0x6c, 0x73, 0x00, 0xab, 0xb2, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, // als............. - 0x00, 0x30, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x02, 0x00, // .0.............. - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x02, 0x00, // ................ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x02, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, // .....(.......... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x02, 0x00, // .............4.. - 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x02, 0x00, // . ...@.......<.. - 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x02, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, // .....L...`...@.. - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x02, 0x00, // .....<.......V.. - 0x00, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x02, 0x00, // .....@.......<.. - 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d, 0x02, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, // .....].......@.. - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x02, 0x00, // .....<.......g.. - 0x00, 0x20, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x02, 0x00, // . ...@.......<.. - 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x02, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, // .....r...`...@.. - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, // .....<.......... - 0x00, 0xa0, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x02, 0x00, // ................ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x02, 0x00, 0x00, 0xa0, 0x09, 0x00, 0x00, 0x40, 0x00, 0x00, // .............@.. - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x02, 0x00, // .....<.......... - 0x00, 0xe0, 0x09, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x02, 0x00, // .....@.......<.. - 0x00, 0x00, 0x00, 0x00, 0x00, 0xb4, 0x02, 0x00, 0x00, 0x20, 0x0a, 0x00, 0x00, 0x04, 0x00, 0x00, // ......... ...... - 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x02, 0x00, // ................ - 0x00, 0x24, 0x0a, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xc0, 0x02, 0x00, // .$.............. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x53, // .....u_texColorS + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, // ampler.u_texColo + 0x72, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, // rTexture.$Global + 0x73, 0x00, 0xab, 0xab, 0xab, 0xa0, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xc4, 0x00, 0x00, // s............... + 0x00, 0x30, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, // .0.............. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x02, 0x00, // ................ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x02, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, // ................ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x02, 0x00, // .............$.. + 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x02, 0x00, // . ...@.......,.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x02, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, // .....<...`...@.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x00, // .....,.......F.. + 0x00, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x02, 0x00, // .....@.......,.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x02, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, // .....M.......@.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0x02, 0x00, // .....,.......W.. + 0x00, 0x20, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x02, 0x00, // . ...@.......,.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x02, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, // .....b...`...@.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x02, 0x00, // .....,.......p.. + 0x00, 0xa0, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x02, 0x00, // .............x.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x02, 0x00, 0x00, 0xa0, 0x09, 0x00, 0x00, 0x40, 0x00, 0x00, // .............@.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x94, 0x02, 0x00, // .....,.......... + 0x00, 0xe0, 0x09, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x02, 0x00, // .....@.......,.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x02, 0x00, 0x00, 0x20, 0x0a, 0x00, 0x00, 0x04, 0x00, 0x00, // ......... ...... + 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x02, 0x00, // ................ + 0x00, 0x24, 0x0a, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xb0, 0x02, 0x00, // .$.............. 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x52, 0x65, 0x63, 0x74, 0x00, // .....u_viewRect. 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ 0x00, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x54, 0x65, 0x78, 0x65, 0x6c, 0x00, 0x75, 0x5f, 0x76, // .u_viewTexel.u_v diff --git a/examples/common/imgui/fs_imgui_image_swizz.bin.h b/examples/common/imgui/fs_imgui_image_swizz.bin.h new file mode 100644 index 000000000..7d86b1387 --- /dev/null +++ b/examples/common/imgui/fs_imgui_image_swizz.bin.h @@ -0,0 +1,146 @@ +static const uint8_t fs_imgui_image_swizz_glsl[377] = +{ + 0x46, 0x53, 0x48, 0x02, 0x6f, 0x1e, 0x3e, 0x3c, 0x03, 0x00, 0x0a, 0x75, 0x5f, 0x69, 0x6d, 0x61, // FSH.o.><...u_ima + 0x67, 0x65, 0x4c, 0x6f, 0x64, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x09, 0x75, 0x5f, 0x73, 0x77, // geLod.......u_sw + 0x69, 0x7a, 0x7a, 0x6c, 0x65, 0x07, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x75, 0x5f, 0x74, 0x65, // izzle.......u_te + 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x38, 0x01, 0x00, 0x00, // xColor......8... + 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x6d, 0x65, 0x64, 0x69, 0x75, 0x6d, 0x70, 0x20, // varying mediump + 0x76, 0x65, 0x63, 0x32, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, // vec2 v_texcoord0 + 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x6d, 0x65, 0x64, 0x69, 0x75, 0x6d, // ;.uniform medium + 0x70, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x75, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x4c, // p float u_imageL + 0x6f, 0x64, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x6d, 0x65, 0x64, 0x69, // od;.uniform medi + 0x75, 0x6d, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x75, 0x5f, 0x73, 0x77, 0x69, 0x7a, 0x7a, // ump vec4 u_swizz + 0x6c, 0x65, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, 0x70, // le;.uniform samp + 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, // ler2D u_texColor + 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, // ;.void main ().{ + 0x0a, 0x20, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, // . lowp vec4 tmp + 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // var_1;. tmpvar_ + 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, // 1.w = 1.0;. tmp + 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x33, // var_1.xyz = vec3 + 0x28, 0x64, 0x6f, 0x74, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x4c, // (dot (texture2DL + 0x6f, 0x64, 0x20, 0x20, 0x20, 0x20, 0x28, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, // od (u_texColo + 0x72, 0x2c, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x2c, 0x20, // r, v_texcoord0, + 0x75, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x4c, 0x6f, 0x64, 0x29, 0x2c, 0x20, 0x75, 0x5f, 0x73, // u_imageLod), u_s + 0x77, 0x69, 0x7a, 0x7a, 0x6c, 0x65, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, // wizzle));. gl_F + 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // ragColor = tmpva + 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // r_1;.}... +}; +static const uint8_t fs_imgui_image_swizz_dx9[410] = +{ + 0x46, 0x53, 0x48, 0x02, 0x6f, 0x1e, 0x3e, 0x3c, 0x02, 0x00, 0x0a, 0x75, 0x5f, 0x69, 0x6d, 0x61, // FSH.o.><...u_ima + 0x67, 0x65, 0x4c, 0x6f, 0x64, 0x14, 0x01, 0x00, 0x00, 0x01, 0x00, 0x09, 0x75, 0x5f, 0x73, 0x77, // geLod.......u_sw + 0x69, 0x7a, 0x7a, 0x6c, 0x65, 0x15, 0x01, 0x01, 0x00, 0x01, 0x00, 0x6c, 0x01, 0x00, 0x03, 0xff, // izzle......l.... + 0xff, 0xfe, 0xff, 0x3a, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0xb3, 0x00, 0x00, // ...:.CTAB....... + 0x00, 0x00, 0x03, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, // ................ + 0x00, 0xac, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .....X.......... + 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, // .d.......t...... + 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, // ................ + 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ + 0x00, 0x75, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x4c, 0x6f, 0x64, 0x00, 0xab, 0x00, 0x00, 0x03, // .u_imageLod..... + 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x73, // .............u_s + 0x77, 0x69, 0x7a, 0x7a, 0x6c, 0x65, 0x00, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, // wizzle.......... + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, // .........u_texCo + 0x6c, 0x6f, 0x72, 0x00, 0xab, 0x04, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, // lor............. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, // .....ps_3_0.Micr + 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, // osoft (R) HLSL S + 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, // hader Compiler 9 + 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x51, 0x00, 0x00, // .29.952.3111.Q.. + 0x05, 0x02, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........?....... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x00, 0x00, 0x03, // ................ + 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x00, 0x08, 0x0f, 0xa0, 0x05, 0x00, 0x00, // ................ + 0x03, 0x00, 0x00, 0x07, 0x80, 0x02, 0x00, 0xd0, 0xa0, 0x00, 0x00, 0xc4, 0x90, 0x01, 0x00, 0x00, // ................ + 0x02, 0x00, 0x00, 0x08, 0x80, 0x00, 0x00, 0x00, 0xa0, 0x5f, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, // ........._...... + 0x80, 0x00, 0x00, 0xe4, 0x80, 0x00, 0x08, 0xe4, 0xa0, 0x09, 0x00, 0x00, 0x03, 0x00, 0x08, 0x07, // ................ + 0x80, 0x00, 0x00, 0xe4, 0x80, 0x01, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x08, // ................ + 0x80, 0x02, 0x00, 0x00, 0xa0, 0xff, 0xff, 0x00, 0x00, 0x00, // .......... +}; +static const uint8_t fs_imgui_image_swizz_dx11[1383] = +{ + 0x46, 0x53, 0x48, 0x02, 0x6f, 0x1e, 0x3e, 0x3c, 0x02, 0x00, 0x0a, 0x75, 0x5f, 0x69, 0x6d, 0x61, // FSH.o.><...u_ima + 0x67, 0x65, 0x4c, 0x6f, 0x64, 0x14, 0x00, 0x24, 0x0a, 0x01, 0x00, 0x09, 0x75, 0x5f, 0x73, 0x77, // geLod..$....u_sw + 0x69, 0x7a, 0x7a, 0x6c, 0x65, 0x15, 0x00, 0x30, 0x0a, 0x01, 0x00, 0x28, 0x05, 0x44, 0x58, 0x42, // izzle..0...(.DXB + 0x43, 0x41, 0xc5, 0x55, 0xf9, 0x51, 0xc7, 0x7f, 0x80, 0x35, 0xb0, 0x72, 0x98, 0x69, 0xc6, 0x28, // CA.U.Q...5.r.i.( + 0x1c, 0x01, 0x00, 0x00, 0x00, 0x28, 0x05, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, // .....(.......4.. + 0x00, 0x5c, 0x03, 0x00, 0x00, 0xb4, 0x03, 0x00, 0x00, 0xe8, 0x03, 0x00, 0x00, 0xac, 0x04, 0x00, // ................ + 0x00, 0x52, 0x44, 0x45, 0x46, 0x20, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, // .RDEF .......... + 0x00, 0x03, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0xff, 0x00, 0x91, 0x00, // ................ + 0x00, 0xed, 0x02, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .....|.......... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ................ + 0x00, 0x01, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, // ................ + 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ................ + 0x00, 0x0d, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ................ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x53, // .....u_texColorS + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, // ampler.u_texColo + 0x72, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, // rTexture.$Global + 0x73, 0x00, 0xab, 0xab, 0xab, 0xa0, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xc4, 0x00, 0x00, // s............... + 0x00, 0x40, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x02, 0x00, // .@.............. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x02, 0x00, // ............. .. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x02, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, // .....0.......... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x02, 0x00, // ..... .......<.. + 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x02, 0x00, // . ...@.......D.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x02, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, // .....T...`...@.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5e, 0x02, 0x00, // .....D.......^.. + 0x00, 0xa0, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x02, 0x00, // .....@.......D.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x02, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, // .....e.......@.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0x02, 0x00, // .....D.......o.. + 0x00, 0x20, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x02, 0x00, // . ...@.......D.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7a, 0x02, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, // .....z...`...@.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x02, 0x00, // .....D.......... + 0x00, 0xa0, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x02, 0x00, // ................ + 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0xa0, 0x09, 0x00, 0x00, 0x40, 0x00, 0x00, // .............@.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xac, 0x02, 0x00, // .....D.......... + 0x00, 0xe0, 0x09, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x02, 0x00, // .....@.......D.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0xbc, 0x02, 0x00, 0x00, 0x20, 0x0a, 0x00, 0x00, 0x04, 0x00, 0x00, // ......... ...... + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x02, 0x00, // ................ + 0x00, 0x24, 0x0a, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xc8, 0x02, 0x00, // .$.............. + 0x00, 0x00, 0x00, 0x00, 0x00, 0xe3, 0x02, 0x00, 0x00, 0x30, 0x0a, 0x00, 0x00, 0x10, 0x00, 0x00, // .........0...... + 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x76, // ..... .......u_v + 0x69, 0x65, 0x77, 0x52, 0x65, 0x63, 0x74, 0x00, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, // iewRect......... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x54, // .........u_viewT + 0x65, 0x78, 0x65, 0x6c, 0x00, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x00, 0xab, 0x03, 0x00, 0x03, // exel.u_view..... + 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x69, // .............u_i + 0x6e, 0x76, 0x56, 0x69, 0x65, 0x77, 0x00, 0x75, 0x5f, 0x70, 0x72, 0x6f, 0x6a, 0x00, 0x75, 0x5f, // nvView.u_proj.u_ + 0x69, 0x6e, 0x76, 0x50, 0x72, 0x6f, 0x6a, 0x00, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, 0x72, // invProj.u_viewPr + 0x6f, 0x6a, 0x00, 0x75, 0x5f, 0x69, 0x6e, 0x76, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, // oj.u_invViewProj + 0x00, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x00, 0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, // .u_model........ + 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, // . .......u_model + 0x56, 0x69, 0x65, 0x77, 0x00, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, // View.u_modelView + 0x50, 0x72, 0x6f, 0x6a, 0x00, 0x75, 0x5f, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x52, 0x65, 0x66, 0x00, // Proj.u_alphaRef. + 0xab, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ + 0x00, 0x75, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x4c, 0x6f, 0x64, 0x00, 0x75, 0x5f, 0x73, 0x77, // .u_imageLod.u_sw + 0x69, 0x7a, 0x7a, 0x6c, 0x65, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, // izzle.Microsoft + 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, // (R) HLSL Shader + 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, // Compiler 9.29.95 + 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x50, 0x00, 0x00, // 2.3111...ISGNP.. + 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .........8...... + 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, // ................ + 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .D.............. + 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, // .........SV_POSI + 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0xab, // TION.TEXCOORD... + 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, // .OSGN,.......... + 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // . .............. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x54, 0x41, 0x52, 0x47, // .........SV_TARG + 0x45, 0x54, 0x00, 0xab, 0xab, 0x53, 0x48, 0x44, 0x52, 0xbc, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, // ET...SHDR....@.. + 0x00, 0x2f, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, // ./...Y...F. .... + 0x00, 0xa4, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x03, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, // .....Z....`..... + 0x00, 0x58, 0x18, 0x00, 0x04, 0x00, 0x70, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, // .X....p......UU. + 0x00, 0x62, 0x10, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, // .b...2.......e.. + 0x03, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, // .. ......h...... + 0x00, 0x48, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, // .H...........F.. + 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x10, // .....F~.......`. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, // ....... ........ + 0x00, 0x11, 0x00, 0x00, 0x08, 0x72, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, // .....r ......F.. + 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa3, 0x00, 0x00, // .....F. ........ + 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, // .6.... .......@. + 0x00, 0x00, 0x00, 0x80, 0x3f, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x74, 0x00, 0x00, // ....?>...STATt.. + 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, // ................ + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ................ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ................ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // ................ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, // ................ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0a, // .....@. +}; diff --git a/examples/common/imgui/fs_imgui_image_swizz.sc b/examples/common/imgui/fs_imgui_image_swizz.sc new file mode 100644 index 000000000..b4f479edf --- /dev/null +++ b/examples/common/imgui/fs_imgui_image_swizz.sc @@ -0,0 +1,18 @@ +$input v_texcoord0 + +/* + * Copyright 2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include + +uniform float u_imageLod; +uniform vec4 u_swizzle; +SAMPLER2D(u_texColor, 0); + +void main() +{ + float color = dot(texture2DLod(u_texColor, v_texcoord0, u_imageLod), u_swizzle); + gl_FragColor = vec4(vec3_splat(color), 1.0); +} diff --git a/examples/common/imgui/fs_imgui_texture.bin.h b/examples/common/imgui/fs_imgui_texture.bin.h index e6eb7ddf9..fa620112f 100644 --- a/examples/common/imgui/fs_imgui_texture.bin.h +++ b/examples/common/imgui/fs_imgui_texture.bin.h @@ -39,25 +39,24 @@ static const uint8_t fs_imgui_texture_dx9[241] = 0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x07, 0x80, 0x00, 0x00, 0xe4, 0x90, 0xff, 0xff, 0x00, 0x00, // ................ 0x00, // . }; -static const uint8_t fs_imgui_texture_dx11[754] = +static const uint8_t fs_imgui_texture_dx11[738] = { - 0x46, 0x53, 0x48, 0x02, 0x01, 0x83, 0xf2, 0xe1, 0x00, 0x00, 0xd4, 0x02, 0x44, 0x58, 0x42, 0x43, // FSH.........DXBC - 0x75, 0xa2, 0xbf, 0x18, 0x85, 0xa7, 0x57, 0xfd, 0x14, 0xc3, 0x19, 0x21, 0xf6, 0x74, 0x34, 0x77, // u.....W....!.t4w - 0x01, 0x00, 0x00, 0x00, 0xd4, 0x02, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, // ............4... - 0x00, 0x01, 0x00, 0x00, 0x74, 0x01, 0x00, 0x00, 0xa8, 0x01, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, // ....t.......X... - 0x52, 0x44, 0x45, 0x46, 0xc4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // RDEF............ + 0x46, 0x53, 0x48, 0x02, 0x01, 0x83, 0xf2, 0xe1, 0x00, 0x00, 0xc4, 0x02, 0x44, 0x58, 0x42, 0x43, // FSH.........DXBC + 0x8f, 0x77, 0x55, 0xdc, 0xbb, 0x5d, 0x37, 0x2c, 0xed, 0xde, 0x24, 0x6d, 0xe4, 0xbc, 0xf1, 0x76, // .wU..]7,..$m...v + 0x01, 0x00, 0x00, 0x00, 0xc4, 0x02, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, // ............4... + 0xf0, 0x00, 0x00, 0x00, 0x64, 0x01, 0x00, 0x00, 0x98, 0x01, 0x00, 0x00, 0x48, 0x02, 0x00, 0x00, // ....d.......H... + 0x52, 0x44, 0x45, 0x46, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // RDEF............ 0x02, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0xff, 0x00, 0x91, 0x00, 0x00, // ................ - 0x92, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ + 0x80, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // ................ - 0x01, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, // ....w........... + 0x01, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, // ....n........... 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // ................ - 0x0d, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x75, 0x5f, // ....u_texColoru_ - 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x75, // texColorampler.u - 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, // _texColoru_texCo - 0x6c, 0x6f, 0x72, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, // lorexture.Micros - 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, // oft (R) HLSL Sha - 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, // der Compiler 9.2 - 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0xab, 0x49, 0x53, 0x47, 0x4e, // 9.952.3111..ISGN + 0x0d, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x53, 0x61, // ....u_texColorSa + 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x75, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, // mpler.u_texColor + 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, // Texture.Microsof + 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, // t (R) HLSL Shade + 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, 0x39, 0x2e, // r Compiler 9.29. + 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0xab, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, // 952.3111....ISGN 0x6c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, // l...........P... 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ 0x0f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................ diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index 5577a7086..b729f21e7 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -39,6 +39,7 @@ #include "fs_imgui_texture.bin.h" #include "vs_imgui_image.bin.h" #include "fs_imgui_image.bin.h" +#include "fs_imgui_image_swizz.bin.h" #include "dds_imgui_x_texture.h" #define USE_NANOVG_FONT 0 @@ -304,12 +305,14 @@ struct Imgui m_invTextureHeight = 1.0f/m_textureHeight; u_imageLod.idx = bgfx::invalidHandle; + u_imageSwizzle.idx = bgfx::invalidHandle; u_texColor.idx = bgfx::invalidHandle; m_missingTexture.idx = bgfx::invalidHandle; m_colorProgram.idx = bgfx::invalidHandle; m_textureProgram.idx = bgfx::invalidHandle; m_imageProgram.idx = bgfx::invalidHandle; + m_imageSwizzProgram.idx = bgfx::invalidHandle; } ImguiFontHandle createFont(const void* _data, float _fontSize) @@ -352,6 +355,7 @@ struct Imgui PosUvVertex::init(); u_imageLod = bgfx::createUniform("u_imageLod", bgfx::UniformType::Uniform1f); + u_imageSwizzle = bgfx::createUniform("u_swizzle", bgfx::UniformType::Uniform4fv); u_texColor = bgfx::createUniform("u_texColor", bgfx::UniformType::Uniform1i); const bgfx::Memory* vs_imgui_color; @@ -360,35 +364,39 @@ struct Imgui const bgfx::Memory* fs_imgui_texture; const bgfx::Memory* vs_imgui_image; const bgfx::Memory* fs_imgui_image; + const bgfx::Memory* fs_imgui_image_swizz; switch (bgfx::getRendererType() ) { case bgfx::RendererType::Direct3D9: - vs_imgui_color = bgfx::makeRef(vs_imgui_color_dx9, sizeof(vs_imgui_color_dx9) ); - fs_imgui_color = bgfx::makeRef(fs_imgui_color_dx9, sizeof(fs_imgui_color_dx9) ); - vs_imgui_texture = bgfx::makeRef(vs_imgui_texture_dx9, sizeof(vs_imgui_texture_dx9) ); - fs_imgui_texture = bgfx::makeRef(fs_imgui_texture_dx9, sizeof(fs_imgui_texture_dx9) ); - vs_imgui_image = bgfx::makeRef(vs_imgui_image_dx9, sizeof(vs_imgui_image_dx9) ); - fs_imgui_image = bgfx::makeRef(fs_imgui_image_dx9, sizeof(fs_imgui_image_dx9) ); + vs_imgui_color = bgfx::makeRef(vs_imgui_color_dx9, sizeof(vs_imgui_color_dx9) ); + fs_imgui_color = bgfx::makeRef(fs_imgui_color_dx9, sizeof(fs_imgui_color_dx9) ); + vs_imgui_texture = bgfx::makeRef(vs_imgui_texture_dx9, sizeof(vs_imgui_texture_dx9) ); + fs_imgui_texture = bgfx::makeRef(fs_imgui_texture_dx9, sizeof(fs_imgui_texture_dx9) ); + vs_imgui_image = bgfx::makeRef(vs_imgui_image_dx9, sizeof(vs_imgui_image_dx9) ); + fs_imgui_image = bgfx::makeRef(fs_imgui_image_dx9, sizeof(fs_imgui_image_dx9) ); + fs_imgui_image_swizz = bgfx::makeRef(fs_imgui_image_swizz_dx9, sizeof(fs_imgui_image_swizz_dx9) ); m_halfTexel = 0.5f; break; case bgfx::RendererType::Direct3D11: - vs_imgui_color = bgfx::makeRef(vs_imgui_color_dx11, sizeof(vs_imgui_color_dx11) ); - fs_imgui_color = bgfx::makeRef(fs_imgui_color_dx11, sizeof(fs_imgui_color_dx11) ); - vs_imgui_texture = bgfx::makeRef(vs_imgui_texture_dx11, sizeof(vs_imgui_texture_dx11) ); - fs_imgui_texture = bgfx::makeRef(fs_imgui_texture_dx11, sizeof(fs_imgui_texture_dx11) ); - vs_imgui_image = bgfx::makeRef(vs_imgui_image_dx11, sizeof(vs_imgui_image_dx11) ); - fs_imgui_image = bgfx::makeRef(fs_imgui_image_dx11, sizeof(fs_imgui_image_dx11) ); + vs_imgui_color = bgfx::makeRef(vs_imgui_color_dx11, sizeof(vs_imgui_color_dx11) ); + fs_imgui_color = bgfx::makeRef(fs_imgui_color_dx11, sizeof(fs_imgui_color_dx11) ); + vs_imgui_texture = bgfx::makeRef(vs_imgui_texture_dx11, sizeof(vs_imgui_texture_dx11) ); + fs_imgui_texture = bgfx::makeRef(fs_imgui_texture_dx11, sizeof(fs_imgui_texture_dx11) ); + vs_imgui_image = bgfx::makeRef(vs_imgui_image_dx11, sizeof(vs_imgui_image_dx11) ); + fs_imgui_image = bgfx::makeRef(fs_imgui_image_dx11, sizeof(fs_imgui_image_dx11) ); + fs_imgui_image_swizz = bgfx::makeRef(fs_imgui_image_swizz_dx11, sizeof(fs_imgui_image_swizz_dx11) ); break; default: - vs_imgui_color = bgfx::makeRef(vs_imgui_color_glsl, sizeof(vs_imgui_color_glsl) ); - fs_imgui_color = bgfx::makeRef(fs_imgui_color_glsl, sizeof(fs_imgui_color_glsl) ); - vs_imgui_texture = bgfx::makeRef(vs_imgui_texture_glsl, sizeof(vs_imgui_texture_glsl) ); - fs_imgui_texture = bgfx::makeRef(fs_imgui_texture_glsl, sizeof(fs_imgui_texture_glsl) ); - vs_imgui_image = bgfx::makeRef(vs_imgui_image_glsl, sizeof(vs_imgui_image_glsl) ); - fs_imgui_image = bgfx::makeRef(fs_imgui_image_glsl, sizeof(fs_imgui_image_glsl) ); + vs_imgui_color = bgfx::makeRef(vs_imgui_color_glsl, sizeof(vs_imgui_color_glsl) ); + fs_imgui_color = bgfx::makeRef(fs_imgui_color_glsl, sizeof(fs_imgui_color_glsl) ); + vs_imgui_texture = bgfx::makeRef(vs_imgui_texture_glsl, sizeof(vs_imgui_texture_glsl) ); + fs_imgui_texture = bgfx::makeRef(fs_imgui_texture_glsl, sizeof(fs_imgui_texture_glsl) ); + vs_imgui_image = bgfx::makeRef(vs_imgui_image_glsl, sizeof(vs_imgui_image_glsl) ); + fs_imgui_image = bgfx::makeRef(fs_imgui_image_glsl, sizeof(fs_imgui_image_glsl) ); + fs_imgui_image_swizz = bgfx::makeRef(fs_imgui_image_swizz_glsl, sizeof(fs_imgui_image_swizz_glsl) ); break; } @@ -410,9 +418,14 @@ struct Imgui vsh = bgfx::createShader(vs_imgui_image); fsh = bgfx::createShader(fs_imgui_image); m_imageProgram = bgfx::createProgram(vsh, fsh); - bgfx::destroyShader(vsh); bgfx::destroyShader(fsh); + // Notice: using the same vsh. + fsh = bgfx::createShader(fs_imgui_image_swizz); + m_imageSwizzProgram = bgfx::createProgram(vsh, fsh); + bgfx::destroyShader(fsh); + bgfx::destroyShader(vsh); + const bgfx::Memory* texMem = bgfx::makeRef(s_xTexture, sizeof(s_xTexture)); m_missingTexture = bgfx::createTexture(texMem); @@ -428,6 +441,7 @@ struct Imgui void destroy() { bgfx::destroyUniform(u_imageLod); + bgfx::destroyUniform(u_imageSwizzle); bgfx::destroyUniform(u_texColor); #if !USE_NANOVG_FONT for (uint16_t ii = 0; ii < IMGUI_CONFIG_MAX_FONTS; ++ii) @@ -442,6 +456,7 @@ struct Imgui bgfx::destroyProgram(m_colorProgram); bgfx::destroyProgram(m_textureProgram); bgfx::destroyProgram(m_imageProgram); + bgfx::destroyProgram(m_imageSwizzProgram); nvgDelete(m_nvg); } @@ -1085,6 +1100,51 @@ struct Imgui image(_image, _lod, int32_t(width), int32_t(height), _align); } + void imageSwizzle(bgfx::TextureHandle _image, const float _swizzle[4], float _lod, int32_t _width, int32_t _height, ImguiImageAlign::Enum _align) + { + int32_t xx; + if (ImguiImageAlign::Left == _align) + { + xx = m_scrollAreaX + SCROLL_AREA_PADDING; + } + else if (ImguiImageAlign::LeftIndented == _align) + { + xx = m_widgetX; + } + else if (ImguiImageAlign::Center == _align) + { + xx = m_scrollAreaX + (m_scrollAreaInnerWidth-_width)/2; + } + else if (ImguiImageAlign::CenterIndented == _align) + { + xx = (m_widgetX + m_scrollAreaInnerWidth + m_scrollAreaX - _width)/2; + } + else //if (ImguiImageAlign::Right == _align). + { + xx = m_scrollAreaX + m_scrollAreaInnerWidth - _width; + } + + const int32_t yy = m_widgetY; + m_widgetY += _height + DEFAULT_SPACING; + + screenQuad(xx, yy, _width, _height); + bgfx::setUniform(u_imageLod, &_lod); + bgfx::setUniform(u_imageSwizzle, _swizzle); + bgfx::setTexture(0, u_texColor, bgfx::isValid(_image) ? _image : m_missingTexture); + bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE); + bgfx::setProgram(m_imageSwizzProgram); + bgfx::setScissor(m_scissor); + bgfx::submit(m_view); + } + + void imageSwizzle(bgfx::TextureHandle _image, const float _swizzle[4], float _lod, float _width, float _aspect, ImguiImageAlign::Enum _align) + { + const float width = _width*float(m_scrollAreaInnerWidth); + const float height = width/_aspect; + + imageSwizzle(_image, _swizzle, _lod, int32_t(width), int32_t(height), _align); + } + bool collapse(const char* _text, const char* _subtext, bool _checked, bool _enabled) { m_widgetId++; @@ -2129,10 +2189,12 @@ struct Imgui #endif // !USE_NANOVG_FONT bgfx::UniformHandle u_imageLod; + bgfx::UniformHandle u_imageSwizzle; bgfx::UniformHandle u_texColor; bgfx::ProgramHandle m_colorProgram; bgfx::ProgramHandle m_textureProgram; bgfx::ProgramHandle m_imageProgram; + bgfx::ProgramHandle m_imageSwizzProgram; bgfx::TextureHandle m_missingTexture; }; @@ -2330,3 +2392,13 @@ void imguiImage(bgfx::TextureHandle _image, float _lod, float _width, float _asp { s_imgui.image(_image, _lod, _width, _aspect, _align); } + +void imguiImageSwizzle(bgfx::TextureHandle _image, const float _swizzle[4], float _lod, int32_t _width, int32_t _height, ImguiImageAlign::Enum _align) +{ + s_imgui.imageSwizzle(_image, _swizzle, _lod, _width, _height, _align); +} + +void imguiImageSwizzle(bgfx::TextureHandle _image, const float _swizzle[4], float _lod, float _width, float _aspect, ImguiImageAlign::Enum _align) +{ + s_imgui.imageSwizzle(_image, _swizzle, _lod, _width, _aspect, _align); +} diff --git a/examples/common/imgui/imgui.h b/examples/common/imgui/imgui.h index 37407729f..8730595e3 100644 --- a/examples/common/imgui/imgui.h +++ b/examples/common/imgui/imgui.h @@ -107,6 +107,8 @@ void imguiColorWheel(float _rgb[3], bool _respectIndentation = false, bool _enab void imguiColorWheel(const char* _str, float _rgb[3], bool& _activated, bool _enabled = true); void imguiImage(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiImageAlign::Enum _align = ImguiImageAlign::LeftIndented); -void imguiImage(bgfx::TextureHandle _image, float _lod, float _scale, float _aspect, ImguiImageAlign::Enum _align = ImguiImageAlign::LeftIndented); //_scale is in [0.0-1.0] range. +void imguiImage(bgfx::TextureHandle _image, float _lod, float _scale, float _aspect, ImguiImageAlign::Enum _align = ImguiImageAlign::LeftIndented); +void imguiImageSwizzle(bgfx::TextureHandle _image, const float _swizzle[4], float _lod, int32_t _width, int32_t _height, ImguiImageAlign::Enum _align = ImguiImageAlign::LeftIndented); +void imguiImageSwizzle(bgfx::TextureHandle _image, const float _swizzle[4], float _lod, float _scale, float _aspect, ImguiImageAlign::Enum _align = ImguiImageAlign::LeftIndented); #endif // IMGUI_H_HEADER_GUARD From 6e3f21f06201d089e3361cb0d3e18f347682dafb Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Sun, 10 Aug 2014 13:11:16 +0100 Subject: [PATCH 4/9] Added imguiBorderButton(). --- examples/common/imgui/imgui.cpp | 133 ++++++++++++++++++++++++++++++-- examples/common/imgui/imgui.h | 14 ++++ 2 files changed, 142 insertions(+), 5 deletions(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index b729f21e7..ba24779c6 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -299,6 +299,8 @@ struct Imgui , m_halfTexel(0.0f) , m_nvg(NULL) , m_view(31) + , m_viewWidth(0) + , m_viewHeight(0) , m_currentFontIdx(0) { m_invTextureWidth = 1.0f/m_textureWidth; @@ -636,6 +638,8 @@ struct Imgui nvgBeginFrame(m_nvg, _width, _height, 1.0f, NVG_STRAIGHT_ALPHA); m_view = _view; + m_viewWidth = _width; + m_viewHeight = _height; bgfx::setViewSeq(_view, true); bgfx::setViewRect(_view, 0, 0, _width, _height); @@ -1169,7 +1173,7 @@ struct Imgui , cy , CHECK_SIZE , CHECK_SIZE - , 2 + , TriangleOrientation::Up , imguiRGBA(255, 255, 255, isActive(id) ? 255 : 200) ); } @@ -1179,7 +1183,7 @@ struct Imgui , cy , CHECK_SIZE , CHECK_SIZE - , 1 + , TriangleOrientation::Right , imguiRGBA(255, 255, 255, isActive(id) ? 255 : 200) ); } @@ -1216,6 +1220,85 @@ struct Imgui return res; } + bool borderButton(ImguiBorder::Enum _border, bool _checked, bool _enabled) + { + m_widgetId++; + uint16_t id = (m_areaId << 8) | m_widgetId; + + const int32_t triSize = 12; + const int32_t borderSize = 15; + + int32_t xx; + int32_t yy; + int32_t width; + int32_t height; + int32_t triX; + int32_t triY; + TriangleOrientation::Enum orientation; + + if (ImguiBorder::Left == _border) + { + xx = -borderSize; + yy = 0; + width = 2*borderSize; + height = m_viewHeight; + triX = 0; + triY = (m_viewHeight-triSize)/2; + orientation = _checked ? TriangleOrientation::Left : TriangleOrientation::Right; + } + else if (ImguiBorder::Right == _border) + { + xx = m_viewWidth - borderSize; + yy = 0; + width = 2*borderSize; + height = m_viewHeight; + triX = m_viewWidth - triSize - 2; + triY = (m_viewHeight-width)/2; + orientation = _checked ? TriangleOrientation::Right : TriangleOrientation::Left; + } + else if (ImguiBorder::Top == _border) + { + xx = 0; + yy = -borderSize; + width = m_viewWidth; + height = 2*borderSize; + triX = (m_viewWidth-triSize)/2; + triY = 0; + orientation = _checked ? TriangleOrientation::Up : TriangleOrientation::Down; + } + else //if (ImguiBorder::Bottom == _border). + { + xx = 0; + yy = m_viewHeight - borderSize; + width = m_viewWidth; + height = 2*borderSize; + triX = (m_viewWidth-triSize)/2; + triY = m_viewHeight-triSize; + orientation = _checked ? TriangleOrientation::Down : TriangleOrientation::Up; + } + + const bool over = _enabled && inRect(xx, yy, width, height, false); + const bool res = buttonLogic(id, over); + + drawRoundedRect( (float)xx + , (float)yy + , (float)width + , (float)height + , 0.0f + , isActive(id) ? imguiRGBA(23, 23, 23, 192) : imguiRGBA(0, 0, 0, 222) + ); + + drawTriangle( triX + , triY + , triSize + , triSize + , orientation + , isHot(id) ? imguiRGBA(255, 196, 0, 222) : imguiRGBA(255, 255, 255, 192) + ); + + return res; + } + void labelVargs(const char* _format, va_list _argList) { char temp[8192]; @@ -1603,9 +1686,31 @@ struct Imgui drawPolygon(verts, 4, _fth, _abgr); } - void drawTriangle(int32_t _x, int32_t _y, int32_t _width, int32_t _height, int32_t _flags, uint32_t _abgr) + struct TriangleOrientation { - if (1 == _flags) + enum Enum + { + Left, + Right, + Up, + Down, + }; + }; + + void drawTriangle(int32_t _x, int32_t _y, int32_t _width, int32_t _height, TriangleOrientation::Enum _orientation, uint32_t _abgr) + { + if (TriangleOrientation::Left == _orientation) + { + const float verts[3 * 2] = + { + (float)_x + 0.5f + (float)_width * 1.0f, (float)_y + 0.5f, + (float)_x + 0.5f, (float)_y + 0.5f + (float)_height / 2.0f - 0.5f, + (float)_x + 0.5f + (float)_width * 1.0f, (float)_y + 0.5f + (float)_height - 1.0f, + }; + + drawPolygon(verts, 3, 1.0f, _abgr); + } + else if (TriangleOrientation::Right == _orientation) { const float verts[3 * 2] = { @@ -1616,7 +1721,7 @@ struct Imgui drawPolygon(verts, 3, 1.0f, _abgr); } - else + else if (TriangleOrientation::Up == _orientation) { const float verts[3 * 2] = { @@ -1625,6 +1730,17 @@ struct Imgui (float)_x + 0.5f + (float)_width - 1.0f, (float)_y + 0.5f + (float)_height - 1.0f, }; + drawPolygon(verts, 3, 1.0f, _abgr); + } + else //if (TriangleOrientation::Down == _orientation). + { + const float verts[3 * 2] = + { + (float)_x + 0.5f, (float)_y + 0.5f, + (float)_x + 0.5f + (float)_width / 2.0f - 0.5f, (float)_y + 0.5f + (float)_height - 1.0f, + (float)_x + 0.5f + (float)_width - 1.0f, (float)_y + 0.5f, + }; + drawPolygon(verts, 3, 1.0f, _abgr); } } @@ -2175,6 +2291,8 @@ struct Imgui NVGcontext* m_nvg; uint8_t m_view; + uint16_t m_viewWidth; + uint16_t m_viewHeight; #if !USE_NANOVG_FONT struct Font @@ -2230,6 +2348,11 @@ void imguiEndFrame() s_imgui.endFrame(); } +bool imguiBorderButton(ImguiBorder::Enum _border, bool _checked, bool _enabled) +{ + return s_imgui.borderButton(_border, _checked, _enabled); +} + bool imguiBeginScrollArea(const char* _name, int32_t _x, int32_t _y, int32_t _width, int32_t _height, int32_t* _scroll, bool _enabled) { return s_imgui.beginScrollArea(_name, _x, _y, _width, _height, _scroll, _enabled); diff --git a/examples/common/imgui/imgui.h b/examples/common/imgui/imgui.h index 8730595e3..aff98f384 100644 --- a/examples/common/imgui/imgui.h +++ b/examples/common/imgui/imgui.h @@ -55,6 +55,17 @@ struct ImguiImageAlign }; }; +struct ImguiBorder +{ + enum Enum + { + Left, + Right, + Top, + Bottom + }; +}; + inline uint32_t imguiRGBA(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a = 255) { return 0 @@ -76,6 +87,9 @@ void imguiDestroy(); void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, char _inputChar = 0, uint8_t _view = 31); void imguiEndFrame(); +/// Notice: this function is not to be called between imguiBeginScrollArea() and imguiEndScrollArea(). +bool imguiBorderButton(ImguiBorder::Enum _border, bool _checked, bool _enabled = true); + bool imguiBeginScrollArea(const char* _name, int _x, int _y, int _width, int _height, int* _scroll, bool _enabled = true); void imguiEndScrollArea(); From b9af3544ad3e45e98595106c9bd5f420771a2d04 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Sun, 10 Aug 2014 15:17:37 +0100 Subject: [PATCH 5/9] Added imguiTabs(). --- examples/common/imgui/imgui.cpp | 85 +++++++++++++++++++++++++++++++++ examples/common/imgui/imgui.h | 3 ++ 2 files changed, 88 insertions(+) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index ba24779c6..a658468e1 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -324,6 +324,7 @@ struct Imgui const bgfx::Memory* mem = bgfx::alloc(m_textureWidth * m_textureHeight); stbtt_BakeFontBitmap( (uint8_t*)_data, 0, _fontSize, mem->data, m_textureWidth, m_textureHeight, 32, 96, m_fonts[handle.idx].m_cdata); m_fonts[handle.idx].m_texture = bgfx::createTexture2D(m_textureWidth, m_textureHeight, 1, bgfx::TextureFormat::R8, BGFX_TEXTURE_NONE, mem); + m_fonts[handle.idx].m_size = _fontSize; #else const ImguiFontHandle handle = { bgfx::invalidHandle }; #endif // !USE_NANOVG_FONT @@ -1060,6 +1061,79 @@ struct Imgui ); } + uint8_t tabs(uint8_t _selected, bool _enabled, va_list _argList) + { + uint8_t count; + const char* titles[16]; + const char* str = va_arg(_argList, const char*); + for (count = 0; str != NULL || count >= 16; ++count, str = va_arg(_argList, const char*) ) + { + titles[count] = str; + } + + const int32_t yy = m_widgetY; + const int32_t height = BUTTON_HEIGHT; + m_widgetY += height + DEFAULT_SPACING; + + uint8_t selected = _selected; + const int32_t tabWidth = m_scrollAreaInnerWidth / count; + const int32_t tabWidthHalf = m_scrollAreaInnerWidth / (count*2); + const int32_t textY = yy + height/2 + int32_t(m_fonts[m_currentFontIdx].m_size)/2 - 1; + + drawRoundedRect( (float)m_widgetX + , (float)yy-1 + , (float)m_scrollAreaInnerWidth + , (float)height+2 + , (float)BUTTON_HEIGHT / 2 - 1 + , imguiRGBA(128, 128, 128, 96) + ); + + for (uint8_t ii = 0; ii < count; ++ii) + { + m_widgetId++; + const uint16_t id = (m_areaId << 8) | m_widgetId; + + int32_t xx = m_widgetX + ii*tabWidth; + int32_t textX = xx + tabWidthHalf; + + const bool enabled = _enabled && isEnabled(m_areaId); + const bool over = enabled && inRect(xx, yy, tabWidth, height); + const bool res = buttonLogic(id, over); + + if (res) + { + selected = ii; + } + + uint32_t textColor; + if (ii == selected) + { + textColor = enabled?imguiRGBA(0,0,0,255):imguiRGBA(255,255,255,100); + + drawRoundedRect( (float)xx + , (float)yy-1 + , (float)tabWidth + , (float)height+2 + , (float)BUTTON_HEIGHT / 2 - 1 + , enabled?imguiRGBA(255,196,0,200):imguiRGBA(128,128,128,96) + ); + } + else + { + textColor = isHot(id) ? imguiRGBA(255, 196, 0, enabled?255:100) : imguiRGBA(255, 255, 255, enabled?200:100); + } + + drawText(textX + , textY + , ImguiTextAlign::Center + , titles[ii] + , textColor + ); + } + + return selected; + } + void image(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiImageAlign::Enum _align) { int32_t xx; @@ -2299,6 +2373,7 @@ struct Imgui { stbtt_bakedchar m_cdata[96]; // ASCII 32..126 is 95 glyphs bgfx::TextureHandle m_texture; + float m_size; }; uint16_t m_currentFontIdx; @@ -2434,6 +2509,16 @@ void imguiInput(const char* _label, char* _str, uint32_t _len, bool _enabled) s_imgui.input(_label, _str, _len, _enabled); } +uint8_t imguiTabsUseMacroInstead(uint8_t _selected, bool _enabled, ...) +{ + va_list argList; + va_start(argList, _enabled); + const uint8_t result = s_imgui.tabs(_selected, _enabled, argList); + va_end(argList); + + return result; +} + uint32_t imguiChooseUseMacroInstead(uint32_t _selected, ...) { va_list argList; diff --git a/examples/common/imgui/imgui.h b/examples/common/imgui/imgui.h index aff98f384..d3ef25d07 100644 --- a/examples/common/imgui/imgui.h +++ b/examples/common/imgui/imgui.h @@ -108,6 +108,9 @@ bool imguiSlider(const char* _text, float& _val, float _vmin, float _vmax, float bool imguiSlider(const char* _text, int32_t& _val, int32_t _vmin, int32_t _vmax, bool _enabled = true); void imguiInput(const char* _label, char* _str, uint32_t _len, bool _enabled = true); +uint8_t imguiTabsUseMacroInstead(uint8_t _selected, bool _enabled, ...); +#define imguiTabs(_selected, _enabled, ...) imguiTabsUseMacroInstead(_selected, _enabled, __VA_ARGS__, NULL) + uint32_t imguiChooseUseMacroInstead(uint32_t _selected, ...); #define imguiChoose(...) imguiChooseUseMacroInstead(__VA_ARGS__, NULL) From 9f31587b09a827d6fa52bff296b459b8575993b1 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Sun, 10 Aug 2014 15:22:24 +0100 Subject: [PATCH 6/9] Added optional _height param for imguiSeparator() and imguiSeparatorLine(). --- examples/common/imgui/imgui.cpp | 18 +++++++++--------- examples/common/imgui/imgui.h | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index a658468e1..dd496d805 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -1529,18 +1529,18 @@ struct Imgui m_widgetW += INDENT_SIZE; } - void separator() + void separator(uint16_t _height) { - m_widgetY += DEFAULT_SPACING * 3; + m_widgetY += _height; } - void separatorLine() + void separatorLine(uint16_t _height) { int32_t xx = m_widgetX; - int32_t yy = m_widgetY + DEFAULT_SPACING*2; + int32_t yy = m_widgetY + _height/2; int32_t width = m_widgetW; int32_t height = 1; - m_widgetY += DEFAULT_SPACING * 4; + m_widgetY += _height; drawRect( (float)xx , (float)yy @@ -2448,14 +2448,14 @@ void imguiUnindent() s_imgui.unindent(); } -void imguiSeparator() +void imguiSeparator(uint16_t _height) { - s_imgui.separator(); + s_imgui.separator(_height); } -void imguiSeparatorLine() +void imguiSeparatorLine(uint16_t _height) { - s_imgui.separatorLine(); + s_imgui.separatorLine(_height); } bool imguiButton(const char* _text, bool _enabled) diff --git a/examples/common/imgui/imgui.h b/examples/common/imgui/imgui.h index d3ef25d07..1bd0b7f9b 100644 --- a/examples/common/imgui/imgui.h +++ b/examples/common/imgui/imgui.h @@ -95,8 +95,8 @@ void imguiEndScrollArea(); void imguiIndent(); void imguiUnindent(); -void imguiSeparator(); -void imguiSeparatorLine(); +void imguiSeparator(uint16_t _height = 12); +void imguiSeparatorLine(uint16_t _height = 12); bool imguiButton(const char* _text, bool _enabled = true); bool imguiItem(const char* _text, bool _enabled = true); From 1c16d97c27df2d76692695a029661b873a65d23c Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Sun, 10 Aug 2014 15:49:06 +0100 Subject: [PATCH 7/9] Fixing imgui scroll area scissoring. --- examples/common/imgui/imgui.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index dd496d805..26788740a 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -685,7 +685,7 @@ struct Imgui m_widgetX = _x + SCROLL_AREA_PADDING; m_widgetY = _y + AREA_HEADER + (*_scroll); - m_widgetW = _width - SCROLL_AREA_PADDING * 4; + m_widgetW = _width - SCROLL_AREA_PADDING * 4 - 2; m_scrollTop = _y + AREA_HEADER; m_scrollBottom = _y + _height; @@ -720,14 +720,14 @@ struct Imgui nvgScissor(m_nvg , float(_x + SCROLL_AREA_PADDING) - , float(_y + AREA_HEADER) - , float(_width - SCROLL_AREA_PADDING * 4) + , float(_y + AREA_HEADER - 1) + , float(_width - SCROLL_AREA_PADDING * 3) , float(_height - AREA_HEADER - SCROLL_AREA_PADDING) ); m_scissor = bgfx::setScissor(uint16_t(_x + SCROLL_AREA_PADDING) - , uint16_t(_y + AREA_HEADER) - , uint16_t(_width - SCROLL_AREA_PADDING * 4) + , uint16_t(_y + AREA_HEADER - 1) + , uint16_t(_width - SCROLL_AREA_PADDING * 3) , uint16_t(_height - AREA_HEADER - SCROLL_AREA_PADDING) ); From 2b01f8a87488ef3358dcb5903cb145e8bf5ca042 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Sun, 10 Aug 2014 15:59:22 +0100 Subject: [PATCH 8/9] Function setWindowTitle() now returns void. --- examples/common/entry/entry.h | 2 +- examples/common/entry/entry_android.cpp | 2 +- examples/common/entry/entry_asmjs.cpp | 2 +- examples/common/entry/entry_ios.mm | 2 +- examples/common/entry/entry_linux.cpp | 2 +- examples/common/entry/entry_nacl.cpp | 2 +- examples/common/entry/entry_osx.mm | 2 +- examples/common/entry/entry_qnx.cpp | 2 +- examples/common/entry/entry_sdl.cpp | 4 ++-- examples/common/entry/entry_windows.cpp | 8 ++++---- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/common/entry/entry.h b/examples/common/entry/entry.h index 9247a9b74..02507f389 100644 --- a/examples/common/entry/entry.h +++ b/examples/common/entry/entry.h @@ -161,7 +161,7 @@ namespace entry bx::FileWriterI* getFileWriter(); void setWindowSize(uint32_t _width, uint32_t _height); - bool setWindowTitle(const char* _title); + void setWindowTitle(const char* _title); void toggleWindowFrame(); void setMouseLock(bool _lock); diff --git a/examples/common/entry/entry_android.cpp b/examples/common/entry/entry_android.cpp index 16847e4ac..466185501 100644 --- a/examples/common/entry/entry_android.cpp +++ b/examples/common/entry/entry_android.cpp @@ -207,7 +207,7 @@ namespace entry BX_UNUSED(_width, _height); } - bool setWindowTitle(const char* _title) + void setWindowTitle(const char* _title) { BX_UNUSED(_title); } diff --git a/examples/common/entry/entry_asmjs.cpp b/examples/common/entry/entry_asmjs.cpp index 1e0c32df0..9099ae334 100644 --- a/examples/common/entry/entry_asmjs.cpp +++ b/examples/common/entry/entry_asmjs.cpp @@ -24,7 +24,7 @@ namespace entry { } - bool setWindowTitle(const char* _title) + void setWindowTitle(const char* _title) { BX_UNUSED(_title); } diff --git a/examples/common/entry/entry_ios.mm b/examples/common/entry/entry_ios.mm index ebca92675..f61308e08 100644 --- a/examples/common/entry/entry_ios.mm +++ b/examples/common/entry/entry_ios.mm @@ -86,7 +86,7 @@ namespace entry BX_UNUSED(_width, _height); } - bool setWindowTitle(const char* _title) + void setWindowTitle(const char* _title) { BX_UNUSED(_title); } diff --git a/examples/common/entry/entry_linux.cpp b/examples/common/entry/entry_linux.cpp index c17cb45f3..9084021f8 100644 --- a/examples/common/entry/entry_linux.cpp +++ b/examples/common/entry/entry_linux.cpp @@ -328,7 +328,7 @@ namespace entry XSendEvent(s_ctx.m_display, s_ctx.m_window, false, ResizeRedirectMask, (XEvent*)&ev); } - bool setWindowTitle(const char* _title) + void setWindowTitle(const char* _title) { BX_UNUSED(_title); } diff --git a/examples/common/entry/entry_nacl.cpp b/examples/common/entry/entry_nacl.cpp index d06b3f5e9..843c9d72f 100644 --- a/examples/common/entry/entry_nacl.cpp +++ b/examples/common/entry/entry_nacl.cpp @@ -61,7 +61,7 @@ namespace entry BX_UNUSED(_width, _height); } - bool setWindowTitle(const char* _title) + void setWindowTitle(const char* _title) { BX_UNUSED(_title); } diff --git a/examples/common/entry/entry_osx.mm b/examples/common/entry/entry_osx.mm index 53cf0a315..cef8064d5 100644 --- a/examples/common/entry/entry_osx.mm +++ b/examples/common/entry/entry_osx.mm @@ -281,7 +281,7 @@ namespace entry BX_UNUSED(_width, _height); } - bool setWindowTitle(const char* _title) + void setWindowTitle(const char* _title) { BX_UNUSED(_title); } diff --git a/examples/common/entry/entry_qnx.cpp b/examples/common/entry/entry_qnx.cpp index 1cdd0e228..ff7e068f7 100644 --- a/examples/common/entry/entry_qnx.cpp +++ b/examples/common/entry/entry_qnx.cpp @@ -25,7 +25,7 @@ namespace entry { } - bool setWindowTitle(const char* _title) + void setWindowTitle(const char* _title) { BX_UNUSED(_title); } diff --git a/examples/common/entry/entry_sdl.cpp b/examples/common/entry/entry_sdl.cpp index e9ad6fee4..f4de73248 100644 --- a/examples/common/entry/entry_sdl.cpp +++ b/examples/common/entry/entry_sdl.cpp @@ -304,7 +304,7 @@ namespace entry } } - bool setWindowTitle(const char* _title) + void setWindowTitle(const char* _title) { SDL_WM_SetCaption(_title, NULL); } @@ -347,7 +347,7 @@ namespace entry SDL_PushEvent(&event); } - bool setWindowTitle(const char* _title) + void setWindowTitle(const char* _title) { s_ctx.setWindowTitle(_title); } diff --git a/examples/common/entry/entry_windows.cpp b/examples/common/entry/entry_windows.cpp index 5aa50f47c..204f5e58f 100644 --- a/examples/common/entry/entry_windows.cpp +++ b/examples/common/entry/entry_windows.cpp @@ -586,9 +586,9 @@ namespace entry } } - bool setWindowTitle(const char* _title) + void setWindowTitle(const char* _title) { - return (1 == SetWindowText(m_hwnd, _title)); + SetWindowText(m_hwnd, _title); } static LRESULT CALLBACK wndProc(HWND _hwnd, UINT _id, WPARAM _wparam, LPARAM _lparam); @@ -639,9 +639,9 @@ namespace entry PostMessage(s_ctx.m_hwnd, WM_USER_SET_WINDOW_SIZE, 0, (_height<<16) | (_width&0xffff) ); } - bool setWindowTitle(const char* _title) + void setWindowTitle(const char* _title) { - return s_ctx.setWindowTitle(_title); + s_ctx.setWindowTitle(_title); } void toggleWindowFrame() From 65f5faceecc850bcdcb78673a6fc196f8470fc5c Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Sun, 10 Aug 2014 16:23:17 +0100 Subject: [PATCH 9/9] Making setWindowTitle() on Windows thread safe. --- examples/common/entry/entry_windows.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/common/entry/entry_windows.cpp b/examples/common/entry/entry_windows.cpp index 204f5e58f..1ce2bda2e 100644 --- a/examples/common/entry/entry_windows.cpp +++ b/examples/common/entry/entry_windows.cpp @@ -17,6 +17,7 @@ #define WM_USER_SET_WINDOW_SIZE (WM_USER+0) #define WM_USER_TOGGLE_WINDOW_FRAME (WM_USER+1) #define WM_USER_MOUSE_LOCK (WM_USER+2) +#define WM_USER_SET_WINDOW_TITLE (WM_USER+3) namespace entry { @@ -259,6 +260,12 @@ namespace entry } break; + case WM_USER_SET_WINDOW_TITLE: + { + SetWindowText(_hwnd, (const char*)_lparam); + } + break; + case WM_USER_TOGGLE_WINDOW_FRAME: { if (m_frame) @@ -586,11 +593,6 @@ namespace entry } } - void setWindowTitle(const char* _title) - { - SetWindowText(m_hwnd, _title); - } - static LRESULT CALLBACK wndProc(HWND _hwnd, UINT _id, WPARAM _wparam, LPARAM _lparam); EventQueue m_eventQueue; @@ -641,7 +643,7 @@ namespace entry void setWindowTitle(const char* _title) { - s_ctx.setWindowTitle(_title); + PostMessage(s_ctx.m_hwnd, WM_USER_SET_WINDOW_TITLE, 0, (LPARAM)_title); } void toggleWindowFrame()