Reuse SDL_Renderer after VM reset

Otherwise mouse input doesn't work after restart in emscripten port.
This commit is contained in:
kichikuou
2022-06-26 15:00:23 +09:00
parent 578a8bf095
commit 2cb0b2a2a2
4 changed files with 16 additions and 14 deletions
+3 -2
View File
@@ -8,6 +8,7 @@
#include <string.h>
extern SDL_Window* g_window;
extern SDL_Renderer* g_renderer;
void AGS::load_cursor(int page)
{
@@ -97,13 +98,13 @@ void AGS::translate_mouse_coords(int* x, int* y)
{
// scale mouse x and y
float scalex, scaley;
SDL_RenderGetScale(sdlRenderer, &scalex, &scaley);
SDL_RenderGetScale(g_renderer, &scalex, &scaley);
*x *= scalex;
*y *= scaley;
// calculate window borders
int logw, logh;
SDL_RenderGetLogicalSize(sdlRenderer, &logw, &logh);
SDL_RenderGetLogicalSize(g_renderer, &logw, &logh);
float scalew, scaleh;
scalew = logw * scalex;