summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2015-10-15 10:42:29 +0200
committer Miodrag Milanovic <mmicko@gmail.com>2015-10-15 10:42:29 +0200
commit8981faa61fc1e9421805938e6656d84ff61be1f9 (patch)
tree6295fadfe79ab1f2bafafd3f321e01063ca3cff7 /3rdparty/bgfx/examples/common
parenta74a7a37ef1f6ea1fd9c96148be8fa7ba09b1054 (diff)
update bgfx to latest (nw)
Diffstat (limited to '3rdparty/bgfx/examples/common')
-rw-r--r--3rdparty/bgfx/examples/common/bgfx_utils.cpp2
-rw-r--r--3rdparty/bgfx/examples/common/bgfx_utils.h2
-rw-r--r--3rdparty/bgfx/examples/common/cube_atlas.cpp2
-rw-r--r--3rdparty/bgfx/examples/common/cube_atlas.h2
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry.cpp2
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_android.cpp2
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_glfw.cpp2
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_ios.mm2
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_nacl.cpp4
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_osx.mm2
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_sdl.cpp2
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_windows.cpp43
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_winrt.cpp2
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_x11.cpp92
-rw-r--r--3rdparty/bgfx/examples/common/font/font_manager.cpp2
-rw-r--r--3rdparty/bgfx/examples/common/font/font_manager.h2
-rw-r--r--3rdparty/bgfx/examples/common/font/text_buffer_manager.cpp25
-rw-r--r--3rdparty/bgfx/examples/common/imgui/imgui.cpp6
-rw-r--r--3rdparty/bgfx/examples/common/imgui/imgui.h64
-rw-r--r--3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp493
-rw-r--r--3rdparty/bgfx/examples/common/imgui/scintilla.cpp4
-rw-r--r--3rdparty/bgfx/examples/common/nanovg/nanovg_bgfx.cpp3
22 files changed, 598 insertions, 162 deletions
diff --git a/3rdparty/bgfx/examples/common/bgfx_utils.cpp b/3rdparty/bgfx/examples/common/bgfx_utils.cpp
index ad1ca9fc4cb..386062c065d 100644
--- a/3rdparty/bgfx/examples/common/bgfx_utils.cpp
+++ b/3rdparty/bgfx/examples/common/bgfx_utils.cpp
@@ -12,7 +12,7 @@
#include <tinystl/string.h>
namespace stl = tinystl;
-#include <bgfx.h>
+#include <bgfx/bgfx.h>
#include <bx/readerwriter.h>
#include <bx/fpumath.h>
#include <bx/string.h>
diff --git a/3rdparty/bgfx/examples/common/bgfx_utils.h b/3rdparty/bgfx/examples/common/bgfx_utils.h
index 6b7d1f05da7..2938abff1b9 100644
--- a/3rdparty/bgfx/examples/common/bgfx_utils.h
+++ b/3rdparty/bgfx/examples/common/bgfx_utils.h
@@ -6,7 +6,7 @@
#ifndef BGFX_UTILS_H_HEADER_GUARD
#define BGFX_UTILS_H_HEADER_GUARD
-#include <bgfx.h>
+#include <bgfx/bgfx.h>
void* load(const char* _filePath, uint32_t* _size = NULL);
void unload(void* _ptr);
diff --git a/3rdparty/bgfx/examples/common/cube_atlas.cpp b/3rdparty/bgfx/examples/common/cube_atlas.cpp
index c0303d0baf9..1d762b6544d 100644
--- a/3rdparty/bgfx/examples/common/cube_atlas.cpp
+++ b/3rdparty/bgfx/examples/common/cube_atlas.cpp
@@ -4,7 +4,7 @@
*/
#include "common.h"
-#include <bgfx.h>
+#include <bgfx/bgfx.h>
#include <limits.h> // INT_MAX
#include <memory.h> // memset
diff --git a/3rdparty/bgfx/examples/common/cube_atlas.h b/3rdparty/bgfx/examples/common/cube_atlas.h
index 903221e7aed..5efde04858d 100644
--- a/3rdparty/bgfx/examples/common/cube_atlas.h
+++ b/3rdparty/bgfx/examples/common/cube_atlas.h
@@ -15,7 +15,7 @@
/// algorithm based on C++ sources provided by Jukka Jylänki at:
/// http://clb.demon.fi/files/RectangleBinPack/
-#include <bgfx.h>
+#include <bgfx/bgfx.h>
struct AtlasRegion
{
diff --git a/3rdparty/bgfx/examples/common/entry/entry.cpp b/3rdparty/bgfx/examples/common/entry/entry.cpp
index fa83cce89ba..61dbe0b3c9c 100644
--- a/3rdparty/bgfx/examples/common/entry/entry.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry.cpp
@@ -3,7 +3,7 @@
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
-#include <bgfx.h>
+#include <bgfx/bgfx.h>
#include <bx/string.h>
#include <bx/readerwriter.h>
diff --git a/3rdparty/bgfx/examples/common/entry/entry_android.cpp b/3rdparty/bgfx/examples/common/entry/entry_android.cpp
index f16b1e5dac6..aef9fee938a 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_android.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry_android.cpp
@@ -7,7 +7,7 @@
#if ENTRY_CONFIG_USE_NATIVE && BX_PLATFORM_ANDROID
-#include <bgfxplatform.h>
+#include <bgfx/bgfxplatform.h>
#include <stdio.h>
#include <bx/thread.h>
diff --git a/3rdparty/bgfx/examples/common/entry/entry_glfw.cpp b/3rdparty/bgfx/examples/common/entry/entry_glfw.cpp
index 42a7bc6f047..615d828cea9 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_glfw.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry_glfw.cpp
@@ -9,7 +9,7 @@
#define GLFW_DLL
#include <GLFW/glfw3.h>
-#include <bgfxplatform.h>
+#include <bgfx/bgfxplatform.h>
#include "dbg.h"
// This is just trivial implementation of GLFW3 integration.
diff --git a/3rdparty/bgfx/examples/common/entry/entry_ios.mm b/3rdparty/bgfx/examples/common/entry/entry_ios.mm
index d2392d898f4..1a10d26f765 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_ios.mm
+++ b/3rdparty/bgfx/examples/common/entry/entry_ios.mm
@@ -17,7 +17,7 @@
//# define HAS_METAL_SDK
#endif
-#include <bgfxplatform.h>
+#include <bgfx/bgfxplatform.h>
#include <bx/uint32_t.h>
#include <bx/thread.h>
diff --git a/3rdparty/bgfx/examples/common/entry/entry_nacl.cpp b/3rdparty/bgfx/examples/common/entry/entry_nacl.cpp
index 8d6fac7baff..bc476290db0 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_nacl.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry_nacl.cpp
@@ -7,7 +7,7 @@
#if ENTRY_CONFIG_USE_NATIVE && BX_PLATFORM_NACL
-#include <bgfxplatform.h>
+#include <bgfx/bgfxplatform.h>
#include <stdio.h>
#include <string.h>
@@ -29,7 +29,7 @@
#include <ppapi/c/ppp_instance.h>
#include <ppapi/gles2/gl2ext_ppapi.h>
-#include <bgfxplatform.h>
+#include <bgfx/bgfxplatform.h>
#include <bx/thread.h>
#include "entry.h"
diff --git a/3rdparty/bgfx/examples/common/entry/entry_osx.mm b/3rdparty/bgfx/examples/common/entry/entry_osx.mm
index c0cec19d9c7..5b59fe06c84 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_osx.mm
+++ b/3rdparty/bgfx/examples/common/entry/entry_osx.mm
@@ -9,7 +9,7 @@
#import <Cocoa/Cocoa.h>
-#include <bgfxplatform.h>
+#include <bgfx/bgfxplatform.h>
#include <bx/uint32_t.h>
#include <bx/thread.h>
diff --git a/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp b/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
index b9094e8c3c3..a9faec69e47 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
@@ -13,7 +13,7 @@
#include <SDL2/SDL.h>
#include <SDL2/SDL_syswm.h>
-#include <bgfxplatform.h>
+#include <bgfx/bgfxplatform.h>
#include <stdio.h>
#include <bx/thread.h>
diff --git a/3rdparty/bgfx/examples/common/entry/entry_windows.cpp b/3rdparty/bgfx/examples/common/entry/entry_windows.cpp
index a6a5ff2c973..c61450c9ab9 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_windows.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry_windows.cpp
@@ -7,12 +7,13 @@
#if ENTRY_CONFIG_USE_NATIVE && BX_PLATFORM_WINDOWS
-#include <bgfxplatform.h>
+#include <bgfx/bgfxplatform.h>
#include <bx/uint32_t.h>
#include <bx/thread.h>
#include <bx/mutex.h>
#include <bx/handlealloc.h>
+#include <bx/timer.h>
#include <tinystl/allocator.h>
#include <tinystl/string.h>
@@ -116,6 +117,17 @@ namespace entry
void update(EventQueue& _eventQueue)
{
+ int64_t now = bx::getHPCounter();
+ static int64_t next = now;
+
+ if (now < next)
+ {
+ return;
+ }
+
+ const int64_t timerFreq = bx::getHPFrequency();
+ next = now + timerFreq/60;
+
if (NULL == m_xinputdll)
{
return;
@@ -518,7 +530,7 @@ namespace entry
, msg->m_y
, msg->m_width
, msg->m_height
- , m_hwnd[0]
+ , NULL
, NULL
, (HINSTANCE)GetModuleHandle(NULL)
, 0
@@ -902,33 +914,6 @@ namespace entry
top = newrect.top +(newrect.bottom-newrect.top-height)/2;
}
- HWND parent = GetWindow(_hwnd, GW_OWNER);
- if (NULL != parent)
- {
- if (_windowFrame)
- {
- SetWindowPos(parent
- , HWND_TOP
- , -32000
- , -32000
- , 0
- , 0
- , SWP_SHOWWINDOW
- );
- }
- else
- {
- SetWindowPos(parent
- , HWND_TOP
- , newrect.left
- , newrect.top
- , newrect.right-newrect.left
- , newrect.bottom-newrect.top
- , SWP_SHOWWINDOW
- );
- }
- }
-
SetWindowPos(_hwnd
, HWND_TOP
, left
diff --git a/3rdparty/bgfx/examples/common/entry/entry_winrt.cpp b/3rdparty/bgfx/examples/common/entry/entry_winrt.cpp
index 44fb92a4ee0..042c032d609 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_winrt.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry_winrt.cpp
@@ -7,7 +7,7 @@
#if BX_PLATFORM_WINRT
-#include <bgfxplatform.h>
+#include <bgfx/bgfxplatform.h>
#include <bx/thread.h>
using namespace Windows::ApplicationModel;
diff --git a/3rdparty/bgfx/examples/common/entry/entry_x11.cpp b/3rdparty/bgfx/examples/common/entry/entry_x11.cpp
index e02548841ae..16b7af4ffa1 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_x11.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry_x11.cpp
@@ -11,7 +11,7 @@
#define XK_LATIN1
#include <X11/keysymdef.h>
#include <X11/Xlib.h> // will include X11 which #defines None... Don't mess with order of includes.
-#include <bgfxplatform.h>
+#include <bgfx/bgfxplatform.h>
#undef None
#include <bx/thread.h>
@@ -299,11 +299,10 @@ namespace entry
m_visual = DefaultVisual(m_display, screen);
m_root = RootWindow(m_display, screen);
- XSetWindowAttributes windowAttrs;
- memset(&windowAttrs, 0, sizeof(windowAttrs) );
- windowAttrs.background_pixmap = 0;
- windowAttrs.border_pixel = 0;
- windowAttrs.event_mask = 0
+ memset(&m_windowAttrs, 0, sizeof(m_windowAttrs) );
+ m_windowAttrs.background_pixmap = 0;
+ m_windowAttrs.border_pixel = 0;
+ m_windowAttrs.event_mask = 0
| ButtonPressMask
| ButtonReleaseMask
| ExposureMask
@@ -322,7 +321,7 @@ namespace entry
, InputOutput
, m_visual
, CWBorderPixel|CWEventMask
- , &windowAttrs
+ , &m_windowAttrs
);
// Clear window to black.
@@ -338,6 +337,20 @@ namespace entry
XMapWindow(m_display, m_window[0]);
XStoreName(m_display, m_window[0], "BGFX");
+ XIM im;
+ im = XOpenIM(m_display, NULL, NULL, NULL);
+
+ XIC ic;
+ ic = XCreateIC(im
+ , XNInputStyle
+ , 0
+ | XIMPreeditNothing
+ | XIMStatusNothing
+ , XNClientWindow
+ , m_window[0]
+ , NULL
+ );
+
//
bgfx::x11SetDisplayWindow(m_display, m_window[0]);
@@ -449,10 +462,30 @@ namespace entry
default:
{
+ WindowHandle handle = findHandle(xkey.window);
+ if (KeyPress == event.type)
+ {
+ Status status = 0;
+ uint8_t utf8[4];
+ int len = Xutf8LookupString(ic, &xkey, (char*)utf8, sizeof(utf8), &keysym, &status);
+ switch (status)
+ {
+ case XLookupChars:
+ case XLookupBoth:
+ if (0 != len)
+ {
+ m_eventQueue.postCharEvent(handle, len, utf8);
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
Key::Enum key = fromXk(keysym);
if (Key::None != key)
{
- WindowHandle handle = findHandle(xkey.window);
m_eventQueue.postKeyEvent(handle, key, m_modifiers, KeyPress == event.type);
}
}
@@ -479,6 +512,9 @@ namespace entry
s_joystick.shutdown();
+ XDestroyIC(ic);
+ XCloseIM(im);
+
XUnmapWindow(m_display, m_window[0]);
XDestroyWindow(m_display, m_window[0]);
@@ -493,21 +529,6 @@ namespace entry
void createWindow(WindowHandle _handle, Msg* msg)
{
- XSetWindowAttributes windowAttrs;
- memset(&windowAttrs, 0, sizeof(windowAttrs) );
- windowAttrs.background_pixmap = 0;
- windowAttrs.border_pixel = 0;
- windowAttrs.event_mask = 0
- | ButtonPressMask
- | ButtonReleaseMask
- | ExposureMask
- | KeyPressMask
- | KeyReleaseMask
- | PointerMotionMask
- | ResizeRedirectMask
- | StructureNotifyMask
- ;
-
Window window = XCreateWindow(m_display
, m_root
, msg->m_x
@@ -519,7 +540,7 @@ namespace entry
, InputOutput
, m_visual
, CWBorderPixel|CWEventMask
- , &windowAttrs
+ , &m_windowAttrs
);
m_window[_handle.idx] = window;
@@ -583,6 +604,8 @@ namespace entry
Visual* m_visual;
Window m_root;
+ XSetWindowAttributes m_windowAttrs;
+
Display* m_display;
Window m_window[ENTRY_CONFIG_MAX_WINDOWS];
uint32_t m_flags[ENTRY_CONFIG_MAX_WINDOWS];
@@ -648,26 +671,23 @@ namespace entry
void setWindowPos(WindowHandle _handle, int32_t _x, int32_t _y)
{
- BX_UNUSED(_handle, _x, _y);
+ Display* display = s_ctx.m_display;
+ Window window = s_ctx.m_window[_handle.idx];
+ XMoveWindow(display, window, _x, _y);
}
void setWindowSize(WindowHandle _handle, uint32_t _width, uint32_t _height)
{
- BX_UNUSED(_handle);
- XResizeRequestEvent ev;
- ev.type = ResizeRequest;
- ev.serial = 0;
- ev.send_event = true;
- ev.display = s_ctx.m_display;
- ev.window = s_ctx.m_window[0];
- ev.width = (int)_width;
- ev.height = (int)_height;
- XSendEvent(s_ctx.m_display, s_ctx.m_window[0], false, ResizeRedirectMask, (XEvent*)&ev);
+ Display* display = s_ctx.m_display;
+ Window window = s_ctx.m_window[_handle.idx];
+ XResizeWindow(display, window, int32_t(_width), int32_t(_height) );
}
void setWindowTitle(WindowHandle _handle, const char* _title)
{
- XStoreName(s_ctx.m_display, s_ctx.m_window[_handle.idx], _title);
+ Display* display = s_ctx.m_display;
+ Window window = s_ctx.m_window[_handle.idx];
+ XStoreName(display, window, _title);
}
void toggleWindowFrame(WindowHandle _handle)
diff --git a/3rdparty/bgfx/examples/common/font/font_manager.cpp b/3rdparty/bgfx/examples/common/font/font_manager.cpp
index 8532a534e03..053f7c95f93 100644
--- a/3rdparty/bgfx/examples/common/font/font_manager.cpp
+++ b/3rdparty/bgfx/examples/common/font/font_manager.cpp
@@ -25,7 +25,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
#include "../common.h"
-#include <bgfx.h>
+#include <bgfx/bgfx.h>
#include <math.h>
#if USE_EDTAA3
diff --git a/3rdparty/bgfx/examples/common/font/font_manager.h b/3rdparty/bgfx/examples/common/font/font_manager.h
index 73d47120333..978440a8f73 100644
--- a/3rdparty/bgfx/examples/common/font/font_manager.h
+++ b/3rdparty/bgfx/examples/common/font/font_manager.h
@@ -7,7 +7,7 @@
#define FONT_MANAGER_H_HEADER_GUARD
#include <bx/handlealloc.h>
-#include <bgfx.h>
+#include <bgfx/bgfx.h>
class Atlas;
diff --git a/3rdparty/bgfx/examples/common/font/text_buffer_manager.cpp b/3rdparty/bgfx/examples/common/font/text_buffer_manager.cpp
index d42e0cb8d40..540a0ea3869 100644
--- a/3rdparty/bgfx/examples/common/font/text_buffer_manager.cpp
+++ b/3rdparty/bgfx/examples/common/font/text_buffer_manager.cpp
@@ -5,7 +5,7 @@
#include "../common.h"
-#include <bgfx.h>
+#include <bgfx/bgfx.h>
#include <stddef.h> // offsetof
#include <memory.h> // memcpy
#include <wchar.h> // wcslen
@@ -329,6 +329,15 @@ void TextBuffer::clearTextBuffer()
void TextBuffer::appendGlyph(FontHandle _handle, CodePoint _codePoint)
{
+ if (_codePoint == L'\t')
+ {
+ for (uint32_t ii = 0; ii < 4; ++ii)
+ {
+ appendGlyph(_handle, L' ');
+ }
+ return;
+ }
+
const GlyphInfo* glyph = m_fontManager->getGlyphInfo(_handle, _codePoint);
BX_WARN(NULL != glyph, "Glyph not found (font handle %d, code point %d)", _handle.idx, _codePoint);
if (NULL == glyph)
@@ -336,27 +345,27 @@ void TextBuffer::appendGlyph(FontHandle _handle, CodePoint _codePoint)
return;
}
- const FontInfo& font = m_fontManager->getFontInfo(_handle);
-
if( m_vertexCount/4 >= MAX_BUFFERED_CHARACTERS)
{
return;
}
+ const FontInfo& font = m_fontManager->getFontInfo(_handle);
+
if (_codePoint == L'\n')
{
m_penX = m_originX;
m_penY += m_lineGap + m_lineAscender -m_lineDescender;
m_lineGap = font.lineGap;
- m_lineDescender = font.descender;
- m_lineAscender = font.ascender;
+ m_lineDescender = font.descender;
+ m_lineAscender = font.ascender;
m_lineStartIndex = m_vertexCount;
return;
}
//is there a change of font size that require the text on the left to be centered again ?
if (font.ascender > m_lineAscender
- || (font.descender < m_lineDescender) )
+ || (font.descender < m_lineDescender) )
{
if (font.descender < m_lineDescender)
{
@@ -377,7 +386,7 @@ void TextBuffer::appendGlyph(FontHandle _handle, CodePoint _codePoint)
const Atlas* atlas = m_fontManager->getAtlas();
if (m_styleFlags & STYLE_BACKGROUND
- && m_backgroundColor & 0xFF000000)
+ && m_backgroundColor & 0xff000000)
{
float x0 = (m_penX - kerning);
float y0 = (m_penY);
@@ -592,7 +601,7 @@ TextBufferManager::TextBufferManager(FontManager* _fontManager)
vs_font_distance_field_subpixel = bgfx::makeRef(vs_font_distance_field_subpixel_mtl, sizeof(vs_font_distance_field_subpixel_mtl) );
fs_font_distance_field_subpixel = bgfx::makeRef(fs_font_distance_field_subpixel_mtl, sizeof(fs_font_distance_field_subpixel_mtl) );
break;
-
+
default:
vs_font_basic = bgfx::makeRef(vs_font_basic_glsl, sizeof(vs_font_basic_glsl) );
fs_font_basic = bgfx::makeRef(fs_font_basic_glsl, sizeof(fs_font_basic_glsl) );
diff --git a/3rdparty/bgfx/examples/common/imgui/imgui.cpp b/3rdparty/bgfx/examples/common/imgui/imgui.cpp
index 1ff8e090818..073191fde57 100644
--- a/3rdparty/bgfx/examples/common/imgui/imgui.cpp
+++ b/3rdparty/bgfx/examples/common/imgui/imgui.cpp
@@ -466,7 +466,7 @@ struct Imgui
_size = sizeof(s_droidSansTtf);
}
- IMGUI_create(_data, _size, _fontSize, _allocator);
+ IMGUI_create(_data, _size, _fontSize, m_allocator);
m_nvg = nvgCreate(1, m_view);
nvgCreateFontMem(m_nvg, "default", (unsigned char*)_data, INT32_MAX, 0);
@@ -3080,8 +3080,8 @@ struct Imgui
bool visible(int32_t _elemY, int32_t _elemHeight, int32_t _scissorY, int32_t _scissorHeight)
{
- return _elemY > _scissorY
- && (_elemY+_elemHeight) < (_scissorY+_scissorHeight);
+ return (_elemY+_elemHeight) > _scissorY
+ && (_elemY) < (_scissorY+_scissorHeight);
}
inline Area& getCurrentArea()
diff --git a/3rdparty/bgfx/examples/common/imgui/imgui.h b/3rdparty/bgfx/examples/common/imgui/imgui.h
index acd6e6daf98..e85b9d3a16a 100644
--- a/3rdparty/bgfx/examples/common/imgui/imgui.h
+++ b/3rdparty/bgfx/examples/common/imgui/imgui.h
@@ -26,8 +26,9 @@
#ifndef IMGUI_H_HEADER_GUARD
#define IMGUI_H_HEADER_GUARD
-#include <bgfx.h>
+#include <bgfx/bgfx.h>
#include <ocornut-imgui/imgui.h>
+#include <ocornut-imgui/imgui_wm.h>
#define IMGUI_MBUT_LEFT 0x01
#define IMGUI_MBUT_RIGHT 0x02
@@ -207,20 +208,65 @@ bool imguiMouseOverArea();
namespace ImGui
{
+#define IMGUI_FLAGS_NONE UINT16_C(0x0000)
+#define IMGUI_FLAGS_ALPHA_BLEND UINT16_C(0x0001)
+
+ // Helper function for passing bgfx::TextureHandle to ImGui::Image.
+ inline void Image(bgfx::TextureHandle _handle
+ , uint16_t _flags
+ , const ImVec2& _size
+ , const ImVec2& _uv0 = ImVec2(0.0f, 0.0f)
+ , const ImVec2& _uv1 = ImVec2(1.0f, 1.0f)
+ , const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
+ , const ImVec4& _borderCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)
+ )
+ {
+ union { struct { uint16_t flags; bgfx::TextureHandle handle; } s; ImTextureID ptr; } texture;
+ texture.s.flags = _flags;
+ texture.s.handle = _handle;
+ Image(texture.ptr, _size, _uv0, _uv1, _tintCol, _borderCol);
+ }
+
// Helper function for passing bgfx::TextureHandle to ImGui::Image.
- inline void Image(bgfx::TextureHandle _handle, const ImVec2& _size, const ImVec2& _uv0 = ImVec2(0, 0), const ImVec2& _uv1 = ImVec2(1, 1), const ImVec4& _tint_col = ImVec4(1, 1, 1, 1), const ImVec4& _border_col = ImVec4(0, 0, 0, 0) )
+ inline void Image(bgfx::TextureHandle _handle
+ , const ImVec2& _size
+ , const ImVec2& _uv0 = ImVec2(0.0f, 0.0f)
+ , const ImVec2& _uv1 = ImVec2(1.0f, 1.0f)
+ , const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
+ , const ImVec4& _borderCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)
+ )
+ {
+ Image(_handle, IMGUI_FLAGS_ALPHA_BLEND, _size, _uv0, _uv1, _tintCol, _borderCol);
+ }
+
+ // Helper function for passing bgfx::TextureHandle to ImGui::ImageButton.
+ inline bool ImageButton(bgfx::TextureHandle _handle
+ , uint16_t _flags
+ , const ImVec2& _size
+ , const ImVec2& _uv0 = ImVec2(0.0f, 0.0f)
+ , const ImVec2& _uv1 = ImVec2(1.0f, 1.0f)
+ , int _framePadding = -1
+ , const ImVec4& _bgCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)
+ , const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
+ )
{
- union { bgfx::TextureHandle handle; ImTextureID ptr; } texture;
- texture.handle = _handle;
- Image(texture.ptr, _size, _uv0, _uv1, _tint_col, _border_col);
+ union { struct { uint16_t flags; bgfx::TextureHandle handle; } s; ImTextureID ptr; } texture;
+ texture.s.flags = _flags;
+ texture.s.handle = _handle;
+ return ImageButton(texture.ptr, _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol);
}
// Helper function for passing bgfx::TextureHandle to ImGui::ImageButton.
- inline bool ImageButton(bgfx::TextureHandle _handle, const ImVec2& _size, const ImVec2& _uv0 = ImVec2(0,0), const ImVec2& _uv1 = ImVec2(1,1), int _frame_padding = -1, const ImVec4& _bg_col = ImVec4(0,0,0,0), const ImVec4& _tint_col = ImVec4(1,1,1,1))
+ inline bool ImageButton(bgfx::TextureHandle _handle
+ , const ImVec2& _size
+ , const ImVec2& _uv0 = ImVec2(0.0f, 0.0f)
+ , const ImVec2& _uv1 = ImVec2(1.0f, 1.0f)
+ , int _framePadding = -1
+ , const ImVec4& _bgCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)
+ , const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
+ )
{
- union { bgfx::TextureHandle handle; ImTextureID ptr; } texture;
- texture.handle = _handle;
- return ImageButton(texture.ptr, _size, _uv0, _uv1, _frame_padding, _bg_col, _tint_col);
+ return ImageButton(_handle, IMGUI_FLAGS_ALPHA_BLEND, _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol);
}
} // namespace ImGui
diff --git a/3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp b/3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp
index aff41ac376a..8efddcc65f8 100644
--- a/3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp
+++ b/3rdparty/bgfx/examples/common/imgui/ocornut_imgui.cpp
@@ -3,15 +3,24 @@
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
-#include <bgfx.h>
+#include <bgfx/bgfx.h>
#include <bx/allocator.h>
#include <bx/fpumath.h>
#include <bx/timer.h>
#include <ocornut-imgui/imgui.h>
+#include <ocornut-imgui/imgui_wm.h>
#include "imgui.h"
#include "ocornut_imgui.h"
#include <stb/stb_image.c>
+#ifndef USE_ENTRY
+# define USE_ENTRY defined(SCI_NAMESPACE)
+#endif // USE_ENTRY
+
+#if USE_ENTRY
+# include "../entry/entry.h"
+#endif // USE_ENTRY
+
#if defined(SCI_NAMESPACE)
# include "../entry/input.h"
# include "scintilla.h"
@@ -20,86 +29,334 @@
#include "vs_ocornut_imgui.bin.h"
#include "fs_ocornut_imgui.bin.h"
+void viewCallback(const ImDrawList* _parentList, const ImDrawCmd* _cmd);
+
+class PlatformWindow : public ImGuiWM::PlatformWindow
+{
+ typedef ImGuiWM::PlatformWindow Super;
+
+public:
+ PlatformWindow(bool _mainWindow, bool _isDragWindow)
+ : ImGuiWM::PlatformWindow(_mainWindow, _isDragWindow)
+ , m_pos(0.0f, 0.0f)
+ , m_size(0.0f, 0.0f)
+ , m_drag(false)
+ {
+#if USE_ENTRY
+ if (!_mainWindow
+ && !_isDragWindow)
+ {
+ m_window = entry::createWindow(0, 0, 640, 380);
+ extern void pwToWindow(entry::WindowHandle _handle, PlatformWindow* _pw);
+ pwToWindow(m_window, this);
+ }
+ else
+ {
+ m_window.idx = 0;
+ }
+#endif // USE_ENTRY
+ }
+
+ virtual ~PlatformWindow() BX_OVERRIDE
+ {
+ }
+
+ virtual bool Init(ImGuiWM::PlatformWindow* /*_parent*/) BX_OVERRIDE
+ {
+ return true;
+ }
+
+ virtual const ImVec2& GetPosition() const BX_OVERRIDE
+ {
+ return m_pos;
+ }
+
+ virtual const ImVec2& GetSize() const BX_OVERRIDE
+ {
+ return m_size;
+ }
+
+ virtual void Show() BX_OVERRIDE
+ {
+ }
+
+ virtual void Hide() BX_OVERRIDE
+ {
+ }
+
+ virtual void SetSize(const ImVec2& _size) BX_OVERRIDE
+ {
+#if USE_ENTRY
+ if (0 != m_window.idx
+ && m_size.x != _size.x
+ && m_size.y != _size.y)
+ {
+ entry::setWindowSize(m_window, int32_t(_size.x), int32_t(_size.y) );
+ }
+#endif // USE_ENTRY
+
+ m_size = _size;
+ }
+
+ virtual void SetPosition(const ImVec2& _pos) BX_OVERRIDE
+ {
+
+#if USE_ENTRY
+ if (0 != m_window.idx
+ && m_pos.x != _pos.x
+ && m_pos.y != _pos.y)
+ {
+ entry::setWindowPos(m_window, int32_t(_pos.x), int32_t(_pos.y) );
+ }
+#endif // USE_ENTRY
+
+ m_pos = _pos;
+ }
+
+ virtual void SetTitle(const char* _title) BX_OVERRIDE
+ {
+#if USE_ENTRY
+ entry::setWindowTitle(m_window, _title);
+#else
+ BX_UNUSED(_title);
+#endif // USE_ENTRY
+ }
+
+ virtual void PreUpdate() BX_OVERRIDE
+ {
+ }
+
+ virtual void PaintBegin()
+ {
+#if USE_ENTRY
+ if (!m_bIsDragWindow)
+ {
+ ImDrawList* drawList = ImGui::GetWindowDrawList();
+ union { entry::WindowHandle handle; void* ptr; } cast = { m_window };
+ drawList->AddCallback(viewCallback, cast.ptr);
+ drawList->PushClipRect(ImVec4(0.0f, 0.0f, m_size.x, m_size.y) );
+ }
+#endif // USE_ENTRY
+ }
+
+ virtual void Paint() BX_OVERRIDE
+ {
+ if (!m_bIsDragWindow)
+ {
+ Super::Paint();
+ }
+ }
+
+ virtual void PaintEnd()
+ {
+#if USE_ENTRY
+ if (!m_bIsDragWindow)
+ {
+ ImDrawList* drawList = ImGui::GetWindowDrawList();
+ drawList->PopClipRect();
+ drawList->AddCallback(viewCallback, NULL);
+ }
+#endif // USE_ENTRY
+ }
+
+ virtual void Destroy() BX_OVERRIDE
+ {
+ }
+
+ virtual void StartDrag() BX_OVERRIDE
+ {
+ m_drag = true;
+ }
+
+ virtual void StopDrag() BX_OVERRIDE
+ {
+ m_drag = false;
+ }
+
+ virtual bool IsDraging() BX_OVERRIDE
+ {
+ return m_drag;
+ }
+
+private:
+ ImVec2 m_pos;
+ ImVec2 m_size;
+ bool m_drag;
+
+#if USE_ENTRY
+ entry::WindowHandle m_window;
+#endif // USE_ENTRY
+};
+
+class WindowManager : public ImGuiWM::WindowManager
+{
+ typedef ImGuiWM::WindowManager Super;
+
+public:
+ WindowManager()
+ {
+ }
+
+ virtual ~WindowManager() BX_OVERRIDE
+ {
+ }
+
+protected:
+ virtual ImGuiWM::PlatformWindow* CreatePlatformWindow(bool _main, ImGuiWM::PlatformWindow* _parent, bool _isDragWindow) BX_OVERRIDE
+ {
+#if USE_ENTRY
+#else
+ if (!_main
+ && !_isDragWindow)
+ {
+ return NULL;
+ }
+#endif // USE_ENTRY
+
+ PlatformWindow* window = new (ImGui::MemAlloc(sizeof(PlatformWindow) ) ) PlatformWindow(_main, _isDragWindow);
+ window->Init(_parent);
+ return static_cast<ImGuiWM::PlatformWindow*>(window);
+ }
+
+ virtual void LogFormatted(const char* _str) BX_OVERRIDE
+ {
+ BX_TRACE("%s", _str); BX_UNUSED(_str);
+ }
+
+ virtual void InternalRun() BX_OVERRIDE
+ {
+ PreUpdate();
+ Update();
+ }
+};
+
struct OcornutImguiContext
{
static void* memAlloc(size_t _size);
static void memFree(void* _ptr);
- static void renderDrawLists(ImDrawData* draw_data);
+ static void renderDrawLists(ImDrawData* _drawData);
- void render(ImDrawData* draw_data)
+ void render(ImDrawData* _drawData)
{
- const float width = ImGui::GetIO().DisplaySize.x;
- const float height = ImGui::GetIO().DisplaySize.y;
+ const ImGuiIO& io = ImGui::GetIO();
+ const float width = io.DisplaySize.x;
+ const float height = io.DisplaySize.y;
- float ortho[16];
- bx::mtxOrtho(ortho, 0.0f, width, height, 0.0f, -1.0f, 1.0f);
+ {
+ float ortho[16];
+ bx::mtxOrtho(ortho, 0.0f, width, height, 0.0f, -1.0f, 1.0f);
+ bgfx::setViewTransform(m_viewId, NULL, ortho);
+ }
- bgfx::setViewTransform(m_viewId, NULL, ortho);
+#if USE_ENTRY
+ for (uint32_t ii = 1; ii < BX_COUNTOF(m_window); ++ii)
+ {
+ Window& window = m_window[ii];
+ if (bgfx::isValid(window.m_fbh) )
+ {
+ const uint8_t viewId = window.m_viewId;
+ bgfx::setViewClear(viewId
+ , BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
+ , 0x303030ff + rand()
+ , 1.0f
+ , 0
+ );
+ bgfx::setViewFrameBuffer(viewId, window.m_fbh);
+ bgfx::setViewRect(viewId
+ , 0
+ , 0
+ , window.m_state.m_width
+ , window.m_state.m_height
+ );
+ float ortho[16];
+ bx::mtxOrtho(ortho
+ , 0.0f
+ , float(window.m_state.m_width)
+ , float(window.m_state.m_height)
+ , 0.0f
+ , -1.0f
+ , 1.0f
+ );
+ bgfx::setViewTransform(viewId
+ , NULL
+ , ortho
+ );
+ }
+ }
+#endif // USE_ENTRY
// Render command lists
- for (int32_t ii = 0; ii < draw_data->CmdListsCount; ++ii)
+ for (int32_t ii = 0, num = _drawData->CmdListsCount; ii < num; ++ii)
{
bgfx::TransientVertexBuffer tvb;
bgfx::TransientIndexBuffer tib;
- const ImDrawList* cmd_list = draw_data->CmdLists[ii];
- uint32_t vtx_size = (uint32_t)cmd_list->VtxBuffer.size();
- uint32_t idx_size = (uint32_t)cmd_list->IdxBuffer.size();
+ const ImDrawList* drawList = _drawData->CmdLists[ii];
+ uint32_t numVertices = (uint32_t)drawList->VtxBuffer.size();
+ uint32_t numIndices = (uint32_t)drawList->IdxBuffer.size();
- if (!bgfx::checkAvailTransientVertexBuffer(vtx_size, m_decl) || !bgfx::checkAvailTransientIndexBuffer(idx_size) )
+ if (!bgfx::checkAvailTransientVertexBuffer(numVertices, m_decl)
+ || !bgfx::checkAvailTransientIndexBuffer(numIndices) )
{
// not enough space in transient buffer just quit drawing the rest...
break;
}
- bgfx::allocTransientVertexBuffer(&tvb, vtx_size, m_decl);
- bgfx::allocTransientIndexBuffer(&tib, idx_size);
+ bgfx::allocTransientVertexBuffer(&tvb, numVertices, m_decl);
+ bgfx::allocTransientIndexBuffer(&tib, numIndices);
ImDrawVert* verts = (ImDrawVert*)tvb.data;
- memcpy(verts, cmd_list->VtxBuffer.begin(), vtx_size * sizeof(ImDrawVert) );
+ memcpy(verts, drawList->VtxBuffer.begin(), numVertices * sizeof(ImDrawVert) );
ImDrawIdx* indices = (ImDrawIdx*)tib.data;
- memcpy(indices, cmd_list->IdxBuffer.begin(), idx_size * sizeof(ImDrawIdx) );
+ memcpy(indices, drawList->IdxBuffer.begin(), numIndices * sizeof(ImDrawIdx) );
- uint32_t elem_offset = 0;
- const ImDrawCmd* pcmd_begin = cmd_list->CmdBuffer.begin();
- const ImDrawCmd* pcmd_end = cmd_list->CmdBuffer.end();
- for (const ImDrawCmd* pcmd = pcmd_begin; pcmd != pcmd_end; pcmd++)
+ uint32_t offset = 0;
+ for (const ImDrawCmd* cmd = drawList->CmdBuffer.begin(), *cmdEnd = drawList->CmdBuffer.end(); cmd != cmdEnd; ++cmd)
{
- if (pcmd->UserCallback)
+ if (cmd->UserCallback)
{
- pcmd->UserCallback(cmd_list, pcmd);
- elem_offset += pcmd->ElemCount;
- continue;
+ cmd->UserCallback(drawList, cmd);
}
- if (0 == pcmd->ElemCount)
+ else if (0 != cmd->ElemCount)
{
- continue;
+ uint64_t state = 0
+ | BGFX_STATE_RGB_WRITE
+ | BGFX_STATE_ALPHA_WRITE
+ | BGFX_STATE_MSAA
+ ;
+
+ bgfx::TextureHandle th = m_texture;
+
+ if (NULL != cmd->TextureId)
+ {
+ union { ImTextureID ptr; struct { uint16_t flags; bgfx::TextureHandle handle; } s; } texture = { cmd->TextureId };
+ state |= 0 != (IMGUI_FLAGS_ALPHA_BLEND & texture.s.flags)
+ ? BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA)
+ : BGFX_STATE_NONE
+ ;
+ th = texture.s.handle;
+ }
+ else
+ {
+ state |= BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA);
+ }
+
+ const uint16_t xx = uint16_t(bx::fmax(cmd->ClipRect.x, 0.0f) );
+ const uint16_t yy = uint16_t(bx::fmax(cmd->ClipRect.y, 0.0f) );
+ bgfx::setScissor(xx, yy
+ , uint16_t(bx::fmin(cmd->ClipRect.z, 65535.0f)-xx)
+ , uint16_t(bx::fmin(cmd->ClipRect.w, 65535.0f)-yy)
+ );
+
+ bgfx::setState(state);
+ bgfx::setTexture(0, s_tex, th);
+ bgfx::setVertexBuffer(&tvb, 0, numVertices);
+ bgfx::setIndexBuffer(&tib, offset, cmd->ElemCount);
+ bgfx::submit(m_viewId, m_program);
}
- bgfx::setState(0
- | BGFX_STATE_RGB_WRITE
- | BGFX_STATE_ALPHA_WRITE
- | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA)
- | BGFX_STATE_MSAA
- );
- bgfx::setScissor(uint16_t(bx::fmax(pcmd->ClipRect.x, 0.0f) )
- , uint16_t(bx::fmax(pcmd->ClipRect.y, 0.0f) )
- , uint16_t(bx::fmin(pcmd->ClipRect.z, 65535.0f)-bx::fmax(pcmd->ClipRect.x, 0.0f) )
- , uint16_t(bx::fmin(pcmd->ClipRect.w, 65535.0f)-bx::fmax(pcmd->ClipRect.y, 0.0f) )
- );
- union { void* ptr; bgfx::TextureHandle handle; } texture = { pcmd->TextureId };
-
- bgfx::setTexture(0, s_tex, 0 != texture.handle.idx
- ? texture.handle
- : m_texture
- );
-
- bgfx::setVertexBuffer(&tvb, 0, vtx_size);
- bgfx::setIndexBuffer(&tib, elem_offset, pcmd->ElemCount);
- bgfx::submit(m_viewId, m_program);
-
- elem_offset += pcmd->ElemCount;
+ offset += cmd->ElemCount;
}
}
}
@@ -176,9 +433,9 @@ struct OcornutImguiContext
m_decl
.begin()
- .add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float)
+ .add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float)
.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float)
- .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true)
+ .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true)
.end();
s_tex = bgfx::createUniform("s_tex", bgfx::UniformType::Int1);
@@ -202,10 +459,61 @@ struct OcornutImguiContext
ImGuiStyle& style = ImGui::GetStyle();
style.FrameRounding = 4.0f;
+
+ m_wm = BX_NEW(m_allocator, WindowManager);
+ m_wm->Init();
+
+#if 0
+ {
+ class Window : public ImGuiWM::Window
+ {
+ public:
+ Window(const char* _title)
+ : ImGuiWM::Window()
+ {
+ SetTitle(_title);
+ }
+
+ virtual void OnGui() BX_OVERRIDE
+ {
+ }
+ };
+
+ class WindowX : public ImGuiWM::Window
+ {
+ public:
+ WindowX(const char* _title)
+ : ImGuiWM::Window()
+ {
+ SetTitle(_title);
+ }
+
+ virtual void OnGui() BX_OVERRIDE
+ {
+#if defined(SCI_NAMESPACE) && 0
+ bool opened = true;
+ ImGuiScintilla("Scintilla Editor", &opened, ImVec2(640.0f, 480.0f) );
+#endif // 0
+ }
+ };
+
+ Window* w0 = new Window("test");
+ WindowX* w1 = new WindowX("abcd");
+ Window* w2 = new Window("xyzw");
+ Window* w3 = new Window("0123");
+
+ m_wm->Dock(w0);
+ m_wm->DockWith(w1, w0, ImGuiWM::E_DOCK_ORIENTATION_RIGHT);
+ m_wm->DockWith(w2, w1, ImGuiWM::E_DOCK_ORIENTATION_BOTTOM);
+ m_wm->DockWith(w3, w0, ImGuiWM::E_DOCK_ORIENTATION_BOTTOM);
+ }
+#endif // 0
}
void destroy()
{
+ m_wm->Exit();
+ BX_DELETE(m_allocator, m_wm);
ImGui::Shutdown();
bgfx::destroyUniform(s_tex);
@@ -217,7 +525,9 @@ struct OcornutImguiContext
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;
+ m_viewId = _viewId;
+ m_defaultViewId = _viewId;
+
ImGuiIO& io = ImGui::GetIO();
if (_inputChar < 0x7f)
{
@@ -261,15 +571,11 @@ struct OcornutImguiContext
bool opened = true;
ShowExampleAppCustomNodeGraph(&opened);
#endif // 0
-
-#if defined(SCI_NAMESPACE) && 0
- bool opened = true;
- ImGuiScintilla("Scintilla Editor", &opened, ImVec2(640.0f, 480.0f) );
-#endif // 0
}
void endFrame()
{
+ m_wm->Run();
ImGui::Render();
}
@@ -278,13 +584,84 @@ struct OcornutImguiContext
bgfx::ProgramHandle m_program;
bgfx::TextureHandle m_texture;
bgfx::UniformHandle s_tex;
+ WindowManager* m_wm;
int64_t m_last;
int32_t m_lastScroll;
uint8_t m_viewId;
+ uint8_t m_defaultViewId;
+
+#if USE_ENTRY
+ struct Window
+ {
+ Window()
+ {
+ m_fbh.idx = bgfx::invalidHandle;
+ }
+
+ entry::WindowState m_state;
+ PlatformWindow* m_pw;
+ bgfx::FrameBufferHandle m_fbh;
+ uint8_t m_viewId;
+ };
+
+ Window m_window[16];
+#endif // USE_ENTRY
};
static OcornutImguiContext s_ctx;
+#if USE_ENTRY
+
+void viewCallback(const ImDrawList* /*_parentList*/, const ImDrawCmd* _cmd)
+{
+ union { void* ptr; entry::WindowHandle handle; } cast = { _cmd->UserCallbackData };
+
+ if (0 != cast.handle.idx)
+ {
+ s_ctx.m_viewId = s_ctx.m_window[cast.handle.idx].m_viewId;
+ }
+ else
+ {
+ s_ctx.m_viewId = s_ctx.m_defaultViewId;
+ }
+}
+
+void pwToWindow(entry::WindowHandle _handle, PlatformWindow* _pw)
+{
+ s_ctx.m_window[_handle.idx].m_pw = _pw;
+}
+
+void imguiUpdateWindow(const entry::WindowState& _state)
+{
+ OcornutImguiContext::Window& window = s_ctx.m_window[_state.m_handle.idx];
+
+ if (window.m_state.m_nwh != _state.m_nwh
+ || (window.m_state.m_width != _state.m_width
+ || window.m_state.m_height != _state.m_height) )
+ {
+ // When window changes size or native window handle changed
+ // frame buffer must be recreated.
+ if (bgfx::isValid(window.m_fbh) )
+ {
+ bgfx::destroyFrameBuffer(window.m_fbh);
+ window.m_fbh.idx = bgfx::invalidHandle;
+ }
+
+ if (NULL != _state.m_nwh)
+ {
+ window.m_fbh = bgfx::createFrameBuffer(_state.m_nwh, _state.m_width, _state.m_height);
+ window.m_viewId = 200 + _state.m_handle.idx;
+ }
+ else
+ {
+ window.m_viewId = s_ctx.m_defaultViewId;
+ }
+ }
+
+ memcpy(&window.m_state, &_state, sizeof(entry::WindowState) );
+}
+#endif // USE_ENTRY
+
void* OcornutImguiContext::memAlloc(size_t _size)
{
return BX_ALLOC(s_ctx.m_allocator, _size);
diff --git a/3rdparty/bgfx/examples/common/imgui/scintilla.cpp b/3rdparty/bgfx/examples/common/imgui/scintilla.cpp
index d88a75efa2d..f9f0d06ea22 100644
--- a/3rdparty/bgfx/examples/common/imgui/scintilla.cpp
+++ b/3rdparty/bgfx/examples/common/imgui/scintilla.cpp
@@ -1105,7 +1105,7 @@ ScintillaEditor* ImGuiScintilla(const char* _name, bool* _opened, const ImVec2&
{
ScintillaEditor* sci = NULL;
- if (ImGui::Begin(_name, _opened, _size) )
+// if (ImGui::Begin(_name, _opened, _size) )
{
ImGuiStorage* storage = ImGui::GetStateStorage();
@@ -1121,7 +1121,7 @@ ScintillaEditor* ImGuiScintilla(const char* _name, bool* _opened, const ImVec2&
sci->draw();
}
- ImGui::End();
+// ImGui::End();
return sci;
}
diff --git a/3rdparty/bgfx/examples/common/nanovg/nanovg_bgfx.cpp b/3rdparty/bgfx/examples/common/nanovg/nanovg_bgfx.cpp
index 817457dbc14..263c1b31b94 100644
--- a/3rdparty/bgfx/examples/common/nanovg/nanovg_bgfx.cpp
+++ b/3rdparty/bgfx/examples/common/nanovg/nanovg_bgfx.cpp
@@ -28,7 +28,7 @@
#include <math.h>
#include "nanovg.h"
-#include <bgfx.h>
+#include <bgfx/bgfx.h>
#include <bx/bx.h>
@@ -667,7 +667,6 @@ namespace
);
bgfx::setVertexBuffer(&gl->tvb, paths[i].strokeOffset, paths[i].strokeCount);
bgfx::setTexture(0, gl->s_tex, gl->th);
- bgfx::setTexture(0, gl->s_tex, gl->th);
bgfx::submit(gl->viewid, gl->prog);
}
}