mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
[rcore] Use FLAG_* macros where possible (#5169)
* use FLAG_* macros where possible * rename `FLAG_CHECK()` to `FLAG_IS_SET()` * remove unnecessary equality checks * fix issues --------- Co-authored-by: Ray <raysan5@gmail.com>
This commit is contained in:
@ -1148,7 +1148,7 @@ int InitPlatform(void)
|
||||
// Initialize graphic device: display/window and graphic context
|
||||
//----------------------------------------------------------------------------
|
||||
CORE.Window.fullscreen = true;
|
||||
CORE.Window.flags |= FLAG_FULLSCREEN_MODE;
|
||||
FLAG_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE);
|
||||
|
||||
#if defined(DEFAULT_GRAPHIC_DEVICE_DRM)
|
||||
platform.fd = open(DEFAULT_GRAPHIC_DEVICE_DRM, O_RDWR);
|
||||
@ -1297,7 +1297,7 @@ int InitPlatform(void)
|
||||
CORE.Window.screen.height = CORE.Window.display.height;
|
||||
}
|
||||
|
||||
const bool allowInterlaced = CORE.Window.flags & FLAG_INTERLACED_HINT;
|
||||
const bool allowInterlaced = FLAG_IS_SET(CORE.Window.flags, FLAG_INTERLACED_HINT);
|
||||
const int fps = (CORE.Time.target > 0) ? (1.0/CORE.Time.target) : 60;
|
||||
|
||||
// Try to find an exact matching mode
|
||||
@ -1328,7 +1328,7 @@ int InitPlatform(void)
|
||||
|
||||
TRACELOG(LOG_INFO, "DISPLAY: Selected DRM connector mode %s (%ux%u%c@%u)", platform.connector->modes[platform.modeIndex].name,
|
||||
platform.connector->modes[platform.modeIndex].hdisplay, platform.connector->modes[platform.modeIndex].vdisplay,
|
||||
(platform.connector->modes[platform.modeIndex].flags & DRM_MODE_FLAG_INTERLACE) ? 'i' : 'p',
|
||||
FLAG_IS_SET(platform.connector->modes[platform.modeIndex].flags, DRM_MODE_FLAG_INTERLACE)? 'i' : 'p',
|
||||
platform.connector->modes[platform.modeIndex].vrefresh);
|
||||
|
||||
drmModeFreeEncoder(enc);
|
||||
@ -1384,7 +1384,7 @@ int InitPlatform(void)
|
||||
|
||||
EGLint samples = 0;
|
||||
EGLint sampleBuffer = 0;
|
||||
if (CORE.Window.flags & FLAG_MSAA_4X_HINT)
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_MSAA_4X_HINT))
|
||||
{
|
||||
samples = 4;
|
||||
sampleBuffer = 1;
|
||||
@ -1561,17 +1561,17 @@ int InitPlatform(void)
|
||||
TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y);
|
||||
#endif
|
||||
|
||||
if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) MinimizeWindow();
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_MINIMIZED)) MinimizeWindow();
|
||||
|
||||
// If graphic device is no properly initialized, we end program
|
||||
if (!CORE.Window.ready) { TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphic device"); return -1; }
|
||||
else SetWindowPosition(GetMonitorWidth(GetCurrentMonitor())/2 - CORE.Window.screen.width/2, GetMonitorHeight(GetCurrentMonitor())/2 - CORE.Window.screen.height/2);
|
||||
|
||||
// Set some default window flags
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_HIDDEN; // false
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED; // false
|
||||
CORE.Window.flags |= FLAG_WINDOW_MAXIMIZED; // true
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_UNFOCUSED; // false
|
||||
FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_HIDDEN); // false
|
||||
FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_MINIMIZED); // false
|
||||
FLAG_SET(CORE.Window.flags, FLAG_WINDOW_MAXIMIZED); // true
|
||||
FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED); // false
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Initialize timing system
|
||||
@ -1720,8 +1720,8 @@ static void InitKeyboard(void)
|
||||
|
||||
// New terminal settings for keyboard: turn off buffering (non-canonical mode), echo and key processing
|
||||
// NOTE: ISIG controls if ^C and ^Z generate break signals or not
|
||||
keyboardNewSettings.c_lflag &= ~(ICANON | ECHO | ISIG);
|
||||
//keyboardNewSettings.c_iflag &= ~(ISTRIP | INLCR | ICRNL | IGNCR | IXON | IXOFF);
|
||||
FLAG_CLEAR(keyboardNewSettings.c_lflag, ICANON | ECHO | ISIG);
|
||||
//FLAG_CLEAR(keyboardNewSettings.c_iflag, ISTRIP | INLCR | ICRNL | IGNCR | IXON | IXOFF);
|
||||
keyboardNewSettings.c_cc[VMIN] = 1;
|
||||
keyboardNewSettings.c_cc[VTIME] = 0;
|
||||
|
||||
@ -2402,7 +2402,7 @@ static int FindMatchingConnectorMode(const drmModeConnector *connector, const dr
|
||||
for (size_t i = 0; i < connector->count_modes; i++)
|
||||
{
|
||||
TRACELOG(LOG_TRACE, "DISPLAY: DRM mode: %d %ux%u@%u %s", i, connector->modes[i].hdisplay, connector->modes[i].vdisplay,
|
||||
connector->modes[i].vrefresh, (connector->modes[i].flags & DRM_MODE_FLAG_INTERLACE)? "interlaced" : "progressive");
|
||||
connector->modes[i].vrefresh, (FLAG_IS_SET(connector->modes[i].flags, DRM_MODE_FLAG_INTERLACE) > 0)? "interlaced" : "progressive");
|
||||
|
||||
if (0 == BINCMP(&platform.crtc->mode, &platform.connector->modes[i])) return i;
|
||||
}
|
||||
@ -2423,9 +2423,9 @@ static int FindExactConnectorMode(const drmModeConnector *connector, uint width,
|
||||
{
|
||||
const drmModeModeInfo *const mode = &platform.connector->modes[i];
|
||||
|
||||
TRACELOG(LOG_TRACE, "DISPLAY: DRM Mode %d %ux%u@%u %s", i, mode->hdisplay, mode->vdisplay, mode->vrefresh, (mode->flags & DRM_MODE_FLAG_INTERLACE)? "interlaced" : "progressive");
|
||||
TRACELOG(LOG_TRACE, "DISPLAY: DRM Mode %d %ux%u@%u %s", i, mode->hdisplay, mode->vdisplay, mode->vrefresh, (FLAG_IS_SET(mode->flags, DRM_MODE_FLAG_INTERLACE) > 0)? "interlaced" : "progressive");
|
||||
|
||||
if ((mode->flags & DRM_MODE_FLAG_INTERLACE) && !allowInterlaced) continue;
|
||||
if ((FLAG_IS_SET(mode->flags, DRM_MODE_FLAG_INTERLACE) > 0) && !allowInterlaced) continue;
|
||||
|
||||
if ((mode->hdisplay == width) && (mode->vdisplay == height) && (mode->vrefresh == fps)) return i;
|
||||
}
|
||||
@ -2449,7 +2449,7 @@ static int FindNearestConnectorMode(const drmModeConnector *connector, uint widt
|
||||
const drmModeModeInfo *const mode = &platform.connector->modes[i];
|
||||
|
||||
TRACELOG(LOG_TRACE, "DISPLAY: DRM mode: %d %ux%u@%u %s", i, mode->hdisplay, mode->vdisplay, mode->vrefresh,
|
||||
(mode->flags & DRM_MODE_FLAG_INTERLACE)? "interlaced" : "progressive");
|
||||
(FLAG_IS_SET(mode->flags, DRM_MODE_FLAG_INTERLACE) > 0)? "interlaced" : "progressive");
|
||||
|
||||
if ((mode->hdisplay < width) || (mode->vdisplay < height))
|
||||
{
|
||||
@ -2457,7 +2457,7 @@ static int FindNearestConnectorMode(const drmModeConnector *connector, uint widt
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((mode->flags & DRM_MODE_FLAG_INTERLACE) && !allowInterlaced)
|
||||
if ((FLAG_IS_SET(mode->flags, DRM_MODE_FLAG_INTERLACE) > 0) && !allowInterlaced)
|
||||
{
|
||||
TRACELOG(LOG_TRACE, "DISPLAY: DRM shouldn't choose an interlaced mode");
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user