Skip to content

Instantly share code, notes, and snippets.

@Furkanzmc
Forked from daltondotgd/VSyncForCocos2dX.cpp
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Furkanzmc/fbdccc8d18ae6c4902d2 to your computer and use it in GitHub Desktop.
Save Furkanzmc/fbdccc8d18ae6c4902d2 to your computer and use it in GitHub Desktop.
To enable VSync for WIN32 in cocos2d-x, modify initWithRect(...) function in CCGLView.cpp, so it contains this code right before 'initGlew();'
...
...
...
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
// Turn on vertical screen sync under Windows.
// (I.e. it uses the WGL_EXT_swap_control extension)
typedef BOOL(WINAPI *PFNWGLSWAPINTERVALEXTPROC)(int interval);
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = NULL;
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
if (wglSwapIntervalEXT)
wglSwapIntervalEXT(1);
#endif
initGlew(); // this already exists int the file
...
...
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment