38 #include <visp3/core/vpConfig.h>
41 #if ( defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) )
42 #include <visp3/gui/vpWin32API.h>
43 #include <visp3/core/vpTime.h>
44 DWORD vpProcessErrors(
const std::string &api_name){
46 DWORD err = GetLastError();
49 FORMAT_MESSAGE_ALLOCATE_BUFFER |
50 FORMAT_MESSAGE_FROM_SYSTEM |
51 FORMAT_MESSAGE_IGNORE_INSERTS,
54 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
57 std::cout <<
"call to " << api_name <<
" failed with the following error code: " << err <<
"(" << (LPTSTR)lpMsgBuf <<
")" << std::endl;
61 BOOL vpLineTo(HDC hdc,
int nXEnd,
int nYEnd){
62 BOOL ret = LineTo(hdc, nXEnd, nYEnd);
64 vpProcessErrors(
"LineTo");
68 BOOL vpMoveToEx(HDC hdc,
int X,
int Y, LPPOINT lpPoint){
69 BOOL ret = MoveToEx(hdc, X, Y, lpPoint);
71 vpProcessErrors(
"MoveToEx");
75 BOOL vpBitBlt(HDC hdcDest,
int nXDest,
int nYDest,
int nWidth,
int nHeight, HDC hdcSrc,
int nXSrc,
int nYSrc, DWORD dwRop){
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){
83 BOOL ret = InvalidateRect(hWnd,lpRect,bErase);
85 vpProcessErrors(
"InvalidateRect");
89 void vpSelectObject(HWND hWnd, HDC hDC, HDC hDCMem, HGDIOBJ h){
91 HGDIOBJ ret = SelectObject(hDCMem,h);
93 vpProcessErrors(
"SelectObject");
100 ReleaseDC(hWnd, hDC);
105 BOOL vpReleaseSemaphore(HANDLE hSemaphore,LONG IReleaseCount,LPLONG lpPreviousCount){
106 BOOL ret = ReleaseSemaphore(hSemaphore,IReleaseCount,lpPreviousCount);
109 vpProcessErrors(
"ReleaseSemaphore");
115 void vpEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection){
116 EnterCriticalSection(lpCriticalSection);
118 void vpLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection){
119 LeaveCriticalSection(lpCriticalSection);
122 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){
130 HBITMAP ret = CreateBitmap(nWidth, nHeight, cPlanes, cBitsPerPel, lpvBits);
132 vpProcessErrors(
"CreateBitmap");
137 #elif !defined(VISP_BUILD_SHARED_LIBS)
139 void dummy_vpWin32API() {};
VISP_EXPORT double measureTimeMs()