mirror of
https://github.com/pevans/erc-c.git
synced 2024-11-27 20:51:17 +00:00
Use SDL's render logical size feature
This allows us to work with the pure x/y coordinate system we set when creating the vm_screen. SDL will take care of the translation of those coordinates to whatever the window size is.
This commit is contained in:
parent
f3966dc010
commit
05a641c8f6
@ -69,6 +69,13 @@ vm_screen_add_window(vm_screen *screen)
|
|||||||
return ERR_GFXINIT;
|
return ERR_GFXINIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We plan to draw onto a surface that is xcoords x ycoords in area,
|
||||||
|
// regardless of the actual size of the window.
|
||||||
|
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
|
||||||
|
SDL_RenderSetLogicalSize(screen->render,
|
||||||
|
screen->xcoords,
|
||||||
|
screen->ycoords);
|
||||||
|
|
||||||
vm_screen_set_color(screen, 0, 0, 0, 0);
|
vm_screen_set_color(screen, 0, 0, 0, 0);
|
||||||
SDL_RenderClear(screen->render);
|
SDL_RenderClear(screen->render);
|
||||||
|
|
||||||
@ -129,13 +136,12 @@ vm_screen_draw_rect(vm_screen *screen,
|
|||||||
int xsize,
|
int xsize,
|
||||||
int ysize)
|
int ysize)
|
||||||
{
|
{
|
||||||
// We need to scale the position and sizes, since the presumption is
|
// The renderer will take care of translating the positions and
|
||||||
// that we are plotting based on the literal x and y coordinates in
|
// sizes into whatever the window is really at.
|
||||||
// the screen.
|
screen->rect.x = xpos;
|
||||||
screen->rect.x = xpos * screen->scale;
|
screen->rect.y = ypos;
|
||||||
screen->rect.y = ypos * screen->scale;
|
screen->rect.w = xsize;
|
||||||
screen->rect.w = xsize * screen->scale;
|
screen->rect.h = ysize;
|
||||||
screen->rect.h = ysize * screen->scale;
|
|
||||||
|
|
||||||
SDL_RenderFillRect(screen->render, &screen->rect);
|
SDL_RenderFillRect(screen->render, &screen->rect);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user