From 53ad4df63d85b8f35d5feaba360c3439e9cbc43c Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Wed, 30 Dec 2015 20:34:26 -1000 Subject: [PATCH] D3D Scissor fix and Scroll events --- lib/graphicsdev/D3D11.cpp | 10 +++++++--- lib/graphicsdev/D3D12.cpp | 8 ++++++-- lib/win/ApplicationWin32.cpp | 1 + lib/win/WindowWin32.cpp | 20 ++++++++++++++++++++ 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/lib/graphicsdev/D3D11.cpp b/lib/graphicsdev/D3D11.cpp index efcf9c6..ef0acea 100644 --- a/lib/graphicsdev/D3D11.cpp +++ b/lib/graphicsdev/D3D11.cpp @@ -435,7 +435,7 @@ class D3D11ShaderPipeline : public IShaderPipeline CD3D11_RASTERIZER_DESC rasDesc(D3D11_FILL_SOLID, backfaceCulling ? D3D11_CULL_BACK : D3D11_CULL_NONE, true, D3D11_DEFAULT_DEPTH_BIAS, D3D11_DEFAULT_DEPTH_BIAS_CLAMP, D3D11_DEFAULT_SLOPE_SCALED_DEPTH_BIAS, - true, false, false, false); + true, true, false, false); ThrowIfFailed(ctx->m_dev->CreateRasterizerState(&rasDesc, &m_rasState)); CD3D11_DEPTH_STENCIL_DESC dsDesc(D3D11_DEFAULT); @@ -783,8 +783,12 @@ struct D3D11CommandQueue : IGraphicsCommandQueue void setScissor(const SWindowRect& rect) { - D3D11_RECT d3drect = {rect.location[0], rect.location[1], rect.size[0], rect.size[1]}; - m_deferredCtx->RSSetScissorRects(1, &d3drect); + if (m_boundTarget) + { + D3D11_RECT d3drect = {LONG(rect.location[0]), LONG(m_boundTarget->m_height - rect.location[1] - rect.size[1]), + LONG(rect.location[0] + rect.size[0]), LONG(m_boundTarget->m_height - rect.location[1])}; + m_deferredCtx->RSSetScissorRects(1, &d3drect); + } } std::unordered_map> m_texResizes; diff --git a/lib/graphicsdev/D3D12.cpp b/lib/graphicsdev/D3D12.cpp index 7097c19..a71289d 100644 --- a/lib/graphicsdev/D3D12.cpp +++ b/lib/graphicsdev/D3D12.cpp @@ -1047,8 +1047,12 @@ struct D3D12CommandQueue : IGraphicsCommandQueue void setScissor(const SWindowRect& rect) { - D3D12_RECT d3drect = {rect.location[0], rect.location[1], rect.size[0], rect.size[1]}; - m_cmdList->RSSetScissorRects(1, &d3drect); + if (m_boundTarget) + { + D3D12_RECT d3drect = {LONG(rect.location[0]), LONG(m_boundTarget->m_height - rect.location[1] - rect.size[1]), + LONG(rect.location[0] + rect.size[0]), LONG(m_boundTarget->m_height - rect.location[1])}; + m_cmdList->RSSetScissorRects(1, &d3drect); + } } std::unordered_map> m_texResizes; diff --git a/lib/win/ApplicationWin32.cpp b/lib/win/ApplicationWin32.cpp index 2db144f..63646a5 100644 --- a/lib/win/ApplicationWin32.cpp +++ b/lib/win/ApplicationWin32.cpp @@ -267,6 +267,7 @@ public: case WM_NCMOUSELEAVE: case WM_MOUSEHOVER: case WM_NCMOUSEHOVER: + case WM_MOUSEWHEEL: case WM_CHAR: case WM_UNICHAR: window->_incomingEvent(&HWNDEvent(uMsg, wParam, lParam)); diff --git a/lib/win/WindowWin32.cpp b/lib/win/WindowWin32.cpp index 9ebaeaf..4766cf1 100644 --- a/lib/win/WindowWin32.cpp +++ b/lib/win/WindowWin32.cpp @@ -1170,6 +1170,26 @@ public: } return; } + case WM_MOUSEWHEEL: + { + if (m_callback) + { + int x, y, w, h; + getWindowFrame(x, y, w, h); + SWindowCoord coord = + { + { GET_X_LPARAM(e.lParam), h-GET_Y_LPARAM(e.lParam) }, + { GET_X_LPARAM(e.lParam), h-GET_Y_LPARAM(e.lParam) }, + { float(GET_X_LPARAM(e.lParam)) / float(w), float(h-GET_Y_LPARAM(e.lParam)) / float(h) } + }; + SScrollDelta scroll = + { + { 0, GET_WHEEL_DELTA_WPARAM(e.wParam) / double(WHEEL_DELTA) }, false + }; + m_callback->scroll(coord, scroll); + } + return; + } case WM_CHAR: case WM_UNICHAR: {