Merge branch 'master' into submodules
This commit is contained in:
commit
205b9e171e
1 changed files with 58 additions and 22 deletions
61
src/rcore.c
61
src/rcore.c
|
|
@ -1312,9 +1312,36 @@ void SetWindowMonitor(int monitor)
|
|||
// Set window minimum dimensions (FLAG_WINDOW_RESIZABLE)
|
||||
void SetWindowMinSize(int width, int height)
|
||||
{
|
||||
CORE.Window.windowMin.width = width;
|
||||
CORE.Window.windowMin.height = height;
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
const GLFWvidmode *mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
|
||||
glfwSetWindowSizeLimits(CORE.Window.handle, width, height, mode->width, mode->height);
|
||||
int minWidth = (CORE.Window.windowMin.width == 0) ? GLFW_DONT_CARE : CORE.Window.windowMin.width;
|
||||
int minHeight = (CORE.Window.windowMin.height == 0) ? GLFW_DONT_CARE : CORE.Window.windowMin.height;
|
||||
int maxWidth = (CORE.Window.windowMax.width == 0) ? GLFW_DONT_CARE : CORE.Window.windowMax.width;
|
||||
int maxHeight = (CORE.Window.windowMax.height == 0) ? GLFW_DONT_CARE : CORE.Window.windowMax.height;
|
||||
glfwSetWindowSizeLimits(CORE.Window.handle, minWidth, minHeight, maxWidth, maxHeight);
|
||||
#endif
|
||||
#if defined(PLATFORM_WEB)
|
||||
// Trigger the resize event once to update the window minimum width and height
|
||||
if ((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) != 0) EmscriptenResizeCallback(EMSCRIPTEN_EVENT_RESIZE, NULL, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set window maximum dimensions (FLAG_WINDOW_RESIZABLE)
|
||||
void SetWindowMaxSize(int width, int height)
|
||||
{
|
||||
CORE.Window.windowMax.width = width;
|
||||
CORE.Window.windowMax.height = height;
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
int minWidth = (CORE.Window.windowMin.width == 0) ? GLFW_DONT_CARE : CORE.Window.windowMin.width;
|
||||
int minHeight = (CORE.Window.windowMin.height == 0) ? GLFW_DONT_CARE : CORE.Window.windowMin.height;
|
||||
int maxWidth = (CORE.Window.windowMax.width == 0) ? GLFW_DONT_CARE : CORE.Window.windowMax.width;
|
||||
int maxHeight = (CORE.Window.windowMax.height == 0) ? GLFW_DONT_CARE : CORE.Window.windowMax.height;
|
||||
glfwSetWindowSizeLimits(CORE.Window.handle, minWidth, minHeight, maxWidth, maxHeight);
|
||||
#endif
|
||||
#if defined(PLATFORM_WEB)
|
||||
// Trigger the resize event once to update the window maximum width and height
|
||||
if ((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) != 0) EmscriptenResizeCallback(EMSCRIPTEN_EVENT_RESIZE, NULL, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -2707,7 +2734,7 @@ bool DirectoryExists(const char *dirPath)
|
|||
int GetFileLength(const char *fileName)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
|
||||
// NOTE: On Unix-like systems, it can by used the POSIX system call: stat(),
|
||||
// but depending on the platform that call could not be available
|
||||
//struct stat result = { 0 };
|
||||
|
|
@ -2720,11 +2747,11 @@ int GetFileLength(const char *fileName)
|
|||
{
|
||||
fseek(file, 0L, SEEK_END);
|
||||
long int fileSize = ftell(file);
|
||||
|
||||
|
||||
// Check for size overflow (INT_MAX)
|
||||
if (fileSize > 2147483647) TRACELOG(LOG_WARNING, "[%s] File size overflows expected limit, do not use GetFileLength()", fileName);
|
||||
else size = (int)fileSize;
|
||||
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
|
|
@ -3290,12 +3317,12 @@ bool IsKeyPressed(int key)
|
|||
bool IsKeyPressedRepeat(int key)
|
||||
{
|
||||
bool repeat = false;
|
||||
|
||||
|
||||
if ((key > 0) && (key < MAX_KEYBOARD_KEYS))
|
||||
{
|
||||
if (CORE.Input.Keyboard.keyRepeatInFrame[key] == 1) repeat = true;
|
||||
}
|
||||
|
||||
|
||||
return repeat;
|
||||
}
|
||||
|
||||
|
|
@ -3303,12 +3330,12 @@ bool IsKeyPressedRepeat(int key)
|
|||
bool IsKeyDown(int key)
|
||||
{
|
||||
bool down = false;
|
||||
|
||||
|
||||
if ((key > 0) && (key < MAX_KEYBOARD_KEYS))
|
||||
{
|
||||
if (CORE.Input.Keyboard.currentKeyState[key] == 1) down = true;
|
||||
}
|
||||
|
||||
|
||||
return down;
|
||||
}
|
||||
|
||||
|
|
@ -3316,7 +3343,7 @@ bool IsKeyDown(int key)
|
|||
bool IsKeyReleased(int key)
|
||||
{
|
||||
bool released = false;
|
||||
|
||||
|
||||
if ((key > 0) && (key < MAX_KEYBOARD_KEYS))
|
||||
{
|
||||
if ((CORE.Input.Keyboard.previousKeyState[key] == 1) && (CORE.Input.Keyboard.currentKeyState[key] == 0)) released = true;
|
||||
|
|
@ -3329,12 +3356,12 @@ bool IsKeyReleased(int key)
|
|||
bool IsKeyUp(int key)
|
||||
{
|
||||
bool up = false;
|
||||
|
||||
|
||||
if ((key > 0) && (key < MAX_KEYBOARD_KEYS))
|
||||
{
|
||||
if (CORE.Input.Keyboard.currentKeyState[key] == 0) up = true;
|
||||
}
|
||||
|
||||
|
||||
return up;
|
||||
}
|
||||
|
||||
|
|
@ -3412,7 +3439,7 @@ const char *GetGamepadName(int gamepad)
|
|||
if (CORE.Input.Gamepad.ready[gamepad]) name = glfwGetJoystickName(gamepad);
|
||||
#endif
|
||||
#if defined(PLATFORM_DRM)
|
||||
if (CORE.Input.Gamepad.ready[gamepad])
|
||||
if (CORE.Input.Gamepad.ready[gamepad])
|
||||
{
|
||||
ioctl(CORE.Input.Gamepad.streamId[gamepad], JSIOCGNAME(64), &CORE.Input.Gamepad.name[gamepad]);
|
||||
name = CORE.Input.Gamepad.name[gamepad];
|
||||
|
|
@ -3586,7 +3613,7 @@ int GetMouseY(void)
|
|||
Vector2 GetMousePosition(void)
|
||||
{
|
||||
Vector2 position = { 0 };
|
||||
|
||||
|
||||
// TODO: Review touch position on PLATFORM_WEB
|
||||
|
||||
#if defined(PLATFORM_ANDROID) //|| defined(PLATFORM_WEB)
|
||||
|
|
@ -3745,6 +3772,12 @@ static bool InitGraphicsDevice(int width, int height)
|
|||
CORE.Window.screen.height = height; // User desired height
|
||||
CORE.Window.screenScale = MatrixIdentity(); // No draw scaling required by default
|
||||
|
||||
// Set the window minimum and maximum default values to 0
|
||||
CORE.Window.windowMin.width = 0;
|
||||
CORE.Window.windowMin.height = 0;
|
||||
CORE.Window.windowMax.width = 0;
|
||||
CORE.Window.windowMax.height = 0;
|
||||
|
||||
// NOTE: Framebuffer (render area - CORE.Window.render.width, CORE.Window.render.height) could include black bars...
|
||||
// ...in top-down or left-right to match display aspect ratio (no weird scaling)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue