From 592edf7dba7a031c892892c8848c00d20b7853d7 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 9 Mar 2016 23:31:54 +0100 Subject: [PATCH] Sprites can now be rendered with the texture ratio in mind --- assets | 2 +- include/Engine/Rendering/SpriteJob.h | 17 ++++++++++++++--- resources/Schema/Components/Sprite.xml | 1 + resources/Schema/Components/Sprite.xsd | 3 +++ src/Engine/Rendering/DrawFinalPass.cpp | 4 ++-- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/assets b/assets index 3af64d8b..85d96f6f 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 3af64d8b1f8cdf3e20198b079dfc02f6d64fdc88 +Subproject commit 85d96f6f3d2269e46962492f9713ec67c54e8ece diff --git a/include/Engine/Rendering/SpriteJob.h b/include/Engine/Rendering/SpriteJob.h index 596e37f2..6b52144f 100644 --- a/include/Engine/Rendering/SpriteJob.h +++ b/include/Engine/Rendering/SpriteJob.h @@ -49,11 +49,22 @@ struct SpriteJob : RenderJob FillColor = fillColor; FillPercentage = fillPercentage; + glm::vec3 scale = Transform::AbsoluteScale(world, cSprite.EntityID); + if((bool)cSprite["KeepRatioX"] == true) { - ScaleX = Transform::AbsoluteScale(world, cSprite.EntityID).x; + ScaleX = scale.x; } - if ((bool)cSprite["KeepRatioZ"] == true) { - ScaleY = Transform::AbsoluteScale(world, cSprite.EntityID).y; + if ((bool)cSprite["KeepRatioY"] == true) { + ScaleY = scale.y; + } + if((bool)cSprite["KeepRatio"] == true) { + if(scale.y >= scale.x) { + ScaleY = (scale.x)/(scale.y); + ScaleX = 1; + } else { + ScaleY = 1; + ScaleX = (scale.x)/(scale.y); + } } }; diff --git a/resources/Schema/Components/Sprite.xml b/resources/Schema/Components/Sprite.xml index 19cd1313..2c0465e9 100644 --- a/resources/Schema/Components/Sprite.xml +++ b/resources/Schema/Components/Sprite.xml @@ -7,5 +7,6 @@ true false false + false false diff --git a/resources/Schema/Components/Sprite.xsd b/resources/Schema/Components/Sprite.xsd index e727040c..eab74bfc 100644 --- a/resources/Schema/Components/Sprite.xsd +++ b/resources/Schema/Components/Sprite.xsd @@ -30,6 +30,9 @@ Wether the sprite should repeat in y instead of stretch when scaled. + + Keep a 1:1 ratio between X and Y. + Wether the background should be blurred begind this sprite. diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 62ce846d..c5b8c591 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -311,8 +311,8 @@ void DrawFinalPass::Draw(RenderScene& scene, BlurHUD* blurHUDPass) GLERROR("TransparentObjects"); //state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); stateSprite->Enable(GL_DEPTH_TEST); - stateSprite->AlphaFunc(GL_GEQUAL, 0.05f); - stateSprite->Enable(GL_ALPHA_TEST); + //stateSprite->AlphaFunc(GL_GEQUAL, 0.05f); + //stateSprite->Enable(GL_ALPHA_TEST); DrawSprites(scene.Jobs.SpriteJob, scene); GLERROR("SpriteJobs");