From d9133f459a57a32804fad5a7f4a9d1bbe8f1a2af Mon Sep 17 00:00:00 2001 From: lanariel Date: Fri, 7 Feb 2014 13:47:09 +0100 Subject: [PATCH] 2d Almost working --- Code/OysterGraphics/DllInterfaces/GFXAPI.cpp | 2 +- .../Render/Rendering/GuiRender.cpp | 39 +++++++++---------- .../Render/Rendering/GuiRender.h | 2 +- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index ff1c632b..36b8653f 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -163,7 +163,7 @@ namespace Oyster void API::RenderGuiElement(API::Texture tex, Math::Float2 pos, Math::Float2 size) { - Render::Rendering::Gui::Render((ID3D11Texture2D*)tex,pos,size); + Render::Rendering::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size); } API::Texture API::CreateTexture(std::wstring filename) diff --git a/Code/OysterGraphics/Render/Rendering/GuiRender.cpp b/Code/OysterGraphics/Render/Rendering/GuiRender.cpp index 923f7123..f347daf2 100644 --- a/Code/OysterGraphics/Render/Rendering/GuiRender.cpp +++ b/Code/OysterGraphics/Render/Rendering/GuiRender.cpp @@ -1,4 +1,6 @@ #include "GuiRender.h" +#include "../Resources/Deffered.h" +#include "../../Definitions/GraphicalDefinition.h" namespace Oyster { @@ -12,31 +14,28 @@ namespace Oyster { } - void Gui::Render(ID3D11Texture2D* tex,Math::Float2 pos, Math::Float2 size) + void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float2 pos, Math::Float2 size) { - //Oyster::Core::DeviceContext->PSSetShaderResources(0,1,&srv); + Core::deviceContext->PSSetShaderResources(0,1,&tex); - //Pos.x -= instance.sizeX/2; - //Pos.x += size.x/2; + pos *= 2; + pos -= 1; + pos.y *= -1; - //Pos.y -= instance.sizeY/2; - //Pos.y += size.y/2; + Definitions::GuiData gd; - //Matrix m; - //m = Math::Matrix::identity; - //float width = (1.0f/(instance.sizeX/2.0f)); - //float height = (1.0f/(instance.sizeY/2.0f)); - //m.m41=Pos.x * width; - //m.m42=-Pos.y * height; - //m.m43=Pos.z; - //m.m11=width*size.x/2; - //m.m22=height*size.y/2; - - //void* dest = Resources::Buffers::CBufferGs.Map(); - //memcpy(dest,&m.GetTranspose(),64); - //Resources::Buffers::CBufferGs.Unmap(); + gd.Translation = Math::Matrix::identity; + gd.Translation.m41 = pos.x; + gd.Translation.m42 = pos.y; + gd.Translation.m11 = size.x; + gd.Translation.m22 = size.y; - //Oyster::Core::DeviceContext->Draw(1,0); + + void* data = Render::Resources::Deffered::GuiData.Map(); + memcpy(data,&gd,sizeof(gd)); + Render::Resources::Deffered::GuiData.Unmap(); + + Core::deviceContext->Draw(1,0); } } } diff --git a/Code/OysterGraphics/Render/Rendering/GuiRender.h b/Code/OysterGraphics/Render/Rendering/GuiRender.h index 1d343f32..d7e25dd7 100644 --- a/Code/OysterGraphics/Render/Rendering/GuiRender.h +++ b/Code/OysterGraphics/Render/Rendering/GuiRender.h @@ -14,7 +14,7 @@ namespace Oyster { public: static void BeginRender(); - static void Render(ID3D11Texture2D* tex, Math::Float2 pos, Math::Float2 size); + static void Render(ID3D11ShaderResourceView* tex, Math::Float2 pos, Math::Float2 size); }; } }