Use eglCheck macro as an expression instead of a statement

Applies missed changes in pr #3239
This commit is contained in:
ZXShady 2024-10-07 23:31:16 +01:00 committed by Vittorio Romeo
parent da1f652c22
commit 04b1808522
2 changed files with 19 additions and 40 deletions

View File

@ -484,7 +484,7 @@ EGLDisplay getInitializedDisplay()
{
gladLoaderLoadEGL(EGL_NO_DISPLAY);
eglCheck(display = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(gbmDevice)));
display = eglCheck(eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(gbmDevice)));
EGLint major = 0;
EGLint minor = 0;
@ -576,8 +576,7 @@ DRMContext::DRMContext(DRMContext* shared, const ContextSettings& settings, Vect
DRMContext::~DRMContext()
{
// Deactivate the current context
EGLContext currentContext = nullptr;
eglCheck(currentContext = eglGetCurrentContext());
const EGLContext currentContext = eglCheck(eglGetCurrentContext());
if (currentContext == m_context)
{
@ -618,7 +617,7 @@ bool DRMContext::makeCurrent(bool current)
{
const EGLSurface surface = current ? m_surface : EGL_NO_SURFACE;
const EGLContext context = current ? m_context : EGL_NO_CONTEXT;
return m_surface != EGL_NO_SURFACE && eglMakeCurrent(m_display, surface, surface, context);
return m_surface != EGL_NO_SURFACE && eglCheck(eglMakeCurrent(m_display, surface, surface, context));
}
@ -700,10 +699,10 @@ void DRMContext::createContext(DRMContext* shared)
toShared = EGL_NO_CONTEXT;
if (toShared != EGL_NO_CONTEXT)
eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglCheck(eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
// Create EGL context
eglCheck(m_context = eglCreateContext(m_display, m_config, toShared, contextVersion));
m_context = eglCheck(eglCreateContext(m_display, m_config, toShared, contextVersion));
if (m_context == EGL_NO_CONTEXT)
err() << "Failed to create EGL context" << std::endl;
}

View File

@ -73,7 +73,7 @@ EGLDisplay getInitializedDisplay()
if (display == EGL_NO_DISPLAY)
{
eglCheck(display = eglGetDisplay(EGL_DEFAULT_DISPLAY));
display = eglCheck(eglGetDisplay(EGL_DEFAULT_DISPLAY));
eglCheck(eglInitialize(display, nullptr, nullptr));
}
@ -128,7 +128,7 @@ EglContext::EglContext(EglContext* shared)
// but this is resulting in a segfault. Bug in Android?
EGLint attribList[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE};
eglCheck(m_surface = eglCreatePbufferSurface(m_display, m_config, attribList));
m_surface = eglCheck(eglCreatePbufferSurface(m_display, m_config, attribList));
// Create EGL context
createContext(shared);
@ -190,8 +190,7 @@ EglContext::~EglContext()
cleanupUnsharedResources();
// Deactivate the current context
EGLContext currentContext = EGL_NO_CONTEXT;
eglCheck(currentContext = eglGetCurrentContext());
const EGLContext currentContext = eglCheck(eglGetCurrentContext());
if (currentContext == m_context)
{
@ -227,18 +226,10 @@ bool EglContext::makeCurrent(bool current)
if (m_surface == EGL_NO_SURFACE)
return false;
EGLBoolean result = EGL_FALSE;
if (current)
{
eglCheck(result = eglMakeCurrent(m_display, m_surface, m_surface, m_context));
}
else
{
eglCheck(result = eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
}
return EGL_FALSE != eglCheck(eglMakeCurrent(m_display, m_surface, m_surface, m_context));
return result != EGL_FALSE;
return EGL_FALSE != eglCheck(eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
}
@ -270,17 +261,17 @@ void EglContext::createContext(EglContext* shared)
toShared = EGL_NO_CONTEXT;
if (toShared != EGL_NO_CONTEXT)
eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglCheck(eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
// Create EGL context
eglCheck(m_context = eglCreateContext(m_display, m_config, toShared, contextVersion));
m_context = eglCheck(eglCreateContext(m_display, m_config, toShared, contextVersion));
}
////////////////////////////////////////////////////////////
void EglContext::createSurface(EGLNativeWindowType window)
{
eglCheck(m_surface = eglCreateWindowSurface(m_display, m_config, window, nullptr));
m_surface = eglCheck(eglCreateWindowSurface(m_display, m_config, window, nullptr));
}
@ -378,30 +369,19 @@ void EglContext::updateSettings()
m_settings.stencilBits = 0;
m_settings.antiAliasingLevel = 0;
EGLBoolean result = EGL_FALSE;
EGLint tmp = 0;
// Update the internal context settings with the current config
eglCheck(result = eglGetConfigAttrib(m_display, m_config, EGL_DEPTH_SIZE, &tmp));
if (result != EGL_FALSE)
if (eglCheck(eglGetConfigAttrib(m_display, m_config, EGL_DEPTH_SIZE, &tmp)) != EGL_FALSE)
m_settings.depthBits = static_cast<unsigned int>(tmp);
eglCheck(result = eglGetConfigAttrib(m_display, m_config, EGL_STENCIL_SIZE, &tmp));
if (result != EGL_FALSE)
if (eglCheck(eglGetConfigAttrib(m_display, m_config, EGL_STENCIL_SIZE, &tmp)) != EGL_FALSE)
m_settings.stencilBits = static_cast<unsigned int>(tmp);
eglCheck(result = eglGetConfigAttrib(m_display, m_config, EGL_SAMPLE_BUFFERS, &tmp));
if ((result != EGL_FALSE) && tmp)
{
eglCheck(result = eglGetConfigAttrib(m_display, m_config, EGL_SAMPLES, &tmp));
if (result != EGL_FALSE)
if (eglCheck(eglGetConfigAttrib(m_display, m_config, EGL_SAMPLE_BUFFERS, &tmp)) != EGL_FALSE && tmp &&
eglCheck(eglGetConfigAttrib(m_display, m_config, EGL_SAMPLES, &tmp)) != EGL_FALSE)
m_settings.antiAliasingLevel = static_cast<unsigned int>(tmp);
}
}
#if defined(SFML_SYSTEM_LINUX) && !defined(SFML_USE_DRM)