Hi!
I am working on a MFC Project. Within my application Ih vae Multiple Views (CView). I am already rendering 3D content in one of the views. Now I am trying to render 2D images within another View using OpenGL. But I am getting
Invalid Operation
in the second view.
void CImageMainView::InitializeOpenGL()
{
m_pDC = new CClientDC(this);
m_hDC = m_pDC->GetSafeHdc();
SetupPixelFormat();
m_hRC = ::wglCreateContext(m_hDC);
BOOL ret = ::wglMakeCurrent(m_hDC, m_hRC);
if(!ret){
printf("Error making current context
");
}
printf("wglMakeCurrent ");
CheckGLError();
GetOpenGLExtendedInformation();
::wglMakeCurrent(NULL, NULL);
printf("wglMakeCurrent to null");
CheckGLError();
return;
}
void CImageMainView::SetupPixelFormat()
{
static PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
PFD_DOUBLEBUFFER, // double buffered
PFD_TYPE_RGBA, // RGBA type
24, // 24-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
32, // 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
};
m_PixelFormat = ::ChoosePixelFormat(m_hDC, &pfd);
::SetPixelFormat(m_hDC, m_PixelFormat, &pfd);
return;
}