From 20f9a1b8a4ed0766e8135e41e855537f07774a72 Mon Sep 17 00:00:00 2001 From: Francisco Javier Trujillo Mata Date: Mon, 8 Aug 2022 17:23:43 +0200 Subject: [PATCH] Implement SetTextureScaleMode --- src/render/ps2/SDL_render_ps2.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/render/ps2/SDL_render_ps2.c b/src/render/ps2/SDL_render_ps2.c index b5143336e..31f01b674 100644 --- a/src/render/ps2/SDL_render_ps2.c +++ b/src/render/ps2/SDL_render_ps2.c @@ -174,8 +174,6 @@ PS2_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, const Uint8 *src; Uint8 *dst; int row, length,dpitch; - GSTEXTURE *ps2_texture = (GSTEXTURE *) texture->driverdata; - PS2_RenderData *data = (PS2_RenderData *) renderer->driverdata; src = pixels; PS2_LockTexture(renderer, texture, rect, (void **)&dst, &dpitch); @@ -198,6 +196,17 @@ PS2_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, static void PS2_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode) { + GSTEXTURE *ps2_texture = (GSTEXTURE *) texture->driverdata; + /* + set texture filtering according to scaleMode + suported hint values are nearest (0, default) or linear (1) + gskit scale mode is either GS_FILTER_NEAREST (good for tile-map) + or GS_FILTER_LINEAR (good for scaling) + */ + uint32_t gsKitScaleMode = (scaleMode == SDL_ScaleModeNearest + ? GS_FILTER_NEAREST + : GS_FILTER_LINEAR); + ps2_texture->Filter = gsKitScaleMode; } static int @@ -577,12 +586,12 @@ PS2_RenderPoints(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand * cmd const uint8_t ColorB = cmd->data.draw.b >> 1; const uint8_t ColorA = cmd->data.draw.a >> 1; + const clear_vertex *verts = (clear_vertex *) (vertices + cmd->data.draw.first); + PS2_SetBlendMode(data, cmd->data.draw.blend); color = GS_SETREG_RGBAQ(ColorR, ColorG, ColorB, ColorA, 0x00); - const clear_vertex *verts = (clear_vertex *) (vertices + cmd->data.draw.first); - for (i = 0; i < count; i++, verts++) { gsKit_prim_point(data->gsGlobal, verts->x, verts->y, 0, color); }