Condor
04-26-2002, 01:40 AM
Hello, I met with strange situation because it worked fain before.
When it tries to set pixel format by using the SetPixelFormat() my MFC dialog stops responding and I neet to restart my PC for properly working of other applications.
Please a look at the code:
int OpenGLWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if(CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
m_hDC = ::GetDC(m_hWnd);
if (SetPixelFormat(m_hDC)==FALSE)
return -1;
if (CreateGLContext(m_hDC)==FALSE)
return -1;
}
BOOL OpenGLWnd::SetPixelFormat(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,//2,
0,
0,
0
};
int pixelFormat;
if((pixelFormat = ::ChoosePixelFormat(hdc, &pfd)) == 0)
{
pixelFormat = 1;
if(DescribePixelFormat(m_hDC, pixelFormat, // Obtains information about the pixel format identified by iPixelFormat of the device associated with hdc
sizeof(PIXELFORMATDESCRIPTOR), &pfd)==0)
return FALSE;
}
if (::SetPixelFormat(hdc, pixelFormat, &pfd) == FALSE)
{
return FALSE;
}
return TRUE;
}
BOOL OpenGLWnd::CreateGLContext(HDC hdc)
{
if((m_hrc = ::wglCreateContext(hdc)) == NULL)
return FALSE;
if(::wglMakeCurrent(hdc, m_hrc) == FALSE)
return FALSE;
return TRUE;
}
the OpenGLWnd class has been derived from CWnd.
I use Windows NT 4.0 SP6. However this problem appears on other OS as well.
Thank you in advance,
Romanas Puisa
When it tries to set pixel format by using the SetPixelFormat() my MFC dialog stops responding and I neet to restart my PC for properly working of other applications.
Please a look at the code:
int OpenGLWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if(CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
m_hDC = ::GetDC(m_hWnd);
if (SetPixelFormat(m_hDC)==FALSE)
return -1;
if (CreateGLContext(m_hDC)==FALSE)
return -1;
}
BOOL OpenGLWnd::SetPixelFormat(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,//2,
0,
0,
0
};
int pixelFormat;
if((pixelFormat = ::ChoosePixelFormat(hdc, &pfd)) == 0)
{
pixelFormat = 1;
if(DescribePixelFormat(m_hDC, pixelFormat, // Obtains information about the pixel format identified by iPixelFormat of the device associated with hdc
sizeof(PIXELFORMATDESCRIPTOR), &pfd)==0)
return FALSE;
}
if (::SetPixelFormat(hdc, pixelFormat, &pfd) == FALSE)
{
return FALSE;
}
return TRUE;
}
BOOL OpenGLWnd::CreateGLContext(HDC hdc)
{
if((m_hrc = ::wglCreateContext(hdc)) == NULL)
return FALSE;
if(::wglMakeCurrent(hdc, m_hrc) == FALSE)
return FALSE;
return TRUE;
}
the OpenGLWnd class has been derived from CWnd.
I use Windows NT 4.0 SP6. However this problem appears on other OS as well.
Thank you in advance,
Romanas Puisa