diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index 8cb80fe2..381b12cf 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -159,7 +159,7 @@ namespace Oyster Render::Gui::Begin2DRender(); } - void API::RenderGuiElement(API::Texture tex, Math::Float2 pos, Math::Float2 size, Math::Float3 color) + void API::RenderGuiElement(API::Texture tex, Math::Float3 pos, Math::Float2 size, Math::Float3 color) { Render::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size,color); } @@ -192,9 +192,9 @@ namespace Oyster Render::Gui::Begin2DTextRender(); } - void API::RenderText(std::wstring text, Math::Float2 Pos, Math::Float2 Size, Math::Float3 color) + void API::RenderText(std::wstring text, Math::Float3 Pos, Math::Float2 Size, float FontSize, Math::Float3 color) { - Render::Gui::RenderText(text,Pos,Size,color); + Render::Gui::RenderText(text, Pos, Size, FontSize, color); } } } \ No newline at end of file diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.h b/Code/OysterGraphics/DllInterfaces/GFXAPI.h index bdf70072..e2cea318 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.h +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.h @@ -57,13 +57,13 @@ namespace Oyster static void StartGuiRender(); //! @brief Renders a single GUI element using the texture provided and the Pos in the center, %based system - static void RenderGuiElement(Texture, Math::Float2 Pos, Math::Float2 Size, Math::Float3 Color = Math::Float3(1,1,1)); + static void RenderGuiElement(Texture, Math::Float3 Pos, Math::Float2 Size, Math::Float3 Color = Math::Float3(1,1,1)); //! @brief Configures Renderer to process 2D Text, data will be passed in to EndFrame() static void StartTextRender(); //! @brief Renders a single GUI string using the texture provided and the Pos in the center, %based system - static void RenderText(std::wstring, Math::Float2 Pos, Math::Float2 Size, Math::Float3 Color = Math::Float3(1,1,1)); + static void RenderText(std::wstring, Math::Float3 Pos, Math::Float2 Size, float FontSize, Math::Float3 Color = Math::Float3(1,1,1)); //! @brief Performs light calculations, post effects and presents the scene static void EndFrame(); diff --git a/Code/OysterGraphics/Render/GuiRenderer.cpp b/Code/OysterGraphics/Render/GuiRenderer.cpp index 7f3285e1..78b2f771 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.cpp +++ b/Code/OysterGraphics/Render/GuiRenderer.cpp @@ -16,7 +16,7 @@ namespace Oyster Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass); } - void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float2 pos, Math::Float2 size, Math::Float3 color) + void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float3 pos, Math::Float2 size, Math::Float3 color) { Core::deviceContext->PSSetShaderResources(0,1,&tex); @@ -28,6 +28,7 @@ namespace Oyster gd.Translation = Math::Matrix::identity; gd.Translation.m41 = pos.x; gd.Translation.m42 = pos.y; + gd.Translation.m43 = pos.z; gd.Translation.m11 = size.x; gd.Translation.m22 = size.y; @@ -49,10 +50,10 @@ namespace Oyster Core::PipelineManager::SetRenderPass(Resources::Gui::Text::Pass); } - void Gui::RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size, Math::Float3 color) + void Gui::RenderText(std::wstring text, Math::Float3 pos, Math::Float2 size, float FontSize, Math::Float3 color) { - size.x = size.x / (text.length() * TEXT_SPACING /2); + //size.x = size.x / (text.length() * TEXT_SPACING /2); pos *= 2; @@ -60,15 +61,18 @@ namespace Oyster pos.y *= -1; - pos.x = pos.x - (size.x * (text.length()-1) * TEXT_SPACING /2); + //pos.x = pos.x - (size.x * (text.length()-1) * TEXT_SPACING /2); + pos.x = pos.x + size.x/ (text.length() * TEXT_SPACING/2); + pos.y = pos.y - size.y/2; Definitions::GuiData gd; 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; + gd.Translation.m43 = pos.z; + gd.Translation.m11 = FontSize * 0.8f; + gd.Translation.m22 = FontSize; void* data = Render::Resources::Gui::Data.Map(); @@ -82,19 +86,20 @@ namespace Oyster void* dest = Resources::Gui::Text::Vertex.Map(); Definitions::Text2D* dataView = reinterpret_cast(dest); - //tmpInst.charOffset=_pos; + for (unsigned int i=0; i size.x) + { + text = text.substr(0,i-1); + break; + } dataView[i]=tmpInst; } - //TextInstances[_id].NumLetters=instances; + Resources::Gui::Text::Vertex.Unmap(); diff --git a/Code/OysterGraphics/Render/GuiRenderer.h b/Code/OysterGraphics/Render/GuiRenderer.h index f5513d2f..3e4a8de0 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.h +++ b/Code/OysterGraphics/Render/GuiRenderer.h @@ -12,9 +12,9 @@ namespace Oyster { public: static void Begin2DRender(); - static void Render(ID3D11ShaderResourceView* tex, Math::Float2 pos, Math::Float2 size, Math::Float3 tint = Math::Float3(1,1,1)); + static void Render(ID3D11ShaderResourceView* tex, Math::Float3 pos, Math::Float2 size, Math::Float3 tint = Math::Float3(1,1,1)); static void Begin2DTextRender(); - static void RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size, Math::Float3 tint = Math::Float3(1,1,1)); + static void RenderText(std::wstring text, Math::Float3 pos, Math::Float2 size, float FontSize, Math::Float3 tint = Math::Float3(1,1,1)); }; } } diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index f0d440d6..ad71dabb 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -246,7 +246,7 @@ HRESULT Render(float deltaTime) fps = std::to_wstring(f); //Oyster::Graphics::API::RenderText(L"Lanariel",Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f)); //Oyster::Graphics::API::RenderText(L"Lanariel WAS HERE",Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f)); - Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float3(0,1,0)); + Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float3(0.5f,0.1f,1.0f),Oyster::Math::Float2(0.5f,0.1f), 0.08f, Oyster::Math::Float3(0,1,0)); Oyster::Graphics::API::EndFrame(); return S_OK;