soft: scale small video

in case if aspect ratio is same as window
This commit is contained in:
Denis Pauk 2023-12-19 01:40:10 +02:00
parent fa3ec83253
commit 2b24ee9b53

View file

@ -2225,9 +2225,14 @@ RE_Draw_StretchDirectRaw(int x, int y, int w, int h, int cols, int rows, const b
int pitch;
Uint32 *pixels;
if (!cols || !rows || !data)
{
return;
}
if (bits != 32 || x || y ||
w != vid_buffer_width || h != vid_buffer_height ||
cols != vid_buffer_width || rows != vid_buffer_height)
cols > vid_buffer_width || rows > vid_buffer_height)
{
/* Not full screen update */
RE_Draw_StretchRaw(x, y, w, h, cols, rows, data, bits);
@ -2257,11 +2262,39 @@ RE_Draw_StretchDirectRaw(int x, int y, int w, int h, int cols, int rows, const b
return;
}
if (cols == vid_buffer_width && rows == vid_buffer_height)
{
memcpy(pixels, data, vid_buffer_width * vid_buffer_height * sizeof(Uint32));
}
else
{
int i;
for (i = 0; i < rows; i++)
{
memcpy(pixels + i * vid_buffer_width,
data + i * cols * sizeof(Uint32),
cols * sizeof(Uint32)
);
}
}
SDL_UnlockTexture(texture);
if (cols == vid_buffer_width && rows == vid_buffer_height)
{
SDL_RenderCopy(renderer, texture, NULL, NULL);
}
else
{
SDL_Rect srcrect;
srcrect.x = 0;
srcrect.y = 0;
srcrect.w = cols;
srcrect.h = rows;
SDL_RenderCopy(renderer, texture, &srcrect, NULL);
}
SDL_RenderPresent(renderer);
is_render_flushed = true;