updated pp2d

This commit is contained in:
Helloman892
2017-12-18 00:48:37 +00:00
parent db0804af3b
commit c85d9d978d
2 changed files with 23 additions and 3 deletions

View File

@@ -27,7 +27,7 @@
* Plug & Play 2D * Plug & Play 2D
* @file pp2d.c * @file pp2d.c
* @author Bernardo Giordano * @author Bernardo Giordano
* @date 17 October 2017 * @date 26 October 2017
* @brief pp2d implementation * @brief pp2d implementation
*/ */
@@ -46,6 +46,11 @@ static C3D_RenderTarget* topLeft;
static C3D_RenderTarget* topRight; static C3D_RenderTarget* topRight;
static C3D_RenderTarget* bot; static C3D_RenderTarget* bot;
static struct {
GPU_TEXTURE_FILTER_PARAM magFilter;
GPU_TEXTURE_FILTER_PARAM minFilter;
} textureFilters;
static struct { static struct {
size_t id; size_t id;
int x; int x;
@@ -341,6 +346,8 @@ Result pp2d_init(void)
if (R_FAILED(res)) if (R_FAILED(res))
return res; return res;
pp2d_set_texture_filter(GPU_NEAREST, GPU_NEAREST);
#ifdef BUILDTOOLS #ifdef BUILDTOOLS
vshader_dvlb = DVLB_ParseFile((u32*)vshader_shbin, vshader_shbin_len); vshader_dvlb = DVLB_ParseFile((u32*)vshader_shbin, vshader_shbin_len);
#else #else
@@ -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); u32 h_pow2 = pp2d_get_next_pow2(height);
C3D_TexInit(&textures[id].tex, (u16)w_pow2, (u16)h_pow2, GPU_RGBA8); 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].allocated = true;
textures[id].width = width; 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) static void pp2d_set_text_color(u32 color)
{ {
C3D_TexEnv* env = C3D_GetTexEnv(0); C3D_TexEnv* env = C3D_GetTexEnv(0);

View File

@@ -27,7 +27,7 @@
* Plug & Play 2D * Plug & Play 2D
* @file pp2d.h * @file pp2d.h
* @author Bernardo Giordano * @author Bernardo Giordano
* @date 17 October 2017 * @date 26 October 2017
* @brief pp2d header * @brief pp2d header
*/ */
@@ -402,6 +402,13 @@ void pp2d_set_3D(int enable);
*/ */
void pp2d_set_screen_color(gfxScreen_t target, u32 color); 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 * @brief Inits a texture to be drawn
* @param id of the texture * @param id of the texture