cocos2dx3.17在开启全屏后,图像移动出现画面撕裂的问题,如何解决?
在窗口产生的代码后面加入开启垂直同步的代码即可
我的做法是如下方法
修改main.cpp文件
1.加入头文件
#include <windows.h> #include <gl/gl.h>
2.在AppDelegate app 的下一行插入垂直同步代码
typedef BOOL(APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int);
PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0;
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress(“wglSwapIntervalEXT”);
wglSwapIntervalEXT(1);//打开垂直分布,限制帧率
以下就是我的main.cpp文件
#include "main.h"
#include "AppDelegate.h"
#include <windows.h>
#include <gl/gl.h>
USING_NS_CC;
// uncomment below line, open debug console
// #define USE_WIN32_CONSOLE
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
#ifdef USE_WIN32_CONSOLE
AllocConsole();
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
#endif
int nScreenWidth, nScreenHeight;
nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
// create the application instance
AppDelegate app( nScreenWidth, nScreenHeight + 1);
typedef BOOL(APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int);
PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0;
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress("wglSwapIntervalEXT");
wglSwapIntervalEXT(1);//打开垂直分布,限制帧率
app.start();
#ifdef USE_WIN32_CONSOLE
FreeConsole();
#endif
return 0;
}
使用这种方法就消除了画面撕裂
1赞
你好,我现在遇到的问题是,全屏之后打开程序是不正常的,需要切换一下窗口才会正常。