From 43608419897d61a8510db3330a116fbf04ce3ce3 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Mon, 16 Mar 2015 13:51:47 +0100 Subject: [PATCH 1/5] Imgui can be now downscaled to fit small resolution screens. --- examples/common/imgui/imgui.cpp | 134 +++++++++++++++---------- examples/common/imgui/imgui.h | 1 + examples/common/nanovg/nanovg.cpp | 11 +- examples/common/nanovg/nanovg.h | 3 +- examples/common/nanovg/nanovg_bgfx.cpp | 7 +- 5 files changed, 96 insertions(+), 60 deletions(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index d1fcbfb3c..852e24731 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -388,6 +388,8 @@ struct Imgui , m_halfTexel(0.0f) , m_nvg(NULL) , m_view(255) + , m_surfaceWidth(0) + , m_surfaceHeight(0) , m_viewWidth(0) , m_viewHeight(0) , m_currentFontIdx(0) @@ -810,21 +812,31 @@ struct Imgui m_char = _inputChar; } - void beginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, char _inputChar, uint8_t _view) + void beginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, uint16_t _surfaceWidth, uint16_t _surfaceHeight, char _inputChar, uint8_t _view) { - IMGUI_beginFrame(_mx, _my, _button, _width, _height, _inputChar, _view); - nvgViewId(m_nvg, _view); - m_view = _view; m_viewWidth = _width; m_viewHeight = _height; + m_surfaceWidth = _surfaceWidth; + m_surfaceHeight = _surfaceHeight; + + const float xscale = float(m_surfaceWidth) /float(m_viewWidth); + const float yscale = float(m_surfaceHeight)/float(m_viewHeight); + const int32_t mx = int32_t(float(_mx)*xscale); + const int32_t my = int32_t(float(_my)*yscale); + + IMGUI_beginFrame(mx, my, _button, _width, _height, _inputChar, _view); + nvgBeginFrameScaled(m_nvg, m_viewWidth, m_viewHeight, m_surfaceWidth, m_surfaceHeight, 1.0f); + nvgViewId(m_nvg, _view); + bgfx::setViewName(_view, "IMGUI"); bgfx::setViewSeq(_view, true); const bgfx::HMD* hmd = bgfx::getHMD(); if (NULL != hmd) { - m_viewWidth = _width / 2; + m_viewWidth = _width / 2; + m_surfaceWidth = _surfaceWidth / 2; float proj[16]; bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f); @@ -837,22 +849,22 @@ struct Imgui const float offset1 = -proj[8] + (hmd->eye[1].viewOffset[0] / dist * proj[0]); float ortho[2][16]; - const float viewOffset = _width/4.0f; - const float viewWidth = _width/2.0f; - bx::mtxOrtho(ortho[0], viewOffset, viewOffset + viewWidth, (float)m_viewHeight, 0.0f, 0.0f, 1000.0f, offset0); - bx::mtxOrtho(ortho[1], viewOffset, viewOffset + viewWidth, (float)m_viewHeight, 0.0f, 0.0f, 1000.0f, offset1); + const float viewOffset = _surfaceWidth/4.0f; + const float viewWidth = _surfaceWidth/2.0f; + bx::mtxOrtho(ortho[0], viewOffset, viewOffset + viewWidth, (float)m_surfaceHeight, 0.0f, 0.0f, 1000.0f, offset0); + bx::mtxOrtho(ortho[1], viewOffset, viewOffset + viewWidth, (float)m_surfaceHeight, 0.0f, 0.0f, 1000.0f, offset1); bgfx::setViewTransform(_view, NULL, ortho[0], BGFX_VIEW_STEREO, ortho[1]); bgfx::setViewRect(_view, 0, 0, hmd->width, hmd->height); } else { float ortho[16]; - bx::mtxOrtho(ortho, 0.0f, (float)m_viewWidth, (float)m_viewHeight, 0.0f, 0.0f, 1000.0f); + bx::mtxOrtho(ortho, 0.0f, (float)m_surfaceWidth, (float)m_surfaceHeight, 0.0f, 0.0f, 1000.0f); bgfx::setViewTransform(_view, NULL, ortho); bgfx::setViewRect(_view, 0, 0, _width, _height); } - updateInput(_mx, _my, _button, _scroll, _inputChar); + updateInput(mx, my, _button, _scroll, _inputChar); m_hot = m_hotToBe; m_hotToBe = 0; @@ -884,6 +896,7 @@ struct Imgui clearInput(); + nvgEndFrame(m_nvg); IMGUI_endFrame(); } @@ -937,12 +950,7 @@ struct Imgui setEnabled(m_areaId); } - nvgScissor(m_nvg - , float(area.m_scissorX) - , float(area.m_scissorY-1) - , float(area.m_scissorWidth) - , float(area.m_scissorHeight+1) - ); + nvgScissor(m_nvg, area); m_insideArea |= area.m_inside; @@ -1080,12 +1088,7 @@ struct Imgui } } - nvgScissor(m_nvg - , float(parentArea.m_scissorX) - , float(parentArea.m_scissorY-1) - , float(parentArea.m_scissorWidth) - , float(parentArea.m_scissorHeight+1) - ); + nvgScissor(m_nvg, parentArea); } bool beginArea(const char* _name, int32_t _x, int32_t _y, int32_t _width, int32_t _height, bool _enabled, int32_t _r) @@ -1159,13 +1162,7 @@ struct Imgui } area.m_scissorEnabled = true; - nvgBeginFrame(m_nvg, m_viewWidth, m_viewHeight, 1.0f); - nvgScissor(m_nvg - , float(area.m_scissorX) - , float(area.m_scissorY-1) - , float(area.m_scissorWidth) - , float(area.m_scissorHeight+1) - ); + nvgScissor(m_nvg, area); m_insideArea |= area.m_inside; return area.m_inside; @@ -1175,7 +1172,6 @@ struct Imgui { m_areaId.pop(); nvgResetScissor(m_nvg); - nvgEndFrame(m_nvg); } bool button(const char* _text, bool _enabled, ImguiAlign::Enum _align, uint32_t _rgb0, int32_t _r) @@ -1204,7 +1200,7 @@ struct Imgui //|| ImguiAlign::CenterIndented == _align). { xx = area.m_widgetX; - width = area.m_widgetW - (area.m_widgetX-area.m_scissorX); + width = area.m_widgetW - (area.m_widgetX-area.m_contentX); } const bool enabled = _enabled && isEnabled(m_areaId); @@ -1387,7 +1383,7 @@ struct Imgui //|| ImguiAlign::CenterIndented == _align). { xx = area.m_widgetX; - width = area.m_widgetW - (area.m_widgetX-area.m_scissorX); + width = area.m_widgetW - (area.m_widgetX-area.m_contentX); } const bool drawLabel = (NULL != _label && _label[0] != '\0'); @@ -1526,7 +1522,7 @@ struct Imgui //|| ImguiAlign::CenterIndented == _align). { xx = area.m_widgetX; - width = area.m_widgetW - (area.m_widgetX-area.m_scissorX); + width = area.m_widgetW - (area.m_widgetX-area.m_contentX); } uint8_t selected = _selected; @@ -1746,7 +1742,7 @@ struct Imgui //|| ImguiAlign::CenterIndented == _align). { xx = area.m_widgetX; - width = area.m_widgetW - (area.m_widgetX-area.m_scissorX); + width = area.m_widgetW - (area.m_widgetX-area.m_contentX); } const int32_t height = width/2; @@ -1799,7 +1795,7 @@ struct Imgui //|| ImguiAlign::CenterIndented == _align). { xx = area.m_widgetX; - width = area.m_widgetW - (area.m_widgetX-area.m_scissorX); + width = area.m_widgetW - (area.m_widgetX-area.m_contentX); } const bool adjustHeight = (_cross && _sameHeight); @@ -2025,39 +2021,39 @@ struct Imgui xx = -borderSize; yy = -1; width = 2*borderSize+1; - height = m_viewHeight+1; + height = m_surfaceHeight+1; triX = 0; - triY = (m_viewHeight-triSize)/2; + triY = (m_surfaceHeight-triSize)/2; orientation = _checked ? TriangleOrientation::Left : TriangleOrientation::Right; } else if (ImguiBorder::Right == _border) { - xx = m_viewWidth - borderSize; + xx = m_surfaceWidth - borderSize; yy = -1; width = 2*borderSize+1; - height = m_viewHeight+1; - triX = m_viewWidth - triSize - 2; - triY = (m_viewHeight-width)/2; + height = m_surfaceHeight+1; + triX = m_surfaceWidth - triSize - 2; + triY = (m_surfaceHeight-width)/2; orientation = _checked ? TriangleOrientation::Right : TriangleOrientation::Left; } else if (ImguiBorder::Top == _border) { xx = 0; yy = -borderSize; - width = m_viewWidth; + width = m_surfaceWidth; height = 2*borderSize; - triX = (m_viewWidth-triSize)/2; + triX = (m_surfaceWidth-triSize)/2; triY = 0; orientation = _checked ? TriangleOrientation::Up : TriangleOrientation::Down; } else //if (ImguiBorder::Bottom == _border). { xx = 0; - yy = m_viewHeight - borderSize; - width = m_viewWidth; + yy = m_surfaceHeight - borderSize; + width = m_surfaceWidth; height = 2*borderSize; - triX = (m_viewWidth-triSize)/2; - triY = m_viewHeight-triSize; + triX = (m_surfaceWidth-triSize)/2; + triY = m_surfaceHeight-triSize; orientation = _checked ? TriangleOrientation::Down : TriangleOrientation::Up; } @@ -2148,7 +2144,7 @@ struct Imgui //|| ImguiAlign::CenterIndented == _align). { xx = area.m_widgetX; - width = area.m_widgetW - (area.m_widgetX-area.m_scissorX); + width = area.m_widgetW - (area.m_widgetX-area.m_contentX); } drawRoundedRect( (float)xx, (float)yy, (float)width, (float)height, 4.0f, imguiRGBA(0, 0, 0, 128) ); @@ -3049,10 +3045,16 @@ struct Imgui const Area& area = getCurrentArea(); if (area.m_scissorEnabled) { - bgfx::setScissor(uint16_t(IMGUI_MAX(0, area.m_scissorX) ) - , uint16_t(IMGUI_MAX(0, area.m_scissorY-1) ) - , area.m_scissorWidth - , area.m_scissorHeight+1 + const float xscale = float(m_viewWidth) /float(m_surfaceWidth); + const float yscale = float(m_viewHeight)/float(m_surfaceHeight); + const int16_t scissorX = int16_t(float(area.m_scissorX)*xscale); + const int16_t scissorY = int16_t(float(area.m_scissorY)*yscale); + const int16_t scissorWidth = int16_t(float(area.m_scissorWidth)*xscale); + const int16_t scissorHeight = int16_t(float(area.m_scissorHeight)*yscale); + bgfx::setScissor(uint16_t(IMGUI_MAX(0, scissorX) ) + , uint16_t(IMGUI_MAX(0, scissorY-1) ) + , scissorWidth + , scissorHeight+1 ); } else @@ -3061,6 +3063,23 @@ struct Imgui } } + inline void nvgScissor(NVGcontext* _ctx, const Area& _area) + { + if (_area.m_scissorEnabled) + { + ::nvgScissor(_ctx + , float(IMGUI_MAX(0, _area.m_scissorX) ) + , float(IMGUI_MAX(0, _area.m_scissorY-1) ) + , float(_area.m_scissorWidth) + , float(_area.m_scissorHeight+1) + ); + } + else + { + nvgResetScissor(_ctx); + } + } + template struct IdStack { @@ -3150,6 +3169,8 @@ struct Imgui uint8_t m_view; uint16_t m_viewWidth; uint16_t m_viewHeight; + uint16_t m_surfaceWidth; + uint16_t m_surfaceHeight; #if !USE_NANOVG_FONT struct Font @@ -3204,9 +3225,14 @@ ImguiFontHandle imguiGetCurrentFont() return handle; } +void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, uint16_t _surfaceWidth, uint16_t _surfaceHeight, char _inputChar, uint8_t _view) +{ + s_imgui.beginFrame(_mx, _my, _button, _scroll, _width, _height, _surfaceWidth, _surfaceHeight, _inputChar, _view); +} + void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, char _inputChar, uint8_t _view) { - s_imgui.beginFrame(_mx, _my, _button, _scroll, _width, _height, _inputChar, _view); + s_imgui.beginFrame(_mx, _my, _button, _scroll, _width, _height, _width, _height, _inputChar, _view); } void imguiEndFrame() diff --git a/examples/common/imgui/imgui.h b/examples/common/imgui/imgui.h index ba99291a7..c99605da4 100644 --- a/examples/common/imgui/imgui.h +++ b/examples/common/imgui/imgui.h @@ -137,6 +137,7 @@ ImguiFontHandle imguiCreate(const void* _data = NULL, uint32_t _size = 0, float 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 = 255); +void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, uint16_t _surfaceWidth, uint16_t _surfaceHeight, char _inputChar = 0, uint8_t _view = 255); void imguiEndFrame(); void imguiDrawText(int _x, int _y, ImguiTextAlign::Enum _align, const char* _text, uint32_t _argb); diff --git a/examples/common/nanovg/nanovg.cpp b/examples/common/nanovg/nanovg.cpp index 1cbb58b57..bb0e6bb35 100644 --- a/examples/common/nanovg/nanovg.cpp +++ b/examples/common/nanovg/nanovg.cpp @@ -296,7 +296,7 @@ void nvgDeleteInternal(NVGcontext* ctx) free(ctx); } -void nvgBeginFrame(NVGcontext* ctx, int windowWidth, int windowHeight, float devicePixelRatio) +void nvgBeginFrameScaled(NVGcontext* ctx, int windowWidth, int windowHeight, int surfaceWidth, int surfaceHeight, float devicePixelRatio) { /* printf("Tris: draws:%d fill:%d stroke:%d text:%d TOT:%d\n", ctx->drawCallCount, ctx->fillTriCount, ctx->strokeTriCount, ctx->textTriCount, @@ -307,8 +307,8 @@ void nvgBeginFrame(NVGcontext* ctx, int windowWidth, int windowHeight, float dev nvgReset(ctx); nvg__setDevicePixelRatio(ctx, devicePixelRatio); - - ctx->params.renderViewport(ctx->params.userPtr, windowWidth, windowHeight); + + ctx->params.renderViewport(ctx->params.userPtr, windowWidth, windowHeight, surfaceWidth, surfaceHeight); ctx->drawCallCount = 0; ctx->fillTriCount = 0; @@ -316,6 +316,11 @@ void nvgBeginFrame(NVGcontext* ctx, int windowWidth, int windowHeight, float dev ctx->textTriCount = 0; } +void nvgBeginFrame(NVGcontext* ctx, int windowWidth, int windowHeight, float devicePixelRatio) +{ + nvgBeginFrameScaled(ctx, windowWidth, windowHeight, windowWidth, windowHeight, devicePixelRatio); +} + void nvgCancelFrame(NVGcontext* ctx) { ctx->params.renderCancel(ctx->params.userPtr); diff --git a/examples/common/nanovg/nanovg.h b/examples/common/nanovg/nanovg.h index 8709db210..f43f90f46 100644 --- a/examples/common/nanovg/nanovg.h +++ b/examples/common/nanovg/nanovg.h @@ -116,6 +116,7 @@ enum NVGimageFlags { // frame buffer size. In that case you would set windowWidth/Height to the window size // devicePixelRatio to: frameBufferWidth / windowWidth. void nvgBeginFrame(NVGcontext* ctx, int windowWidth, int windowHeight, float devicePixelRatio); +void nvgBeginFrameScaled(NVGcontext* ctx, int windowWidth, int windowHeight, int surfaceWidth, int surfaceHeight, float devicePixelRatio); // Cancels drawing the current frame. void nvgCancelFrame(NVGcontext* ctx); @@ -588,7 +589,7 @@ struct NVGparams { int (*renderDeleteTexture)(void* uptr, int image); int (*renderUpdateTexture)(void* uptr, int image, int x, int y, int w, int h, const unsigned char* data); int (*renderGetTextureSize)(void* uptr, int image, int* w, int* h); - void (*renderViewport)(void* uptr, int width, int height); + void (*renderViewport)(void* uptr, int width, int height, int surfaceWidth, int surfaceHeight); void (*renderCancel)(void* uptr); void (*renderFlush)(void* uptr); void (*renderFill)(void* uptr, NVGpaint* paint, NVGscissor* scissor, float fringe, const float* bounds, const NVGpath* paths, int npaths); diff --git a/examples/common/nanovg/nanovg_bgfx.cpp b/examples/common/nanovg/nanovg_bgfx.cpp index 6be7bbf90..394022370 100644 --- a/examples/common/nanovg/nanovg_bgfx.cpp +++ b/examples/common/nanovg/nanovg_bgfx.cpp @@ -132,6 +132,7 @@ namespace struct GLNVGtexture* textures; float view[2]; + float surface[2]; int ntextures; int ctextures; int textureId; @@ -516,11 +517,13 @@ namespace gl->th = handle; } - static void nvgRenderViewport(void* _userPtr, int width, int height) + static void nvgRenderViewport(void* _userPtr, int width, int height, int surfaceWidth, int surfaceHeight) { struct GLNVGcontext* gl = (struct GLNVGcontext*)_userPtr; gl->view[0] = (float)width; gl->view[1] = (float)height; + gl->surface[0] = (float)surfaceWidth; + gl->surface[1] = (float)surfaceHeight; bgfx::setViewRect(gl->viewid, 0, 0, width, height); } @@ -720,7 +723,7 @@ namespace ); } - bgfx::setUniform(gl->u_viewSize, gl->view); + bgfx::setUniform(gl->u_viewSize, gl->surface); for (uint32_t ii = 0, num = gl->ncalls; ii < num; ++ii) { From 7c188f4e0eb2e8746f3f5ac0174d0674ed2b2f5a Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Mon, 16 Mar 2015 14:12:37 +0100 Subject: [PATCH 2/5] Fixing EXC_BAD_ACCESS error. --- examples/common/entry/entry_osx.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/common/entry/entry_osx.mm b/examples/common/entry/entry_osx.mm index b46fbdb4b..14a493012 100644 --- a/examples/common/entry/entry_osx.mm +++ b/examples/common/entry/entry_osx.mm @@ -584,10 +584,10 @@ namespace entry if (!s_ctx.m_fullscreen) { - [NSMenu setMenuBarVisible: false]; s_ctx.m_style &= ~NSTitledWindowMask; dispatch_async(dispatch_get_main_queue() , ^{ + [NSMenu setMenuBarVisible: false]; [window setStyleMask: s_ctx.m_style]; [window setFrame:screenRect display:YES]; }); @@ -596,10 +596,10 @@ namespace entry } else { - [NSMenu setMenuBarVisible: true]; s_ctx.m_style |= NSTitledWindowMask; dispatch_async(dispatch_get_main_queue() , ^{ + [NSMenu setMenuBarVisible: true]; [window setStyleMask: s_ctx.m_style]; [window setFrame:s_ctx.m_windowFrame display:YES]; }); From f3c300980d5d3471bd728f18e292b6d1200b7d72 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Mon, 16 Mar 2015 14:20:45 +0100 Subject: [PATCH 3/5] Imgui separator line can be now aligned. --- examples/common/imgui/imgui.cpp | 39 +++++++++++++++++++++++++-------- examples/common/imgui/imgui.h | 2 +- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index 852e24731..00e0bc675 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -2262,19 +2262,40 @@ struct Imgui area.m_widgetY += _height; } - void separatorLine(uint16_t _height) + void separatorLine(uint16_t _height, ImguiAlign::Enum _align) { Area& area = getCurrentArea(); - const int32_t rectWidth = area.m_widgetW; - const int32_t rectHeight = 1; - const int32_t xx = area.m_widgetX; - const int32_t yy = area.m_widgetY + _height/2 - rectHeight; + //const int32_t width = area.m_widgetW; + const int32_t height = 1; + //const int32_t xx = area.m_widgetX; + const int32_t yy = area.m_widgetY + _height/2 - height; + + int32_t xx; + int32_t width; + if (ImguiAlign::Left == _align) + { + xx = area.m_contentX + SCROLL_AREA_PADDING; + width = area.m_widgetW; + } + else if (ImguiAlign::LeftIndented == _align + || ImguiAlign::Right == _align) + { + xx = area.m_widgetX; + width = area.m_widgetW; + } + else //if (ImguiAlign::Center == _align + //|| ImguiAlign::CenterIndented == _align). + { + xx = area.m_widgetX; + width = area.m_widgetW - (area.m_widgetX-area.m_contentX) + 1; + } + area.m_widgetY += _height; drawRect( (float)xx , (float)yy - , (float)rectWidth - , (float)rectHeight + , (float)width + , (float)height , imguiRGBA(255, 255, 255, 32) ); } @@ -3315,9 +3336,9 @@ void imguiSeparator(uint16_t _height) s_imgui.separator(_height); } -void imguiSeparatorLine(uint16_t _height) +void imguiSeparatorLine(uint16_t _height, ImguiAlign::Enum _align) { - s_imgui.separatorLine(_height); + s_imgui.separatorLine(_height, _align); } int32_t imguiGetWidgetX() diff --git a/examples/common/imgui/imgui.h b/examples/common/imgui/imgui.h index c99605da4..0ab69038d 100644 --- a/examples/common/imgui/imgui.h +++ b/examples/common/imgui/imgui.h @@ -159,7 +159,7 @@ void imguiEndScrollArea(int32_t _r = IMGUI_SCROLL_BAR_R); void imguiIndent(uint16_t _width = IMGUI_INDENT_VALUE); void imguiUnindent(uint16_t _width = IMGUI_INDENT_VALUE); void imguiSeparator(uint16_t _height = IMGUI_SEPARATOR_VALUE); -void imguiSeparatorLine(uint16_t _height = IMGUI_SEPARATOR_VALUE); +void imguiSeparatorLine(uint16_t _height = IMGUI_SEPARATOR_VALUE, ImguiAlign::Enum = ImguiAlign::LeftIndented); int32_t imguiGetWidgetX(); int32_t imguiGetWidgetY(); From acd4dedfe174648bf24cc63d3ca7b8439b15a123 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Mon, 16 Mar 2015 15:19:35 +0100 Subject: [PATCH 4/5] Added mouse scroll support to entry_sdl. --- examples/common/entry/entry_sdl.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/examples/common/entry/entry_sdl.cpp b/examples/common/entry/entry_sdl.cpp index c279f0fd2..48a049ea1 100644 --- a/examples/common/entry/entry_sdl.cpp +++ b/examples/common/entry/entry_sdl.cpp @@ -211,6 +211,9 @@ namespace entry : m_width(ENTRY_DEFAULT_WIDTH) , m_height(ENTRY_DEFAULT_HEIGHT) , m_aspectRatio(16.0f/9.0f) + , m_mx(0) + , m_my(0) + , m_mz(0) , m_mouseLock(false) , m_fullscreen(false) { @@ -376,10 +379,13 @@ namespace entry case SDL_MOUSEMOTION: { const SDL_MouseMotionEvent& mev = event.motion; + m_mx = mev.x; + m_my = mev.y; + WindowHandle handle = findHandle(mev.windowID); if (isValid(handle) ) { - m_eventQueue.postMouseEvent(handle, mev.x, mev.y, 0); + m_eventQueue.postMouseEvent(handle, m_mx, m_my, m_mz); } } break; @@ -411,6 +417,19 @@ namespace entry } break; + case SDL_MOUSEWHEEL: + { + const SDL_MouseWheelEvent& mev = event.wheel; + m_mz += mev.y; + + WindowHandle handle = findHandle(mev.windowID); + if (isValid(handle) ) + { + m_eventQueue.postMouseEvent(handle, m_mx, m_my, m_mz); + } + } + break; + case SDL_KEYDOWN: { const SDL_KeyboardEvent& kev = event.key; @@ -745,6 +764,7 @@ namespace entry int32_t m_mx; int32_t m_my; + int32_t m_mz; bool m_mouseLock; bool m_fullscreen; }; From c758d294edf922ada25fcb73e967b978b90852dd Mon Sep 17 00:00:00 2001 From: fysx Date: Mon, 16 Mar 2015 21:22:06 +0100 Subject: [PATCH 5/5] Linux: fixed building of shared libraries --- scripts/bgfx.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/bgfx.lua b/scripts/bgfx.lua index 30646cfd1..644f9c4e9 100644 --- a/scripts/bgfx.lua +++ b/scripts/bgfx.lua @@ -25,6 +25,11 @@ function bgfxProject(_name, _kind, _defines) "-shared", } + configuration { "linux-*" } + buildoptions { + "-fPIC", + } + configuration {} end