Merge branch 'master' into clone_sound
This commit is contained in:
commit
b9a10b5db7
|
|
@ -46,6 +46,7 @@ cmake_dependent_option(SUPPORT_BUSY_WAIT_LOOP "Use busy wait loop for timing syn
|
||||||
cmake_dependent_option(SUPPORT_EVENTS_WAITING "Wait for events passively (sleeping while no events) instead of polling them actively every frame" OFF CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_EVENTS_WAITING "Wait for events passively (sleeping while no events) instead of polling them actively every frame" OFF CUSTOMIZE_BUILD OFF)
|
||||||
cmake_dependent_option(SUPPORT_WINMM_HIGHRES_TIMER "Setting a higher resolution can improve the accuracy of time-out intervals in wait functions" OFF CUSTOMIZE_BUILD OFF)
|
cmake_dependent_option(SUPPORT_WINMM_HIGHRES_TIMER "Setting a higher resolution can improve the accuracy of time-out intervals in wait functions" OFF CUSTOMIZE_BUILD OFF)
|
||||||
cmake_dependent_option(SUPPORT_COMPRESSION_API "Support for compression API" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_COMPRESSION_API "Support for compression API" ON CUSTOMIZE_BUILD ON)
|
||||||
|
cmake_dependent_option(SUPPORT_CUSTOM_FRAME_CONTROL "Enabling this flag allows manual control of the frame processes, use at your own risk" OFF CUSTOMIZE_BUILD OFF)
|
||||||
|
|
||||||
# rshapes.c
|
# rshapes.c
|
||||||
cmake_dependent_option(SUPPORT_QUADS_DRAW_MODE "Use QUADS instead of TRIANGLES for drawing when possible. Some lines-based shapes could still use lines" ON CUSTOMIZE_BUILD ON)
|
cmake_dependent_option(SUPPORT_QUADS_DRAW_MODE "Use QUADS instead of TRIANGLES for drawing when possible. Some lines-based shapes could still use lines" ON CUSTOMIZE_BUILD ON)
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ if (${CUSTOMIZE_BUILD})
|
||||||
define_if("raylib" SUPPORT_EVENTS_WAITING)
|
define_if("raylib" SUPPORT_EVENTS_WAITING)
|
||||||
define_if("raylib" SUPPORT_WINMM_HIGHRES_TIMER)
|
define_if("raylib" SUPPORT_WINMM_HIGHRES_TIMER)
|
||||||
define_if("raylib" SUPPORT_COMPRESSION_API)
|
define_if("raylib" SUPPORT_COMPRESSION_API)
|
||||||
|
define_if("raylib" SUPPORT_CUSTOM_FRAME_CONTROL)
|
||||||
define_if("raylib" SUPPORT_QUADS_DRAW_MODE)
|
define_if("raylib" SUPPORT_QUADS_DRAW_MODE)
|
||||||
define_if("raylib" SUPPORT_IMAGE_EXPORT)
|
define_if("raylib" SUPPORT_IMAGE_EXPORT)
|
||||||
define_if("raylib" SUPPORT_IMAGE_GENERATION)
|
define_if("raylib" SUPPORT_IMAGE_GENERATION)
|
||||||
|
|
|
||||||
|
|
@ -526,6 +526,7 @@ typedef enum {
|
||||||
FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer
|
FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer
|
||||||
FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI
|
FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI
|
||||||
FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000, // Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED
|
FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000, // Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED
|
||||||
|
FLAG_BORDERLESS_WINDOWED_MODE = 0x00008000, // Set to run program in borderless windowed mode
|
||||||
FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X
|
FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X
|
||||||
FLAG_INTERLACED_HINT = 0x00010000 // Set to try enabling interlaced video format (for V3D)
|
FLAG_INTERLACED_HINT = 0x00010000 // Set to try enabling interlaced video format (for V3D)
|
||||||
} ConfigFlags;
|
} ConfigFlags;
|
||||||
|
|
@ -947,12 +948,13 @@ RLAPI bool IsWindowState(unsigned int flag); // Check if on
|
||||||
RLAPI void SetWindowState(unsigned int flags); // Set window configuration state using flags (only PLATFORM_DESKTOP)
|
RLAPI void SetWindowState(unsigned int flags); // Set window configuration state using flags (only PLATFORM_DESKTOP)
|
||||||
RLAPI void ClearWindowState(unsigned int flags); // Clear window configuration state flags
|
RLAPI void ClearWindowState(unsigned int flags); // Clear window configuration state flags
|
||||||
RLAPI void ToggleFullscreen(void); // Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP)
|
RLAPI void ToggleFullscreen(void); // Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP)
|
||||||
|
RLAPI void ToggleBorderlessWindowed(void); // Toggle window state: borderless windowed (only PLATFORM_DESKTOP)
|
||||||
RLAPI void MaximizeWindow(void); // Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
|
RLAPI void MaximizeWindow(void); // Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
|
||||||
RLAPI void MinimizeWindow(void); // Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
|
RLAPI void MinimizeWindow(void); // Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
|
||||||
RLAPI void RestoreWindow(void); // Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
|
RLAPI void RestoreWindow(void); // Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
|
||||||
RLAPI void SetWindowIcon(Image image); // Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP)
|
RLAPI void SetWindowIcon(Image image); // Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP)
|
||||||
RLAPI void SetWindowIcons(Image *images, int count); // Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
|
RLAPI void SetWindowIcons(Image *images, int count); // Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
|
||||||
RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP)
|
RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)
|
||||||
RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)
|
RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)
|
||||||
RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window
|
RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window
|
||||||
RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
|
RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
|
||||||
|
|
|
||||||
106
src/rcore.c
106
src/rcore.c
|
|
@ -412,6 +412,8 @@ typedef struct CoreData {
|
||||||
Size render; // Framebuffer width and height (render area, including black bars if required)
|
Size render; // Framebuffer width and height (render area, including black bars if required)
|
||||||
Point renderOffset; // Offset from render area (must be divided by 2)
|
Point renderOffset; // Offset from render area (must be divided by 2)
|
||||||
Matrix screenScale; // Matrix to scale screen (framebuffer rendering)
|
Matrix screenScale; // Matrix to scale screen (framebuffer rendering)
|
||||||
|
Point previousPosition; // Previous screen position (required on borderless windowed toggle)
|
||||||
|
Size previousScreen; // Previous screen size (required on borderless windowed toggle)
|
||||||
|
|
||||||
char **dropFilepaths; // Store dropped files paths pointers (provided by GLFW)
|
char **dropFilepaths; // Store dropped files paths pointers (provided by GLFW)
|
||||||
unsigned int dropFileCount; // Count dropped files strings
|
unsigned int dropFileCount; // Count dropped files strings
|
||||||
|
|
@ -1324,6 +1326,82 @@ void ToggleFullscreen(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Toggle borderless windowed mode (only PLATFORM_DESKTOP)
|
||||||
|
void ToggleBorderlessWindowed(void)
|
||||||
|
{
|
||||||
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
// Leave fullscreen before attempting to set borderless windowed mode and get screen position from it
|
||||||
|
bool wasOnFullscreen = false;
|
||||||
|
if (CORE.Window.fullscreen)
|
||||||
|
{
|
||||||
|
CORE.Window.previousPosition = CORE.Window.position;
|
||||||
|
ToggleFullscreen();
|
||||||
|
wasOnFullscreen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int monitor = GetCurrentMonitor();
|
||||||
|
int monitorCount;
|
||||||
|
GLFWmonitor **monitors = glfwGetMonitors(&monitorCount);
|
||||||
|
if ((monitor >= 0) && (monitor < monitorCount))
|
||||||
|
{
|
||||||
|
const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
|
||||||
|
if (mode)
|
||||||
|
{
|
||||||
|
if (!IsWindowState(FLAG_BORDERLESS_WINDOWED_MODE))
|
||||||
|
{
|
||||||
|
// Store screen position and size
|
||||||
|
// NOTE: If it was on fullscreen, screen position was already stored, so skip setting it here
|
||||||
|
if (!wasOnFullscreen) glfwGetWindowPos(CORE.Window.handle, &CORE.Window.previousPosition.x, &CORE.Window.previousPosition.y);
|
||||||
|
CORE.Window.previousScreen = CORE.Window.screen;
|
||||||
|
|
||||||
|
// Set undecorated and topmost modes and flags
|
||||||
|
glfwSetWindowAttrib(CORE.Window.handle, GLFW_DECORATED, GLFW_FALSE);
|
||||||
|
CORE.Window.flags |= FLAG_WINDOW_UNDECORATED;
|
||||||
|
glfwSetWindowAttrib(CORE.Window.handle, GLFW_FLOATING, GLFW_TRUE);
|
||||||
|
CORE.Window.flags |= FLAG_WINDOW_TOPMOST;
|
||||||
|
|
||||||
|
// Get monitor position and size
|
||||||
|
int monitorPosX = 0;
|
||||||
|
int monitorPosY = 0;
|
||||||
|
glfwGetMonitorPos(monitors[monitor], &monitorPosX, &monitorPosY);
|
||||||
|
const int monitorWidth = mode->width;
|
||||||
|
const int monitorHeight = mode->height;
|
||||||
|
glfwSetWindowSize(CORE.Window.handle, monitorWidth, monitorHeight);
|
||||||
|
|
||||||
|
// Set screen position and size
|
||||||
|
glfwSetWindowPos(CORE.Window.handle, monitorPosX, monitorPosY);
|
||||||
|
glfwSetWindowSize(CORE.Window.handle, monitorWidth, monitorHeight);
|
||||||
|
|
||||||
|
// Refocus window
|
||||||
|
glfwFocusWindow(CORE.Window.handle);
|
||||||
|
|
||||||
|
CORE.Window.flags |= FLAG_BORDERLESS_WINDOWED_MODE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Remove topmost and undecorated modes and flags
|
||||||
|
glfwSetWindowAttrib(CORE.Window.handle, GLFW_FLOATING, GLFW_FALSE);
|
||||||
|
CORE.Window.flags &= ~FLAG_WINDOW_TOPMOST;
|
||||||
|
glfwSetWindowAttrib(CORE.Window.handle, GLFW_DECORATED, GLFW_TRUE);
|
||||||
|
CORE.Window.flags &= ~FLAG_WINDOW_UNDECORATED;
|
||||||
|
|
||||||
|
// Return previous screen size and position
|
||||||
|
// NOTE: The order matters here, it must set size first, then set position, otherwise the screen will be positioned incorrectly
|
||||||
|
glfwSetWindowSize(CORE.Window.handle, CORE.Window.previousScreen.width, CORE.Window.previousScreen.height);
|
||||||
|
glfwSetWindowPos(CORE.Window.handle, CORE.Window.previousPosition.x, CORE.Window.previousPosition.y);
|
||||||
|
|
||||||
|
// Refocus window
|
||||||
|
glfwFocusWindow(CORE.Window.handle);
|
||||||
|
|
||||||
|
CORE.Window.flags &= ~FLAG_BORDERLESS_WINDOWED_MODE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
|
||||||
|
}
|
||||||
|
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
|
// Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
|
||||||
void MaximizeWindow(void)
|
void MaximizeWindow(void)
|
||||||
{
|
{
|
||||||
|
|
@ -1373,6 +1451,13 @@ void SetWindowState(unsigned int flags)
|
||||||
CORE.Window.flags |= FLAG_VSYNC_HINT;
|
CORE.Window.flags |= FLAG_VSYNC_HINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// State change: FLAG_BORDERLESS_WINDOWED_MODE
|
||||||
|
// NOTE: This must be handled before FLAG_FULLSCREEN_MODE because ToggleBorderlessWindowed() needs to get some fullscreen values if fullscreen is running
|
||||||
|
if (((CORE.Window.flags & FLAG_BORDERLESS_WINDOWED_MODE) != (flags & FLAG_BORDERLESS_WINDOWED_MODE)) && ((flags & FLAG_BORDERLESS_WINDOWED_MODE) > 0))
|
||||||
|
{
|
||||||
|
ToggleBorderlessWindowed(); // NOTE: Window state flag updated inside function
|
||||||
|
}
|
||||||
|
|
||||||
// State change: FLAG_FULLSCREEN_MODE
|
// State change: FLAG_FULLSCREEN_MODE
|
||||||
if ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) != (flags & FLAG_FULLSCREEN_MODE))
|
if ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) != (flags & FLAG_FULLSCREEN_MODE))
|
||||||
{
|
{
|
||||||
|
|
@ -1483,6 +1568,13 @@ void ClearWindowState(unsigned int flags)
|
||||||
CORE.Window.flags &= ~FLAG_VSYNC_HINT;
|
CORE.Window.flags &= ~FLAG_VSYNC_HINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// State change: FLAG_BORDERLESS_WINDOWED_MODE
|
||||||
|
// NOTE: This must be handled before FLAG_FULLSCREEN_MODE because ToggleBorderlessWindowed() needs to get some fullscreen values if fullscreen is running
|
||||||
|
if (((CORE.Window.flags & FLAG_BORDERLESS_WINDOWED_MODE) > 0) && ((flags & FLAG_BORDERLESS_WINDOWED_MODE) > 0))
|
||||||
|
{
|
||||||
|
ToggleBorderlessWindowed(); // NOTE: Window state flag updated inside function
|
||||||
|
}
|
||||||
|
|
||||||
// State change: FLAG_FULLSCREEN_MODE
|
// State change: FLAG_FULLSCREEN_MODE
|
||||||
if (((CORE.Window.flags & FLAG_FULLSCREEN_MODE) > 0) && ((flags & FLAG_FULLSCREEN_MODE) > 0))
|
if (((CORE.Window.flags & FLAG_FULLSCREEN_MODE) > 0) && ((flags & FLAG_FULLSCREEN_MODE) > 0))
|
||||||
{
|
{
|
||||||
|
|
@ -1644,13 +1736,16 @@ void SetWindowIcons(Image *images, int count)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set title for window (only PLATFORM_DESKTOP)
|
// Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)
|
||||||
void SetWindowTitle(const char *title)
|
void SetWindowTitle(const char *title)
|
||||||
{
|
{
|
||||||
CORE.Window.title = title;
|
CORE.Window.title = title;
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
glfwSetWindowTitle(CORE.Window.handle, title);
|
glfwSetWindowTitle(CORE.Window.handle, title);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(PLATFORM_WEB)
|
||||||
|
emscripten_set_window_title(title);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set window position on screen (windowed mode)
|
// Set window position on screen (windowed mode)
|
||||||
|
|
@ -1693,8 +1788,8 @@ void SetWindowMonitor(int monitor)
|
||||||
if ((screenWidth >= monitorWorkareaWidth) || (screenHeight >= monitorWorkareaHeight)) glfwSetWindowPos(CORE.Window.handle, monitorWorkareaX, monitorWorkareaY);
|
if ((screenWidth >= monitorWorkareaWidth) || (screenHeight >= monitorWorkareaHeight)) glfwSetWindowPos(CORE.Window.handle, monitorWorkareaX, monitorWorkareaY);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const int x = monitorWorkareaX + (monitorWorkareaWidth*0.5f) - (screenWidth*0.5f);
|
const int x = monitorWorkareaX + (monitorWorkareaWidth/2) - (screenWidth/2);
|
||||||
const int y = monitorWorkareaY + (monitorWorkareaHeight*0.5f) - (screenHeight*0.5f);
|
const int y = monitorWorkareaY + (monitorWorkareaHeight/2) - (screenHeight/2);
|
||||||
glfwSetWindowPos(CORE.Window.handle, x, y);
|
glfwSetWindowPos(CORE.Window.handle, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4341,6 +4436,11 @@ static bool InitGraphicsDevice(int width, int height)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// glfwCreateWindow title doesn't work with emscripten.
|
||||||
|
#if defined(PLATFORM_WEB)
|
||||||
|
emscripten_set_window_title((CORE.Window.title != 0)? CORE.Window.title : " ");
|
||||||
|
#endif
|
||||||
|
|
||||||
// Set window callback events
|
// Set window callback events
|
||||||
glfwSetWindowSizeCallback(CORE.Window.handle, WindowSizeCallback); // NOTE: Resizing not allowed by default!
|
glfwSetWindowSizeCallback(CORE.Window.handle, WindowSizeCallback); // NOTE: Resizing not allowed by default!
|
||||||
#if !defined(PLATFORM_WEB)
|
#if !defined(PLATFORM_WEB)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user