18 #if defined(ION_PLATFORM_MAC)
19 # include <OpenGL/OpenGL.h>
46 #if defined(ION_PLATFORM_IOS) || defined(ION_PLATFORM_ANDROID) || \
47 defined(ION_PLATFORM_ASMJS) || defined(ION_PLATFORM_NACL) || \
48 defined(ION_PLATFORM_GENERIC_ARM)
50 #elif defined(ION_PLATFORM_LINUX)
51 typedef int (ION_APIENTRY *SwapIntervalProc)(
int interval);
52 SwapIntervalProc vsync_func =
reinterpret_cast<SwapIntervalProc
>(
54 return vsync_func && vsync_func(interval) == 0;
55 #elif defined(ION_PLATFORM_MAC)
56 if (CGLContextObj context = CGLGetCurrentContext()) {
57 CGLSetParameter(context, kCGLCPSwapInterval, &interval);
58 int new_interval = -1;
59 CGLGetParameter(context, kCGLCPSwapInterval, &new_interval);
60 return interval == new_interval;
63 #elif defined(ION_PLATFORM_WINDOWS) && !defined(ION_ANGLE)
64 typedef BOOL (ION_APIENTRY *SwapIntervalProc)(
int interval);
65 typedef int (ION_APIENTRY *GetSwapIntervalProc)();
66 SwapIntervalProc vsync_set_func =
reinterpret_cast<SwapIntervalProc
>(
68 GetSwapIntervalProc vsync_get_func =
reinterpret_cast<GetSwapIntervalProc
>(
70 if (vsync_get_func && vsync_set_func) {
71 BOOL set_val = vsync_set_func(interval);
72 int get_val = vsync_get_func();
73 return set_val == TRUE && get_val == interval;
76 #elif defined(ION_GFX_OGLES20) || defined(ION_ANGLE)
77 EGLDisplay display = eglGetCurrentDisplay();
78 return display != EGL_NO_DISPLAY &&
79 eglSwapInterval(display, interval) == EGL_TRUE;
void * GetGlProcAddress(const char *name, bool is_core)
Returns a generic pointer to an OpenGL function or OpenGL extension function with the given name...
bool SetSwapInterval(int interval)
Setting the swap interval is very platform-dependent, so we define a wrapper function for it here...