From 9a0f363146ca95742edcf6b143f8b85853954ef5 Mon Sep 17 00:00:00 2001 From: lanariel Date: Fri, 7 Feb 2014 13:15:38 +0100 Subject: [PATCH] framerate double --- .../Definitions/GraphicalDefinition.h | 4 +- Code/OysterGraphics/DllInterfaces/GFXAPI.cpp | 10 +++++ Code/OysterGraphics/DllInterfaces/GFXAPI.h | 1 + .../Render/Rendering/BasicRender.cpp | 38 +++++-------------- .../Shader/Passes/Gather/Header.hlsli | 4 +- 5 files changed, 25 insertions(+), 32 deletions(-) diff --git a/Code/OysterGraphics/Definitions/GraphicalDefinition.h b/Code/OysterGraphics/Definitions/GraphicalDefinition.h index ae7bbeb8..41420cce 100644 --- a/Code/OysterGraphics/Definitions/GraphicalDefinition.h +++ b/Code/OysterGraphics/Definitions/GraphicalDefinition.h @@ -18,6 +18,8 @@ namespace Oyster { Math::Matrix WV; Math::Matrix WVP; + int Animated; + Math::Float3 Pad; }; struct FinalVertex @@ -52,8 +54,6 @@ namespace Oyster struct AnimationData { Math::Float4x4 AnimatedData[100]; - int Animated; - Math::Float3 Pad; }; struct GuiData diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index d7d30968..ff1c632b 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -165,5 +165,15 @@ namespace Oyster { Render::Rendering::Gui::Render((ID3D11Texture2D*)tex,pos,size); } + + API::Texture API::CreateTexture(std::wstring filename) + { + return Core::loader.LoadResource((Core::texturePath + filename).c_str(),Oyster::Graphics::Loading::LoadTexture, Oyster::Graphics::Loading::UnloadTexture); + } + + void API::DeleteTexture(API::Texture tex) + { + Core::loader.ReleaseResource(tex); + } } } \ No newline at end of file diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.h b/Code/OysterGraphics/DllInterfaces/GFXAPI.h index 64a774d6..a6f5ac7d 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.h +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.h @@ -68,6 +68,7 @@ namespace Oyster static void DeleteModel(Oyster::Graphics::Model::Model* model); static Texture CreateTexture(std::wstring filename); + static void DeleteTexture(Texture); //! @brief adds a light to the scene static void AddLight(Definitions::Pointlight light); diff --git a/Code/OysterGraphics/Render/Rendering/BasicRender.cpp b/Code/OysterGraphics/Render/Rendering/BasicRender.cpp index 24059331..f1abb56c 100644 --- a/Code/OysterGraphics/Render/Rendering/BasicRender.cpp +++ b/Code/OysterGraphics/Render/Rendering/BasicRender.cpp @@ -72,12 +72,7 @@ namespace Oyster pm.WV = View * models[i].WorldMatrix; pm.WVP = Projection * pm.WV; - void* data = Resources::Deffered::ModelData.Map(); - memcpy(data,&(pm),sizeof(pm)); - Resources::Deffered::ModelData.Unmap(); - - Model::ModelInfo* info = (Model::ModelInfo*)models[i].info; - + Model::ModelInfo* info = models[i].info; Definitions::AnimationData am; //final if(info->Animated && models[i].AnimationPlaying != -1) @@ -105,12 +100,7 @@ namespace Oyster cube2->WorldMatrix = Scale; cube2->WorldMatrix.v[3] = info->bones[b].Absolute.v[3]; - //Basic::RenderScene(cube2,1, View, Projection); } - //BoneAnimated[8] = Math3D::RotationMatrix(3.14/4, Math::Float3(0, 0, 1)) * info->bones[8].Relative; - //BoneAnimated[31] = Math3D::RotationMatrix(3.14/4, Math::Float3(0, 0, 1)) * info->bones[31].Relative; - ////for each bone in animation - ////HACK use first bone int b = 0; Model::Animation A = info->Animations[models[i].AnimationPlaying]; while(models[i].AnimationTime>A.duration) @@ -160,27 +150,19 @@ namespace Oyster am.AnimatedData[b] = (BoneAbsAnimated[b] * SkinTransform[b]); } - //retore to draw animated model - Definitions::PerModel pm; - pm.WV = View * models[i].WorldMatrix; - pm.WVP = Projection * pm.WV; + + void *data = Resources::Deffered::AnimationData.Map(); + memcpy(data,&am,sizeof(Definitions::AnimationData)); + Resources::Deffered::AnimationData.Unmap(); - void* data = Resources::Deffered::ModelData.Map(); - memcpy(data,&(pm),sizeof(pm)); - Resources::Deffered::ModelData.Unmap(); - - //delete[]SkinTransform; - //delete[]BoneAbsAnimated; - //delete[]BoneAnimated; - - am.Animated = 1; + pm.Animated = 1; } else - am.Animated = 0; + pm.Animated = 0; - data = Resources::Deffered::AnimationData.Map(); - memcpy(data,&am,sizeof(Definitions::AnimationData)); - Resources::Deffered::AnimationData.Unmap(); + void* data = Resources::Deffered::ModelData.Map(); + memcpy(data,&(pm),sizeof(pm)); + Resources::Deffered::ModelData.Unmap(); if(info->Material.size()) { diff --git a/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli b/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli index 06583cd6..a313a649 100644 --- a/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli +++ b/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli @@ -33,12 +33,12 @@ SamplerState S1 : register(s0); cbuffer Animation : register(b0) { float4x4 AnimatedData[100]; - int Animated; - float3 Pad; } cbuffer PerModel : register(b1) { matrix WV; matrix WVP; + int Animated; + float3 Pad; } \ No newline at end of file