mirror of https://github.com/libsdl-org/SDL
Update GL_GetSwapInterval for backends (#6963)
This commit is contained in:
parent
d764de77d4
commit
023f067903
|
@ -1180,14 +1180,14 @@ int SDL_EGL_SetSwapInterval(_THIS, int interval)
|
|||
return SDL_EGL_SetError("Unable to set the EGL swap interval", "eglSwapInterval");
|
||||
}
|
||||
|
||||
int SDL_EGL_GetSwapInterval(_THIS)
|
||||
int SDL_EGL_GetSwapInterval(_THIS, int *interval)
|
||||
{
|
||||
if (!_this->egl_data) {
|
||||
SDL_SetError("EGL not initialized");
|
||||
return 0;
|
||||
return SDL_SetError("EGL not initialized");
|
||||
}
|
||||
|
||||
return _this->egl_data->egl_swapinterval;
|
||||
*interval = _this->egl_data->egl_swapinterval;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_EGL_SwapBuffers(_THIS, EGLSurface egl_surface)
|
||||
|
|
|
@ -138,7 +138,7 @@ extern void SDL_EGL_UnloadLibrary(_THIS);
|
|||
extern void SDL_EGL_SetRequiredVisualId(_THIS, int visual_id);
|
||||
extern int SDL_EGL_ChooseConfig(_THIS);
|
||||
extern int SDL_EGL_SetSwapInterval(_THIS, int interval);
|
||||
extern int SDL_EGL_GetSwapInterval(_THIS);
|
||||
extern int SDL_EGL_GetSwapInterval(_THIS, int *interval);
|
||||
extern void SDL_EGL_DeleteContext(_THIS, SDL_GLContext context);
|
||||
extern EGLSurface *SDL_EGL_CreateSurface(_THIS, NativeWindowType nw);
|
||||
extern void SDL_EGL_DestroySurface(_THIS, EGLSurface egl_surface);
|
||||
|
|
|
@ -271,7 +271,7 @@ struct SDL_VideoDevice
|
|||
void (*GL_GetDrawableSize)(_THIS, SDL_Window *window, int *w, int *h);
|
||||
SDL_EGLSurface (*GL_GetEGLSurface)(_THIS, SDL_Window *window);
|
||||
int (*GL_SetSwapInterval)(_THIS, int interval);
|
||||
int (*GL_GetSwapInterval)(_THIS);
|
||||
int (*GL_GetSwapInterval)(_THIS, int *interval);
|
||||
int (*GL_SwapWindow)(_THIS, SDL_Window *window);
|
||||
void (*GL_DeleteContext)(_THIS, SDL_GLContext context);
|
||||
void (*GL_DefaultProfileConfig)(_THIS, int *mask, int *major, int *minor);
|
||||
|
|
|
@ -4066,10 +4066,7 @@ int SDL_GL_GetSwapInterval(int *interval)
|
|||
} else if (SDL_GL_GetCurrentContext() == NULL) {
|
||||
return SDL_SetError("no current context");;
|
||||
} else if (_this->GL_GetSwapInterval) {
|
||||
int val = _this->GL_GetSwapInterval(_this);
|
||||
|
||||
*interval = val;
|
||||
return 0;
|
||||
return _this->GL_GetSwapInterval(_this, interval);
|
||||
} else {
|
||||
return SDL_SetError("not implemented");;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ extern SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window *window);
|
|||
extern int Cocoa_GL_MakeCurrent(_THIS, SDL_Window *window,
|
||||
SDL_GLContext context);
|
||||
extern int Cocoa_GL_SetSwapInterval(_THIS, int interval);
|
||||
extern int Cocoa_GL_GetSwapInterval(_THIS);
|
||||
extern int Cocoa_GL_GetSwapInterval(_THIS, int *interval);
|
||||
extern int Cocoa_GL_SwapWindow(_THIS, SDL_Window *window);
|
||||
extern void Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context);
|
||||
|
||||
|
|
|
@ -467,11 +467,16 @@ int Cocoa_GL_SetSwapInterval(_THIS, int interval)
|
|||
}
|
||||
}
|
||||
|
||||
int Cocoa_GL_GetSwapInterval(_THIS)
|
||||
int Cocoa_GL_GetSwapInterval(_THIS, int *interval)
|
||||
{
|
||||
@autoreleasepool {
|
||||
SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)SDL_GL_GetCurrentContext();
|
||||
return nscontext ? SDL_AtomicGet(&nscontext->swapIntervalSetting) : 0;
|
||||
if (nscontext) {
|
||||
*interval = SDL_AtomicGet(&nscontext->swapIntervalSetting);
|
||||
return 0;
|
||||
} else {
|
||||
return SDL_SetError("no OpenGL context");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,16 +57,19 @@ int Emscripten_GLES_SetSwapInterval(_THIS, int interval)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int Emscripten_GLES_GetSwapInterval(_THIS)
|
||||
int Emscripten_GLES_GetSwapInterval(_THIS, int *interval)
|
||||
{
|
||||
int mode, value;
|
||||
|
||||
emscripten_get_main_loop_timing(&mode, &value);
|
||||
|
||||
if (mode == EM_TIMING_RAF)
|
||||
return value;
|
||||
|
||||
return 0;
|
||||
if (mode == EM_TIMING_RAF) {
|
||||
*interval = value;
|
||||
return 0;
|
||||
} else {
|
||||
*interval = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_GLContext
|
||||
|
|
|
@ -32,7 +32,7 @@ extern int Emscripten_GLES_LoadLibrary(_THIS, const char *path);
|
|||
extern void Emscripten_GLES_UnloadLibrary(_THIS);
|
||||
extern void *Emscripten_GLES_GetProcAddress(_THIS, const char *proc);
|
||||
extern int Emscripten_GLES_SetSwapInterval(_THIS, int interval);
|
||||
extern int Emscripten_GLES_GetSwapInterval(_THIS);
|
||||
extern int Emscripten_GLES_GetSwapInterval(_THIS, int *interval);
|
||||
extern SDL_GLContext Emscripten_GLES_CreateContext(_THIS, SDL_Window *window);
|
||||
extern void Emscripten_GLES_DeleteContext(_THIS, SDL_GLContext context);
|
||||
extern int Emscripten_GLES_SwapWindow(_THIS, SDL_Window *window);
|
||||
|
|
|
@ -159,9 +159,8 @@ int HAIKU_GL_SetSwapInterval(_THIS, int interval) {
|
|||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int HAIKU_GL_GetSwapInterval(_THIS) {
|
||||
/* TODO: Implement this, if necessary? */
|
||||
return 0;
|
||||
int HAIKU_GL_GetSwapInterval(_THIS, int *interval) {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ extern void HAIKU_GL_UnloadLibrary(_THIS); /* TODO */
|
|||
extern int HAIKU_GL_MakeCurrent(_THIS, SDL_Window *window,
|
||||
SDL_GLContext context);
|
||||
extern int HAIKU_GL_SetSwapInterval(_THIS, int interval); /* TODO */
|
||||
extern int HAIKU_GL_GetSwapInterval(_THIS); /* TODO */
|
||||
extern int HAIKU_GL_GetSwapInterval(_THIS, int *interval); /* TODO */
|
||||
extern int HAIKU_GL_SwapWindow(_THIS, SDL_Window *window);
|
||||
extern SDL_GLContext HAIKU_GL_CreateContext(_THIS, SDL_Window *window);
|
||||
extern void HAIKU_GL_DeleteContext(_THIS, SDL_GLContext context);
|
||||
|
|
|
@ -153,9 +153,10 @@ int PSP_GL_SetSwapInterval(_THIS, int interval)
|
|||
return SDL_SetError("Unable to set the EGL swap interval");
|
||||
}
|
||||
|
||||
int PSP_GL_GetSwapInterval(_THIS)
|
||||
int PSP_GL_GetSwapInterval(_THIS, int *interval)
|
||||
{
|
||||
return _this->gl_data->swapinterval;
|
||||
*interval = _this->gl_data->swapinterval;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PSP_GL_SwapWindow(_THIS, SDL_Window *window)
|
||||
|
|
|
@ -45,6 +45,6 @@ extern SDL_GLContext PSP_GL_CreateContext(_THIS, SDL_Window *window);
|
|||
extern int PSP_GL_LoadLibrary(_THIS, const char *path);
|
||||
extern void PSP_GL_UnloadLibrary(_THIS);
|
||||
extern int PSP_GL_SetSwapInterval(_THIS, int interval);
|
||||
extern int PSP_GL_GetSwapInterval(_THIS);
|
||||
extern int PSP_GL_GetSwapInterval(_THIS, int *interval);
|
||||
|
||||
#endif /* SDL_pspgl_c_h_ */
|
||||
|
|
|
@ -75,7 +75,7 @@ void PSP_GL_UnloadLibrary(_THIS);
|
|||
SDL_GLContext PSP_GL_CreateContext(_THIS, SDL_Window *window);
|
||||
int PSP_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context);
|
||||
int PSP_GL_SetSwapInterval(_THIS, int interval);
|
||||
int PSP_GL_GetSwapInterval(_THIS);
|
||||
int PSP_GL_GetSwapInterval(_THIS, int *interval);
|
||||
int PSP_GL_SwapWindow(_THIS, SDL_Window *window);
|
||||
void PSP_GL_DeleteContext(_THIS, SDL_GLContext context);
|
||||
|
||||
|
|
|
@ -92,14 +92,14 @@ int Wayland_GLES_SetSwapInterval(_THIS, int interval)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int Wayland_GLES_GetSwapInterval(_THIS)
|
||||
int Wayland_GLES_GetSwapInterval(_THIS, int *interval)
|
||||
{
|
||||
if (!_this->egl_data) {
|
||||
SDL_SetError("EGL not initialized");
|
||||
return 0;
|
||||
return SDL_SetError("EGL not initialized");
|
||||
}
|
||||
|
||||
return _this->egl_data->egl_swapinterval;
|
||||
*interval =_this->egl_data->egl_swapinterval;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
|
||||
|
|
|
@ -39,7 +39,7 @@ typedef struct SDL_PrivateGLESData
|
|||
extern int Wayland_GLES_LoadLibrary(_THIS, const char *path);
|
||||
extern SDL_GLContext Wayland_GLES_CreateContext(_THIS, SDL_Window *window);
|
||||
extern int Wayland_GLES_SetSwapInterval(_THIS, int interval);
|
||||
extern int Wayland_GLES_GetSwapInterval(_THIS);
|
||||
extern int Wayland_GLES_GetSwapInterval(_THIS, int *interval);
|
||||
extern int Wayland_GLES_SwapWindow(_THIS, SDL_Window *window);
|
||||
extern int Wayland_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context);
|
||||
extern void Wayland_GLES_DeleteContext(_THIS, SDL_GLContext context);
|
||||
|
|
|
@ -866,13 +866,14 @@ int WIN_GL_SetSwapInterval(_THIS, int interval)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int WIN_GL_GetSwapInterval(_THIS)
|
||||
int WIN_GL_GetSwapInterval(_THIS, int *interval)
|
||||
{
|
||||
int retval = 0;
|
||||
if (_this->gl_data->wglGetSwapIntervalEXT) {
|
||||
retval = _this->gl_data->wglGetSwapIntervalEXT();
|
||||
*interval = _this->gl_data->wglGetSwapIntervalEXT();
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int WIN_GL_SwapWindow(_THIS, SDL_Window *window)
|
||||
|
|
|
@ -111,7 +111,7 @@ extern SDL_GLContext WIN_GL_CreateContext(_THIS, SDL_Window *window);
|
|||
extern int WIN_GL_MakeCurrent(_THIS, SDL_Window *window,
|
||||
SDL_GLContext context);
|
||||
extern int WIN_GL_SetSwapInterval(_THIS, int interval);
|
||||
extern int WIN_GL_GetSwapInterval(_THIS);
|
||||
extern int WIN_GL_GetSwapInterval(_THIS, int *interval);
|
||||
extern int WIN_GL_SwapWindow(_THIS, SDL_Window *window);
|
||||
extern void WIN_GL_DeleteContext(_THIS, SDL_GLContext context);
|
||||
extern void WIN_GL_InitExtensions(_THIS);
|
||||
|
|
|
@ -885,7 +885,8 @@ int X11_GL_SetSwapInterval(_THIS, int interval)
|
|||
* it has the wrong value cached. To work around it, we just run a no-op
|
||||
* update to the current value.
|
||||
*/
|
||||
int currentInterval = X11_GL_GetSwapInterval(_this);
|
||||
int currentInterval = 0;
|
||||
X11_GL_GetSwapInterval(_this, ¤tInterval);
|
||||
_this->gl_data->glXSwapIntervalEXT(display, drawable, currentInterval);
|
||||
_this->gl_data->glXSwapIntervalEXT(display, drawable, interval);
|
||||
|
||||
|
@ -911,7 +912,7 @@ int X11_GL_SetSwapInterval(_THIS, int interval)
|
|||
return status;
|
||||
}
|
||||
|
||||
int X11_GL_GetSwapInterval(_THIS)
|
||||
int X11_GL_GetSwapInterval(_THIS, int *interval)
|
||||
{
|
||||
if (_this->gl_data->glXSwapIntervalEXT) {
|
||||
Display *display = ((SDL_VideoData *)_this->driverdata)->display;
|
||||
|
@ -920,7 +921,7 @@ int X11_GL_GetSwapInterval(_THIS)
|
|||
->driverdata;
|
||||
Window drawable = windowdata->xwindow;
|
||||
unsigned int allow_late_swap_tearing = 0;
|
||||
unsigned int interval = 0;
|
||||
unsigned int val = 0;
|
||||
|
||||
if (_this->gl_data->HAS_GLX_EXT_swap_control_tear) {
|
||||
_this->gl_data->glXQueryDrawable(display, drawable,
|
||||
|
@ -929,17 +930,25 @@ int X11_GL_GetSwapInterval(_THIS)
|
|||
}
|
||||
|
||||
_this->gl_data->glXQueryDrawable(display, drawable,
|
||||
GLX_SWAP_INTERVAL_EXT, &interval);
|
||||
GLX_SWAP_INTERVAL_EXT, &val);
|
||||
|
||||
if ((allow_late_swap_tearing) && (interval > 0)) {
|
||||
return -((int)interval);
|
||||
if ((allow_late_swap_tearing) && (val > 0)) {
|
||||
*interval = -((int)val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int)interval;
|
||||
*interval = (int)val;
|
||||
return 0;
|
||||
} else if (_this->gl_data->glXGetSwapIntervalMESA) {
|
||||
return _this->gl_data->glXGetSwapIntervalMESA();
|
||||
int val = _this->gl_data->glXGetSwapIntervalMESA();
|
||||
if (val == GLX_BAD_CONTEXT) {
|
||||
return SDL_SetError("GLX_BAD_CONTEXT");
|
||||
}
|
||||
*interval = val;
|
||||
return 0;
|
||||
} else {
|
||||
return swapinterval;
|
||||
*interval = swapinterval;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ extern SDL_GLContext X11_GL_CreateContext(_THIS, SDL_Window *window);
|
|||
extern int X11_GL_MakeCurrent(_THIS, SDL_Window *window,
|
||||
SDL_GLContext context);
|
||||
extern int X11_GL_SetSwapInterval(_THIS, int interval);
|
||||
extern int X11_GL_GetSwapInterval(_THIS);
|
||||
extern int X11_GL_GetSwapInterval(_THIS, int *interval);
|
||||
extern int X11_GL_SwapWindow(_THIS, SDL_Window *window);
|
||||
extern void X11_GL_DeleteContext(_THIS, SDL_GLContext context);
|
||||
|
||||
|
|
Loading…
Reference in New Issue