diff --git a/Code/OysterGraphics/Definitions/GraphicalDefinition.h b/Code/OysterGraphics/Definitions/GraphicalDefinition.h index 7c0d76d7..0b30ee76 100644 --- a/Code/OysterGraphics/Definitions/GraphicalDefinition.h +++ b/Code/OysterGraphics/Definitions/GraphicalDefinition.h @@ -66,6 +66,13 @@ namespace Oyster int x; int y; }; + + struct Text2D + { + float pos; + int offset; + float coff; + }; } } } \ No newline at end of file diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index 5a92f0de..a175aa58 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -29,11 +29,10 @@ namespace Oyster { return API::Fail; } + Render::Resources::Gui::Text::Font = (ID3D11ShaderResourceView*)API::CreateTexture(L"font_generic.png"); Render::Resources::Init(); Render::Preparations::Basic::SetViewPort(); - Render::DefaultRenderer::cube = API::CreateModel(L"box.dan"); - Render::DefaultRenderer::cube2 = API::CreateModel(L"box2.dan"); return API::Sucsess; } @@ -111,8 +110,7 @@ namespace Oyster void API::Clean() { - DeleteModel(Render::DefaultRenderer::cube); - DeleteModel(Render::DefaultRenderer::cube2); + DeleteTexture(Render::Resources::Gui::Text::Font); SAFE_DELETE(Core::viewPort); Core::loader.Clean(); Oyster::Graphics::Core::PipelineManager::Clean(); @@ -157,12 +155,12 @@ namespace Oyster void API::StartGuiRender() { - Render::Rendering::Gui::BeginRender(); + Render::Gui::Begin2DRender(); } 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) @@ -187,5 +185,15 @@ namespace Oyster { 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); + } } } \ No newline at end of file diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.h b/Code/OysterGraphics/DllInterfaces/GFXAPI.h index 65f82460..6511fc4d 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.h +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.h @@ -59,6 +59,12 @@ namespace Oyster //! @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); + //! @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 static void EndFrame(); diff --git a/Code/OysterGraphics/OldRender/TextBox.h b/Code/OysterGraphics/OldRender/TextBox.h index 6b95dce7..40046210 100644 --- a/Code/OysterGraphics/OldRender/TextBox.h +++ b/Code/OysterGraphics/OldRender/TextBox.h @@ -10,31 +10,6 @@ struct Text2D int offset; 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 { @@ -49,9 +24,6 @@ namespace Oyster static HRESULT CreateVertexBuffer(); static HRESULT CreateTextfield(int _id); public: - //static Oyster::Buffer TextBuffer; - //static int NumVertices; - //static std::vector TextInstances; static Buffer TextBuffer; static int NumLetters; static ID3D11ShaderResourceView* Texture; @@ -59,8 +31,10 @@ namespace Oyster static bool Init(); static bool UpdateTextField(std::string _str); static bool SetTexture(const char* _file); + //Updates a textbox with the certain id static void Update(std::string _str, float _scale); + //Removes all old instances and recreates it with the input data static HRESULT Reset(int _count, std::string* _str, Float3* _pos); static void Apply(int _id); diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj b/Code/OysterGraphics/OysterGraphics.vcxproj index c19e073f..fc00bde5 100644 --- a/Code/OysterGraphics/OysterGraphics.vcxproj +++ b/Code/OysterGraphics/OysterGraphics.vcxproj @@ -231,6 +231,22 @@ Vertex Vertex + + Geometry + 4.0 + Geometry + 4.0 + Geometry + 4.0 + Geometry + 4.0 + + + Vertex + Vertex + Vertex + Vertex + Compute Compute @@ -319,6 +335,7 @@ + diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj.filters b/Code/OysterGraphics/OysterGraphics.vcxproj.filters index 4fcaee03..d76a066f 100644 --- a/Code/OysterGraphics/OysterGraphics.vcxproj.filters +++ b/Code/OysterGraphics/OysterGraphics.vcxproj.filters @@ -107,6 +107,8 @@ + + @@ -117,5 +119,6 @@ + \ No newline at end of file diff --git a/Code/OysterGraphics/Render/DefaultRenderer.cpp b/Code/OysterGraphics/Render/DefaultRenderer.cpp index c3b91192..3573ad0a 100644 --- a/Code/OysterGraphics/Render/DefaultRenderer.cpp +++ b/Code/OysterGraphics/Render/DefaultRenderer.cpp @@ -13,8 +13,6 @@ namespace Oyster namespace Render { 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) { @@ -67,17 +65,11 @@ namespace Oyster if(info->Animated && models[i].Animation.AnimationPlaying != NULL) { models[i].Animation.AnimationTime += deltaTime; - cube->WorldMatrix = Math::Matrix::identity; ////store inverse absolut transform Math::Matrix SkinTransform[100]; Math::Matrix BoneAnimated[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 BoneCount; ++b) @@ -86,10 +78,6 @@ namespace Oyster SkinTransform[b] = Bone.Absolute.GetInverse(); BoneAnimated[b] = Bone.Relative; BoneAbsAnimated[b] = Bone.Absolute; - - - cube2->WorldMatrix = Scale; - cube2->WorldMatrix.v[3] = info->bones[b].Absolute.v[3]; } int b = 0; Model::Animation A = *models[i].Animation.AnimationPlaying; @@ -127,11 +115,6 @@ namespace Oyster for(int b = 0; b < info->BoneCount; ++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 diff --git a/Code/OysterGraphics/Render/DefaultRenderer.h b/Code/OysterGraphics/Render/DefaultRenderer.h index 627998fa..b45f672f 100644 --- a/Code/OysterGraphics/Render/DefaultRenderer.h +++ b/Code/OysterGraphics/Render/DefaultRenderer.h @@ -16,9 +16,6 @@ namespace Oyster 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 EndFrame(); - - static Model::Model* cube; - static Model::Model* cube2; }; } } diff --git a/Code/OysterGraphics/Render/GuiRenderer.cpp b/Code/OysterGraphics/Render/GuiRenderer.cpp index 62b724cd..0fbda1be 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.cpp +++ b/Code/OysterGraphics/Render/GuiRenderer.cpp @@ -7,37 +7,104 @@ namespace Oyster namespace Graphics { namespace Render - { - namespace Rendering + { + const int TEXT_NR_LETTERS=95; + const float TEXT_SIZE=2.5; + + void Gui::Begin2DRender() { - void Gui::BeginRender() + Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass); + } + + void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float2 pos, Math::Float2 size) + { + Core::deviceContext->PSSetShaderResources(0,1,&tex); + + pos *= 2; + pos -= 1; + pos.y *= -1; + + 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; + + 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(); + memcpy(data,&gd,sizeof(Definitions::GuiData)); + Render::Resources::Gui::Data.Unmap(); + Definitions::Text2D tmpInst; + + void* dest = Resources::Gui::Text::Vertex.Map(); + Definitions::Text2D* dataView = reinterpret_cast(dest); + //tmpInst.charOffset=_pos; + for (unsigned int i=0; iPSSetShaderResources(0,1,&tex); - - pos *= 2; - pos -= 1; - pos.y *= -1; - - 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; - - - void* data = Render::Resources::Gui::Data.Map(); - memcpy(data,&gd,sizeof(Definitions::GuiData)); - Render::Resources::Gui::Data.Unmap(); - - Core::deviceContext->Draw(1,0); - } + + Core::deviceContext->Draw(text.length(), 0); } } } diff --git a/Code/OysterGraphics/Render/GuiRenderer.h b/Code/OysterGraphics/Render/GuiRenderer.h index c722ae24..6d865950 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.h +++ b/Code/OysterGraphics/Render/GuiRenderer.h @@ -8,15 +8,14 @@ namespace Oyster { namespace Render { - namespace Rendering + class Gui { - class Gui - { - public: - static void BeginRender(); - static void Render(ID3D11ShaderResourceView* tex, Math::Float2 pos, Math::Float2 size); - }; - } + public: + static void Begin2DRender(); + 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); + }; } } } \ No newline at end of file diff --git a/Code/OysterGraphics/Render/Resources.cpp b/Code/OysterGraphics/Render/Resources.cpp index f7b1144d..9f2adbb3 100644 --- a/Code/OysterGraphics/Render/Resources.cpp +++ b/Code/OysterGraphics/Render/Resources.cpp @@ -14,6 +14,9 @@ const std::wstring PathToCSO = L"..\\Content\\Shaders\\"; const int KernelSize = 10; const int SampleSpread = 16; + +const int MAX_LETTER_COUNT=60; + namespace Oyster { namespace Graphics @@ -34,6 +37,7 @@ namespace Oyster Shader::RenderPass Resources::Light::Pass; Shader::RenderPass Resources::Post::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::HorPass; //Set this pass first when doing a "fullscreen" blur @@ -41,6 +45,7 @@ namespace Oyster Buffer Resources::Gather::AnimationData = Buffer(); Buffer Resources::Light::LightConstantsData = Buffer(); Buffer Resources::Gui::Data = Buffer(); + Buffer Resources::Gui::Text::Vertex = Buffer(); Buffer Resources::Post::Data = Buffer(); Buffer Resources::Light::PointLightsData = Buffer(); @@ -52,6 +57,9 @@ namespace Oyster ID3D11RasterizerState* Resources::RenderStates::rs = NULL; ID3D11SamplerState** Resources::RenderStates::ss = new ID3D11SamplerState*[1]; ID3D11DepthStencilState* Resources::RenderStates::dsState = NULL; + ID3D11BlendState* Resources::RenderStates::bs = NULL; + + ID3D11ShaderResourceView* Resources::Gui::Text::Font = NULL; 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"2DGeometry" + end,ShaderType::Geometry, 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; } @@ -121,6 +134,12 @@ namespace Oyster desc.NumElements = MaxLightSize; desc.Type = Buffer::STRUCTURED_BUFFER; 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; } @@ -178,6 +197,23 @@ namespace Oyster 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; } @@ -368,6 +404,28 @@ namespace Oyster //And the Ambient UAV is now the output texture 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; } @@ -389,6 +447,7 @@ namespace Oyster Light::LightConstantsData.~Buffer(); Light::PointLightsData.~Buffer(); Gui::Data.~Buffer(); + Gui::Text::Vertex.~Buffer(); Post::Data.~Buffer(); SAFE_RELEASE(Light::PointLightView); SAFE_RELEASE(Light::SSAOKernel); @@ -425,6 +484,10 @@ namespace Oyster SAFE_DELETE_ARRAY(Gather::Pass.RenderStates.SampleState); SAFE_RELEASE(Gui::Pass.IAStage.Layout); + + SAFE_RELEASE(Gui::Text::Pass.RenderStates.BlendState); + + SAFE_RELEASE(Gui::Text::Pass.IAStage.Layout); } } } diff --git a/Code/OysterGraphics/Render/Resources.h b/Code/OysterGraphics/Render/Resources.h index 2d05aab6..cdc12efc 100644 --- a/Code/OysterGraphics/Render/Resources.h +++ b/Code/OysterGraphics/Render/Resources.h @@ -36,6 +36,7 @@ namespace Oyster static ID3D11RasterizerState* rs; static ID3D11SamplerState** ss; static ID3D11DepthStencilState* dsState; + static ID3D11BlendState* bs; }; struct Gather @@ -60,7 +61,12 @@ namespace Oyster { static Core::PipelineManager::RenderPass Pass; static Core::Buffer Data; - static Core::Buffer Vertex; + struct Text + { + static Core::PipelineManager::RenderPass Pass; + static Core::Buffer Vertex; + static ID3D11ShaderResourceView* Font; + }; }; struct Blur diff --git a/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl b/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl new file mode 100644 index 00000000..feefbed7 --- /dev/null +++ b/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl @@ -0,0 +1,29 @@ +#include "Header.hlsli" + +[maxvertexcount(4)] +void main(point Text2DIn input[1],inout TriangleStream 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); +} \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextVertex.hlsl b/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextVertex.hlsl new file mode 100644 index 00000000..91497124 --- /dev/null +++ b/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextVertex.hlsl @@ -0,0 +1,6 @@ +#include "Header.hlsli" + +Text2DIn main(Text2DIn input) +{ + return input; +} \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/Passes/2D/Text/Header.hlsli b/Code/OysterGraphics/Shader/Passes/2D/Text/Header.hlsli new file mode 100644 index 00000000..7b64fd79 --- /dev/null +++ b/Code/OysterGraphics/Shader/Passes/2D/Text/Header.hlsli @@ -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; +}; \ No newline at end of file diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index a577f010..c857b320 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -158,19 +158,21 @@ HRESULT InitDirect3D() { 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(); o.modelPath = L"..\\Content\\Models\\"; o.texturePath = L"..\\Content\\Textures\\"; 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"); - m2 = Oyster::Graphics::API::CreateModel(L"char_fake_bin.dan"); - m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null); - Oyster::Graphics::API::PlayAnimation(m2, L"Bend",true); + m2 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan"); + 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"movement",true); t = Oyster::Graphics::API::CreateTexture(L"structure_corp_mdg.png"); @@ -195,8 +197,8 @@ HRESULT InitDirect3D() float angle = 0; HRESULT Update(float 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); + //angle += Oyster::Math::pi/16 * deltaTime; + 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::Graphics::API::Update(deltaTime); //m2->Animation.data.AnimationTime += deltaTime;// * 0.5f; @@ -211,7 +213,9 @@ HRESULT Render(float deltaTime) Oyster::Graphics::API::RenderModel(m); Oyster::Graphics::API::RenderModel(m2); 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(); return S_OK; @@ -254,10 +258,12 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam //m2->AnimationTime -= 0.1f; //if(m2->AnimationTime < 0) //m2->AnimationTime = 0; + angle += Oyster::Math::pi / 16; break; //X + case 0x58: //m2->AnimationTime += 0.1f; + angle -= Oyster::Math::pi / 16; break; }