Use SmoothColorImage as final filtering

This commit is contained in:
Denis Pauk 2020-10-29 22:57:57 +02:00
parent be2e91e142
commit 2e93364940
5 changed files with 28 additions and 18 deletions

View file

@ -161,8 +161,6 @@ extern oldrefdef_t r_refdef;
#define ALIAS_Z_CLIP 0x0010
#define ALIAS_XY_CLIP_MASK 0x000F
#define SURFCACHE_SIZE_AT_320X240 1024*768
#define BMODEL_FULLY_CLIPPED 0x10 // value returned by R_BmodelCheckBBox ()
// if bbox is trivially rejected

View file

@ -228,13 +228,13 @@ R_LoadWal (char *name, imagetype_t type)
file_size = ri.FS_LoadFile (name, (void **)&mt);
if (!mt)
{
R_Printf(PRINT_ALL, "R_LoadWal: can't load %s\n", name);
R_Printf(PRINT_ALL, "%s: can't load %s\n", __func__, name);
return r_notexture_mip;
}
if (file_size < sizeof(miptex_t))
{
R_Printf(PRINT_ALL, "R_LoadWal: can't load %s, small header\n", name);
R_Printf(PRINT_ALL, "%s: can't load %s, small header\n", __func__, name);
ri.FS_FreeFile((void *)mt);
return r_notexture_mip;
}
@ -251,7 +251,7 @@ R_LoadWal (char *name, imagetype_t type)
if ((ofs <= 0) || (image->width <= 0) || (image->height <= 0) ||
((file_size - ofs) / image->width < image->height))
{
R_Printf(PRINT_ALL, "LoadWal: can't load %s, small body\n", name);
R_Printf(PRINT_ALL, "%s: can't load %s, small body\n", __func__, name);
ri.FS_FreeFile((void *)mt);
return r_notexture_mip;
}

View file

@ -1293,7 +1293,8 @@ RE_RenderFrame (refdef_t *fd)
VectorCopy (fd->viewangles, r_refdef.viewangles);
// compare current position with old
if (!VectorCompareRound(fd->vieworg, lastvieworg) ||
if (vid.width <= 640 ||
!VectorCompareRound(fd->vieworg, lastvieworg) ||
!VectorCompare(fd->viewangles, lastviewangles))
{
fastmoving = true;
@ -1426,6 +1427,8 @@ RE_BeginFrame( float camera_separation )
{
// pallete without changes
palette_changed = false;
// run without speed optimization
fastmoving = false;
while (r_mode->modified || vid_fullscreen->modified || r_vsync->modified)
{
@ -2055,10 +2058,13 @@ RE_CopyFrame (Uint32 * pixels, int pitch, int vmin, int vmax)
max_pixels = pixels + vmax;
buffer_pos = vid_buffer + vmin;
for (pixels_pos = pixels + vmin; pixels_pos < max_pixels; pixels_pos++)
pixels_pos = pixels + vmin;
while ( pixels_pos < max_pixels)
{
*pixels_pos = sdl_palette[*buffer_pos];
buffer_pos++;
pixels_pos++;
}
}
else
@ -2128,6 +2134,7 @@ RE_CleanFrame(void)
Com_Printf("Can't lock texture: %s\n", SDL_GetError());
return;
}
// only cleanup texture without flush texture to screen
memset(pixels, 0, pitch * vid.height);
SDL_UnlockTexture(texture);
@ -2157,6 +2164,12 @@ RE_FlushFrame(int vmin, int vmax)
// code have to copy a whole screen to the texture
RE_CopyFrame (pixels, pitch / sizeof(Uint32), 0, vid.height * vid.width);
}
if (((int)sw_texture_filtering->value & 0x01) && !fastmoving)
{
SmoothColorImage(pixels + vmin, vmax - vmin, vid.width >> 7);
}
SDL_UnlockTexture(texture);
SDL_RenderCopy(renderer, texture, NULL, NULL);

View file

@ -719,7 +719,7 @@ D_DrawSpansPow2 (espan_t *pspan, float d_ziorigin, float d_zistepu, float d_zist
}
// Drawing phrase
if (texture_filtering == 0 || fastmoving)
if ((texture_filtering & 0x02) == 0 || fastmoving)
{
pdest = D_DrawSpan(pdest, pbase, s, t, sstep, tstep,
spancount);

View file

@ -213,18 +213,17 @@ R_InitCaches (void)
int size;
// calculate size to allocate
if (sw_surfcacheoverride->value)
{
size = sw_surfcacheoverride->value;
}
else
{
int pix;
size = SURFCACHE_SIZE_AT_320X240;
// surface cache size at 320X240
size = 1024*768;
pix = vid.width*vid.height;
if (pix > 64000)
size += (pix-64000)*3;
if (sw_surfcacheoverride->value > size)
{
size = sw_surfcacheoverride->value;
}
// round up to page size