I am trying to implement double buffering, but it does not seem to work, i.e. the graphics are still flickering.
WM_PAINT is called every time the mouse moves. (WM_MOUSEMOVE)
Insert WM_PAINT below:
case WM_PAINT: { hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... RECT rect; GetClientRect(hWnd, &rect); int width=rect.right; int height=rect.bottom; HDC backbuffDC = CreateCompatibleDC(hdc); HBITMAP backbuffer = CreateCompatibleBitmap( hdc, width, height); int savedDC = SaveDC(backbuffDC); SelectObject( backbuffDC, backbuffer ); HBRUSH hBrush = CreateSolidBrush(RGB(255,255,255)); FillRect(backbuffDC,&rect,hBrush); DeleteObject(hBrush); if(fileImport) { importFile(backbuffDC); } if(renderWiredCube) { wireframeCube(backbuffDC); } if(renderColoredCube) { renderColorCube(backbuffDC); } BitBlt(hdc,0,0,width,height,backbuffDC,0,0,SRCCOPY); RestoreDC(backbuffDC,savedDC); DeleteObject(backbuffer); DeleteDC(backbuffDC); EndPaint(hWnd, &ps); }
user1788175
source share