]> git.mxchange.org Git - quix0rs-blobwars.git/commitdiff
Fix mouse scaling in fullscreen mode.
authorGuus Sliepen <guus@debian.org>
Thu, 6 Aug 2015 16:49:33 +0000 (18:49 +0200)
committerGuus Sliepen <guus@debian.org>
Thu, 6 Aug 2015 16:49:33 +0000 (18:49 +0200)
src/CEngine.cpp

index 32262f11d51d9f26fc4b320d8beb209bf3df2933..45f30eff7d65632ea499b839addaa083a480a5d2 100644 (file)
@@ -157,6 +157,12 @@ void Engine::getInput()
 {
        SDL_GetMouseState(&mouseX, &mouseY);
 
+       // Scale from window coordinates to graphics coordinates
+       int w, h;
+       SDL_GetWindowSize(graphics.window, &w, &h);
+       mouseX = mouseX * 640 / w;
+       mouseY = mouseY * 480 / h;
+
        while (SDL_PollEvent(&event))
        {
                switch (event.type)