Below is my code to create a OpenGL Render RC:
m_hDC=::GetDC(m_hWnd);
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW |PFD_SUPPORT_OPENGL |PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA, // RGBA type
32, // 32-bit color depth
0, 0, 0, 0, 0, 0, // color bits ignored
0, // no alpha buffer
0, // shift bit ignored
0, // no accumulation buffer
0, 0, 0, 0, // accum bits ignored
0, // 32-bit z-buffer
0, // no stencil buffer
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
};
BOOL bRet=FALSE;
int index=ChoosePixelFormat(m_hDC,&pfd);
if(index)
{
if(SetPixelFormat(m_hDC,index,&pfd))
{
m_hRC=wglCreateContext(m_hDC);
if(m_hRC)
bRet=wglMakeCurrent(m_hDC,m_hRC);
}
}
if(bRet)
Reshape();
else
assert(FALSE);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glEnable(GL_TEXTURE_2D);
wglSwapIntervalEXT(1);// turn on VSync
assert(wglGetSwapIntervalEXT() == 1); // Check VSync is opened or not
return bRet;
In WindowsXP,the code can turn on the “VSync” function and the rendered image looks smooth in OpenGL window,but in Windows7,the OpenGL API tell me I had turn on the function(the “wglGetSwapIntervalEXT()” return 1),but the rendered image in OpenGL Window is chapped,just like VSync is off,why the code can not turn on VSync under Windows7?
My test computer use NV Geforce GTX 670 display card,with V320.49 driver.