aiscape
08-26-2003, 12:41 PM
hello!
i want to copy an opengl scene on a bitmap, but SetPixelFormat fails. it returns 0, getlasterror returns 0 too. rendering on the screen runs fine. m_pDC is the cdc of the cview object.
does anybody know whats wrong?
thanks, jan.
// copy-function
unsigned cx = 200, cy = 200;
CDC *pMemDC = new CDC();
HGLRC hRC;
CBitmap bmp;
CRect rect;
if(!pMemDC->CreateCompatibleDC(m_pDC))
AfxMessageBox("CreateCompatibleDC failed!");
GetWindowRect(&rect);
bmp.CreateCompatibleBitmap(pMemDC, cx, cy);
CBitmap *pOldBitmap = pMemDC->SelectObject(&bmp);
// Rendering
wglMakeCurrent(0,0);
PIXELFORMATDESCRIPTOR pfd ;
memset(&pfd,0,sizeof(PIXELFORMATDESCRIPTOR)) ;
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR) ;
pfd.nVersion = 1 ;
pfd.dwFlags = PFD_DRAW_TO_BITMAP |PFD_SUPPORT_OPENGL|PFD_DRAW_TO_WINDOW ;
pfd.iPixelType = PFD_TYPE_RGBA ;
pfd.cColorBits = 32 ;
pfd.cDepthBits = 16 ;
pfd.iLayerType = PFD_MAIN_PLANE ;
int nPixelFormat = ChoosePixelFormat(pMemDC->GetSafeHdc(), &pfd);
if (!nPixelFormat)
AfxMessageBox("ChoosePixelFormat Failed %d\r\n",GetLastError());
nPixelFormat = SetPixelFormat(pMemDC->GetSafeHdc(), nPixelFormat, &pfd);
if(!nPixelFormat)
AfxMessageBox("SetPixelFormat Failed!");
...
i want to copy an opengl scene on a bitmap, but SetPixelFormat fails. it returns 0, getlasterror returns 0 too. rendering on the screen runs fine. m_pDC is the cdc of the cview object.
does anybody know whats wrong?
thanks, jan.
// copy-function
unsigned cx = 200, cy = 200;
CDC *pMemDC = new CDC();
HGLRC hRC;
CBitmap bmp;
CRect rect;
if(!pMemDC->CreateCompatibleDC(m_pDC))
AfxMessageBox("CreateCompatibleDC failed!");
GetWindowRect(&rect);
bmp.CreateCompatibleBitmap(pMemDC, cx, cy);
CBitmap *pOldBitmap = pMemDC->SelectObject(&bmp);
// Rendering
wglMakeCurrent(0,0);
PIXELFORMATDESCRIPTOR pfd ;
memset(&pfd,0,sizeof(PIXELFORMATDESCRIPTOR)) ;
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR) ;
pfd.nVersion = 1 ;
pfd.dwFlags = PFD_DRAW_TO_BITMAP |PFD_SUPPORT_OPENGL|PFD_DRAW_TO_WINDOW ;
pfd.iPixelType = PFD_TYPE_RGBA ;
pfd.cColorBits = 32 ;
pfd.cDepthBits = 16 ;
pfd.iLayerType = PFD_MAIN_PLANE ;
int nPixelFormat = ChoosePixelFormat(pMemDC->GetSafeHdc(), &pfd);
if (!nPixelFormat)
AfxMessageBox("ChoosePixelFormat Failed %d\r\n",GetLastError());
nPixelFormat = SetPixelFormat(pMemDC->GetSafeHdc(), nPixelFormat, &pfd);
if(!nPixelFormat)
AfxMessageBox("SetPixelFormat Failed!");
...