review of sw_texture_sample_linear

This commit is contained in:
Bigfoot71 2025-10-24 16:42:44 +02:00
parent 3fdefb7839
commit 5027e4481e

14
src/external/rlsw.h vendored
View File

@ -1942,18 +1942,20 @@ static inline void sw_texture_sample_linear(float *color, const sw_texture_t *te
// TODO: With a bit more cleverness we could clearly reduce the
// number of operations here, but for now it works fine.
float xf = u*tex->width - 0.5f;
float yf = v*tex->height - 0.5f;
float xf = (u * tex->width) - 0.5f;
float yf = (v * tex->height) - 0.5f;
int x0 = (int)floorf(xf);
int y0 = (int)floorf(yf);
float fx = sw_fract(xf);
float fy = sw_fract(yf);
float fx = xf - x0;
float fy = yf - y0;
int x0 = (int)xf;
int y0 = (int)yf;
int x1 = x0 + 1;
int y1 = y0 + 1;
// NOTE: If the textures are POT we could avoid the division for SW_REPEAT
if (tex->sWrap == SW_CLAMP)
{
x0 = (x0 > tex->wMinus1)? tex->wMinus1 : x0;