From fae41ff29c3932ab8db60a27b77e2ec5ab61ec1b Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 15 Oct 2018 21:26:43 -1000 Subject: [PATCH] Mechanism for handling device-coordinate transformation --- specter/include/specter/Button.hpp | 2 +- specter/include/specter/SplitView.hpp | 2 +- specter/include/specter/TextField.hpp | 2 +- specter/include/specter/View.hpp | 9 ++++++++- specter/lib/ModalWindow.cpp | 2 +- specter/lib/RootView.cpp | 4 ++-- specter/lib/SplitView.cpp | 2 +- specter/lib/Toolbar.cpp | 2 +- specter/lib/Tooltip.cpp | 2 +- specter/lib/View.cpp | 14 ++++++++++++-- specter/shaders/SpecterTextViewShaders.shader | 1 - specter/shaders/SpecterViewShaders.shader | 2 -- 12 files changed, 29 insertions(+), 15 deletions(-) diff --git a/specter/include/specter/Button.hpp b/specter/include/specter/Button.hpp index 620ea588e..204cfb4ee 100644 --- a/specter/include/specter/Button.hpp +++ b/specter/include/specter/Button.hpp @@ -122,7 +122,7 @@ public: View::setMultiplyColor(color); m_viewVertBlock.m_color = color; if (m_viewVertBlockBuf) - m_viewVertBlockBuf.access() = m_viewVertBlock; + m_viewVertBlockBuf.access().finalAssign(m_viewVertBlock); m_text->setMultiplyColor(color); if (m_icon) m_icon->setMultiplyColor(color); diff --git a/specter/include/specter/SplitView.hpp b/specter/include/specter/SplitView.hpp index 061790392..2e42ee981 100644 --- a/specter/include/specter/SplitView.hpp +++ b/specter/include/specter/SplitView.hpp @@ -104,7 +104,7 @@ public: { View::setMultiplyColor(color); m_splitBlock.m_color = color; - m_splitBlockBuf.access() = m_splitBlock; + m_splitBlockBuf.access().finalAssign(m_splitBlock); if (m_views[0].m_view) m_views[0].m_view->setMultiplyColor(color); diff --git a/specter/include/specter/TextField.hpp b/specter/include/specter/TextField.hpp index 5f1190cb1..e28c7adc4 100644 --- a/specter/include/specter/TextField.hpp +++ b/specter/include/specter/TextField.hpp @@ -117,7 +117,7 @@ public: View::setMultiplyColor(color); m_viewVertBlock.m_color = color; if (m_viewVertBlockBuf) - m_viewVertBlockBuf.access() = m_viewVertBlock; + m_viewVertBlockBuf.access().finalAssign(m_viewVertBlock); m_text->setMultiplyColor(color); if (m_errText) m_errText->setMultiplyColor(color); diff --git a/specter/include/specter/View.hpp b/specter/include/specter/View.hpp index 250df89cb..c98e39b29 100644 --- a/specter/include/specter/View.hpp +++ b/specter/include/specter/View.hpp @@ -16,6 +16,8 @@ class IThemeData; class ViewResources; class RootView; +extern zeus::CMatrix4f g_PlatformMatrix; + class RectangleConstraint { public: @@ -101,6 +103,11 @@ public: m_mv[3][0] = sub.location[0] * m_mv[0][0] - 1.0f; m_mv[3][1] = sub.location[1] * m_mv[1][1] - 1.0f; } + void finalAssign(const ViewBlock& other) + { + m_mv = g_PlatformMatrix * other.m_mv; + m_color = other.m_color; + } }; template @@ -222,7 +229,7 @@ public: { m_viewVertBlock.m_color = color; if (m_viewVertBlockBuf) - m_viewVertBlockBuf.access() = m_viewVertBlock; + m_viewVertBlockBuf.access().finalAssign(m_viewVertBlock); } virtual int nominalWidth() const {return 0;} diff --git a/specter/lib/ModalWindow.cpp b/specter/lib/ModalWindow.cpp index 476310d22..0e072b589 100644 --- a/specter/lib/ModalWindow.cpp +++ b/specter/lib/ModalWindow.cpp @@ -453,7 +453,7 @@ void ModalWindow::resized(const boo::SWindowRect& root, const boo::SWindowRect& centerRect.location[1] = root.size[1] / 2 - m_height / 2.0; View::resized(root, centerRect); m_viewBlock.setViewRect(root, centerRect); - m_viewBlockBuf.access() = m_viewBlock; + m_viewBlockBuf.access().finalAssign(m_viewBlock); setLineVerts(m_width, m_height, pf, m_lineTime); setFillVerts(m_width, m_height, pf); diff --git a/specter/lib/RootView.cpp b/specter/lib/RootView.cpp index d7dad8315..c27d64901 100644 --- a/specter/lib/RootView.cpp +++ b/specter/lib/RootView.cpp @@ -111,7 +111,7 @@ void RootView::SplitMenuSystem::setArrowVerts(const boo::SWindowRect& rect, Spli m_viewBlock.m_mv[3][1] = 2.0f * (rect.location[1] + (dir == SplitView::ArrowDir::Down ? rect.size[1] : 0)) / float(root.size[1]) - 1.0f; } - m_viewVertBlockBuf.access() = m_viewBlock; + m_viewVertBlockBuf.access().finalAssign(m_viewBlock); } void RootView::SplitMenuSystem::setLineVerts(const boo::SWindowRect& rect, float split, SplitView::Axis axis) @@ -135,7 +135,7 @@ void RootView::SplitMenuSystem::setLineVerts(const boo::SWindowRect& rect, float m_viewBlock.m_mv[3][0] = (rect.location[0] + split * rect.size[0]) * m_viewBlock.m_mv[0][0] - 1.0f; m_viewBlock.m_mv[3][1] = 2.0f * (rect.location[1] + rect.size[1] / 2.0f) / float(root.size[1]) - 1.0f; } - m_viewVertBlockBuf.access() = m_viewBlock; + m_viewVertBlockBuf.access().finalAssign(m_viewBlock); } void RootView::destroyed() diff --git a/specter/lib/SplitView.cpp b/specter/lib/SplitView.cpp index 5ad014d36..237b40226 100644 --- a/specter/lib/SplitView.cpp +++ b/specter/lib/SplitView.cpp @@ -476,7 +476,7 @@ void SplitView::resized(const boo::SWindowRect& root, const boo::SWindowRect& su m_splitBlock.setViewRect(root, ssub); setVerticalVerts(ssub.size[1]); } - m_splitBlockBuf.access() = m_splitBlock; + m_splitBlockBuf.access().finalAssign(m_splitBlock); m_splitVertsBinding.load(m_splitVerts); } diff --git a/specter/lib/Toolbar.cpp b/specter/lib/Toolbar.cpp index 7548e43d4..d0b6e82ad 100644 --- a/specter/lib/Toolbar.cpp +++ b/specter/lib/Toolbar.cpp @@ -140,7 +140,7 @@ void Toolbar::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub) setHorizontalVerts(sub.size[0]); m_vertsBinding.load(m_tbVerts); m_tbBlock.setViewRect(root, sub); - m_tbBlockBuf.access() = m_tbBlock; + m_tbBlockBuf.access().finalAssign(m_tbBlock); float gaugeUnit = rootView().viewRes().pixelFactor() * SPECTER_TOOLBAR_GAUGE; float yOff = 0.0; diff --git a/specter/lib/Tooltip.cpp b/specter/lib/Tooltip.cpp index d723ac9b1..80f215e48 100644 --- a/specter/lib/Tooltip.cpp +++ b/specter/lib/Tooltip.cpp @@ -84,7 +84,7 @@ void Tooltip::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub) float pf = rootView().viewRes().pixelFactor(); setVerts(m_nomWidth, m_nomHeight, pf); m_ttBlock.setViewRect(root, sub); - m_ttBlockBuf.access() = m_ttBlock; + m_ttBlockBuf.access().finalAssign(m_ttBlock); std::pair margin = m_cornersFilled[0]->queryGlyphDimensions(0); diff --git a/specter/lib/View.cpp b/specter/lib/View.cpp index 19de26055..50a53dfed 100644 --- a/specter/lib/View.cpp +++ b/specter/lib/View.cpp @@ -7,8 +7,18 @@ namespace specter { static logvisor::Module Log("specter::View"); +zeus::CMatrix4f g_PlatformMatrix; + void View::Resources::init(boo::IGraphicsDataFactory::Context& ctx, const IThemeData& theme) { + switch (ctx.platform()) + { + case boo::IGraphicsDataFactory::Platform::Vulkan: + g_PlatformMatrix.m[1][1] = -1.f; + break; + default: + break; + } m_solidShader = hecl::conv->convert(ctx, Shader_SpecterViewShaderSolid{}); m_texShader = hecl::conv->convert(ctx, Shader_SpecterViewShaderTex{}); } @@ -41,7 +51,7 @@ void View::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub) m_bgRect[2].m_pos.assign(sub.size[0], sub.size[1], 0.f); m_bgRect[3].m_pos.assign(sub.size[0], 0.f, 0.f); if (m_viewVertBlockBuf) - m_viewVertBlockBuf.access() = m_viewVertBlock; + m_viewVertBlockBuf.access().finalAssign(m_viewVertBlock); m_bgVertsBinding.load(m_bgRect); } @@ -53,7 +63,7 @@ void View::resized(const ViewBlock& vb, const boo::SWindowRect& sub) m_bgRect[2].m_pos.assign(sub.size[0], sub.size[1], 0.f); m_bgRect[3].m_pos.assign(sub.size[0], 0.f, 0.f); if (m_viewVertBlockBuf) - m_viewVertBlockBuf.access() = vb; + m_viewVertBlockBuf.access().finalAssign(vb); m_bgVertsBinding.load(m_bgRect); } diff --git a/specter/shaders/SpecterTextViewShaders.shader b/specter/shaders/SpecterTextViewShaders.shader index 7302cc2f6..35951c9b7 100644 --- a/specter/shaders/SpecterTextViewShaders.shader +++ b/specter/shaders/SpecterTextViewShaders.shader @@ -39,7 +39,6 @@ void main() vtf.uv = uvIn[gl_VertexID]; vtf.color = colorIn * mulColor; gl_Position = mv * mvMtx * vec4(pos, 1.0); - gl_Position = FLIPFROMGL(gl_Position); } #fragment glsl diff --git a/specter/shaders/SpecterViewShaders.shader b/specter/shaders/SpecterViewShaders.shader index aa86e3bd1..0fdda5fbb 100644 --- a/specter/shaders/SpecterViewShaders.shader +++ b/specter/shaders/SpecterViewShaders.shader @@ -23,7 +23,6 @@ void main() { vtf.color = colorIn * mulColor; gl_Position = mv * vec4(posIn, 1.0); - gl_Position = FLIPFROMGL(gl_Position); } #fragment glsl @@ -125,7 +124,6 @@ void main() vtf.uv.xy = uvIn; vtf.color = mulColor; gl_Position = mv * vec4(posIn, 1.0); - gl_Position = FLIPFROMGL(gl_Position); } #fragment glsl