From c85d9d978dffb3c5b8b32f0ec7ca9e4e918b66df Mon Sep 17 00:00:00 2001 From: Helloman892 <1565516+Helloman892@users.noreply.github.com> Date: Mon, 18 Dec 2017 00:48:37 +0000 Subject: [PATCH] updated pp2d --- source/pp2d/pp2d/pp2d.c | 17 +++++++++++++++-- source/pp2d/pp2d/pp2d.h | 9 ++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/source/pp2d/pp2d/pp2d.c b/source/pp2d/pp2d/pp2d.c index 066adca..fefb09c 100644 --- a/source/pp2d/pp2d/pp2d.c +++ b/source/pp2d/pp2d/pp2d.c @@ -27,7 +27,7 @@ * Plug & Play 2D * @file pp2d.c * @author Bernardo Giordano - * @date 17 October 2017 + * @date 26 October 2017 * @brief pp2d implementation */ @@ -46,6 +46,11 @@ static C3D_RenderTarget* topLeft; static C3D_RenderTarget* topRight; static C3D_RenderTarget* bot; +static struct { + GPU_TEXTURE_FILTER_PARAM magFilter; + GPU_TEXTURE_FILTER_PARAM minFilter; +} textureFilters; + static struct { size_t id; int x; @@ -340,6 +345,8 @@ Result pp2d_init(void) res = fontEnsureMapped(); if (R_FAILED(res)) return res; + + pp2d_set_texture_filter(GPU_NEAREST, GPU_NEAREST); #ifdef BUILDTOOLS vshader_dvlb = DVLB_ParseFile((u32*)vshader_shbin, vshader_shbin_len); @@ -503,7 +510,7 @@ void pp2d_load_texture_memory(size_t id, void* buf, u32 width, u32 height) u32 h_pow2 = pp2d_get_next_pow2(height); C3D_TexInit(&textures[id].tex, (u16)w_pow2, (u16)h_pow2, GPU_RGBA8); - C3D_TexSetFilter(&textures[id].tex, GPU_NEAREST, GPU_NEAREST); + C3D_TexSetFilter(&textures[id].tex, textureFilters.magFilter, textureFilters.minFilter); textures[id].allocated = true; textures[id].width = width; @@ -608,6 +615,12 @@ void pp2d_set_screen_color(gfxScreen_t target, u32 color) } } +void pp2d_set_texture_filter(GPU_TEXTURE_FILTER_PARAM magFilter, GPU_TEXTURE_FILTER_PARAM minFilter) +{ + textureFilters.magFilter = magFilter; + textureFilters.minFilter = minFilter; +} + static void pp2d_set_text_color(u32 color) { C3D_TexEnv* env = C3D_GetTexEnv(0); diff --git a/source/pp2d/pp2d/pp2d.h b/source/pp2d/pp2d/pp2d.h index 7ed93a0..080f057 100644 --- a/source/pp2d/pp2d/pp2d.h +++ b/source/pp2d/pp2d/pp2d.h @@ -27,7 +27,7 @@ * Plug & Play 2D * @file pp2d.h * @author Bernardo Giordano - * @date 17 October 2017 + * @date 26 October 2017 * @brief pp2d header */ @@ -402,6 +402,13 @@ void pp2d_set_3D(int enable); */ void pp2d_set_screen_color(gfxScreen_t target, u32 color); +/** + * @brief Sets filters to load texture with + * @param magFilter GPU_NEAREST or GPU_LINEAR + * @param minFilter GPU_NEAREST or GPU_LINEAR + */ +void pp2d_set_texture_filter(GPU_TEXTURE_FILTER_PARAM magFilter, GPU_TEXTURE_FILTER_PARAM minFilter); + /** * @brief Inits a texture to be drawn * @param id of the texture