From 31efb2991ff165b6724599f7fb16d3ab88b19f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 8 Nov 2014 20:57:47 -0800 Subject: [PATCH 01/16] Updated to OVR 0.4.3. Added support for event char to read keyboard text input. --- examples/10-font/font.cpp | 9 ++-- examples/common/entry/entry.cpp | 19 ++++++- examples/common/entry/entry_p.h | 17 +++++++ examples/common/entry/entry_windows.cpp | 20 ++++++++ examples/common/entry/input.cpp | 53 ++++++++++++++++++++ examples/common/entry/input.h | 9 ++++ examples/common/font/text_buffer_manager.cpp | 10 +++- examples/common/font/text_metrics.cpp | 4 +- examples/common/imgui/imgui.cpp | 4 +- include/bgfx.h | 2 +- src/ovr.cpp | 12 ++--- src/renderer_d3d11.cpp | 6 +-- src/renderer_gl.cpp | 6 +-- 13 files changed, 146 insertions(+), 25 deletions(-) diff --git a/examples/10-font/font.cpp b/examples/10-font/font.cpp index 2662d770..56b79e69 100644 --- a/examples/10-font/font.cpp +++ b/examples/10-font/font.cpp @@ -12,6 +12,7 @@ #include "font/font_manager.h" #include "font/text_buffer_manager.h" +#include "entry/input.h" #include #include @@ -192,8 +193,8 @@ int _main_(int /*_argc*/, char** /*_argv*/) textBufferManager->appendText(transientText, visitor10, L"text buffer\n"); textBufferManager->appendText(transientText, visitor10, fpsText); - float at[3] = { 0, 0, 0.0f }; - float eye[3] = {0, 0, -1.0f }; + float at[3] = { 0, 0, 0.0f }; + float eye[3] = { 0, 0, -1.0f }; float view[16]; bx::mtxLookAt(view, eye, at); @@ -211,8 +212,8 @@ int _main_(int /*_argc*/, char** /*_argv*/) time += 0.05f; const float dist = 10.0f; - const float offset0 = -proj[8] + (hmd->eye[0].adjust[0] / dist * proj[0]); - const float offset1 = -proj[8] + (hmd->eye[1].adjust[0] / dist * proj[0]); + const float offset0 = -proj[8] + (hmd->eye[0].viewOffset[0] / dist * proj[0]); + const float offset1 = -proj[8] + (hmd->eye[1].viewOffset[0] / dist * proj[0]); float ortho[2][16]; const float offsetx = width/2.0f; diff --git a/examples/common/entry/entry.cpp b/examples/common/entry/entry.cpp index 210588cc..70a619f9 100644 --- a/examples/common/entry/entry.cpp +++ b/examples/common/entry/entry.cpp @@ -242,12 +242,12 @@ namespace entry if (_shiftModifier) { // Big letters. - if(ascii >= 'a' && ascii <= 'z') + if (ascii >= 'a' && ascii <= 'z') { ascii += 'A' - 'a'; } // Special cases. - else if('-' == ascii) + else if ('-' == ascii) { ascii = '_'; } @@ -322,6 +322,13 @@ namespace entry } break; + case Event::Char: + { + const CharEvent* chev = static_cast(ev); + inputChar(chev->m_len, chev->m_char); + } + break; + case Event::Size: { const SizeEvent* size = static_cast(ev); @@ -440,6 +447,14 @@ namespace entry } break; + case Event::Char: + { + const CharEvent* chev = static_cast(ev); + win.m_handle = chev->m_handle; + inputChar(chev->m_len, chev->m_char); + } + break; + case Event::Size: { const SizeEvent* size = static_cast(ev); diff --git a/examples/common/entry/entry_p.h b/examples/common/entry/entry_p.h index bf67a30d..62cb3775 100644 --- a/examples/common/entry/entry_p.h +++ b/examples/common/entry/entry_p.h @@ -45,6 +45,7 @@ namespace entry { Exit, Key, + Char, Mouse, Size, Window, @@ -75,6 +76,14 @@ namespace entry bool m_down; }; + struct CharEvent : public Event + { + ENTRY_IMPLEMENT_EVENT(CharEvent, Event::Char); + + uint8_t m_len; + uint8_t m_char[4]; + }; + struct MouseEvent : public Event { ENTRY_IMPLEMENT_EVENT(MouseEvent, Event::Mouse); @@ -124,6 +133,14 @@ namespace entry m_queue.push(ev); } + void postCharEvent(WindowHandle _handle, uint8_t _len, const uint8_t _char[4]) + { + CharEvent* ev = new CharEvent(_handle); + ev->m_len = _len; + memcpy(ev->m_char, _char, 4); + m_queue.push(ev); + } + void postMouseEvent(WindowHandle _handle, int32_t _mx, int32_t _my, int32_t _mz) { MouseEvent* ev = new MouseEvent(_handle); diff --git a/examples/common/entry/entry_windows.cpp b/examples/common/entry/entry_windows.cpp index 1d8d51f2..ce0f911b 100644 --- a/examples/common/entry/entry_windows.cpp +++ b/examples/common/entry/entry_windows.cpp @@ -532,6 +532,26 @@ namespace entry } break; + case WM_CHAR: + { + uint8_t utf8[4] = {}; + uint8_t len = (uint8_t)WideCharToMultiByte(CP_UTF8 + , 0 + , (LPCWSTR)&_wparam + , 1 + , (LPSTR)utf8 + , BX_COUNTOF(utf8) + , NULL + , NULL + ); + if (0 != len) + { + WindowHandle handle = findHandle(_hwnd); + m_eventQueue.postCharEvent(handle, len, utf8); + } + } + break; + default: break; } diff --git a/examples/common/entry/input.cpp b/examples/common/entry/input.cpp index 110e3cde..bd3c2bbd 100644 --- a/examples/common/entry/input.cpp +++ b/examples/common/entry/input.cpp @@ -8,6 +8,7 @@ #include "entry_p.h" #include "input.h" +#include #include #include namespace stl = tinystl; @@ -68,6 +69,7 @@ struct Mouse struct Keyboard { Keyboard() + : m_ring(BX_COUNTOF(m_char) ) { } @@ -97,8 +99,44 @@ struct Keyboard m_once[_key] = false; } + void pushChar(uint8_t _len, const uint8_t _char[4]) + { + for (uint32_t len = m_ring.reserve(4) + ; len < _len + ; len = m_ring.reserve(4) + ) + { + popChar(); + } + + memcpy(&m_char[m_ring.m_write], _char, 4); + m_ring.commit(4); + } + + const uint8_t* popChar() + { + if (0 < m_ring.available() ) + { + uint8_t* utf8 = &m_char[m_ring.m_read]; + m_ring.consume(4); + return utf8; + } + + return NULL; + } + + void charFlush() + { + m_ring.m_current = 0; + m_ring.m_write = 0; + m_ring.m_read = 0; + } + uint32_t m_key[256]; bool m_once[256]; + + bx::RingBufferControl m_ring; + uint8_t m_char[256]; }; struct Input @@ -204,6 +242,21 @@ void inputSetKeyState(entry::Key::Enum _key, uint8_t _modifiers, bool _down) s_input.m_keyboard.setKeyState(_key, _modifiers, _down); } +void inputChar(uint8_t _len, const uint8_t _char[4]) +{ + s_input.m_keyboard.pushChar(_len, _char); +} + +const uint8_t* inputGetChar() +{ + return s_input.m_keyboard.popChar(); +} + +void inputCharFlush() +{ + s_input.m_keyboard.charFlush(); +} + void inputSetMousePos(int32_t _mx, int32_t _my, int32_t _mz) { s_input.m_mouse.setPos(_mx, _my, _mz); diff --git a/examples/common/entry/input.h b/examples/common/entry/input.h index b16dcfd1..a48a182d 100644 --- a/examples/common/entry/input.h +++ b/examples/common/entry/input.h @@ -34,6 +34,15 @@ void inputProcess(); /// void inputSetKeyState(entry::Key::Enum _key, uint8_t _modifiers, bool _down); +/// Adds single UTF-8 encoded character into input buffer. +void inputChar(uint8_t _len, const uint8_t _char[4]); + +/// Returns single UTF-8 encoded character from input buffer. +const uint8_t* inputGetChar(); + +/// Flush internal input buffer. +void inputCharFlush(); + /// void inputSetMouseResolution(uint16_t _width, uint16_t _height); diff --git a/examples/common/font/text_buffer_manager.cpp b/examples/common/font/text_buffer_manager.cpp index 0d5a8bdc..654d1cab 100644 --- a/examples/common/font/text_buffer_manager.cpp +++ b/examples/common/font/text_buffer_manager.cpp @@ -236,7 +236,13 @@ void TextBuffer::appendText(FontHandle _fontHandle, const char* _string, const c CodePoint codepoint = 0; uint32_t state = 0; - for (; *_string && _string<_end ; ++_string) + if (_end == NULL) + { + _end = _string + strlen(_string); + } + BX_CHECK(_end >= _string); + + for (; *_string && _string < _end ; ++_string) { if (utf8_decode(&state, (uint32_t*)&codepoint, *_string) == UTF8_ACCEPT ) { @@ -260,7 +266,7 @@ void TextBuffer::appendText(FontHandle _fontHandle, const wchar_t* _string, cons if (_end == NULL) { - _end = _string + (uint32_t) wcslen(_string); + _end = _string + wcslen(_string); } BX_CHECK(_end >= _string); diff --git a/examples/common/font/text_metrics.cpp b/examples/common/font/text_metrics.cpp index 841fa08d..d48035fb 100644 --- a/examples/common/font/text_metrics.cpp +++ b/examples/common/font/text_metrics.cpp @@ -162,9 +162,9 @@ void TextLineMetrics::getSubText(const char* _string, uint32_t _firstLine, uint3 { for (; *_string; ++_string) { - if(utf8_decode(&state, (uint32_t*)&codepoint, *_string) == UTF8_ACCEPT) + if (utf8_decode(&state, (uint32_t*)&codepoint, *_string) == UTF8_ACCEPT) { - if(codepoint == L'\n') + if (codepoint == L'\n') { ++currentLine; ++_string; diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index 61a7bb2e..06472954 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -788,8 +788,8 @@ struct Imgui time += 0.05f; const float dist = 10.0f; - const float offset0 = -proj[8] + (hmd->eye[0].adjust[0] / dist * proj[0]); - const float offset1 = -proj[8] + (hmd->eye[1].adjust[0] / dist * proj[0]); + const float offset0 = -proj[8] + (hmd->eye[0].viewOffset[0] / dist * proj[0]); + const float offset1 = -proj[8] + (hmd->eye[1].viewOffset[0] / dist * proj[0]); float ortho[2][16]; const float viewOffset = _width/4.0f; diff --git a/include/bgfx.h b/include/bgfx.h index d9516f70..e40cfe28 100644 --- a/include/bgfx.h +++ b/include/bgfx.h @@ -378,7 +378,7 @@ namespace bgfx float rotation[4]; //!< Eye rotation represented as quaternion. float translation[3]; //!< Eye translation. float fov[4]; //!< Field of view (up, down, left, right). - float adjust[3]; //!< Eye view matrix translation adjustment. + float viewOffset[3]; //!< Eye view matrix translation adjustment. float pixelsPerTanAngle[2]; //!< }; diff --git a/src/ovr.cpp b/src/ovr.cpp index 4181e332..52255fb3 100644 --- a/src/ovr.cpp +++ b/src/ovr.cpp @@ -153,8 +153,8 @@ ovrError: m_timing = ovrHmd_BeginFrame(m_hmd, 0); - m_pose[0] = ovrHmd_GetEyePose(m_hmd, ovrEye_Left); - m_pose[1] = ovrHmd_GetEyePose(m_hmd, ovrEye_Right); + m_pose[0] = ovrHmd_GetHmdPosePerEye(m_hmd, ovrEye_Left); + m_pose[1] = ovrHmd_GetHmdPosePerEye(m_hmd, ovrEye_Right); return true; } @@ -175,7 +175,7 @@ ovrError: for (int ii = 0; ii < 2; ++ii) { ovrPosef& pose = m_pose[ii]; - pose = ovrHmd_GetEyePose(m_hmd, eye[ii]); + pose = ovrHmd_GetHmdPosePerEye(m_hmd, eye[ii]); HMD::Eye& eye = _hmd.eye[ii]; eye.rotation[0] = pose.Orientation.x; @@ -191,9 +191,9 @@ ovrError: eye.fov[1] = erd.Fov.DownTan; eye.fov[2] = erd.Fov.LeftTan; eye.fov[3] = erd.Fov.RightTan; - eye.adjust[0] = erd.ViewAdjust.x; - eye.adjust[1] = erd.ViewAdjust.y; - eye.adjust[2] = erd.ViewAdjust.z; + eye.viewOffset[0] = erd.HmdToEyeViewOffset.x; + eye.viewOffset[1] = erd.HmdToEyeViewOffset.y; + eye.viewOffset[2] = erd.HmdToEyeViewOffset.z; eye.pixelsPerTanAngle[0] = erd.PixelsPerTanAngleAtCenter.x; eye.pixelsPerTanAngle[1] = erd.PixelsPerTanAngleAtCenter.y; } diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 2dfcf4e2..288dfcdb 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -2967,9 +2967,9 @@ RENDERDOC_IMPORT for (uint32_t eye = 0; eye < 2; ++eye) { const HMD::Eye& hmdEye = hmd.eye[eye]; - viewAdjust.un.val[12] = hmdEye.adjust[0]; - viewAdjust.un.val[13] = hmdEye.adjust[1]; - viewAdjust.un.val[14] = hmdEye.adjust[2]; + viewAdjust.un.val[12] = hmdEye.viewOffset[0]; + viewAdjust.un.val[13] = hmdEye.viewOffset[1]; + viewAdjust.un.val[14] = hmdEye.viewOffset[2]; for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii) { diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 769f1609..d988eeea 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -4136,9 +4136,9 @@ namespace bgfx for (uint32_t eye = 0; eye < 2; ++eye) { const HMD::Eye& hmdEye = hmd.eye[eye]; - viewAdjust.un.val[12] = hmdEye.adjust[0]; - viewAdjust.un.val[13] = hmdEye.adjust[1]; - viewAdjust.un.val[14] = hmdEye.adjust[2]; + viewAdjust.un.val[12] = hmdEye.viewOffset[0]; + viewAdjust.un.val[13] = hmdEye.viewOffset[1]; + viewAdjust.un.val[14] = hmdEye.viewOffset[2]; for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii) { From 7f2f523c4367aacbc0219d081ec1573ea137c47e Mon Sep 17 00:00:00 2001 From: Branimir Karadzic Date: Sat, 8 Nov 2014 22:09:31 -0800 Subject: [PATCH 02/16] Fixed compile error. --- examples/11-fontsdf/fontsdf.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/11-fontsdf/fontsdf.cpp b/examples/11-fontsdf/fontsdf.cpp index 203ae4eb..da5de076 100644 --- a/examples/11-fontsdf/fontsdf.cpp +++ b/examples/11-fontsdf/fontsdf.cpp @@ -217,8 +217,8 @@ int _main_(int /*_argc*/, char** /*_argv*/) time += 0.05f; const float dist = 10.0f; - const float offset0 = -proj[8] + (hmd->eye[0].adjust[0] / dist * proj[0]); - const float offset1 = -proj[8] + (hmd->eye[1].adjust[0] / dist * proj[0]); + const float offset0 = -proj[8] + (hmd->eye[0].viewOffset[0] / dist * proj[0]); + const float offset1 = -proj[8] + (hmd->eye[1].viewOffset[0] / dist * proj[0]); float ortho[2][16]; const float viewOffset = width/4.0f; From 0f48d59a014015ccb66457a63d0d81719f06f7f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sun, 9 Nov 2014 11:55:45 -0800 Subject: [PATCH 03/16] Fixed typo. --- examples/09-hdr/hdr.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/09-hdr/hdr.cpp b/examples/09-hdr/hdr.cpp index 0f696204..0b3f8455 100644 --- a/examples/09-hdr/hdr.cpp +++ b/examples/09-hdr/hdr.cpp @@ -236,7 +236,7 @@ int _main_(int /*_argc*/, char** /*_argv*/) float speed = 0.37f; float middleGray = 0.18f; float white = 1.1f; - float treshold = 1.5f; + float threshold = 1.5f; int32_t scrollArea = 0; @@ -285,7 +285,7 @@ int _main_(int /*_argc*/, char** /*_argv*/) imguiSlider("Middle gray", middleGray, 0.1f, 1.0f, 0.01f); imguiSlider("White point", white, 0.1f, 2.0f, 0.01f); - imguiSlider("Treshold", treshold, 0.1f, 2.0f, 0.01f); + imguiSlider("Threshold", threshold, 0.1f, 2.0f, 0.01f); imguiEndScrollArea(); imguiEndFrame(); @@ -425,10 +425,10 @@ int _main_(int /*_argc*/, char** /*_argv*/) screenSpaceQuad(1.0f, 1.0f, s_originBottomLeft); bgfx::submit(6); - float tonemap[4] = { middleGray, square(white), treshold, 0.0f }; + float tonemap[4] = { middleGray, square(white), threshold, 0.0f }; bgfx::setUniform(u_tonemap, tonemap); - // Bright pass treshold is tonemap[3]. + // Bright pass threshold is tonemap[3]. setOffsets4x4Lum(u_offset, width/2, height/2); bgfx::setTexture(0, u_texColor, fbtextures[0]); bgfx::setTexture(1, u_texLum, lum[4]); From 43b9802b4867b6600b2d65254969a33c65143a80 Mon Sep 17 00:00:00 2001 From: Branimir Karadzic Date: Mon, 10 Nov 2014 09:08:26 -0800 Subject: [PATCH 04/16] Fixed Linux build. --- examples/common/entry/entry_p.h | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/common/entry/entry_p.h b/examples/common/entry/entry_p.h index 62cb3775..1b42df0c 100644 --- a/examples/common/entry/entry_p.h +++ b/examples/common/entry/entry_p.h @@ -9,6 +9,7 @@ #include #include "entry.h" +#include // memcpy #ifndef ENTRY_CONFIG_USE_SDL # define ENTRY_CONFIG_USE_SDL 0 From 96055834915899e214535b8afe5f450550a0ca45 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Sun, 12 Oct 2014 19:49:36 +0200 Subject: [PATCH 05/16] Collapse switch for imguiColorWheel() is now always enabeld. --- examples/common/imgui/imgui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index 06472954..34575c9a 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -3277,7 +3277,7 @@ void imguiColorWheel(const char* _text, float _rgb[3], bool& _activated, bool _e , _rgb[2] ); - if (imguiCollapse(_text, buf, _activated, _enabled) ) + if (imguiCollapse(_text, buf, _activated) ) { _activated = !_activated; } From ea4d52ff466ada11456efddc7154a046b62398cd Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Sat, 25 Oct 2014 02:56:12 +0200 Subject: [PATCH 06/16] Added click event for imguiImage(). --- examples/common/imgui/imgui.cpp | 42 ++++++++++++++++++++++----------- examples/common/imgui/imgui.h | 8 +++---- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index 34575c9a..83ead986 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -1547,8 +1547,9 @@ struct Imgui return selected; } - void image(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align, bool _originBottomLeft) + bool image(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align, bool _originBottomLeft) { + const uint32_t id = getId(); Area& area = getCurrentArea(); int32_t xx; @@ -1576,6 +1577,10 @@ struct Imgui const int32_t yy = area.m_widgetY; area.m_widgetY += _height + DEFAULT_SPACING; + const bool enabled = isEnabled(m_areaId); + const bool over = enabled && inRect(xx, yy, _width, _height); + const bool res = buttonLogic(id, over); + screenQuad(xx, yy, _width, _height, _originBottomLeft); bgfx::setUniform(u_imageLod, &_lod); bgfx::setTexture(0, s_texColor, bgfx::isValid(_image) ? _image : m_missingTexture); @@ -1583,20 +1588,23 @@ struct Imgui bgfx::setProgram(m_imageProgram); setCurrentScissor(); bgfx::submit(m_view); + + return res; } - void image(bgfx::TextureHandle _image, float _lod, float _width, float _aspect, ImguiAlign::Enum _align, bool _originBottomLeft) + bool image(bgfx::TextureHandle _image, float _lod, float _width, float _aspect, ImguiAlign::Enum _align, bool _originBottomLeft) { const float width = _width*float(getCurrentArea().m_widgetW); const float height = width/_aspect; - image(_image, _lod, int32_t(width), int32_t(height), _align, _originBottomLeft); + return image(_image, _lod, int32_t(width), int32_t(height), _align, _originBottomLeft); } - void imageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align) + bool imageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align) { BX_CHECK(_channel < 4, "Channel param must be from 0 to 3!"); + const uint32_t id = getId(); Area& area = getCurrentArea(); int32_t xx; @@ -1624,6 +1632,10 @@ struct Imgui const int32_t yy = area.m_widgetY; area.m_widgetY += _height + DEFAULT_SPACING; + const bool enabled = isEnabled(m_areaId); + const bool over = enabled && inRect(xx, yy, _width, _height); + const bool res = buttonLogic(id, over); + screenQuad(xx, yy, _width, _height); bgfx::setUniform(u_imageLod, &_lod); @@ -1636,14 +1648,16 @@ struct Imgui bgfx::setProgram(m_imageSwizzProgram); setCurrentScissor(); bgfx::submit(m_view); + + return res; } - void imageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, float _width, float _aspect, ImguiAlign::Enum _align) + bool imageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, float _width, float _aspect, ImguiAlign::Enum _align) { const float width = _width*float(getCurrentArea().m_widgetW); const float height = width/_aspect; - imageChannel(_image, _channel, _lod, int32_t(width), int32_t(height), _align); + return imageChannel(_image, _channel, _lod, int32_t(width), int32_t(height), _align); } bool cubeMap(bgfx::TextureHandle _cubemap, float _lod, bool _cross, ImguiAlign::Enum _align) @@ -3288,24 +3302,24 @@ void imguiColorWheel(const char* _text, float _rgb[3], bool& _activated, bool _e } } -void imguiImage(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align, bool _originBottomLeft) +bool imguiImage(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align, bool _originBottomLeft) { - s_imgui.image(_image, _lod, _width, _height, _align, _originBottomLeft); + return s_imgui.image(_image, _lod, _width, _height, _align, _originBottomLeft); } -void imguiImage(bgfx::TextureHandle _image, float _lod, float _width, float _aspect, ImguiAlign::Enum _align, bool _originBottomLeft) +bool imguiImage(bgfx::TextureHandle _image, float _lod, float _width, float _aspect, ImguiAlign::Enum _align, bool _originBottomLeft) { - s_imgui.image(_image, _lod, _width, _aspect, _align, _originBottomLeft); + return s_imgui.image(_image, _lod, _width, _aspect, _align, _originBottomLeft); } -void imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align) +bool imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align) { - s_imgui.imageChannel(_image, _channel, _lod, _width, _height, _align); + return s_imgui.imageChannel(_image, _channel, _lod, _width, _height, _align); } -void imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, float _width, float _aspect, ImguiAlign::Enum _align) +bool imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, float _width, float _aspect, ImguiAlign::Enum _align) { - s_imgui.imageChannel(_image, _channel, _lod, _width, _aspect, _align); + return s_imgui.imageChannel(_image, _channel, _lod, _width, _aspect, _align); } bool imguiCube(bgfx::TextureHandle _cubemap, float _lod, bool _cross, ImguiAlign::Enum _align) diff --git a/examples/common/imgui/imgui.h b/examples/common/imgui/imgui.h index e7761aa4..764e9362 100644 --- a/examples/common/imgui/imgui.h +++ b/examples/common/imgui/imgui.h @@ -174,10 +174,10 @@ uint32_t imguiChooseUseMacroInstead(uint32_t _selected, ...); void imguiColorWheel(float _rgb[3], bool _respectIndentation = false, bool _enabled = true); 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, ImguiAlign::Enum _align = ImguiAlign::LeftIndented, bool _originBottomLeft = false); -void imguiImage(bgfx::TextureHandle _image, float _lod, float _scale, float _aspect, ImguiAlign::Enum _align = ImguiAlign::LeftIndented, bool _originBottomLeft = false); -void imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align = ImguiAlign::LeftIndented); -void imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, float _scale, float _aspect, ImguiAlign::Enum _align = ImguiAlign::LeftIndented); +bool imguiImage(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align = ImguiAlign::LeftIndented, bool _originBottomLeft = false); +bool imguiImage(bgfx::TextureHandle _image, float _lod, float _scale, float _aspect, ImguiAlign::Enum _align = ImguiAlign::LeftIndented, bool _originBottomLeft = false); +bool imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align = ImguiAlign::LeftIndented); +bool imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, float _scale, float _aspect, ImguiAlign::Enum _align = ImguiAlign::LeftIndented); bool imguiCube(bgfx::TextureHandle _cubemap, float _lod = 0.0f, bool _cross = true, ImguiAlign::Enum _align = ImguiAlign::LeftIndented); float imguiGetTextLength(const char* _text, ImguiFontHandle _handle); From be0ec20d796c97f7ebc64227b536f9066d027142 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Wed, 29 Oct 2014 02:04:43 +0100 Subject: [PATCH 07/16] Cleanup. --- examples/common/imgui/imgui.cpp | 56 ++++++++++++++++----------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index 83ead986..e82b4cfd 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -1677,24 +1677,24 @@ struct Imgui if (_cross) { - vertex->set( 0.0f, 0.5f, 0.0f, -1.0f, 1.0f, -1.0f); ++vertex; - vertex->set( 0.0f, 1.0f, 0.0f, -1.0f, -1.0f, -1.0f); ++vertex; + vertex->set(0.0f, 0.5f, 0.0f, -1.0f, 1.0f, -1.0f); ++vertex; + vertex->set(0.0f, 1.0f, 0.0f, -1.0f, -1.0f, -1.0f); ++vertex; - vertex->set( 0.5f, 0.0f, 0.0f, -1.0f, 1.0f, -1.0f); ++vertex; - vertex->set( 0.5f, 0.5f, 0.0f, -1.0f, 1.0f, 1.0f); ++vertex; - vertex->set( 0.5f, 1.0f, 0.0f, -1.0f, -1.0f, 1.0f); ++vertex; - vertex->set( 0.5f, 1.5f, 0.0f, -1.0f, -1.0f, -1.0f); ++vertex; + vertex->set(0.5f, 0.0f, 0.0f, -1.0f, 1.0f, -1.0f); ++vertex; + vertex->set(0.5f, 0.5f, 0.0f, -1.0f, 1.0f, 1.0f); ++vertex; + vertex->set(0.5f, 1.0f, 0.0f, -1.0f, -1.0f, 1.0f); ++vertex; + vertex->set(0.5f, 1.5f, 0.0f, -1.0f, -1.0f, -1.0f); ++vertex; - vertex->set( 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, -1.0f); ++vertex; - vertex->set( 1.0f, 0.5f, 0.0f, 1.0f, 1.0f, 1.0f); ++vertex; - vertex->set( 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f); ++vertex; - vertex->set( 1.0f, 1.5f, 0.0f, 1.0f, -1.0f, -1.0f); ++vertex; + vertex->set(1.0f, 0.0f, 0.0f, 1.0f, 1.0f, -1.0f); ++vertex; + vertex->set(1.0f, 0.5f, 0.0f, 1.0f, 1.0f, 1.0f); ++vertex; + vertex->set(1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f); ++vertex; + vertex->set(1.0f, 1.5f, 0.0f, 1.0f, -1.0f, -1.0f); ++vertex; - vertex->set( 1.5f, 0.5f, 0.0f, 1.0f, 1.0f, -1.0f); ++vertex; - vertex->set( 1.5f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f); ++vertex; + vertex->set(1.5f, 0.5f, 0.0f, 1.0f, 1.0f, -1.0f); ++vertex; + vertex->set(1.5f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f); ++vertex; - vertex->set( 2.0f, 0.5f, 0.0f, -1.0f, 1.0f, -1.0f); ++vertex; - vertex->set( 2.0f, 1.0f, 0.0f, -1.0f, -1.0f, -1.0f); ++vertex; + vertex->set(2.0f, 0.5f, 0.0f, -1.0f, 1.0f, -1.0f); ++vertex; + vertex->set(2.0f, 1.0f, 0.0f, -1.0f, -1.0f, -1.0f); ++vertex; indices += addQuad(indices, 0, 3, 4, 1); indices += addQuad(indices, 2, 6, 7, 3); @@ -1705,25 +1705,25 @@ struct Imgui } else { - vertex->set( 0.0f, 0.25f, 0.0f, -1.0f, 1.0f, -1.0f); ++vertex; - vertex->set( 0.0f, 0.75f, 0.0f, -1.0f, -1.0f, -1.0f); ++vertex; + vertex->set(0.0f, 0.25f, 0.0f, -1.0f, 1.0f, -1.0f); ++vertex; + vertex->set(0.0f, 0.75f, 0.0f, -1.0f, -1.0f, -1.0f); ++vertex; - vertex->set( 0.5f, 0.00f, 0.0f, -1.0f, 1.0f, 1.0f); ++vertex; - vertex->set( 0.5f, 0.50f, 0.0f, -1.0f, -1.0f, 1.0f); ++vertex; - vertex->set( 0.5f, 1.00f, 0.0f, 1.0f, -1.0f, -1.0f); ++vertex; + vertex->set(0.5f, 0.00f, 0.0f, -1.0f, 1.0f, 1.0f); ++vertex; + vertex->set(0.5f, 0.50f, 0.0f, -1.0f, -1.0f, 1.0f); ++vertex; + vertex->set(0.5f, 1.00f, 0.0f, 1.0f, -1.0f, -1.0f); ++vertex; - vertex->set( 1.0f, 0.25f, 0.0f, 1.0f, 1.0f, 1.0f); ++vertex; - vertex->set( 1.0f, 0.75f, 0.0f, 1.0f, -1.0f, 1.0f); ++vertex; + vertex->set(1.0f, 0.25f, 0.0f, 1.0f, 1.0f, 1.0f); ++vertex; + vertex->set(1.0f, 0.75f, 0.0f, 1.0f, -1.0f, 1.0f); ++vertex; - vertex->set( 1.0f, 0.25f, 0.0f, 1.0f, 1.0f, 1.0f); ++vertex; - vertex->set( 1.0f, 0.75f, 0.0f, 1.0f, -1.0f, 1.0f); ++vertex; + vertex->set(1.0f, 0.25f, 0.0f, 1.0f, 1.0f, 1.0f); ++vertex; + vertex->set(1.0f, 0.75f, 0.0f, 1.0f, -1.0f, 1.0f); ++vertex; - vertex->set( 1.5f, 0.00f, 0.0f, -1.0f, 1.0f, 1.0f); ++vertex; - vertex->set( 1.5f, 0.50f, 0.0f, 1.0f, 1.0f, -1.0f); ++vertex; - vertex->set( 1.5f, 1.00f, 0.0f, 1.0f, -1.0f, -1.0f); ++vertex; + vertex->set(1.5f, 0.00f, 0.0f, -1.0f, 1.0f, 1.0f); ++vertex; + vertex->set(1.5f, 0.50f, 0.0f, 1.0f, 1.0f, -1.0f); ++vertex; + vertex->set(1.5f, 1.00f, 0.0f, 1.0f, -1.0f, -1.0f); ++vertex; - vertex->set( 2.0f, 0.25f, 0.0f, -1.0f, 1.0f, -1.0f); ++vertex; - vertex->set( 2.0f, 0.75f, 0.0f, -1.0f, -1.0f, -1.0f); ++vertex; + vertex->set(2.0f, 0.25f, 0.0f, -1.0f, 1.0f, -1.0f); ++vertex; + vertex->set(2.0f, 0.75f, 0.0f, -1.0f, -1.0f, -1.0f); ++vertex; indices += addQuad(indices, 0, 2, 3, 1); indices += addQuad(indices, 1, 3, 6, 4); From c7bd2c5e67e86c60df55ba55142566dabc8b5d88 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Wed, 29 Oct 2014 02:07:15 +0100 Subject: [PATCH 08/16] Making imguiCube() align better. --- examples/common/imgui/imgui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index e82b4cfd..08ba528f 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -1747,7 +1747,7 @@ struct Imgui || ImguiAlign::Right == _align) { xx = area.m_widgetX; - width = area.m_widgetW-1; //TODO: -1 ! + width = area.m_widgetW; } else //if (ImguiAlign::Center == _align //|| ImguiAlign::CenterIndented == _align). @@ -1764,7 +1764,7 @@ struct Imgui const bool over = enabled && inRect(xx, yy, width, height); const bool res = buttonLogic(id, over); - const float scale = float(width/2); + const float scale = float(width/2)+0.25f; float mtx[16]; bx::mtxSRT(mtx, scale, scale, 1.0f, 0.0f, 0.0f, 0.0f, float(xx), float(yy), 0.0f); From aa6c92ff402e40aca5723a7148b9024c18d1e084 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Tue, 11 Nov 2014 02:09:39 +0100 Subject: [PATCH 09/16] Fixing inputGetChar(). --- examples/common/entry/input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/common/entry/input.cpp b/examples/common/entry/input.cpp index bd3c2bbd..49f1eb51 100644 --- a/examples/common/entry/input.cpp +++ b/examples/common/entry/input.cpp @@ -109,7 +109,7 @@ struct Keyboard popChar(); } - memcpy(&m_char[m_ring.m_write], _char, 4); + memcpy(&m_char[m_ring.m_current], _char, 4); m_ring.commit(4); } From 9cc92fd2e1dedfae839297738cf75d22293827a0 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Tue, 11 Nov 2014 02:27:13 +0100 Subject: [PATCH 10/16] Cleanup unused code. --- examples/common/entry/entry.cpp | 104 -------------------------------- examples/common/entry/entry.h | 1 - 2 files changed, 105 deletions(-) diff --git a/examples/common/entry/entry.cpp b/examples/common/entry/entry.cpp index 70a619f9..5b3941d8 100644 --- a/examples/common/entry/entry.cpp +++ b/examples/common/entry/entry.cpp @@ -156,110 +156,6 @@ namespace entry return result; } - char keyToAscii(entry::Key::Enum _key, bool _shiftModifier) - { - static const char s_keyToAscii[entry::Key::Count] = - { - '\0', // None - 0x1b, // Esc - 0x0d, // Return - 0x09, // Tab - 0x20, // Space - 0x08, // Backspace - '\0', // Up - '\0', // Down - '\0', // Left - '\0', // Right - '\0', // PageUp - '\0', // PageDown - '\0', // Home - '\0', // End - '\0', // Print - 0x3d, // Equals - 0x2d, // Minus - '\0', // F1 - '\0', // F2 - '\0', // F3 - '\0', // F4 - '\0', // F5 - '\0', // F6 - '\0', // F7 - '\0', // F8 - '\0', // F9 - '\0', // F10 - '\0', // F11 - '\0', // F12 - 0x30, // NumPad0 - 0x31, // NumPad1 - 0x32, // NumPad2 - 0x33, // NumPad3 - 0x34, // NumPad4 - 0x35, // NumPad5 - 0x36, // NumPad6 - 0x37, // NumPad7 - 0x38, // NumPad8 - 0x39, // NumPad9 - 0x30, // Key0 - 0x31, // Key1 - 0x32, // Key2 - 0x33, // Key3 - 0x34, // Key4 - 0x35, // Key5 - 0x36, // Key6 - 0x37, // Key7 - 0x38, // Key8 - 0x39, // Key9 - 0x61, // KeyA - 0x62, // KeyB - 0x63, // KeyC - 0x64, // KeyD - 0x65, // KeyE - 0x66, // KeyF - 0x67, // KeyG - 0x68, // KeyH - 0x69, // KeyI - 0x6a, // KeyJ - 0x6b, // KeyK - 0x6c, // KeyL - 0x6d, // KeyM - 0x6e, // KeyN - 0x6f, // KeyO - 0x70, // KeyP - 0x71, // KeyQ - 0x72, // KeyR - 0x73, // KeyS - 0x74, // KeyT - 0x75, // KeyU - 0x76, // KeyV - 0x77, // KeyW - 0x78, // KeyX - 0x79, // KeyY - 0x7a, // KeyZ - }; - - char ascii = s_keyToAscii[_key]; - - if (_shiftModifier) - { - // Big letters. - if (ascii >= 'a' && ascii <= 'z') - { - ascii += 'A' - 'a'; - } - // Special cases. - else if ('-' == ascii) - { - ascii = '_'; - } - else if ('=' == ascii) - { - ascii = '+'; - } - } - - return ascii; - } - bool processEvents(uint32_t& _width, uint32_t& _height, uint32_t& _debug, uint32_t& _reset, MouseState* _mouse) { s_debug = _debug; diff --git a/examples/common/entry/entry.h b/examples/common/entry/entry.h index b5325dbb..f2fc2b32 100644 --- a/examples/common/entry/entry.h +++ b/examples/common/entry/entry.h @@ -155,7 +155,6 @@ namespace entry uint8_t m_buttons[entry::MouseButton::Count]; }; - char keyToAscii(entry::Key::Enum _key, bool _shiftModifier); bool processEvents(uint32_t& _width, uint32_t& _height, uint32_t& _debug, uint32_t& _reset, MouseState* _mouse = NULL); bx::FileReaderI* getFileReader(); From 7e242aa8d2788b8261de23c51d128d88dcab97fa Mon Sep 17 00:00:00 2001 From: Branimir Karadzic Date: Tue, 11 Nov 2014 19:28:30 -0800 Subject: [PATCH 11/16] Fixed OSX tools build. --- .../glsl-optimizer/src/glsl/glcpp/glcpp-lex.c | 73 ++++++++++--------- .../glsl-optimizer/src/glsl/glcpp/glcpp-lex.l | 1 + makefile | 2 +- 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/3rdparty/glsl-optimizer/src/glsl/glcpp/glcpp-lex.c b/3rdparty/glsl-optimizer/src/glsl/glcpp/glcpp-lex.c index 80ac1669..7105a8d1 100644 --- a/3rdparty/glsl-optimizer/src/glsl/glcpp/glcpp-lex.c +++ b/3rdparty/glsl-optimizer/src/glsl/glcpp/glcpp-lex.c @@ -21,6 +21,7 @@ #include #include #include +#include /* end standard C headers. */ @@ -34,7 +35,7 @@ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. + * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 @@ -51,7 +52,7 @@ typedef uint32_t flex_uint32_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; @@ -184,7 +185,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) - + /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ @@ -246,7 +247,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -822,9 +823,9 @@ static int yy_init_globals (yyscan_t yyscanner ); /* This must go here because YYSTYPE and YYLTYPE are included * from bison output in section 1.*/ # define yylval yyg->yylval_r - + # define yylloc yyg->yylloc_r - + int glcpp_lex_init (yyscan_t* scanner); int glcpp_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); @@ -863,9 +864,9 @@ YYSTYPE * glcpp_get_lval (yyscan_t yyscanner ); void glcpp_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); YYLTYPE *glcpp_get_lloc (yyscan_t yyscanner ); - + void glcpp_set_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner ); - + /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -879,7 +880,7 @@ extern int glcpp_wrap (yyscan_t yyscanner ); #endif static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner); - + #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); #endif @@ -899,11 +900,11 @@ static int input (yyscan_t yyscanner ); #endif static void yy_push_state (int new_state ,yyscan_t yyscanner); - + static void yy_pop_state (yyscan_t yyscanner ); - + static int yy_top_state (yyscan_t yyscanner ); - + /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #ifdef __ia64__ @@ -1361,7 +1362,7 @@ YY_RULE_SETUP * While in the state we also need to explicitly * handle a few other things that may appear before the * identifier: - * + * * * Comments, (handled above with the main support for * comments). * @@ -2184,7 +2185,7 @@ static void glcpp__load_buffer_state (yyscan_t yyscanner) YY_BUFFER_STATE glcpp__create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + b = (YY_BUFFER_STATE) glcpp_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in glcpp__create_buffer()" ); @@ -2250,7 +2251,7 @@ static void glcpp__load_buffer_state (yyscan_t yyscanner) } b->yy_is_interactive = 0; - + errno = oerrno; } @@ -2356,9 +2357,9 @@ static void glcpp_ensure_buffer_stack (yyscan_t yyscanner) , yyscanner); if ( ! yyg->yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in glcpp_ensure_buffer_stack()" ); - + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + yyg->yy_buffer_stack_max = num_to_alloc; yyg->yy_buffer_stack_top = 0; return; @@ -2387,12 +2388,12 @@ static void glcpp_ensure_buffer_stack (yyscan_t yyscanner) * @param base the character buffer * @param size the size in bytes of the character buffer * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE glcpp__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) @@ -2428,7 +2429,7 @@ YY_BUFFER_STATE glcpp__scan_buffer (char * base, yy_size_t size , yyscan_t yys */ YY_BUFFER_STATE glcpp__scan_string (yyconst char * yystr , yyscan_t yyscanner) { - + return glcpp__scan_bytes(yystr,strlen(yystr) ,yyscanner); } @@ -2445,7 +2446,7 @@ YY_BUFFER_STATE glcpp__scan_bytes (yyconst char * yybytes, int _yybytes_len , char *buf; yy_size_t n; int i; - + /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; buf = (char *) glcpp_alloc(n ,yyscanner ); @@ -2553,10 +2554,10 @@ YY_EXTRA_TYPE glcpp_get_extra (yyscan_t yyscanner) int glcpp_get_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yylineno; } @@ -2566,10 +2567,10 @@ int glcpp_get_lineno (yyscan_t yyscanner) int glcpp_get_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yycolumn; } @@ -2630,8 +2631,8 @@ void glcpp_set_lineno (int line_number , yyscan_t yyscanner) /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "glcpp_set_lineno called with no buffer" , yyscanner); - + yy_fatal_error( "glcpp_set_lineno called with no buffer" , yyscanner); + yylineno = line_number; } @@ -2645,8 +2646,8 @@ void glcpp_set_column (int column_no , yyscan_t yyscanner) /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "glcpp_set_column called with no buffer" , yyscanner); - + yy_fatal_error( "glcpp_set_column called with no buffer" , yyscanner); + yycolumn = column_no; } @@ -2699,13 +2700,13 @@ YYLTYPE *glcpp_get_lloc (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yylloc; } - + void glcpp_set_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylloc = yylloc_param; } - + /* User-visible API */ /* glcpp_lex_init is special because it creates the scanner itself, so it is @@ -2753,20 +2754,20 @@ int glcpp_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals errno = EINVAL; return 1; } - + *ptr_yy_globals = (yyscan_t) glcpp_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - + if (*ptr_yy_globals == NULL){ errno = ENOMEM; return 1; } - + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - + glcpp_set_extra (yy_user_defined, *ptr_yy_globals); - + return yy_init_globals ( *ptr_yy_globals ); } diff --git a/3rdparty/glsl-optimizer/src/glsl/glcpp/glcpp-lex.l b/3rdparty/glsl-optimizer/src/glsl/glcpp/glcpp-lex.l index 8b20fabd..419f1a18 100644 --- a/3rdparty/glsl-optimizer/src/glsl/glcpp/glcpp-lex.l +++ b/3rdparty/glsl-optimizer/src/glsl/glcpp/glcpp-lex.l @@ -25,6 +25,7 @@ #include #include #include +#include #include "glcpp.h" #include "glcpp-parse.h" diff --git a/makefile b/makefile index fd03455b..4fe50a7b 100644 --- a/makefile +++ b/makefile @@ -202,7 +202,7 @@ ifeq ($(UNAME),$(filter $(UNAME),Linux Darwin)) ifeq ($(UNAME),$(filter $(UNAME),Darwin)) OS=darwin BUILD_PROJECT_DIR=gmake-osx -BUILD_OUTPUT_DIR=osx64_gcc +BUILD_OUTPUT_DIR=osx64_clang BUILD_TOOLS_CONFIG=release64 EXE= else From 4ce229b13a99bc4e7478adbab47646d0081fbafc Mon Sep 17 00:00:00 2001 From: Branimir Karadzic Date: Tue, 11 Nov 2014 20:04:20 -0800 Subject: [PATCH 12/16] Fixed unused parameter warning. --- 3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.cpp b/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.cpp index 6e738119..80fdbe9a 100644 --- a/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.cpp @@ -44,13 +44,13 @@ _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, } void -_mesa_shader_debug(struct gl_context *, GLenum, GLuint *id, +_mesa_shader_debug(struct gl_context *, GLenum, GLuint *, const char *, int) { } extern "C" void -_mesa_error_no_memory(const char *caller) +_mesa_error_no_memory(const char *) { } From e147e7b2e6490275f940632f80acbc525d1c8466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 12 Nov 2014 21:26:28 -0800 Subject: [PATCH 13/16] OVR: Added rendering without distortion. --- examples/common/entry/entry.cpp | 1 + src/ovr.cpp | 71 ++++++++++++++++++++++++++++++--- src/ovr.h | 11 +++++ src/renderer_d3d11.cpp | 4 +- src/renderer_gl.cpp | 4 +- 5 files changed, 82 insertions(+), 9 deletions(-) diff --git a/examples/common/entry/entry.cpp b/examples/common/entry/entry.cpp index 5b3941d8..e11d6aac 100644 --- a/examples/common/entry/entry.cpp +++ b/examples/common/entry/entry.cpp @@ -118,6 +118,7 @@ namespace entry { entry::Key::F3, entry::Modifier::None, 1, cmd, "graphics wireframe" }, { entry::Key::F4, entry::Modifier::None, 1, cmd, "graphics hmd" }, { entry::Key::F4, entry::Modifier::LeftShift, 1, cmd, "graphics hmdrecenter" }, + { entry::Key::F4, entry::Modifier::LeftCtrl, 1, cmd, "graphics hmddbg" }, { entry::Key::F7, entry::Modifier::None, 1, cmd, "graphics vsync" }, { entry::Key::F8, entry::Modifier::None, 1, cmd, "graphics msaa" }, { entry::Key::Print, entry::Modifier::None, 1, cmd, "graphics screenshot" }, diff --git a/src/ovr.cpp b/src/ovr.cpp index 52255fb3..f70f3e5d 100644 --- a/src/ovr.cpp +++ b/src/ovr.cpp @@ -12,6 +12,7 @@ namespace bgfx OVR::OVR() : m_hmd(NULL) , m_initialized(false) + , m_debug(false) { } @@ -39,6 +40,46 @@ namespace bgfx return false; } + if (_debug) + { + switch (_config->Header.API) + { +#if BGFX_CONFIG_RENDERER_DIRECT3D9 + case ovrRenderAPI_D3D9: + { + ovrD3D9ConfigData* data = (ovrD3D9ConfigData*)_config; + m_rtSize = data->Header.RTSize; + } + break; +#endif // BGFX_CONFIG_RENDERER_DIRECT3D9 + +#if BGFX_CONFIG_RENDERER_DIRECT3D11 + case ovrRenderAPI_D3D11: + { + ovrD3D11ConfigData* data = (ovrD3D11ConfigData*)_config; + m_rtSize = data->Header.RTSize; + } + break; +#endif // BGFX_CONFIG_RENDERER_DIRECT3D11 + +#if BGFX_CONFIG_RENDERER_OPENGL + case ovrRenderAPI_OpenGL: + { + ovrGLConfigData* data = (ovrGLConfigData*)_config; + m_rtSize = data->Header.RTSize; + } + break; +#endif // BGFX_CONFIG_RENDERER_OPENGL + + default: + BX_CHECK(false, "You should not be here!"); + break; + } + + m_debug = true; + return false; + } + if (!_debug) { m_hmd = ovrHmd_Create(0); @@ -67,6 +108,7 @@ namespace bgfx | ovrDistortionCap_Vignette | ovrDistortionCap_TimeWarp | ovrDistortionCap_Overdrive + | ovrDistortionCap_NoRestore , eyeFov , m_erd ); @@ -135,6 +177,8 @@ ovrError: ovrHmd_Destroy(m_hmd); m_hmd = NULL; } + + m_debug = false; } bool OVR::swap() @@ -197,15 +241,32 @@ ovrError: eye.pixelsPerTanAngle[0] = erd.PixelsPerTanAngleAtCenter.x; eye.pixelsPerTanAngle[1] = erd.PixelsPerTanAngleAtCenter.y; } - - _hmd.width = uint16_t(m_rtSize.w); - _hmd.height = uint16_t(m_rtSize.h); } else { - _hmd.width = 0; - _hmd.height = 0; + for (int ii = 0; ii < 2; ++ii) + { + _hmd.eye[ii].rotation[0] = 0.0f; + _hmd.eye[ii].rotation[1] = 0.0f; + _hmd.eye[ii].rotation[2] = 0.0f; + _hmd.eye[ii].rotation[3] = 1.0f; + _hmd.eye[ii].translation[0] = 0.0f; + _hmd.eye[ii].translation[1] = 0.0f; + _hmd.eye[ii].translation[2] = 0.0f; + _hmd.eye[ii].fov[0] = 1.32928634f; + _hmd.eye[ii].fov[1] = 1.32928634f; + _hmd.eye[ii].fov[2] = 0 == ii ? 1.05865765f : 1.09236801f; + _hmd.eye[ii].fov[3] = 0 == ii ? 1.09236801f : 1.05865765f; + _hmd.eye[ii].viewOffset[0] = 0 == ii ? 0.0355070010f : -0.0375000015f; + _hmd.eye[ii].viewOffset[1] = 0.0f; + _hmd.eye[ii].viewOffset[2] = 0 == ii ? 0.00150949787f : -0.00150949787f; + _hmd.eye[ii].pixelsPerTanAngle[0] = 1; + _hmd.eye[ii].pixelsPerTanAngle[1] = 1; + } } + + _hmd.width = uint16_t(m_rtSize.w); + _hmd.height = uint16_t(m_rtSize.h); } } // namespace bgfx diff --git a/src/ovr.h b/src/ovr.h index 5fc18ef6..e08da30f 100644 --- a/src/ovr.h +++ b/src/ovr.h @@ -44,6 +44,11 @@ namespace bgfx return NULL != m_hmd; } + bool isDebug() const + { + return m_debug; + } + void init(); void shutdown(); @@ -68,6 +73,7 @@ namespace bgfx ovrSizei m_rtSize; bool m_warning; bool m_initialized; + bool m_debug; }; } // namespace bgfx @@ -104,6 +110,11 @@ namespace bgfx return false; } + bool isDebug() const + { + return false; + } + bool swap() { return false; diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 288dfcdb..e935f8c4 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -1833,9 +1833,9 @@ RENDERDOC_IMPORT void ovrPreReset() { #if BGFX_CONFIG_USE_OVR + m_ovr.preReset(); if (NULL != m_ovrRtv) { - m_ovr.preReset(); std::swap(m_ovrRtv, m_backBufferColor); std::swap(m_ovrDsv, m_backBufferDepthStencil); BX_CHECK(NULL == m_backBufferDepthStencil, ""); @@ -2952,7 +2952,7 @@ RENDERDOC_IMPORT Matrix4* mtxView[2] = { _render->m_view, mtxViewTmp[1] }; Matrix4 mtxViewProj[2][BGFX_CONFIG_MAX_VIEWS]; - const bool hmdEnabled = m_ovr.isEnabled(); + const bool hmdEnabled = m_ovr.isEnabled() || m_ovr.isDebug(); _render->m_hmdEnabled = hmdEnabled; if (hmdEnabled) diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index d988eeea..ae9bae09 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -2017,9 +2017,9 @@ namespace bgfx void ovrPreReset() { #if BGFX_CONFIG_USE_OVR + m_ovr.preReset(); if (m_ovr.isEnabled() ) { - m_ovr.preReset(); GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0) ); GL_CHECK(glDeleteFramebuffers(1, &m_msaaBackBufferFbo) ); m_msaaBackBufferFbo = m_ovrFbo; @@ -4121,7 +4121,7 @@ namespace bgfx Matrix4* mtxView[2] = { _render->m_view, mtxViewTmp[1] }; Matrix4 mtxViewProj[2][BGFX_CONFIG_MAX_VIEWS]; - const bool hmdEnabled = m_ovr.isEnabled(); + const bool hmdEnabled = m_ovr.isEnabled() || m_ovr.isDebug(); _render->m_hmdEnabled = hmdEnabled; if (hmdEnabled) From 545978d661698b881c1cccbc3b429d1ab4e97dc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 12 Nov 2014 22:16:19 -0800 Subject: [PATCH 14/16] Cleanup. --- examples/common/entry/input.cpp | 6 +++++- src/bgfx_p.h | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/common/entry/input.cpp b/examples/common/entry/input.cpp index 49f1eb51..543100be 100644 --- a/examples/common/entry/input.cpp +++ b/examples/common/entry/input.cpp @@ -157,7 +157,11 @@ struct Input void removeBindings(const char* _name) { - m_inputBindingsMap.erase(m_inputBindingsMap.find(_name)); + InputBindingMap::iterator it = m_inputBindingsMap.find(_name); + if (it != m_inputBindingsMap.end() ) + { + m_inputBindingsMap.erase(it); + } } void process(const InputBinding* _bindings) diff --git a/src/bgfx_p.h b/src/bgfx_p.h index da52055b..9de97a3d 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -2223,7 +2223,12 @@ namespace bgfx && BGFX_CHUNK_MAGIC_FSH != magic && BGFX_CHUNK_MAGIC_VSH != magic) { - BX_WARN(false, "Invalid shader signature! 0x%08x.", magic); + BX_WARN(false, "Invalid shader signature! %c%c%c%d." + , ( (uint8_t*)&magic)[0] + , ( (uint8_t*)&magic)[1] + , ( (uint8_t*)&magic)[2] + , ( (uint8_t*)&magic)[3] + ); ShaderHandle invalid = BGFX_INVALID_HANDLE; return invalid; } From 49286969675e5a133ed645cc0d06141bcdf3e474 Mon Sep 17 00:00:00 2001 From: Branimir Karadzic Date: Thu, 13 Nov 2014 13:31:46 -0800 Subject: [PATCH 15/16] Updated .editorconfig. --- .editorconfig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.editorconfig b/.editorconfig index 9e3e77c8..b13d9958 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,10 +1,10 @@ [*] indent_style = tab indent_size = 4 -end_of_line = LF +end_of_line = lf max_line_length = 100 - -insert_final_newline = true - -[{*.c, *.cpp, *.sc, *.sh, *.lua, *.m, *.mm, *.mk, makefile}] +insert_final_newline = true trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false From 8e578b3d3723de58b83906986141e9792889a5ed Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Fri, 14 Nov 2014 11:26:54 +0100 Subject: [PATCH 16/16] Fixing imgui mouse scroll. --- examples/common/imgui/imgui.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index 08ba528f..33dd7915 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -911,14 +911,23 @@ struct Imgui const float barHeight = (float)height / (float)sh; - const int32_t diff = height - sh; - if (diff < 0) + // Handle mouse scrolling. + if (area.m_inside && !anyActive() ) { - *area.m_scrollVal = (*area.m_scrollVal > diff) ? *area.m_scrollVal : diff; - } - else - { - *area.m_scrollVal = 0; + const int32_t min = height - sh; + if (min > 0) + { + *area.m_scrollVal = 0; + } + else if (m_scroll) + { + const int32_t val = *area.m_scrollVal + 20*m_scroll; + const int32_t max = 0; + *area.m_scrollVal = ( val > max ? max + : val < min ? min + : val + ); + } } if (barHeight < 1.0f) @@ -1017,15 +1026,6 @@ struct Imgui ); } } - - // Handle mouse scrolling. - if (area.m_inside) // && !anyActive() ) - { - if (m_scroll) - { - *area.m_scrollVal += bx::uint32_clamp(20 * m_scroll, 0, sh - height); - } - } } area.m_inside = false;