Colored Text and Tinted Gui elements
This commit is contained in:
parent
ebf313ccd6
commit
f92bed35f5
|
@ -158,9 +158,9 @@ namespace Oyster
|
||||||
Render::Gui::Begin2DRender();
|
Render::Gui::Begin2DRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
void API::RenderGuiElement(API::Texture tex, Math::Float2 pos, Math::Float2 size)
|
void API::RenderGuiElement(API::Texture tex, Math::Float2 pos, Math::Float2 size, Math::Float3 color)
|
||||||
{
|
{
|
||||||
Render::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size);
|
Render::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size,color);
|
||||||
}
|
}
|
||||||
|
|
||||||
API::Texture API::CreateTexture(std::wstring filename)
|
API::Texture API::CreateTexture(std::wstring filename)
|
||||||
|
@ -191,9 +191,9 @@ namespace Oyster
|
||||||
Render::Gui::Begin2DTextRender();
|
Render::Gui::Begin2DTextRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
void API::RenderText(std::wstring text, Math::Float2 Pos, Math::Float2 Size)
|
void API::RenderText(std::wstring text, Math::Float2 Pos, Math::Float2 Size, Math::Float3 color)
|
||||||
{
|
{
|
||||||
Render::Gui::RenderText(text,Pos,Size);
|
Render::Gui::RenderText(text,Pos,Size,color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -57,13 +57,13 @@ namespace Oyster
|
||||||
static void StartGuiRender();
|
static void StartGuiRender();
|
||||||
|
|
||||||
//! @brief Renders a single GUI element using the texture provided and the Pos in the center, %based system
|
//! @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);
|
static void RenderGuiElement(Texture, Math::Float2 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()
|
//! @brief Configures Renderer to process 2D Text, data will be passed in to EndFrame()
|
||||||
static void StartTextRender();
|
static void StartTextRender();
|
||||||
|
|
||||||
//! @brief Renders a single GUI string using the texture provided and the Pos in the center, %based system
|
//! @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);
|
static void RenderText(std::wstring, Math::Float2 Pos, Math::Float2 Size, Math::Float3 Color = Math::Float3(1,1,1));
|
||||||
|
|
||||||
//! @brief Performs light calculations, post effects and presents the scene
|
//! @brief Performs light calculations, post effects and presents the scene
|
||||||
static void EndFrame();
|
static void EndFrame();
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Oyster
|
||||||
Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass);
|
Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float2 pos, Math::Float2 size)
|
void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float2 pos, Math::Float2 size, Math::Float3 color)
|
||||||
{
|
{
|
||||||
Core::deviceContext->PSSetShaderResources(0,1,&tex);
|
Core::deviceContext->PSSetShaderResources(0,1,&tex);
|
||||||
|
|
||||||
|
@ -34,6 +34,12 @@ namespace Oyster
|
||||||
void* data = Render::Resources::Gui::Data.Map();
|
void* data = Render::Resources::Gui::Data.Map();
|
||||||
memcpy(data,&gd,sizeof(Definitions::GuiData));
|
memcpy(data,&gd,sizeof(Definitions::GuiData));
|
||||||
Render::Resources::Gui::Data.Unmap();
|
Render::Resources::Gui::Data.Unmap();
|
||||||
|
|
||||||
|
data = Render::Resources::Gui::Color.Map();
|
||||||
|
memcpy(data,&color,sizeof(Math::Float3));
|
||||||
|
Render::Resources::Gui::Color.Unmap();
|
||||||
|
|
||||||
|
|
||||||
Core::deviceContext->Draw(1,0);
|
Core::deviceContext->Draw(1,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +49,7 @@ namespace Oyster
|
||||||
Core::PipelineManager::SetRenderPass(Resources::Gui::Text::Pass);
|
Core::PipelineManager::SetRenderPass(Resources::Gui::Text::Pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size)
|
void Gui::RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size, Math::Float3 color)
|
||||||
{
|
{
|
||||||
|
|
||||||
size.x = size.x / (text.length() * TEXT_SPACING /2);
|
size.x = size.x / (text.length() * TEXT_SPACING /2);
|
||||||
|
@ -70,6 +76,10 @@ namespace Oyster
|
||||||
Render::Resources::Gui::Data.Unmap();
|
Render::Resources::Gui::Data.Unmap();
|
||||||
Definitions::Text2D tmpInst;
|
Definitions::Text2D tmpInst;
|
||||||
|
|
||||||
|
data = Render::Resources::Gui::Color.Map();
|
||||||
|
memcpy(data,&color,sizeof(Math::Float3));
|
||||||
|
Render::Resources::Gui::Color.Unmap();
|
||||||
|
|
||||||
void* dest = Resources::Gui::Text::Vertex.Map();
|
void* dest = Resources::Gui::Text::Vertex.Map();
|
||||||
Definitions::Text2D* dataView = reinterpret_cast<Definitions::Text2D*>(dest);
|
Definitions::Text2D* dataView = reinterpret_cast<Definitions::Text2D*>(dest);
|
||||||
//tmpInst.charOffset=_pos;
|
//tmpInst.charOffset=_pos;
|
||||||
|
|
|
@ -12,9 +12,9 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void Begin2DRender();
|
static void Begin2DRender();
|
||||||
static void Render(ID3D11ShaderResourceView* tex, Math::Float2 pos, Math::Float2 size);
|
static void Render(ID3D11ShaderResourceView* tex, Math::Float2 pos, Math::Float2 size, Math::Float3 tint = Math::Float3(1,1,1));
|
||||||
static void Begin2DTextRender();
|
static void Begin2DTextRender();
|
||||||
static void RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size);
|
static void RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size, Math::Float3 tint = Math::Float3(1,1,1));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace Oyster
|
||||||
Buffer Resources::Gather::AnimationData = Buffer();
|
Buffer Resources::Gather::AnimationData = Buffer();
|
||||||
Buffer Resources::Light::LightConstantsData = Buffer();
|
Buffer Resources::Light::LightConstantsData = Buffer();
|
||||||
Buffer Resources::Gui::Data = Buffer();
|
Buffer Resources::Gui::Data = Buffer();
|
||||||
|
Buffer Resources::Gui::Color = Buffer();
|
||||||
Buffer Resources::Gui::Text::Vertex = Buffer();
|
Buffer Resources::Gui::Text::Vertex = Buffer();
|
||||||
Buffer Resources::Post::Data = Buffer();
|
Buffer Resources::Post::Data = Buffer();
|
||||||
|
|
||||||
|
@ -118,6 +119,10 @@ namespace Oyster
|
||||||
desc.ElementSize = sizeof(Definitions::AnimationData);
|
desc.ElementSize = sizeof(Definitions::AnimationData);
|
||||||
Gather::AnimationData.Init(desc);
|
Gather::AnimationData.Init(desc);
|
||||||
|
|
||||||
|
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_PS;
|
||||||
|
desc.ElementSize = sizeof(Math::Float3);
|
||||||
|
Gui::Color.Init(desc);
|
||||||
|
|
||||||
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_GS;
|
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_GS;
|
||||||
desc.NumElements = 1;
|
desc.NumElements = 1;
|
||||||
desc.ElementSize = sizeof(Definitions::GuiData);
|
desc.ElementSize = sizeof(Definitions::GuiData);
|
||||||
|
@ -378,6 +383,7 @@ namespace Oyster
|
||||||
Gui::Pass.Shaders.Geometry = GetShader::Geometry(L"2D");
|
Gui::Pass.Shaders.Geometry = GetShader::Geometry(L"2D");
|
||||||
Gui::Pass.RTV.push_back(GBufferRTV[2]);
|
Gui::Pass.RTV.push_back(GBufferRTV[2]);
|
||||||
Gui::Pass.CBuffers.Geometry.push_back(Gui::Data);
|
Gui::Pass.CBuffers.Geometry.push_back(Gui::Data);
|
||||||
|
Gui::Pass.CBuffers.Pixel.push_back(Gui::Color);
|
||||||
|
|
||||||
D3D11_INPUT_ELEMENT_DESC indesc2D[] =
|
D3D11_INPUT_ELEMENT_DESC indesc2D[] =
|
||||||
{
|
{
|
||||||
|
@ -421,6 +427,7 @@ namespace Oyster
|
||||||
|
|
||||||
Shader::CreateInputLayout(Text2Ddesc,3, GetShader::Vertex(L"2DText") ,Gui::Text::Pass.IAStage.Layout);
|
Shader::CreateInputLayout(Text2Ddesc,3, GetShader::Vertex(L"2DText") ,Gui::Text::Pass.IAStage.Layout);
|
||||||
Gui::Text::Pass.CBuffers.Geometry.push_back(Gui::Data);
|
Gui::Text::Pass.CBuffers.Geometry.push_back(Gui::Data);
|
||||||
|
Gui::Text::Pass.CBuffers.Pixel.push_back(Gui::Color);
|
||||||
Gui::Text::Pass.SRV.Pixel.push_back(Gui::Text::Font);
|
Gui::Text::Pass.SRV.Pixel.push_back(Gui::Text::Font);
|
||||||
Gui::Text::Pass.RTV.push_back(GBufferRTV[2]);
|
Gui::Text::Pass.RTV.push_back(GBufferRTV[2]);
|
||||||
Gui::Text::Pass.RenderStates.SampleCount = 1;
|
Gui::Text::Pass.RenderStates.SampleCount = 1;
|
||||||
|
@ -448,6 +455,7 @@ namespace Oyster
|
||||||
Light::LightConstantsData.~Buffer();
|
Light::LightConstantsData.~Buffer();
|
||||||
Light::PointLightsData.~Buffer();
|
Light::PointLightsData.~Buffer();
|
||||||
Gui::Data.~Buffer();
|
Gui::Data.~Buffer();
|
||||||
|
Gui::Color.~Buffer();
|
||||||
Gui::Text::Vertex.~Buffer();
|
Gui::Text::Vertex.~Buffer();
|
||||||
Post::Data.~Buffer();
|
Post::Data.~Buffer();
|
||||||
SAFE_RELEASE(Light::PointLightView);
|
SAFE_RELEASE(Light::PointLightView);
|
||||||
|
|
|
@ -61,6 +61,7 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
static Core::PipelineManager::RenderPass Pass;
|
static Core::PipelineManager::RenderPass Pass;
|
||||||
static Core::Buffer Data;
|
static Core::Buffer Data;
|
||||||
|
static Core::Buffer Color;
|
||||||
struct Text
|
struct Text
|
||||||
{
|
{
|
||||||
static Core::PipelineManager::RenderPass Pass;
|
static Core::PipelineManager::RenderPass Pass;
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
|
|
||||||
float4 main(Pixel2DIn input) : SV_Target0
|
float4 main(Pixel2DIn input) : SV_Target0
|
||||||
{
|
{
|
||||||
return Material.Sample(LinearSampler,input.Uv);
|
return Material.Sample(LinearSampler,input.Uv) * float4(Color,1);
|
||||||
}
|
}
|
|
@ -3,11 +3,16 @@ struct Vertex2DIn
|
||||||
float2 Pos : Position;
|
float2 Pos : Position;
|
||||||
};
|
};
|
||||||
|
|
||||||
cbuffer EveryObject2D : register(c0)
|
cbuffer EveryObject2D : register(b0)
|
||||||
{
|
{
|
||||||
float4x4 Translation;
|
float4x4 Translation;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
cbuffer ColorData : register(b0)
|
||||||
|
{
|
||||||
|
float3 Color;
|
||||||
|
};
|
||||||
|
|
||||||
struct Pixel2DIn
|
struct Pixel2DIn
|
||||||
{
|
{
|
||||||
float4 Pos : SV_Position;
|
float4 Pos : SV_Position;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "../Header.hlsli"
|
#include "../Header.hlsli"
|
||||||
cbuffer TextPerObject : register(c0)
|
cbuffer TextPerObject : register(b0)
|
||||||
{
|
{
|
||||||
float4x4 gWorld;
|
float4x4 gWorld;
|
||||||
};
|
};
|
||||||
|
|
|
@ -233,14 +233,14 @@ HRESULT Render(float deltaTime)
|
||||||
Oyster::Graphics::API::RenderModel(m2);
|
Oyster::Graphics::API::RenderModel(m2);
|
||||||
Oyster::Graphics::API::StartGuiRender();
|
Oyster::Graphics::API::StartGuiRender();
|
||||||
Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(1,1));
|
Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(1,1));
|
||||||
Oyster::Graphics::API::RenderGuiElement(t2,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f));
|
//Oyster::Graphics::API::RenderGuiElement(t2,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float3(1,0,0));
|
||||||
Oyster::Graphics::API::StartTextRender();
|
Oyster::Graphics::API::StartTextRender();
|
||||||
std::wstring fps;
|
std::wstring fps;
|
||||||
float f = 1/deltaTime;
|
float f = 1/deltaTime;
|
||||||
fps = std::to_wstring(f);
|
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",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(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::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::EndFrame();
|
Oyster::Graphics::API::EndFrame();
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
Loading…
Reference in New Issue