void mfc_render_flip(void *mfc_render_handle) { HRESULT hRet; _MFC_RENDER_OVERLAY *pMFC_RENDER_OVERLAY; LPDIRECTDRAWSURFACE pDDSOverlay; if (mfc_render_handle == NULL) { PRINT_ERRMSG(TEXT("\nmfc_render_handle is NULL.")); return; } pMFC_RENDER_OVERLAY = (_MFC_RENDER_OVERLAY *) mfc_render_handle; if (pMFC_RENDER_OVERLAY->show == 0) { RECT rs, rd; rs.left = 0; rs.top = 0; rs.right = pMFC_RENDER_OVERLAY->src_wd; rs.bottom = pMFC_RENDER_OVERLAY->src_hi; rd.left = pMFC_RENDER_OVERLAY->x; rd.top = pMFC_RENDER_OVERLAY->y; rd.right = pMFC_RENDER_OVERLAY->dst_wd; rd.bottom = pMFC_RENDER_OVERLAY->dst_hi; pDDSOverlay = pMFC_RENDER_OVERLAY->pDD; // Update the overlay parameters. hRet = pDDSOverlay->UpdateOverlay(&rs, g_pDDSPrimary, &rd, DDOVER_SHOW, NULL); if (hRet != DD_OK) { PRINT_ERRMSG(TEXT("Unable to show overlay surface!")); return; } hRet = pDDSOverlay->SetOverlayPosition(0, 0); if (hRet != DD_OK) { PRINT_ERRMSG(TEXT("Unable to SetOverlayPosition!")); return; } pMFC_RENDER_OVERLAY->show = 1; } if (pMFC_RENDER_OVERLAY->which == 0) { pMFC_RENDER_OVERLAY->pDD->Flip(NULL, 0); pMFC_RENDER_OVERLAY->which = 1; } else if (pMFC_RENDER_OVERLAY->which == 1) { pMFC_RENDER_OVERLAY->pDD_back->Flip(NULL, 0); pMFC_RENDER_OVERLAY->which = 0; } }