From f9da039e14c1821c5041ccb7682360fb76efcb94 Mon Sep 17 00:00:00 2001 From: turanszkij Date: Fri, 16 Sep 2016 00:56:03 +0200 Subject: [PATCH] screenprojection helper in device --- WickedEngine/wiFont.cpp | 2 +- WickedEngine/wiGraphicsDevice.h | 5 +++++ WickedEngine/wiImage.cpp | 2 +- WickedEngine/wiVersion.cpp | 2 +- WickedEngine/wiWidget.cpp | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/WickedEngine/wiFont.cpp b/WickedEngine/wiFont.cpp index bab0aadd9..7463581ba 100644 --- a/WickedEngine/wiFont.cpp +++ b/WickedEngine/wiFont.cpp @@ -304,7 +304,7 @@ void wiFont::Draw(GRAPHICSTHREAD threadID, bool scissorTest){ ConstantBuffer cb; cb.mTransform = XMMatrixTranspose( XMMatrixTranslation(newProps.posX, newProps.posY, 0) - * XMMatrixOrthographicOffCenterLH(0, (float)device->GetScreenWidth(), (float)device->GetScreenHeight(), 0, -1, 1) + * device->GetScreenProjection() ); device->UpdateBuffer(constantBuffer,&cb,threadID); diff --git a/WickedEngine/wiGraphicsDevice.h b/WickedEngine/wiGraphicsDevice.h index 8a2906310..429d83e33 100644 --- a/WickedEngine/wiGraphicsDevice.h +++ b/WickedEngine/wiGraphicsDevice.h @@ -68,6 +68,11 @@ namespace wiGraphicsTypes }; virtual bool CheckCapability(GRAPHICSDEVICE_CAPABILITY capability) = 0; + XMMATRIX GetScreenProjection() + { + return XMMatrixOrthographicOffCenterLH(0, (float)GetScreenWidth(), (float)GetScreenHeight(), 0, -1, 1); + } + ///////////////Thread-sensitive//////////////////////// virtual void BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0; diff --git a/WickedEngine/wiImage.cpp b/WickedEngine/wiImage.cpp index f03fdd8a8..9b6b91fb9 100644 --- a/WickedEngine/wiImage.cpp +++ b/WickedEngine/wiImage.cpp @@ -280,7 +280,7 @@ void wiImage::Draw(Texture2D* texture, const wiImageEffects& effects,GRAPHICSTHR XMMatrixScaling(effects.scale.x*effects.siz.x, effects.scale.y*effects.siz.y, 1) * XMMatrixRotationZ(effects.rotation) * XMMatrixTranslation(effects.pos.x, effects.pos.y, 0) - * XMMatrixOrthographicOffCenterLH(0, (float)device->GetScreenWidth(), (float)device->GetScreenHeight(), 0, -1, 1) + * device->GetScreenProjection() ); } else if(effects.typeFlag==WORLD){ diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 4b2ea61d4..fa712ea5a 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -7,7 +7,7 @@ namespace wiVersion // minor features, major bug fixes const int minor = 8; // minor bug fixes, alterations, refactors - const int revision = 48; + const int revision = 49; long GetVersion() diff --git a/WickedEngine/wiWidget.cpp b/WickedEngine/wiWidget.cpp index 37c595448..a8c868bfa 100644 --- a/WickedEngine/wiWidget.cpp +++ b/WickedEngine/wiWidget.cpp @@ -1116,7 +1116,7 @@ void wiColorPicker::Render(wiGUI* gui) } - XMMATRIX __cam = XMMatrixOrthographicOffCenterLH(0, (float)wiRenderer::GetDevice()->GetScreenWidth(), (float)wiRenderer::GetDevice()->GetScreenHeight(), 0, -1, 1); + XMMATRIX __cam = wiRenderer::GetDevice()->GetScreenProjection(); wiRenderer::GetDevice()->BindConstantBufferVS(wiRenderer::constantBuffers[CBTYPE_MISC], CBSLOT_RENDERER_MISC, threadID); wiRenderer::GetDevice()->BindRasterizerState(wiRenderer::rasterizers[RSTYPE_DOUBLESIDED], threadID);