VIDEO: Stretch frame buffer to accomodate output window.
This commit is contained in:
parent
d93bfe62de
commit
6ca7a938ad
1 changed files with 24 additions and 7 deletions
31
sim_video.c
31
sim_video.c
|
@ -1418,21 +1418,38 @@ else
|
|||
return SCPE_OK;
|
||||
}
|
||||
|
||||
static void vid_stretch(SDL_Rect *r)
|
||||
{
|
||||
/* Return in r a rectangle with the same aspect ratio as the video
|
||||
buffer but scaled to fit precisely in the output window. Normally,
|
||||
the buffer and the window have the same sizes, but if the window is
|
||||
resized, or fullscreen is in effect, they are not. */
|
||||
int w, h;
|
||||
SDL_GetRendererOutputSize(vid_renderer, &w, &h);
|
||||
if ((double)h / vid_height < (double)w / vid_width) {
|
||||
r->w = vid_width * h / vid_height;
|
||||
r->h = h;
|
||||
r->x = (w - r->w) / 2;
|
||||
r->y = 0;
|
||||
}
|
||||
else {
|
||||
r->w = w;
|
||||
r->h = vid_height * w / vid_width;
|
||||
r->x = 0;
|
||||
r->y = (h - r->h) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
void vid_update (void)
|
||||
{
|
||||
SDL_Rect vid_dst;
|
||||
|
||||
vid_dst.x = 0;
|
||||
vid_dst.y = 0;
|
||||
vid_dst.w = vid_width;
|
||||
vid_dst.h = vid_height;
|
||||
|
||||
vid_stretch(&vid_dst);
|
||||
sim_debug (SIM_VID_DBG_VIDEO, vid_dev, "Video Update Event: \n");
|
||||
if (sim_deb)
|
||||
fflush (sim_deb);
|
||||
if (SDL_RenderClear (vid_renderer))
|
||||
sim_printf ("%s: Video Update Event: SDL_RenderClear error: %s\n", vid_dname(vid_dev), SDL_GetError());
|
||||
if (SDL_RenderCopy (vid_renderer, vid_texture, NULL, NULL))
|
||||
if (SDL_RenderCopy (vid_renderer, vid_texture, NULL, &vid_dst))
|
||||
sim_printf ("%s: Video Update Event: SDL_RenderCopy error: %s\n", vid_dname(vid_dev), SDL_GetError());
|
||||
SDL_RenderPresent (vid_renderer);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue