diff options
author | 2015-10-15 10:42:29 +0200 | |
---|---|---|
committer | 2015-10-15 10:42:29 +0200 | |
commit | 8981faa61fc1e9421805938e6656d84ff61be1f9 (patch) | |
tree | 6295fadfe79ab1f2bafafd3f321e01063ca3cff7 /3rdparty/bgfx/examples/common/entry | |
parent | a74a7a37ef1f6ea1fd9c96148be8fa7ba09b1054 (diff) |
update bgfx to latest (nw)
Diffstat (limited to '3rdparty/bgfx/examples/common/entry')
10 files changed, 79 insertions, 74 deletions
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) |