Move 13 functions out of rcore:
ToggleBorderlessWindowed SetWindowState ClearWindowState SetWindowIcon SetWindowIcons SetWindowTitle SetWindowPosition SetWindowMonitor SetWindowMinSize SetWindowMaxSize SetWindowSize SetWindowOpacity SetWindowFocused
This commit is contained in:
parent
67d04b96e4
commit
6af88f60eb
541
src/rcore.c
541
src/rcore.c
|
|
@ -192,49 +192,7 @@
|
|||
#define CHDIR chdir
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
#define GLFW_INCLUDE_NONE // Disable the standard OpenGL header inclusion on GLFW3
|
||||
// NOTE: Already provided by rlgl implementation (on glad.h)
|
||||
#include "GLFW/glfw3.h" // GLFW3 library: Windows, OpenGL context and Input management
|
||||
// NOTE: GLFW3 already includes gl.h (OpenGL) headers
|
||||
|
||||
// Support retrieving native window handlers
|
||||
#if defined(_WIN32)
|
||||
typedef void *PVOID;
|
||||
typedef PVOID HANDLE;
|
||||
typedef HANDLE HWND;
|
||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||
#define GLFW_NATIVE_INCLUDE_NONE // To avoid some symbols re-definition in windows.h
|
||||
#include "GLFW/glfw3native.h"
|
||||
|
||||
#if defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP)
|
||||
// NOTE: Those functions require linking with winmm library
|
||||
unsigned int __stdcall timeBeginPeriod(unsigned int uPeriod);
|
||||
unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
|
||||
#endif
|
||||
#endif
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#include <sys/time.h> // Required for: timespec, nanosleep(), select() - POSIX
|
||||
|
||||
//#define GLFW_EXPOSE_NATIVE_X11 // WARNING: Exposing Xlib.h > X.h results in dup symbols for Font type
|
||||
//#define GLFW_EXPOSE_NATIVE_WAYLAND
|
||||
//#define GLFW_EXPOSE_NATIVE_MIR
|
||||
#include "GLFW/glfw3native.h" // Required for: glfwGetX11Window()
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
#include <unistd.h> // Required for: usleep()
|
||||
|
||||
//#define GLFW_EXPOSE_NATIVE_COCOA // WARNING: Fails due to type redefinition
|
||||
void *glfwGetCocoaWindow(GLFWwindow* handle);
|
||||
#include "GLFW/glfw3native.h" // Required for: glfwGetCocoaWindow()
|
||||
#endif
|
||||
|
||||
// TODO: HACK: Added flag if not provided by GLFW when using external library
|
||||
// Latest GLFW release (GLFW 3.3.8) does not implement this flag, it was added for 3.4.0-dev
|
||||
#if !defined(GLFW_MOUSE_PASSTHROUGH)
|
||||
#define GLFW_MOUSE_PASSTHROUGH 0x0002000D
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition
|
||||
|
|
@ -437,505 +395,6 @@ bool IsWindowState(unsigned int flag)
|
|||
return ((CORE.Window.flags & flag) > 0);
|
||||
}
|
||||
|
||||
// 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 configuration state using flags
|
||||
void SetWindowState(unsigned int flags)
|
||||
{
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
// Check previous state and requested state to apply required changes
|
||||
// NOTE: In most cases the functions already change the flags internally
|
||||
|
||||
// State change: FLAG_VSYNC_HINT
|
||||
if (((CORE.Window.flags & FLAG_VSYNC_HINT) != (flags & FLAG_VSYNC_HINT)) && ((flags & FLAG_VSYNC_HINT) > 0))
|
||||
{
|
||||
glfwSwapInterval(1);
|
||||
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
|
||||
if ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) != (flags & FLAG_FULLSCREEN_MODE))
|
||||
{
|
||||
ToggleFullscreen(); // NOTE: Window state flag updated inside function
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_RESIZABLE
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) != (flags & FLAG_WINDOW_RESIZABLE)) && ((flags & FLAG_WINDOW_RESIZABLE) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_RESIZABLE, GLFW_TRUE);
|
||||
CORE.Window.flags |= FLAG_WINDOW_RESIZABLE;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_UNDECORATED
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_UNDECORATED) != (flags & FLAG_WINDOW_UNDECORATED)) && (flags & FLAG_WINDOW_UNDECORATED))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_DECORATED, GLFW_FALSE);
|
||||
CORE.Window.flags |= FLAG_WINDOW_UNDECORATED;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_HIDDEN
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_HIDDEN) != (flags & FLAG_WINDOW_HIDDEN)) && ((flags & FLAG_WINDOW_HIDDEN) > 0))
|
||||
{
|
||||
glfwHideWindow(CORE.Window.handle);
|
||||
CORE.Window.flags |= FLAG_WINDOW_HIDDEN;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_MINIMIZED
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) != (flags & FLAG_WINDOW_MINIMIZED)) && ((flags & FLAG_WINDOW_MINIMIZED) > 0))
|
||||
{
|
||||
//GLFW_ICONIFIED
|
||||
MinimizeWindow(); // NOTE: Window state flag updated inside function
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_MAXIMIZED
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) != (flags & FLAG_WINDOW_MAXIMIZED)) && ((flags & FLAG_WINDOW_MAXIMIZED) > 0))
|
||||
{
|
||||
//GLFW_MAXIMIZED
|
||||
MaximizeWindow(); // NOTE: Window state flag updated inside function
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_UNFOCUSED
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) != (flags & FLAG_WINDOW_UNFOCUSED)) && ((flags & FLAG_WINDOW_UNFOCUSED) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_FOCUS_ON_SHOW, GLFW_FALSE);
|
||||
CORE.Window.flags |= FLAG_WINDOW_UNFOCUSED;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_TOPMOST
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_TOPMOST) != (flags & FLAG_WINDOW_TOPMOST)) && ((flags & FLAG_WINDOW_TOPMOST) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_FLOATING, GLFW_TRUE);
|
||||
CORE.Window.flags |= FLAG_WINDOW_TOPMOST;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_ALWAYS_RUN
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) != (flags & FLAG_WINDOW_ALWAYS_RUN)) && ((flags & FLAG_WINDOW_ALWAYS_RUN) > 0))
|
||||
{
|
||||
CORE.Window.flags |= FLAG_WINDOW_ALWAYS_RUN;
|
||||
}
|
||||
|
||||
// The following states can not be changed after window creation
|
||||
|
||||
// State change: FLAG_WINDOW_TRANSPARENT
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_TRANSPARENT) != (flags & FLAG_WINDOW_TRANSPARENT)) && ((flags & FLAG_WINDOW_TRANSPARENT) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WINDOW: Framebuffer transparency can only be configured before window initialization");
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_HIGHDPI
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) != (flags & FLAG_WINDOW_HIGHDPI)) && ((flags & FLAG_WINDOW_HIGHDPI) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WINDOW: High DPI can only be configured before window initialization");
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_MOUSE_PASSTHROUGH
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) != (flags & FLAG_WINDOW_MOUSE_PASSTHROUGH)) && ((flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_MOUSE_PASSTHROUGH, GLFW_TRUE);
|
||||
CORE.Window.flags |= FLAG_WINDOW_MOUSE_PASSTHROUGH;
|
||||
}
|
||||
|
||||
// State change: FLAG_MSAA_4X_HINT
|
||||
if (((CORE.Window.flags & FLAG_MSAA_4X_HINT) != (flags & FLAG_MSAA_4X_HINT)) && ((flags & FLAG_MSAA_4X_HINT) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WINDOW: MSAA can only be configured before window initialization");
|
||||
}
|
||||
|
||||
// State change: FLAG_INTERLACED_HINT
|
||||
if (((CORE.Window.flags & FLAG_INTERLACED_HINT) != (flags & FLAG_INTERLACED_HINT)) && ((flags & FLAG_INTERLACED_HINT) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "RPI: Interlaced mode can only be configured before window initialization");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Clear window configuration state flags
|
||||
void ClearWindowState(unsigned int flags)
|
||||
{
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
// Check previous state and requested state to apply required changes
|
||||
// NOTE: In most cases the functions already change the flags internally
|
||||
|
||||
// State change: FLAG_VSYNC_HINT
|
||||
if (((CORE.Window.flags & FLAG_VSYNC_HINT) > 0) && ((flags & FLAG_VSYNC_HINT) > 0))
|
||||
{
|
||||
glfwSwapInterval(0);
|
||||
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
|
||||
if (((CORE.Window.flags & FLAG_FULLSCREEN_MODE) > 0) && ((flags & FLAG_FULLSCREEN_MODE) > 0))
|
||||
{
|
||||
ToggleFullscreen(); // NOTE: Window state flag updated inside function
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_RESIZABLE
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) > 0) && ((flags & FLAG_WINDOW_RESIZABLE) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_RESIZABLE, GLFW_FALSE);
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_RESIZABLE;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_HIDDEN
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_HIDDEN) > 0) && ((flags & FLAG_WINDOW_HIDDEN) > 0))
|
||||
{
|
||||
glfwShowWindow(CORE.Window.handle);
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_HIDDEN;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_MINIMIZED
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) && ((flags & FLAG_WINDOW_MINIMIZED) > 0))
|
||||
{
|
||||
RestoreWindow(); // NOTE: Window state flag updated inside function
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_MAXIMIZED
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) > 0) && ((flags & FLAG_WINDOW_MAXIMIZED) > 0))
|
||||
{
|
||||
RestoreWindow(); // NOTE: Window state flag updated inside function
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_UNDECORATED
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_UNDECORATED) > 0) && ((flags & FLAG_WINDOW_UNDECORATED) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_DECORATED, GLFW_TRUE);
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_UNDECORATED;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_UNFOCUSED
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) > 0) && ((flags & FLAG_WINDOW_UNFOCUSED) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_FOCUS_ON_SHOW, GLFW_TRUE);
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_UNFOCUSED;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_TOPMOST
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_TOPMOST) > 0) && ((flags & FLAG_WINDOW_TOPMOST) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_FLOATING, GLFW_FALSE);
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_TOPMOST;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_ALWAYS_RUN
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) > 0) && ((flags & FLAG_WINDOW_ALWAYS_RUN) > 0))
|
||||
{
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_ALWAYS_RUN;
|
||||
}
|
||||
|
||||
// The following states can not be changed after window creation
|
||||
|
||||
// State change: FLAG_WINDOW_TRANSPARENT
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_TRANSPARENT) > 0) && ((flags & FLAG_WINDOW_TRANSPARENT) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WINDOW: Framebuffer transparency can only be configured before window initialization");
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_HIGHDPI
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) > 0) && ((flags & FLAG_WINDOW_HIGHDPI) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WINDOW: High DPI can only be configured before window initialization");
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_MOUSE_PASSTHROUGH
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0) && ((flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_MOUSE_PASSTHROUGH, GLFW_FALSE);
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_MOUSE_PASSTHROUGH;
|
||||
}
|
||||
|
||||
// State change: FLAG_MSAA_4X_HINT
|
||||
if (((CORE.Window.flags & FLAG_MSAA_4X_HINT) > 0) && ((flags & FLAG_MSAA_4X_HINT) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WINDOW: MSAA can only be configured before window initialization");
|
||||
}
|
||||
|
||||
// State change: FLAG_INTERLACED_HINT
|
||||
if (((CORE.Window.flags & FLAG_INTERLACED_HINT) > 0) && ((flags & FLAG_INTERLACED_HINT) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "RPI: Interlaced mode can only be configured before window initialization");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set icon for window (only PLATFORM_DESKTOP)
|
||||
// NOTE 1: Image must be in RGBA format, 8bit per channel
|
||||
// NOTE 2: Image is scaled by the OS for all required sizes
|
||||
void SetWindowIcon(Image image)
|
||||
{
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
if (image.data == NULL)
|
||||
{
|
||||
// Revert to the default window icon, pass in an empty image array
|
||||
glfwSetWindowIcon(CORE.Window.handle, 0, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (image.format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
|
||||
{
|
||||
GLFWimage icon[1] = { 0 };
|
||||
|
||||
icon[0].width = image.width;
|
||||
icon[0].height = image.height;
|
||||
icon[0].pixels = (unsigned char *)image.data;
|
||||
|
||||
// NOTE 1: We only support one image icon
|
||||
// NOTE 2: The specified image data is copied before this function returns
|
||||
glfwSetWindowIcon(CORE.Window.handle, 1, icon);
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "GLFW: Window icon image must be in R8G8B8A8 pixel format");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set icon for window (multiple images, only PLATFORM_DESKTOP)
|
||||
// NOTE 1: Images must be in RGBA format, 8bit per channel
|
||||
// NOTE 2: The multiple images are used depending on provided sizes
|
||||
// Standard Windows icon sizes: 256, 128, 96, 64, 48, 32, 24, 16
|
||||
void SetWindowIcons(Image *images, int count)
|
||||
{
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
if ((images == NULL) || (count <= 0))
|
||||
{
|
||||
// Revert to the default window icon, pass in an empty image array
|
||||
glfwSetWindowIcon(CORE.Window.handle, 0, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
int valid = 0;
|
||||
GLFWimage *icons = RL_CALLOC(count, sizeof(GLFWimage));
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (images[i].format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
|
||||
{
|
||||
icons[valid].width = images[i].width;
|
||||
icons[valid].height = images[i].height;
|
||||
icons[valid].pixels = (unsigned char *)images[i].data;
|
||||
|
||||
valid++;
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "GLFW: Window icon image must be in R8G8B8A8 pixel format");
|
||||
}
|
||||
// NOTE: Images data is copied internally before this function returns
|
||||
glfwSetWindowIcon(CORE.Window.handle, valid, icons);
|
||||
|
||||
RL_FREE(icons);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)
|
||||
void SetWindowTitle(const char *title)
|
||||
{
|
||||
CORE.Window.title = title;
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
glfwSetWindowTitle(CORE.Window.handle, title);
|
||||
#endif
|
||||
#if defined(PLATFORM_WEB)
|
||||
emscripten_set_window_title(title);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set window position on screen (windowed mode)
|
||||
void SetWindowPosition(int x, int y)
|
||||
{
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
glfwSetWindowPos(CORE.Window.handle, x, y);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set monitor for the current window
|
||||
void SetWindowMonitor(int monitor)
|
||||
{
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
int monitorCount = 0;
|
||||
GLFWmonitor **monitors = glfwGetMonitors(&monitorCount);
|
||||
|
||||
if ((monitor >= 0) && (monitor < monitorCount))
|
||||
{
|
||||
if (CORE.Window.fullscreen)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "GLFW: Selected fullscreen monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor]));
|
||||
|
||||
const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
|
||||
glfwSetWindowMonitor(CORE.Window.handle, monitors[monitor], 0, 0, mode->width, mode->height, mode->refreshRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACELOG(LOG_INFO, "GLFW: Selected monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor]));
|
||||
|
||||
const int screenWidth = CORE.Window.screen.width;
|
||||
const int screenHeight = CORE.Window.screen.height;
|
||||
int monitorWorkareaX = 0;
|
||||
int monitorWorkareaY = 0;
|
||||
int monitorWorkareaWidth = 0;
|
||||
int monitorWorkareaHeight = 0;
|
||||
glfwGetMonitorWorkarea(monitors[monitor], &monitorWorkareaX, &monitorWorkareaY, &monitorWorkareaWidth, &monitorWorkareaHeight);
|
||||
|
||||
// If the screen size is larger than the monitor workarea, anchor it on the top left corner, otherwise, center it
|
||||
if ((screenWidth >= monitorWorkareaWidth) || (screenHeight >= monitorWorkareaHeight)) glfwSetWindowPos(CORE.Window.handle, monitorWorkareaX, monitorWorkareaY);
|
||||
else
|
||||
{
|
||||
const int x = monitorWorkareaX + (monitorWorkareaWidth/2) - (screenWidth/2);
|
||||
const int y = monitorWorkareaY + (monitorWorkareaHeight/2) - (screenHeight/2);
|
||||
glfwSetWindowPos(CORE.Window.handle, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
|
||||
#endif
|
||||
}
|
||||
|
||||
// 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)
|
||||
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
|
||||
}
|
||||
|
||||
// Set window dimensions
|
||||
void SetWindowSize(int width, int height)
|
||||
{
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
||||
glfwSetWindowSize(CORE.Window.handle, width, height);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set window opacity, value opacity is between 0.0 and 1.0
|
||||
void SetWindowOpacity(float opacity)
|
||||
{
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
if (opacity >= 1.0f) opacity = 1.0f;
|
||||
else if (opacity <= 0.0f) opacity = 0.0f;
|
||||
glfwSetWindowOpacity(CORE.Window.handle, opacity);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set window focused
|
||||
void SetWindowFocused(void)
|
||||
{
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
glfwFocusWindow(CORE.Window.handle);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Get current screen width
|
||||
int GetScreenWidth(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1325,29 +1325,113 @@ bool IsWindowResized(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Toggle fullscreen mode (only PLATFORM_DESKTOP)
|
||||
void ToggleFullscreen(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "SYSTEM: Failed to toggle to windowed mode");
|
||||
}
|
||||
|
||||
|
||||
// Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
|
||||
void MaximizeWindow(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "MaximizeWindow not implemented in rcore_android.c");
|
||||
TRACELOG(LOG_INFO, "MaximizeWindow not implemented in rcore_android.c");
|
||||
}
|
||||
|
||||
// Set window state: minimized (only PLATFORM_DESKTOP)
|
||||
void MinimizeWindow(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "MinimizeWindow not implemented in rcore_android.c");
|
||||
TRACELOG(LOG_INFO, "MinimizeWindow not implemented in rcore_android.c");
|
||||
}
|
||||
|
||||
// Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
|
||||
void RestoreWindow(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "RestoreWindow not implemented in rcore_android.c");
|
||||
TRACELOG(LOG_INFO, "RestoreWindow not implemented in rcore_android.c");
|
||||
}
|
||||
|
||||
|
||||
// Toggle borderless windowed mode (only PLATFORM_DESKTOP)
|
||||
void ToggleBorderlessWindowed(void)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "ToggleBorderlessWindowed not implemented in rcore_android.c");
|
||||
}
|
||||
|
||||
// Set window configuration state using flags
|
||||
void SetWindowState(unsigned int flags)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowState not implemented in rcore_android.c");
|
||||
}
|
||||
|
||||
// Clear window configuration state flags
|
||||
void ClearWindowState(unsigned int flags)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "ClearWindowState not implemented in rcore_android.c");
|
||||
}
|
||||
|
||||
// Set icon for window (only PLATFORM_DESKTOP)
|
||||
// NOTE 1: Image must be in RGBA format, 8bit per channel
|
||||
// NOTE 2: Image is scaled by the OS for all required sizes
|
||||
void SetWindowIcon(Image image)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowIcon not implemented in rcore_android.c");
|
||||
}
|
||||
|
||||
// Set icon for window (multiple images, only PLATFORM_DESKTOP)
|
||||
// NOTE 1: Images must be in RGBA format, 8bit per channel
|
||||
// NOTE 2: The multiple images are used depending on provided sizes
|
||||
// Standard Windows icon sizes: 256, 128, 96, 64, 48, 32, 24, 16
|
||||
void SetWindowIcons(Image *images, int count)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowIcons not implemented in rcore_android.c");
|
||||
}
|
||||
|
||||
// Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)
|
||||
void SetWindowTitle(const char *title)
|
||||
{
|
||||
CORE.Window.title = title;
|
||||
}
|
||||
|
||||
// Set window position on screen (windowed mode)
|
||||
void SetWindowPosition(int x, int y)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowPosition not implemented in rcore_android.c");
|
||||
}
|
||||
|
||||
// Set monitor for the current window
|
||||
void SetWindowMonitor(int monitor)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowMonitor not implemented in rcore_android.c");
|
||||
}
|
||||
|
||||
// Set window minimum dimensions (FLAG_WINDOW_RESIZABLE)
|
||||
void SetWindowMinSize(int width, int height)
|
||||
{
|
||||
CORE.Window.windowMin.width = width;
|
||||
CORE.Window.windowMin.height = height;
|
||||
}
|
||||
|
||||
// Set window maximum dimensions (FLAG_WINDOW_RESIZABLE)
|
||||
void SetWindowMaxSize(int width, int height)
|
||||
{
|
||||
CORE.Window.windowMax.width = width;
|
||||
CORE.Window.windowMax.height = height;
|
||||
}
|
||||
|
||||
// Set window dimensions
|
||||
void SetWindowSize(int width, int height)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowSize not implemented in rcore_android.c");
|
||||
}
|
||||
|
||||
// Set window opacity, value opacity is between 0.0 and 1.0
|
||||
void SetWindowOpacity(float opacity)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowOpacity not implemented in rcore_android.c");
|
||||
}
|
||||
|
||||
// Set window focused
|
||||
void SetWindowFocused(void)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowFocused not implemented in rcore_android.c");
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,51 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "raylib.h"
|
||||
#include "rlgl.h"
|
||||
#include "rcore.h"
|
||||
|
||||
#define GLFW_INCLUDE_NONE // Disable the standard OpenGL header inclusion on GLFW3
|
||||
// NOTE: Already provided by rlgl implementation (on glad.h)
|
||||
#include "GLFW/glfw3.h" // GLFW3 library: Windows, OpenGL context and Input management
|
||||
// NOTE: GLFW3 already includes gl.h (OpenGL) headers
|
||||
|
||||
// Support retrieving native window handlers
|
||||
#if defined(_WIN32)
|
||||
typedef void *PVOID;
|
||||
typedef PVOID HANDLE;
|
||||
typedef HANDLE HWND;
|
||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||
#define GLFW_NATIVE_INCLUDE_NONE // To avoid some symbols re-definition in windows.h
|
||||
#include "GLFW/glfw3native.h"
|
||||
|
||||
#if defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP)
|
||||
// NOTE: Those functions require linking with winmm library
|
||||
unsigned int __stdcall timeBeginPeriod(unsigned int uPeriod);
|
||||
unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
|
||||
#endif
|
||||
#endif
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#include <sys/time.h> // Required for: timespec, nanosleep(), select() - POSIX
|
||||
|
||||
//#define GLFW_EXPOSE_NATIVE_X11 // WARNING: Exposing Xlib.h > X.h results in dup symbols for Font type
|
||||
//#define GLFW_EXPOSE_NATIVE_WAYLAND
|
||||
//#define GLFW_EXPOSE_NATIVE_MIR
|
||||
#include "GLFW/glfw3native.h" // Required for: glfwGetX11Window()
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
#include <unistd.h> // Required for: usleep()
|
||||
|
||||
//#define GLFW_EXPOSE_NATIVE_COCOA // WARNING: Fails due to type redefinition
|
||||
void *glfwGetCocoaWindow(GLFWwindow* handle);
|
||||
#include "GLFW/glfw3native.h" // Required for: glfwGetCocoaWindow()
|
||||
#endif
|
||||
|
||||
// TODO: HACK: Added flag if not provided by GLFW when using external library
|
||||
// Latest GLFW release (GLFW 3.3.8) does not implement this flag, it was added for 3.4.0-dev
|
||||
#if !defined(GLFW_MOUSE_PASSTHROUGH)
|
||||
#define GLFW_MOUSE_PASSTHROUGH 0x0002000D
|
||||
#endif
|
||||
|
||||
static bool InitGraphicsDevice(int width, int height); // Initialize graphics device
|
||||
static void ErrorCallback(int error, const char *description); // GLFW3 Error Callback, runs on GLFW3 error
|
||||
// Window callbacks events
|
||||
|
|
@ -629,3 +672,465 @@ void RestoreWindow(void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Toggle borderless windowed mode (only PLATFORM_DESKTOP)
|
||||
void ToggleBorderlessWindowed(void)
|
||||
{
|
||||
// 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");
|
||||
}
|
||||
|
||||
// Set window configuration state using flags
|
||||
void SetWindowState(unsigned int flags)
|
||||
{
|
||||
// Check previous state and requested state to apply required changes
|
||||
// NOTE: In most cases the functions already change the flags internally
|
||||
|
||||
// State change: FLAG_VSYNC_HINT
|
||||
if (((CORE.Window.flags & FLAG_VSYNC_HINT) != (flags & FLAG_VSYNC_HINT)) && ((flags & FLAG_VSYNC_HINT) > 0))
|
||||
{
|
||||
glfwSwapInterval(1);
|
||||
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
|
||||
if ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) != (flags & FLAG_FULLSCREEN_MODE))
|
||||
{
|
||||
ToggleFullscreen(); // NOTE: Window state flag updated inside function
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_RESIZABLE
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) != (flags & FLAG_WINDOW_RESIZABLE)) && ((flags & FLAG_WINDOW_RESIZABLE) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_RESIZABLE, GLFW_TRUE);
|
||||
CORE.Window.flags |= FLAG_WINDOW_RESIZABLE;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_UNDECORATED
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_UNDECORATED) != (flags & FLAG_WINDOW_UNDECORATED)) && (flags & FLAG_WINDOW_UNDECORATED))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_DECORATED, GLFW_FALSE);
|
||||
CORE.Window.flags |= FLAG_WINDOW_UNDECORATED;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_HIDDEN
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_HIDDEN) != (flags & FLAG_WINDOW_HIDDEN)) && ((flags & FLAG_WINDOW_HIDDEN) > 0))
|
||||
{
|
||||
glfwHideWindow(CORE.Window.handle);
|
||||
CORE.Window.flags |= FLAG_WINDOW_HIDDEN;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_MINIMIZED
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) != (flags & FLAG_WINDOW_MINIMIZED)) && ((flags & FLAG_WINDOW_MINIMIZED) > 0))
|
||||
{
|
||||
//GLFW_ICONIFIED
|
||||
MinimizeWindow(); // NOTE: Window state flag updated inside function
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_MAXIMIZED
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) != (flags & FLAG_WINDOW_MAXIMIZED)) && ((flags & FLAG_WINDOW_MAXIMIZED) > 0))
|
||||
{
|
||||
//GLFW_MAXIMIZED
|
||||
MaximizeWindow(); // NOTE: Window state flag updated inside function
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_UNFOCUSED
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) != (flags & FLAG_WINDOW_UNFOCUSED)) && ((flags & FLAG_WINDOW_UNFOCUSED) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_FOCUS_ON_SHOW, GLFW_FALSE);
|
||||
CORE.Window.flags |= FLAG_WINDOW_UNFOCUSED;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_TOPMOST
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_TOPMOST) != (flags & FLAG_WINDOW_TOPMOST)) && ((flags & FLAG_WINDOW_TOPMOST) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_FLOATING, GLFW_TRUE);
|
||||
CORE.Window.flags |= FLAG_WINDOW_TOPMOST;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_ALWAYS_RUN
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) != (flags & FLAG_WINDOW_ALWAYS_RUN)) && ((flags & FLAG_WINDOW_ALWAYS_RUN) > 0))
|
||||
{
|
||||
CORE.Window.flags |= FLAG_WINDOW_ALWAYS_RUN;
|
||||
}
|
||||
|
||||
// The following states can not be changed after window creation
|
||||
|
||||
// State change: FLAG_WINDOW_TRANSPARENT
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_TRANSPARENT) != (flags & FLAG_WINDOW_TRANSPARENT)) && ((flags & FLAG_WINDOW_TRANSPARENT) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WINDOW: Framebuffer transparency can only be configured before window initialization");
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_HIGHDPI
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) != (flags & FLAG_WINDOW_HIGHDPI)) && ((flags & FLAG_WINDOW_HIGHDPI) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WINDOW: High DPI can only be configured before window initialization");
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_MOUSE_PASSTHROUGH
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) != (flags & FLAG_WINDOW_MOUSE_PASSTHROUGH)) && ((flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_MOUSE_PASSTHROUGH, GLFW_TRUE);
|
||||
CORE.Window.flags |= FLAG_WINDOW_MOUSE_PASSTHROUGH;
|
||||
}
|
||||
|
||||
// State change: FLAG_MSAA_4X_HINT
|
||||
if (((CORE.Window.flags & FLAG_MSAA_4X_HINT) != (flags & FLAG_MSAA_4X_HINT)) && ((flags & FLAG_MSAA_4X_HINT) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WINDOW: MSAA can only be configured before window initialization");
|
||||
}
|
||||
|
||||
// State change: FLAG_INTERLACED_HINT
|
||||
if (((CORE.Window.flags & FLAG_INTERLACED_HINT) != (flags & FLAG_INTERLACED_HINT)) && ((flags & FLAG_INTERLACED_HINT) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "RPI: Interlaced mode can only be configured before window initialization");
|
||||
}
|
||||
}
|
||||
|
||||
// Clear window configuration state flags
|
||||
void ClearWindowState(unsigned int flags)
|
||||
{
|
||||
// Check previous state and requested state to apply required changes
|
||||
// NOTE: In most cases the functions already change the flags internally
|
||||
|
||||
// State change: FLAG_VSYNC_HINT
|
||||
if (((CORE.Window.flags & FLAG_VSYNC_HINT) > 0) && ((flags & FLAG_VSYNC_HINT) > 0))
|
||||
{
|
||||
glfwSwapInterval(0);
|
||||
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
|
||||
if (((CORE.Window.flags & FLAG_FULLSCREEN_MODE) > 0) && ((flags & FLAG_FULLSCREEN_MODE) > 0))
|
||||
{
|
||||
ToggleFullscreen(); // NOTE: Window state flag updated inside function
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_RESIZABLE
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) > 0) && ((flags & FLAG_WINDOW_RESIZABLE) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_RESIZABLE, GLFW_FALSE);
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_RESIZABLE;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_HIDDEN
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_HIDDEN) > 0) && ((flags & FLAG_WINDOW_HIDDEN) > 0))
|
||||
{
|
||||
glfwShowWindow(CORE.Window.handle);
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_HIDDEN;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_MINIMIZED
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) && ((flags & FLAG_WINDOW_MINIMIZED) > 0))
|
||||
{
|
||||
RestoreWindow(); // NOTE: Window state flag updated inside function
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_MAXIMIZED
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) > 0) && ((flags & FLAG_WINDOW_MAXIMIZED) > 0))
|
||||
{
|
||||
RestoreWindow(); // NOTE: Window state flag updated inside function
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_UNDECORATED
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_UNDECORATED) > 0) && ((flags & FLAG_WINDOW_UNDECORATED) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_DECORATED, GLFW_TRUE);
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_UNDECORATED;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_UNFOCUSED
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) > 0) && ((flags & FLAG_WINDOW_UNFOCUSED) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_FOCUS_ON_SHOW, GLFW_TRUE);
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_UNFOCUSED;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_TOPMOST
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_TOPMOST) > 0) && ((flags & FLAG_WINDOW_TOPMOST) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_FLOATING, GLFW_FALSE);
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_TOPMOST;
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_ALWAYS_RUN
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) > 0) && ((flags & FLAG_WINDOW_ALWAYS_RUN) > 0))
|
||||
{
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_ALWAYS_RUN;
|
||||
}
|
||||
|
||||
// The following states can not be changed after window creation
|
||||
|
||||
// State change: FLAG_WINDOW_TRANSPARENT
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_TRANSPARENT) > 0) && ((flags & FLAG_WINDOW_TRANSPARENT) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WINDOW: Framebuffer transparency can only be configured before window initialization");
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_HIGHDPI
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) > 0) && ((flags & FLAG_WINDOW_HIGHDPI) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WINDOW: High DPI can only be configured before window initialization");
|
||||
}
|
||||
|
||||
// State change: FLAG_WINDOW_MOUSE_PASSTHROUGH
|
||||
if (((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0) && ((flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0))
|
||||
{
|
||||
glfwSetWindowAttrib(CORE.Window.handle, GLFW_MOUSE_PASSTHROUGH, GLFW_FALSE);
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_MOUSE_PASSTHROUGH;
|
||||
}
|
||||
|
||||
// State change: FLAG_MSAA_4X_HINT
|
||||
if (((CORE.Window.flags & FLAG_MSAA_4X_HINT) > 0) && ((flags & FLAG_MSAA_4X_HINT) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WINDOW: MSAA can only be configured before window initialization");
|
||||
}
|
||||
|
||||
// State change: FLAG_INTERLACED_HINT
|
||||
if (((CORE.Window.flags & FLAG_INTERLACED_HINT) > 0) && ((flags & FLAG_INTERLACED_HINT) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "RPI: Interlaced mode can only be configured before window initialization");
|
||||
}
|
||||
}
|
||||
|
||||
// Set icon for window (only PLATFORM_DESKTOP)
|
||||
// NOTE 1: Image must be in RGBA format, 8bit per channel
|
||||
// NOTE 2: Image is scaled by the OS for all required sizes
|
||||
void SetWindowIcon(Image image)
|
||||
{
|
||||
if (image.data == NULL)
|
||||
{
|
||||
// Revert to the default window icon, pass in an empty image array
|
||||
glfwSetWindowIcon(CORE.Window.handle, 0, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (image.format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
|
||||
{
|
||||
GLFWimage icon[1] = { 0 };
|
||||
|
||||
icon[0].width = image.width;
|
||||
icon[0].height = image.height;
|
||||
icon[0].pixels = (unsigned char *)image.data;
|
||||
|
||||
// NOTE 1: We only support one image icon
|
||||
// NOTE 2: The specified image data is copied before this function returns
|
||||
glfwSetWindowIcon(CORE.Window.handle, 1, icon);
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "GLFW: Window icon image must be in R8G8B8A8 pixel format");
|
||||
}
|
||||
}
|
||||
|
||||
// Set icon for window (multiple images, only PLATFORM_DESKTOP)
|
||||
// NOTE 1: Images must be in RGBA format, 8bit per channel
|
||||
// NOTE 2: The multiple images are used depending on provided sizes
|
||||
// Standard Windows icon sizes: 256, 128, 96, 64, 48, 32, 24, 16
|
||||
void SetWindowIcons(Image *images, int count)
|
||||
{
|
||||
if ((images == NULL) || (count <= 0))
|
||||
{
|
||||
// Revert to the default window icon, pass in an empty image array
|
||||
glfwSetWindowIcon(CORE.Window.handle, 0, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
int valid = 0;
|
||||
GLFWimage *icons = RL_CALLOC(count, sizeof(GLFWimage));
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (images[i].format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
|
||||
{
|
||||
icons[valid].width = images[i].width;
|
||||
icons[valid].height = images[i].height;
|
||||
icons[valid].pixels = (unsigned char *)images[i].data;
|
||||
|
||||
valid++;
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "GLFW: Window icon image must be in R8G8B8A8 pixel format");
|
||||
}
|
||||
// NOTE: Images data is copied internally before this function returns
|
||||
glfwSetWindowIcon(CORE.Window.handle, valid, icons);
|
||||
|
||||
RL_FREE(icons);
|
||||
}
|
||||
}
|
||||
|
||||
// Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)
|
||||
void SetWindowTitle(const char *title)
|
||||
{
|
||||
CORE.Window.title = title;
|
||||
glfwSetWindowTitle(CORE.Window.handle, title);
|
||||
}
|
||||
|
||||
// Set window position on screen (windowed mode)
|
||||
void SetWindowPosition(int x, int y)
|
||||
{
|
||||
glfwSetWindowPos(CORE.Window.handle, x, y);
|
||||
}
|
||||
|
||||
// Set monitor for the current window
|
||||
void SetWindowMonitor(int monitor)
|
||||
{
|
||||
int monitorCount = 0;
|
||||
GLFWmonitor **monitors = glfwGetMonitors(&monitorCount);
|
||||
|
||||
if ((monitor >= 0) && (monitor < monitorCount))
|
||||
{
|
||||
if (CORE.Window.fullscreen)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "GLFW: Selected fullscreen monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor]));
|
||||
|
||||
const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
|
||||
glfwSetWindowMonitor(CORE.Window.handle, monitors[monitor], 0, 0, mode->width, mode->height, mode->refreshRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACELOG(LOG_INFO, "GLFW: Selected monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor]));
|
||||
|
||||
const int screenWidth = CORE.Window.screen.width;
|
||||
const int screenHeight = CORE.Window.screen.height;
|
||||
int monitorWorkareaX = 0;
|
||||
int monitorWorkareaY = 0;
|
||||
int monitorWorkareaWidth = 0;
|
||||
int monitorWorkareaHeight = 0;
|
||||
glfwGetMonitorWorkarea(monitors[monitor], &monitorWorkareaX, &monitorWorkareaY, &monitorWorkareaWidth, &monitorWorkareaHeight);
|
||||
|
||||
// If the screen size is larger than the monitor workarea, anchor it on the top left corner, otherwise, center it
|
||||
if ((screenWidth >= monitorWorkareaWidth) || (screenHeight >= monitorWorkareaHeight)) glfwSetWindowPos(CORE.Window.handle, monitorWorkareaX, monitorWorkareaY);
|
||||
else
|
||||
{
|
||||
const int x = monitorWorkareaX + (monitorWorkareaWidth/2) - (screenWidth/2);
|
||||
const int y = monitorWorkareaY + (monitorWorkareaHeight/2) - (screenHeight/2);
|
||||
glfwSetWindowPos(CORE.Window.handle, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
|
||||
}
|
||||
|
||||
// Set window minimum dimensions (FLAG_WINDOW_RESIZABLE)
|
||||
void SetWindowMinSize(int width, int height)
|
||||
{
|
||||
CORE.Window.windowMin.width = width;
|
||||
CORE.Window.windowMin.height = 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);
|
||||
}
|
||||
|
||||
// Set window maximum dimensions (FLAG_WINDOW_RESIZABLE)
|
||||
void SetWindowMaxSize(int width, int height)
|
||||
{
|
||||
CORE.Window.windowMax.width = width;
|
||||
CORE.Window.windowMax.height = 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);
|
||||
}
|
||||
|
||||
// Set window dimensions
|
||||
void SetWindowSize(int width, int height)
|
||||
{
|
||||
glfwSetWindowSize(CORE.Window.handle, width, height);
|
||||
}
|
||||
|
||||
// Set window opacity, value opacity is between 0.0 and 1.0
|
||||
void SetWindowOpacity(float opacity)
|
||||
{
|
||||
if (opacity >= 1.0f) opacity = 1.0f;
|
||||
else if (opacity <= 0.0f) opacity = 0.0f;
|
||||
glfwSetWindowOpacity(CORE.Window.handle, opacity);
|
||||
}
|
||||
|
||||
// Set window focused
|
||||
void SetWindowFocused(void)
|
||||
{
|
||||
glfwFocusWindow(CORE.Window.handle);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1054,18 +1054,103 @@ void ToggleFullscreen(void)
|
|||
// Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
|
||||
void MaximizeWindow(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "MaximizeWindow not implemented in rcore_drm.c");
|
||||
TRACELOG(LOG_INFO, "MaximizeWindow not implemented in rcore_drm.c");
|
||||
}
|
||||
|
||||
// Set window state: minimized (only PLATFORM_DESKTOP)
|
||||
void MinimizeWindow(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "MinimizeWindow not implemented in rcore_drm.c");
|
||||
TRACELOG(LOG_INFO, "MinimizeWindow not implemented in rcore_drm.c");
|
||||
}
|
||||
|
||||
// Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
|
||||
void RestoreWindow(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "RestoreWindow not implemented in rcore_drm.c");
|
||||
TRACELOG(LOG_INFO, "RestoreWindow not implemented in rcore_drm.c");
|
||||
}
|
||||
|
||||
|
||||
// Toggle borderless windowed mode (only PLATFORM_DESKTOP)
|
||||
void ToggleBorderlessWindowed(void)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "ToggleBorderlessWindowed not implemented in rcore_drm.c");
|
||||
}
|
||||
|
||||
// Set window configuration state using flags
|
||||
void SetWindowState(unsigned int flags)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowState not implemented in rcore_drm.c");
|
||||
}
|
||||
|
||||
// Clear window configuration state flags
|
||||
void ClearWindowState(unsigned int flags)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "ClearWindowState not implemented in rcore_drm.c");
|
||||
}
|
||||
|
||||
// Set icon for window (only PLATFORM_DESKTOP)
|
||||
// NOTE 1: Image must be in RGBA format, 8bit per channel
|
||||
// NOTE 2: Image is scaled by the OS for all required sizes
|
||||
void SetWindowIcon(Image image)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowIcon not implemented in rcore_drm.c");
|
||||
}
|
||||
|
||||
// Set icon for window (multiple images, only PLATFORM_DESKTOP)
|
||||
// NOTE 1: Images must be in RGBA format, 8bit per channel
|
||||
// NOTE 2: The multiple images are used depending on provided sizes
|
||||
// Standard Windows icon sizes: 256, 128, 96, 64, 48, 32, 24, 16
|
||||
void SetWindowIcons(Image *images, int count)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowIcons not implemented in rcore_drm.c");
|
||||
}
|
||||
|
||||
// Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)
|
||||
void SetWindowTitle(const char *title)
|
||||
{
|
||||
CORE.Window.title = title;
|
||||
}
|
||||
|
||||
// Set window position on screen (windowed mode)
|
||||
void SetWindowPosition(int x, int y)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowPosition not implemented in rcore_drm.c");
|
||||
}
|
||||
|
||||
// Set monitor for the current window
|
||||
void SetWindowMonitor(int monitor)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowMonitor not implemented in rcore_drm.c");
|
||||
}
|
||||
|
||||
// Set window minimum dimensions (FLAG_WINDOW_RESIZABLE)
|
||||
void SetWindowMinSize(int width, int height)
|
||||
{
|
||||
CORE.Window.windowMin.width = width;
|
||||
CORE.Window.windowMin.height = height;
|
||||
}
|
||||
|
||||
// Set window maximum dimensions (FLAG_WINDOW_RESIZABLE)
|
||||
void SetWindowMaxSize(int width, int height)
|
||||
{
|
||||
CORE.Window.windowMax.width = width;
|
||||
CORE.Window.windowMax.height = height;
|
||||
}
|
||||
|
||||
// Set window dimensions
|
||||
void SetWindowSize(int width, int height)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowSize not implemented in rcore_drm.c");
|
||||
}
|
||||
|
||||
// Set window opacity, value opacity is between 0.0 and 1.0
|
||||
void SetWindowOpacity(float opacity)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowOpacity not implemented in rcore_drm.c");
|
||||
}
|
||||
|
||||
// Set window focused
|
||||
void SetWindowFocused(void)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowFocused not implemented in rcore_drm.c");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1237,17 +1237,107 @@ void ToggleFullscreen(void)
|
|||
// Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
|
||||
void MaximizeWindow(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "MaximizeWindow not implemented in rcore_web.c");
|
||||
TRACELOG(LOG_INFO, "MaximizeWindow not implemented in rcore_web.c");
|
||||
}
|
||||
|
||||
// Set window state: minimized (only PLATFORM_DESKTOP)
|
||||
void MinimizeWindow(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "MinimizeWindow not implemented in rcore_web.c");
|
||||
TRACELOG(LOG_INFO, "MinimizeWindow not implemented in rcore_web.c");
|
||||
}
|
||||
|
||||
// Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
|
||||
void RestoreWindow(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "RestoreWindow not implemented in rcore_web.c");
|
||||
TRACELOG(LOG_INFO, "RestoreWindow not implemented in rcore_web.c");
|
||||
}
|
||||
|
||||
// Toggle borderless windowed mode (only PLATFORM_DESKTOP)
|
||||
void ToggleBorderlessWindowed(void)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "ToggleBorderlessWindows not implemented in rcore_web.c");
|
||||
}
|
||||
|
||||
// Set window configuration state using flags
|
||||
void SetWindowState(unsigned int flags)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowState not implemented in rcore_web.c");
|
||||
}
|
||||
|
||||
// Clear window configuration state flags
|
||||
void ClearWindowState(unsigned int flags)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "ClearWindowState not implemented in rcore_web.c");
|
||||
}
|
||||
|
||||
// Set icon for window (only PLATFORM_DESKTOP)
|
||||
// NOTE 1: Image must be in RGBA format, 8bit per channel
|
||||
// NOTE 2: Image is scaled by the OS for all required sizes
|
||||
void SetWindowIcon(Image image)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowIcon not implemented in rcore_web.c");
|
||||
}
|
||||
|
||||
// Set icon for window (multiple images, only PLATFORM_DESKTOP)
|
||||
// NOTE 1: Images must be in RGBA format, 8bit per channel
|
||||
// NOTE 2: The multiple images are used depending on provided sizes
|
||||
// Standard Windows icon sizes: 256, 128, 96, 64, 48, 32, 24, 16
|
||||
void SetWindowIcons(Image *images, int count)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowIcons not implemented in rcore_web.c");
|
||||
}
|
||||
|
||||
// Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)
|
||||
void SetWindowTitle(const char *title)
|
||||
{
|
||||
CORE.Window.title = title;
|
||||
emscripten_set_window_title(title);
|
||||
}
|
||||
|
||||
// Set window position on screen (windowed mode)
|
||||
void SetWindowPosition(int x, int y)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowPosition not implemented in rcore_web.c");
|
||||
}
|
||||
|
||||
// Set monitor for the current window
|
||||
void SetWindowMonitor(int monitor)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowMonitor not implemented in rcore_web.c");
|
||||
}
|
||||
|
||||
// Set window minimum dimensions (FLAG_WINDOW_RESIZABLE)
|
||||
void SetWindowMinSize(int width, int height)
|
||||
{
|
||||
CORE.Window.windowMin.width = width;
|
||||
CORE.Window.windowMin.height = height;
|
||||
// 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);
|
||||
}
|
||||
|
||||
// Set window maximum dimensions (FLAG_WINDOW_RESIZABLE)
|
||||
void SetWindowMaxSize(int width, int height)
|
||||
{
|
||||
CORE.Window.windowMax.width = width;
|
||||
CORE.Window.windowMax.height = height;
|
||||
// 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);
|
||||
}
|
||||
|
||||
// Set window dimensions
|
||||
void SetWindowSize(int width, int height)
|
||||
{
|
||||
glfwSetWindowSize(CORE.Window.handle, width, height);
|
||||
}
|
||||
|
||||
// Set window opacity, value opacity is between 0.0 and 1.0
|
||||
void SetWindowOpacity(float opacity)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowOpacity not implemented in rcore_web.c");
|
||||
}
|
||||
|
||||
// Set window focused
|
||||
void SetWindowFocused(void)
|
||||
{
|
||||
TRACELOG(LOG_INFO, "SetWindowFocused not implemented in rcore_web.c");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user