Basic 2d Render + Anim Updates

This commit is contained in:
lanariel 2014-02-11 13:29:19 +01:00
parent cc55a3471f
commit f0df377bcd
16 changed files with 291 additions and 100 deletions

View File

@ -66,6 +66,13 @@ namespace Oyster
int x; int x;
int y; int y;
}; };
struct Text2D
{
float pos;
int offset;
float coff;
};
} }
} }
} }

View File

@ -29,11 +29,10 @@ namespace Oyster
{ {
return API::Fail; return API::Fail;
} }
Render::Resources::Gui::Text::Font = (ID3D11ShaderResourceView*)API::CreateTexture(L"font_generic.png");
Render::Resources::Init(); Render::Resources::Init();
Render::Preparations::Basic::SetViewPort(); Render::Preparations::Basic::SetViewPort();
Render::DefaultRenderer::cube = API::CreateModel(L"box.dan");
Render::DefaultRenderer::cube2 = API::CreateModel(L"box2.dan");
return API::Sucsess; return API::Sucsess;
} }
@ -111,8 +110,7 @@ namespace Oyster
void API::Clean() void API::Clean()
{ {
DeleteModel(Render::DefaultRenderer::cube); DeleteTexture(Render::Resources::Gui::Text::Font);
DeleteModel(Render::DefaultRenderer::cube2);
SAFE_DELETE(Core::viewPort); SAFE_DELETE(Core::viewPort);
Core::loader.Clean(); Core::loader.Clean();
Oyster::Graphics::Core::PipelineManager::Clean(); Oyster::Graphics::Core::PipelineManager::Clean();
@ -157,12 +155,12 @@ namespace Oyster
void API::StartGuiRender() void API::StartGuiRender()
{ {
Render::Rendering::Gui::BeginRender(); 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)
{ {
Render::Rendering::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size); Render::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size);
} }
API::Texture API::CreateTexture(std::wstring filename) API::Texture API::CreateTexture(std::wstring filename)
@ -187,5 +185,15 @@ namespace Oyster
{ {
deltaTime = dt; deltaTime = dt;
} }
void API::StartTextRender()
{
Render::Gui::Begin2DTextRender();
}
void API::RenderText(std::wstring text, Math::Float2 Pos, Math::Float2 Size)
{
Render::Gui::RenderText(text,Pos,Size);
}
} }
} }

View File

@ -59,6 +59,12 @@ namespace Oyster
//! @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);
//! @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);
//! @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();

View File

@ -10,31 +10,6 @@ struct Text2D
int offset; int offset;
float coff; float coff;
}; };
/*struct TextInstanceData
{
Oyster::Buffer InstanceBuffer;
bool Visible;
int NumLetters;
Oyster::Math::Float4x4 World;
};*/
/*struct TextData
{
Oyster::Math::Float3 pos;
Oyster::Math::Float2 uv;
};
struct PerCharData
{
float data;
Oyster::Math::Float3 charOffset;
};
struct TextInstanceData
{
Oyster::Buffer InstanceBuffer;
bool Visible;
int NumLetters;
Oyster::Math::Float4x4 World;
};*/
namespace Oyster namespace Oyster
{ {
@ -49,9 +24,6 @@ namespace Oyster
static HRESULT CreateVertexBuffer(); static HRESULT CreateVertexBuffer();
static HRESULT CreateTextfield(int _id); static HRESULT CreateTextfield(int _id);
public: public:
//static Oyster::Buffer TextBuffer;
//static int NumVertices;
//static std::vector<TextInstanceData> TextInstances;
static Buffer TextBuffer; static Buffer TextBuffer;
static int NumLetters; static int NumLetters;
static ID3D11ShaderResourceView* Texture; static ID3D11ShaderResourceView* Texture;
@ -59,8 +31,10 @@ namespace Oyster
static bool Init(); static bool Init();
static bool UpdateTextField(std::string _str); static bool UpdateTextField(std::string _str);
static bool SetTexture(const char* _file); static bool SetTexture(const char* _file);
//Updates a textbox with the certain id //Updates a textbox with the certain id
static void Update(std::string _str, float _scale); static void Update(std::string _str, float _scale);
//Removes all old instances and recreates it with the input data //Removes all old instances and recreates it with the input data
static HRESULT Reset(int _count, std::string* _str, Float3* _pos); static HRESULT Reset(int _count, std::string* _str, Float3* _pos);
static void Apply(int _id); static void Apply(int _id);

View File

@ -231,6 +231,22 @@
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType> <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType> <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
</FxCompile> </FxCompile>
<FxCompile Include="Shader\Passes\2D\Text\2DTextGeometry.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Geometry</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Geometry</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Geometry</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Geometry</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0</ShaderModel>
</FxCompile>
<FxCompile Include="Shader\Passes\2D\Text\2DTextVertex.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
</FxCompile>
<FxCompile Include="Shader\Passes\Light\LightPass.hlsl"> <FxCompile Include="Shader\Passes\Light\LightPass.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType> <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType> <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
@ -319,6 +335,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Shader\Passes\2D\Header.hlsli" /> <None Include="Shader\Passes\2D\Header.hlsli" />
<None Include="Shader\Passes\2D\Text\Header.hlsli" />
<None Include="Shader\Passes\Light\Defines.hlsli" /> <None Include="Shader\Passes\Light\Defines.hlsli" />
<None Include="Shader\Passes\Gather\Header.hlsli" /> <None Include="Shader\Passes\Gather\Header.hlsli" />
<None Include="Shader\Passes\Light\LightCalc.hlsli" /> <None Include="Shader\Passes\Light\LightCalc.hlsli" />

View File

@ -107,6 +107,8 @@
<FxCompile Include="Shader\Passes\2D\2DGeometry.hlsl" /> <FxCompile Include="Shader\Passes\2D\2DGeometry.hlsl" />
<FxCompile Include="Shader\Passes\Blur\BlurHor.hlsl" /> <FxCompile Include="Shader\Passes\Blur\BlurHor.hlsl" />
<FxCompile Include="Shader\Passes\Blur\BlurVert.hlsl" /> <FxCompile Include="Shader\Passes\Blur\BlurVert.hlsl" />
<FxCompile Include="Shader\Passes\2D\Text\2DTextVertex.hlsl" />
<FxCompile Include="Shader\Passes\2D\Text\2DTextGeometry.hlsl" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Shader\HLSL\SimpleDebug\Debug.hlsl" /> <None Include="Shader\HLSL\SimpleDebug\Debug.hlsl" />
@ -117,5 +119,6 @@
<None Include="Shader\Passes\2D\Header.hlsli" /> <None Include="Shader\Passes\2D\Header.hlsli" />
<None Include="Shader\Passes\Gather\Header.hlsli" /> <None Include="Shader\Passes\Gather\Header.hlsli" />
<None Include="Shader\Passes\Blur\BlurSharedData.hlsli" /> <None Include="Shader\Passes\Blur\BlurSharedData.hlsli" />
<None Include="Shader\Passes\2D\Text\Header.hlsli" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -13,8 +13,6 @@ namespace Oyster
namespace Render namespace Render
{ {
Definitions::Pointlight pl; Definitions::Pointlight pl;
Model::Model* DefaultRenderer::cube = NULL;
Model::Model* DefaultRenderer::cube2 = NULL;
void DefaultRenderer::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight Lights, int numLights) void DefaultRenderer::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight Lights, int numLights)
{ {
@ -67,17 +65,11 @@ namespace Oyster
if(info->Animated && models[i].Animation.AnimationPlaying != NULL) if(info->Animated && models[i].Animation.AnimationPlaying != NULL)
{ {
models[i].Animation.AnimationTime += deltaTime; models[i].Animation.AnimationTime += deltaTime;
cube->WorldMatrix = Math::Matrix::identity;
////store inverse absolut transform ////store inverse absolut transform
Math::Matrix SkinTransform[100]; Math::Matrix SkinTransform[100];
Math::Matrix BoneAnimated[100]; Math::Matrix BoneAnimated[100];
Math::Matrix BoneAbsAnimated[100]; Math::Matrix BoneAbsAnimated[100];
Math::Matrix Scale = Math::Matrix::identity;
Scale.m[0][0] = 1;
Scale.m[1][1] = 1;
Scale.m[2][2] = 2;
for(int b = 0; b <info->BoneCount; ++b) for(int b = 0; b <info->BoneCount; ++b)
@ -86,10 +78,6 @@ namespace Oyster
SkinTransform[b] = Bone.Absolute.GetInverse(); SkinTransform[b] = Bone.Absolute.GetInverse();
BoneAnimated[b] = Bone.Relative; BoneAnimated[b] = Bone.Relative;
BoneAbsAnimated[b] = Bone.Absolute; BoneAbsAnimated[b] = Bone.Absolute;
cube2->WorldMatrix = Scale;
cube2->WorldMatrix.v[3] = info->bones[b].Absolute.v[3];
} }
int b = 0; int b = 0;
Model::Animation A = *models[i].Animation.AnimationPlaying; Model::Animation A = *models[i].Animation.AnimationPlaying;
@ -127,11 +115,6 @@ namespace Oyster
for(int b = 0; b < info->BoneCount; ++b) for(int b = 0; b < info->BoneCount; ++b)
{ {
BoneAbsAnimated[b] = BoneAbsAnimated[info->bones[b].Parent] * BoneAnimated[b]; BoneAbsAnimated[b] = BoneAbsAnimated[info->bones[b].Parent] * BoneAnimated[b];
//SkinTransform[b] = BoneAbsAnimated[b];
cube->WorldMatrix = Scale;
cube->WorldMatrix.v[3] = BoneAbsAnimated[b].v[3];
cube->WorldMatrix = models[i].WorldMatrix * cube->WorldMatrix;
DefaultRenderer::RenderScene(cube,1,View,Projection);
} }
//write data to am //write data to am

View File

@ -16,9 +16,6 @@ namespace Oyster
static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight Lights, int numLights); static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight Lights, int numLights);
static void RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection, float DeltaTime = 0); static void RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection, float DeltaTime = 0);
static void EndFrame(); static void EndFrame();
static Model::Model* cube;
static Model::Model* cube2;
}; };
} }
} }

View File

@ -8,9 +8,10 @@ namespace Oyster
{ {
namespace Render namespace Render
{ {
namespace Rendering const int TEXT_NR_LETTERS=95;
{ const float TEXT_SIZE=2.5;
void Gui::BeginRender()
void Gui::Begin2DRender()
{ {
Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass); Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass);
} }
@ -24,20 +25,86 @@ namespace Oyster
pos.y *= -1; pos.y *= -1;
Definitions::GuiData gd; Definitions::GuiData gd;
gd.Translation = Math::Matrix::identity; gd.Translation = Math::Matrix::identity;
gd.Translation.m41 = pos.x; gd.Translation.m41 = pos.x;
gd.Translation.m42 = pos.y; gd.Translation.m42 = pos.y;
gd.Translation.m11 = size.x; gd.Translation.m11 = size.x;
gd.Translation.m22 = size.y; gd.Translation.m22 = size.y;
void* data = Render::Resources::Gui::Data.Map();
memcpy(data,&gd,sizeof(Definitions::GuiData));
Render::Resources::Gui::Data.Unmap();
Core::deviceContext->Draw(1,0);
}
void Gui::Begin2DTextRender()
{
Resources::Gui::Text::Vertex.Apply();
Core::PipelineManager::SetRenderPass(Resources::Gui::Text::Pass);
}
void Gui::RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size)
{
//Pos.x -= instance.sizeX/2;
//Pos.x += size.x;
//Pos.y -= instance.sizeY/2;
//Pos.y += size.y;
//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;
//m.m22=height*size.y;
//void* dest = Resources::Buffers::CBufferGs.Map();
//memcpy(dest,&m.GetTranspose(),64);
//Resources::Buffers::CBufferGs.Unmap();
//Oyster::Render::Textbox::Update(text, size.x);
//Oyster::Engine::PrepareForRendering::Begin2DTextRender();
//Oyster::Core::DeviceContext->PSSetShaderResources(0,1,&(Oyster::Render::Textbox::Texture));
////Should be able to be outside of the for loop. Keeping it here for now though.
//Oyster::Core::DeviceContext->Draw(Oyster::Render::Textbox::NumLetters, 0);
pos *= 2;
pos -= 1;
pos.y *= -1;
Definitions::GuiData gd;
gd.Translation = Math::Matrix::identity;
gd.Translation.m41 = (pos.x - (size.x/2 * text.length()));
gd.Translation.m42 = pos.y;
gd.Translation.m11 = size.x;
gd.Translation.m22 = size.y;
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();
Definitions::Text2D tmpInst;
Core::deviceContext->Draw(1,0); void* dest = Resources::Gui::Text::Vertex.Map();
} Definitions::Text2D* dataView = reinterpret_cast<Definitions::Text2D*>(dest);
//tmpInst.charOffset=_pos;
for (unsigned int i=0; i<text.length(); i++)
{
tmpInst.coff=(1.0f/TEXT_NR_LETTERS);
tmpInst.offset=text[i]-32;
tmpInst.pos=i*(size.x*2);
//float tst=getCharID(_str[i]);
//tmpInst.offset=tst;
//tmpInst.charOffset.x=_pos.x-i*TEXT_SIZE;
//tmpInst.data=tst;
dataView[i]=tmpInst;
}
//TextInstances[_id].NumLetters=instances;
Resources::Gui::Text::Vertex.Unmap();
Core::deviceContext->Draw(text.length(), 0);
} }
} }
} }

View File

@ -7,16 +7,15 @@ namespace Oyster
namespace Graphics namespace Graphics
{ {
namespace Render namespace Render
{
namespace Rendering
{ {
class Gui class Gui
{ {
public: public:
static void BeginRender(); 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);
static void Begin2DTextRender();
static void RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size);
}; };
} }
} }
} }
}

View File

@ -14,6 +14,9 @@ const std::wstring PathToCSO = L"..\\Content\\Shaders\\";
const int KernelSize = 10; const int KernelSize = 10;
const int SampleSpread = 16; const int SampleSpread = 16;
const int MAX_LETTER_COUNT=60;
namespace Oyster namespace Oyster
{ {
namespace Graphics namespace Graphics
@ -34,6 +37,7 @@ namespace Oyster
Shader::RenderPass Resources::Light::Pass; Shader::RenderPass Resources::Light::Pass;
Shader::RenderPass Resources::Post::Pass; Shader::RenderPass Resources::Post::Pass;
Shader::RenderPass Resources::Gui::Pass; Shader::RenderPass Resources::Gui::Pass;
Shader::RenderPass Resources::Gui::Text::Pass;
Shader::RenderPass Resources::Blur::VertPass; //Set this pass second when doing a "fullscreen" blur Shader::RenderPass Resources::Blur::VertPass; //Set this pass second when doing a "fullscreen" blur
Shader::RenderPass Resources::Blur::HorPass; //Set this pass first when doing a "fullscreen" blur Shader::RenderPass Resources::Blur::HorPass; //Set this pass first when doing a "fullscreen" blur
@ -41,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::Text::Vertex = Buffer();
Buffer Resources::Post::Data = Buffer(); Buffer Resources::Post::Data = Buffer();
Buffer Resources::Light::PointLightsData = Buffer(); Buffer Resources::Light::PointLightsData = Buffer();
@ -52,6 +57,9 @@ namespace Oyster
ID3D11RasterizerState* Resources::RenderStates::rs = NULL; ID3D11RasterizerState* Resources::RenderStates::rs = NULL;
ID3D11SamplerState** Resources::RenderStates::ss = new ID3D11SamplerState*[1]; ID3D11SamplerState** Resources::RenderStates::ss = new ID3D11SamplerState*[1];
ID3D11DepthStencilState* Resources::RenderStates::dsState = NULL; ID3D11DepthStencilState* Resources::RenderStates::dsState = NULL;
ID3D11BlendState* Resources::RenderStates::bs = NULL;
ID3D11ShaderResourceView* Resources::Gui::Text::Font = NULL;
Core::Init::State Resources::InitShaders() Core::Init::State Resources::InitShaders()
@ -85,6 +93,11 @@ namespace Oyster
Core::PipelineManager::Init(path + L"2DVertex" + end,ShaderType::Vertex, L"2D"); Core::PipelineManager::Init(path + L"2DVertex" + end,ShaderType::Vertex, L"2D");
Core::PipelineManager::Init(path + L"2DGeometry" + end,ShaderType::Geometry, L"2D"); Core::PipelineManager::Init(path + L"2DGeometry" + end,ShaderType::Geometry, L"2D");
Core::PipelineManager::Init(path + L"2DPixel" + end,ShaderType::Pixel, L"2D"); Core::PipelineManager::Init(path + L"2DPixel" + end,ShaderType::Pixel, L"2D");
#ifdef _DEBUG
path = PathToHLSL+L"2D\\Text\\";
#endif
Core::PipelineManager::Init(path + L"2DTextVertex" + end,ShaderType::Vertex, L"2DText");
Core::PipelineManager::Init(path + L"2DTextGeometry" + end,ShaderType::Geometry, L"2DText");
return Core::Init::State::Success; return Core::Init::State::Success;
} }
@ -121,6 +134,12 @@ namespace Oyster
desc.NumElements = MaxLightSize; desc.NumElements = MaxLightSize;
desc.Type = Buffer::STRUCTURED_BUFFER; desc.Type = Buffer::STRUCTURED_BUFFER;
Light::PointLightsData.Init(desc); Light::PointLightsData.Init(desc);
desc.Type = Buffer::BUFFER_TYPE::VERTEX_BUFFER;
desc.ElementSize = sizeof(Definitions::Text2D);
desc.NumElements = MAX_LETTER_COUNT;
Gui::Text::Vertex.Init(desc);
return Core::Init::Success; return Core::Init::Success;
} }
@ -178,6 +197,23 @@ namespace Oyster
Core::device->CreateDepthStencilState(&ddesc,&RenderStates::dsState); Core::device->CreateDepthStencilState(&ddesc,&RenderStates::dsState);
D3D11_BLEND_DESC bdesc;
bdesc.AlphaToCoverageEnable = true;
bdesc.IndependentBlendEnable = false;
bdesc.RenderTarget[0].BlendEnable = true;
bdesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
bdesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
bdesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
bdesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
bdesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE;
bdesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_MAX;
bdesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
Core::device->CreateBlendState(&bdesc,&RenderStates::bs);
return Core::Init::Success; return Core::Init::Success;
} }
@ -368,6 +404,28 @@ namespace Oyster
//And the Ambient UAV is now the output texture //And the Ambient UAV is now the output texture
Blur::VertPass.UAV.Compute.push_back(LBufferUAV[2]); Blur::VertPass.UAV.Compute.push_back(LBufferUAV[2]);
////---------------- 2DText Pass Setup ----------------------------
Gui::Text::Pass.Shaders.Vertex = GetShader::Vertex(L"2DText");
Gui::Text::Pass.Shaders.Geometry = GetShader::Geometry(L"2DText");
Gui::Text::Pass.Shaders.Pixel = GetShader::Pixel(L"2D");
Gui::Text::Pass.IAStage.Topology = D3D11_PRIMITIVE_TOPOLOGY_POINTLIST;
D3D11_INPUT_ELEMENT_DESC Text2Ddesc[] =
{
{"Position",0, DXGI_FORMAT_R32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"Offset",0, DXGI_FORMAT_R32_SINT, 0, 4, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"CharOffset",0, DXGI_FORMAT_R32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0},
};
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.SRV.Pixel.push_back(Gui::Text::Font);
Gui::Text::Pass.RTV.push_back(GBufferRTV[2]);
Gui::Text::Pass.RenderStates.SampleCount = 1;
Gui::Text::Pass.RenderStates.SampleState = RenderStates::ss;
Gui::Text::Pass.RenderStates.BlendState = RenderStates::bs;
return Core::Init::Success; return Core::Init::Success;
} }
@ -389,6 +447,7 @@ namespace Oyster
Light::LightConstantsData.~Buffer(); Light::LightConstantsData.~Buffer();
Light::PointLightsData.~Buffer(); Light::PointLightsData.~Buffer();
Gui::Data.~Buffer(); Gui::Data.~Buffer();
Gui::Text::Vertex.~Buffer();
Post::Data.~Buffer(); Post::Data.~Buffer();
SAFE_RELEASE(Light::PointLightView); SAFE_RELEASE(Light::PointLightView);
SAFE_RELEASE(Light::SSAOKernel); SAFE_RELEASE(Light::SSAOKernel);
@ -425,6 +484,10 @@ namespace Oyster
SAFE_DELETE_ARRAY(Gather::Pass.RenderStates.SampleState); SAFE_DELETE_ARRAY(Gather::Pass.RenderStates.SampleState);
SAFE_RELEASE(Gui::Pass.IAStage.Layout); SAFE_RELEASE(Gui::Pass.IAStage.Layout);
SAFE_RELEASE(Gui::Text::Pass.RenderStates.BlendState);
SAFE_RELEASE(Gui::Text::Pass.IAStage.Layout);
} }
} }
} }

View File

@ -36,6 +36,7 @@ namespace Oyster
static ID3D11RasterizerState* rs; static ID3D11RasterizerState* rs;
static ID3D11SamplerState** ss; static ID3D11SamplerState** ss;
static ID3D11DepthStencilState* dsState; static ID3D11DepthStencilState* dsState;
static ID3D11BlendState* bs;
}; };
struct Gather struct Gather
@ -60,7 +61,12 @@ namespace Oyster
{ {
static Core::PipelineManager::RenderPass Pass; static Core::PipelineManager::RenderPass Pass;
static Core::Buffer Data; static Core::Buffer Data;
struct Text
{
static Core::PipelineManager::RenderPass Pass;
static Core::Buffer Vertex; static Core::Buffer Vertex;
static ID3D11ShaderResourceView* Font;
};
}; };
struct Blur struct Blur

View File

@ -0,0 +1,29 @@
#include "Header.hlsli"
[maxvertexcount(4)]
void main(point Text2DIn input[1],inout TriangleStream<Pixel2DIn> Quads)
{
float startoff=input[0].off*input[0].coff;
float endoff=startoff+input[0].coff;
Pixel2DIn output;
output.Pos = mul(float4(-1,-1,0,1), Translation);
output.Pos.x += input[0].Pos;
output.Uv = float2(startoff,1);
Quads.Append(output);
output.Pos = mul(float4(-1,1,0,1), Translation);
output.Pos.x += input[0].Pos;
output.Uv = float2(startoff,0);
Quads.Append(output);
output.Pos = mul(float4(1,-1,0,1), Translation);
output.Pos.x += input[0].Pos;
output.Uv = float2(endoff,1);
Quads.Append(output);
output.Pos = mul(float4(1,1,0,1), Translation);
output.Pos.x += input[0].Pos;
output.Uv = float2(endoff,0);
Quads.Append(output);
}

View File

@ -0,0 +1,6 @@
#include "Header.hlsli"
Text2DIn main(Text2DIn input)
{
return input;
}

View File

@ -0,0 +1,20 @@
#include "../Header.hlsli"
cbuffer TextPerObject : register(c0)
{
float4x4 gWorld;
};
Texture2D g_tex1 : register(t0);
struct Text2DIn
{
float Pos : Position;
int off : Offset;
float coff : CharOffset;
};
struct TEXT_VS_OUT
{
float4 pos : SV_POSITION;
float2 texCoord : TEXCOORD;
};

View File

@ -158,19 +158,21 @@ HRESULT InitDirect3D()
{ {
HRESULT hr = S_OK;; HRESULT hr = S_OK;;
if(Oyster::Graphics::API::Init(g_hWnd,false,false, Oyster::Math::Float2( 1024, 768 )) == Oyster::Graphics::API::Fail)
{
return E_FAIL;
}
Oyster::Graphics::API::Option o = Oyster::Graphics::API::GetOption(); Oyster::Graphics::API::Option o = Oyster::Graphics::API::GetOption();
o.modelPath = L"..\\Content\\Models\\"; o.modelPath = L"..\\Content\\Models\\";
o.texturePath = L"..\\Content\\Textures\\"; o.texturePath = L"..\\Content\\Textures\\";
Oyster::Graphics::API::SetOptions(o); Oyster::Graphics::API::SetOptions(o);
if(Oyster::Graphics::API::Init(g_hWnd,false,false, Oyster::Math::Float2( 1024, 768 )) == Oyster::Graphics::API::Fail)
{
return E_FAIL;
}
m = Oyster::Graphics::API::CreateModel(L"crate_colonists.dan"); m = Oyster::Graphics::API::CreateModel(L"crate_colonists.dan");
m2 = Oyster::Graphics::API::CreateModel(L"char_fake_bin.dan"); m2 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan");
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null); m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(4,0,0),Oyster::Math::Float3::null);
Oyster::Graphics::API::PlayAnimation(m2, L"Bend",true); Oyster::Graphics::API::PlayAnimation(m2, L"movement",true);
t = Oyster::Graphics::API::CreateTexture(L"structure_corp_mdg.png"); t = Oyster::Graphics::API::CreateTexture(L"structure_corp_mdg.png");
@ -195,8 +197,8 @@ HRESULT InitDirect3D()
float angle = 0; float angle = 0;
HRESULT Update(float deltaTime) HRESULT Update(float deltaTime)
{ {
angle += Oyster::Math::pi/16 * deltaTime; //angle += Oyster::Math::pi/16 * deltaTime;
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0)*-angle,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null); m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0) * angle,Oyster::Math::Float3(4,0,0),Oyster::Math::Float3::null);
//Oyster::Math::Matrix ma = Oyster::Math::Matrix::identity; //Oyster::Math::Matrix ma = Oyster::Math::Matrix::identity;
Oyster::Graphics::API::Update(deltaTime); Oyster::Graphics::API::Update(deltaTime);
//m2->Animation.data.AnimationTime += deltaTime;// * 0.5f; //m2->Animation.data.AnimationTime += deltaTime;// * 0.5f;
@ -211,7 +213,9 @@ HRESULT Render(float deltaTime)
Oyster::Graphics::API::RenderModel(m); Oyster::Graphics::API::RenderModel(m);
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(0.2f,0.2f)); Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(0.8f,0.2f));
Oyster::Graphics::API::StartTextRender();
Oyster::Graphics::API::RenderText(L"Lanariel Was Here",Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.05f,0.08f));
Oyster::Graphics::API::EndFrame(); Oyster::Graphics::API::EndFrame();
return S_OK; return S_OK;
@ -254,10 +258,12 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
//m2->AnimationTime -= 0.1f; //m2->AnimationTime -= 0.1f;
//if(m2->AnimationTime < 0) //if(m2->AnimationTime < 0)
//m2->AnimationTime = 0; //m2->AnimationTime = 0;
angle += Oyster::Math::pi / 16;
break; break;
//X + //X +
case 0x58: case 0x58:
//m2->AnimationTime += 0.1f; //m2->AnimationTime += 0.1f;
angle -= Oyster::Math::pi / 16;
break; break;
} }