42 #include <visp/vpConfig.h>
43 #include <visp/vpWin32API.h>
44 #include <visp/vpTime.h>
47 #if ( defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) )
48 DWORD vpProcessErrors(
const std::string &api_name){
50 DWORD err = GetLastError();
53 FORMAT_MESSAGE_ALLOCATE_BUFFER |
54 FORMAT_MESSAGE_FROM_SYSTEM |
55 FORMAT_MESSAGE_IGNORE_INSERTS,
58 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
61 std::cout <<
"call to " << api_name <<
" failed with the following error code: " << err <<
"(" << (LPTSTR)lpMsgBuf <<
")" << std::endl;
65 BOOL vpLineTo(HDC hdc,
int nXEnd,
int nYEnd){
66 BOOL ret = LineTo(hdc, nXEnd, nYEnd);
68 vpProcessErrors(
"LineTo");
72 BOOL vpMoveToEx(HDC hdc,
int X,
int Y, LPPOINT lpPoint){
73 BOOL ret = MoveToEx(hdc, X, Y, lpPoint);
75 vpProcessErrors(
"MoveToEx");
79 BOOL vpBitBlt(HDC hdcDest,
int nXDest,
int nYDest,
int nWidth,
int nHeight, HDC hdcSrc,
int nXSrc,
int nYSrc, DWORD dwRop){
80 BOOL ret = BitBlt(hdcDest,nXDest,nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
82 vpProcessErrors(
"BitBlt");
86 BOOL vpInvalidateRect(HWND hWnd,
const RECT *lpRect, BOOL bErase){
87 BOOL ret = InvalidateRect(hWnd,lpRect,bErase);
89 vpProcessErrors(
"InvalidateRect");
93 void vpSelectObject(HWND hWnd, HDC hDC, HDC hDCMem, HGDIOBJ h){
95 HGDIOBJ ret = SelectObject(hDCMem,h);
97 vpProcessErrors(
"SelectObject");
104 ReleaseDC(hWnd, hDC);
109 BOOL vpReleaseSemaphore(HANDLE hSemaphore,LONG IReleaseCount,LPLONG lpPreviousCount){
110 BOOL ret = ReleaseSemaphore(hSemaphore,IReleaseCount,lpPreviousCount);
112 vpProcessErrors(
"ReleaseSemaphore");
118 void vpEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection){
119 EnterCriticalSection(lpCriticalSection);
121 void vpLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection){
122 LeaveCriticalSection(lpCriticalSection);
125 COLORREF vpSetPixel(HDC hdc,
int X,
int Y, COLORREF crColor){
126 COLORREF ret = SetPixel(hdc, X, Y, crColor);
128 vpProcessErrors(
"SetPixel");
132 HBITMAP vpCreateBitmap(
int nWidth,
int nHeight, UINT cPlanes, UINT cBitsPerPel,
const VOID *lpvBits){
133 HBITMAP ret = CreateBitmap(nWidth, nHeight, cPlanes, cBitsPerPel, lpvBits);
135 vpProcessErrors(
"CreateBitmap");
static double measureTimeMs()