it seems that it is not only happen on a ati
and not caused by wglMakeCurrent()
that is a example of mine
could any body take his or her time to have a look at it if it has any problem in it
int COpenGL::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
MySetPixelFormat(::GetDC(m_hWnd));
hdc = ::GetDC(m_hWnd);
hglrc = wglCreateContext(hdc);
return 0;
}
===============
void COpenGL::OnPaint()
{
//CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
wglMakeCurrent(hdc, hglrc);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
s+=0.005;
if(s>1.0)
s=0.1;
step = step + 1.0;
if (step > 360.0)
step = step - 360.0;
glPushMatrix();
glScalef(s,s,s);
glRotatef(step,0.0,1.0,0.0);
glRotatef(step,0.0,0.0,1.0);
glRotatef(step,1.0,0.0,0.0);
DrawColorBox();
glPopMatrix();
glFlush();
SwapBuffers(hdc);
wglMakeCurrent(NULL, NULL);
// Do not call CWnd::OnPaint() for painting messages
}
=====================
int COpenGL::MySetPixelFormat(HDC hdc)
{
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 };
int iPixelFormat;
if((iPixelFormat = ChoosePixelFormat(hdc, &pfd)) == 0)
{
MessageBox("ChoosePixelFormat Failed", NULL, MB_OK);
return 0;
}
if(SetPixelFormat(hdc, iPixelFormat, &pfd) == FALSE)
{
MessageBox("SetPixelFormat Failed", NULL, MB_OK);
return 0;
}
return 1;
}
======================
COpenGL::OnDestroy()
{
wglMakeCurrent(NULL, NULL) ;
wglDeleteContext(hglrc); ::ReleaseDC (m_hWnd, hdc) ;
}