Added new functions

- SetWindowSize() to scale Windows in runtime
- SetMouseScale() to scale mouse input, useful when rendering game to a
RenderTexture2D that will be scaled to Window size (used on rFXGen tool)
This commit is contained in:
Ray San 2018-03-09 11:43:53 +01:00
parent 276847eca9
commit df50eada53
2 changed files with 25 additions and 4 deletions

View file

@ -326,6 +326,7 @@ static int lastGamepadButtonPressed = -1; // Register last gamepad button pres
static int gamepadAxisCount = 0; // Register number of available gamepad axis
static Vector2 mousePosition; // Mouse position on screen
static float mouseScale = 1.0f; // Mouse default scale
#if defined(PLATFORM_WEB)
static bool toggleCursorLock = false; // Ask for cursor pointer lock on next click
@ -736,6 +737,15 @@ void SetWindowMinSize(int width, int height)
#endif
}
// Set window dimensions
void SetWindowSize(int width, int height)
{
#if defined(PLATFORM_DESKTOP)
glfwSetWindowSize(window, width, height);
#endif
}
// Get current screen width
int GetScreenWidth(void)
{
@ -1253,7 +1263,7 @@ const char *GetExtension(const char *fileName)
{
const char *dot = strrchr(fileName, '.');
if (!dot || dot == fileName) return "";
if (!dot || dot == fileName) return NULL;
return (dot + 1);
}
@ -1648,7 +1658,7 @@ int GetMouseX(void)
#if defined(PLATFORM_ANDROID)
return (int)touchPosition[0].x;
#else
return (int)mousePosition.x;
return (int)(mousePosition.x*mouseScale);
#endif
}
@ -1658,7 +1668,7 @@ int GetMouseY(void)
#if defined(PLATFORM_ANDROID)
return (int)touchPosition[0].x;
#else
return (int)mousePosition.y;
return (int)(mousePosition.y*mouseScale);
#endif
}
@ -1668,7 +1678,7 @@ Vector2 GetMousePosition(void)
#if defined(PLATFORM_ANDROID)
return GetTouchPosition(0);
#else
return mousePosition;
return (Vector2){ mousePosition.x*mouseScale, mousePosition.y*mouseScale };
#endif
}
@ -1682,6 +1692,15 @@ void SetMousePosition(Vector2 position)
#endif
}
// Set mouse scaling
// NOTE: Useful when rendering to different size targets
void SetMouseScale(float scale)
{
#if !defined(PLATFORM_ANDROID)
mouseScale = scale;
#endif
}
// Returns mouse wheel movement Y
int GetMouseWheelMove(void)
{