mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 10:05:10 +00:00
EGL: Implement glfwGetBufferAge()
This feature is provided by the EGL_EXT_buffer_age extension, otherwise always return 0.
This commit is contained in:
parent
0d2ce23071
commit
c8233ce7d3
@ -254,6 +254,24 @@ static void swapIntervalEGL(int interval)
|
||||
eglSwapInterval(_glfw.egl.display, interval);
|
||||
}
|
||||
|
||||
static int getBufferAgeEGL(_GLFWwindow* window)
|
||||
{
|
||||
EGLint buffer_age;
|
||||
|
||||
if (window != _glfwPlatformGetTls(&_glfw.contextSlot))
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"EGL: The context must be current on the calling thread when swapping buffers");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!eglQuerySurface(_glfw.egl.display, window->context.egl.surface,
|
||||
EGL_BUFFER_AGE_EXT, &buffer_age))
|
||||
return 0;
|
||||
|
||||
return buffer_age;
|
||||
}
|
||||
|
||||
static int extensionSupportedEGL(const char* extension)
|
||||
{
|
||||
const char* extensions = eglQueryString(_glfw.egl.display, EGL_EXTENSIONS);
|
||||
@ -384,6 +402,8 @@ GLFWbool _glfwInitEGL(void)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglSwapInterval");
|
||||
_glfw.egl.QueryString = (PFN_eglQueryString)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglQueryString");
|
||||
_glfw.egl.QuerySurface = (PFN_eglQuerySurface)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglQuerySurface");
|
||||
_glfw.egl.GetProcAddress = (PFN_eglGetProcAddress)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglGetProcAddress");
|
||||
|
||||
@ -402,6 +422,7 @@ GLFWbool _glfwInitEGL(void)
|
||||
!_glfw.egl.SwapBuffers ||
|
||||
!_glfw.egl.SwapInterval ||
|
||||
!_glfw.egl.QueryString ||
|
||||
!_glfw.egl.QuerySurface ||
|
||||
!_glfw.egl.GetProcAddress)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
@ -719,6 +740,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
window->context.swapBuffers = swapBuffersEGL;
|
||||
window->context.swapBuffersWithDamage = swapBuffersWithDamageEGL;
|
||||
window->context.swapInterval = swapIntervalEGL;
|
||||
window->context.getBufferAge = getBufferAgeEGL;
|
||||
window->context.extensionSupported = extensionSupportedEGL;
|
||||
window->context.getProcAddress = getProcAddressEGL;
|
||||
window->context.destroy = destroyContextEGL;
|
||||
|
@ -107,6 +107,8 @@ typedef struct wl_egl_window* EGLNativeWindowType;
|
||||
#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0
|
||||
#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098
|
||||
|
||||
#define EGL_BUFFER_AGE_EXT 0x313D
|
||||
|
||||
typedef int EGLint;
|
||||
typedef unsigned int EGLBoolean;
|
||||
typedef unsigned int EGLenum;
|
||||
@ -131,6 +133,7 @@ typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLS
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
|
||||
typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglQuerySurface)(EGLDisplay,EGLSurface,EGLint,EGLint*);
|
||||
typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffersWithDamageKHR)(EGLDisplay,EGLSurface,EGLint*,EGLint);
|
||||
#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
|
||||
@ -148,6 +151,7 @@ typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffersWithDamageKHR)(EGLDisplay,EG
|
||||
#define eglSwapBuffers _glfw.egl.SwapBuffers
|
||||
#define eglSwapInterval _glfw.egl.SwapInterval
|
||||
#define eglQueryString _glfw.egl.QueryString
|
||||
#define eglQuerySurface _glfw.egl.QuerySurface
|
||||
#define eglGetProcAddress _glfw.egl.GetProcAddress
|
||||
#define eglSwapBuffersWithDamageKHR _glfw.egl.SwapBuffersWithDamageKHR
|
||||
|
||||
@ -199,6 +203,7 @@ typedef struct _GLFWlibraryEGL
|
||||
PFN_eglSwapBuffers SwapBuffers;
|
||||
PFN_eglSwapInterval SwapInterval;
|
||||
PFN_eglQueryString QueryString;
|
||||
PFN_eglQuerySurface QuerySurface;
|
||||
PFN_eglGetProcAddress GetProcAddress;
|
||||
PFN_eglSwapBuffersWithDamageKHR SwapBuffersWithDamageKHR;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user