new Tutorial

tutorial with sprite offset, sprite sheet and texture filtering
This commit is contained in:
Guido Diego Quispe Robles
2023-05-28 13:47:48 -03:00
parent fbcb38d37a
commit 4f6e55c0b0
9 changed files with 321 additions and 16 deletions
@@ -84,10 +84,10 @@ void RendererCore2D::render(const Sprite& sprite,
else if (sizeY > sizeX)
texS = texMax / (sizeY / sizeX);
rect->t0.s = sprite.flipHorizontal ? texS : 0.0F;
rect->t0.t = sprite.flipVertical ? texT : 0.0F;
rect->t1.s = sprite.flipHorizontal ? 0.0F : texS;
rect->t1.t = sprite.flipVertical ? 0.0F : texT;
rect->t0.s = sprite.flipHorizontal ? (texS+sprite.offset.x) : sprite.offset.x;
rect->t0.t = sprite.flipVertical ? (texT+sprite.offset.y) : sprite.offset.y;
rect->t1.s = sprite.flipHorizontal ? sprite.offset.x : (texS+sprite.offset.x);
rect->t1.t = sprite.flipVertical ? sprite.offset.y : (texT+sprite.offset.y);
rect->color.r = sprite.color.r;
rect->color.g = sprite.color.g;
@@ -131,4 +131,9 @@ void RendererCore2D::render(const Sprite& sprite,
context = !context;
}
void RendererCore2D::setTextureMappingType(const PipelineTextureMappingType textureMappingType){
lod.mag_filter = textureMappingType;
lod.min_filter = textureMappingType;
}
} // namespace Tyra
@@ -18,6 +18,7 @@ Sprite::Sprite() {
flipVertical = false;
size.set(32.0F, 32.0F);
position.set(100.0F, 100.0F);
offset.set(0.0F,0.0F);
scale = 1.0F;
mode = MODE_REPEAT;
setDefaultColor();