SetPixelFormat函数返回值为false的原因有哪些??
如题,这个函数返回值一直是false,很郁闷啊
求大神~~~
[解决办法]
虽然没用过这个函数,还是给你几个建议。
1,查看msdn对返回值的详细解释
2,GetLastError获得错误码,在vs的错误查找工具中查看具体错误原因
[解决办法]
不给上下文代码,只能用GetLastError自己排查了
[解决办法]
象素格式不是任意设置就 ok 的,
你没有一个判断函数么?
- C/C++ code
boolCGLWindowLite::setPixelFormat(HDC hdc, int colorBits, int depthBits, int stencilBits){ PIXELFORMATDESCRIPTOR pfd; // find out the best matched pixel format int pixelFormat = findPixelFormat(hdc, colorBits, depthBits, stencilBits); if(pixelFormat == 0) return false; // set members of PIXELFORMATDESCRIPTOR with given mode ID ::DescribePixelFormat(hdc, pixelFormat, sizeof(pfd), &pfd); // set the fixel format if(!::SetPixelFormat(hdc, pixelFormat, &pfd)) return false; return true;}