40 #include <visp3/core/vpConfig.h> 42 #if (defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9)) 43 #include <visp3/core/vpTime.h> 44 #include <visp3/gui/vpWin32API.h> 45 DWORD vpProcessErrors(
const std::string &api_name)
48 DWORD err = GetLastError();
50 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err,
51 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL);
52 std::cout <<
"call to " << api_name <<
" failed with the following error code: " << err <<
"(" << (LPTSTR)lpMsgBuf
57 BOOL vpLineTo(HDC hdc,
int nXEnd,
int nYEnd)
59 BOOL ret = LineTo(hdc, nXEnd, nYEnd);
61 vpProcessErrors(
"LineTo");
65 BOOL vpMoveToEx(HDC hdc,
int X,
int Y, LPPOINT lpPoint)
67 BOOL ret = MoveToEx(hdc, X, Y, lpPoint);
69 vpProcessErrors(
"MoveToEx");
73 BOOL vpBitBlt(HDC hdcDest,
int nXDest,
int nYDest,
int nWidth,
int nHeight, HDC hdcSrc,
int nXSrc,
int nYSrc,
76 BOOL ret = BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
78 vpProcessErrors(
"BitBlt");
82 BOOL vpInvalidateRect(HWND hWnd,
const RECT *lpRect, BOOL bErase)
84 BOOL ret = InvalidateRect(hWnd, lpRect, bErase);
86 vpProcessErrors(
"InvalidateRect");
90 void vpSelectObject(HWND hWnd, HDC hDC, HDC hDCMem, HGDIOBJ h)
93 HGDIOBJ ret = SelectObject(hDCMem, h);
95 vpProcessErrors(
"SelectObject");
102 ReleaseDC(hWnd, hDC);
107 BOOL vpReleaseSemaphore(HANDLE hSemaphore, LONG IReleaseCount, LPLONG lpPreviousCount)
109 BOOL ret = ReleaseSemaphore(hSemaphore, IReleaseCount, lpPreviousCount);
112 vpProcessErrors(
"ReleaseSemaphore");
118 void vpEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { EnterCriticalSection(lpCriticalSection); }
119 void vpLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { LeaveCriticalSection(lpCriticalSection); }
121 COLORREF vpSetPixel(HDC hdc,
int X,
int Y, COLORREF crColor)
123 COLORREF ret = SetPixel(hdc, X, Y, crColor);
125 vpProcessErrors(
"SetPixel");
129 HBITMAP vpCreateBitmap(
int nWidth,
int nHeight, UINT cPlanes, UINT cBitsPerPel,
const VOID *lpvBits)
131 HBITMAP ret = CreateBitmap(nWidth, nHeight, cPlanes, cBitsPerPel, lpvBits);
133 vpProcessErrors(
"CreateBitmap");
138 #elif !defined(VISP_BUILD_SHARED_LIBS) 141 void dummy_vpWin32API(){};
VISP_EXPORT double measureTimeMs()