35#include <visp3/core/vpConfig.h>
37#if (defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9))
38#include <visp3/core/vpTime.h>
39#include <visp3/gui/vpWin32API.h>
43DWORD vpProcessErrors(
const std::string &api_name)
46 DWORD err = GetLastError();
48 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr, err,
49 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0,
nullptr);
50 std::cout <<
"call to " << api_name <<
" failed with the following error code: " << err <<
"(" << (LPTSTR)lpMsgBuf
55BOOL vpLineTo(HDC hdc,
int nXEnd,
int nYEnd)
57 BOOL ret = LineTo(hdc, nXEnd, nYEnd);
59 vpProcessErrors(
"LineTo");
63BOOL vpMoveToEx(HDC hdc,
int X,
int Y, LPPOINT lpPoint)
65 BOOL ret = MoveToEx(hdc, X, Y, lpPoint);
67 vpProcessErrors(
"MoveToEx");
71BOOL vpBitBlt(HDC hdcDest,
int nXDest,
int nYDest,
int nWidth,
int nHeight, HDC hdcSrc,
int nXSrc,
int nYSrc,
74 BOOL ret = BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
76 vpProcessErrors(
"BitBlt");
80BOOL vpInvalidateRect(HWND hWnd,
const RECT *lpRect, BOOL bErase)
82 BOOL ret = InvalidateRect(hWnd, lpRect, bErase);
84 vpProcessErrors(
"InvalidateRect");
88void vpSelectObject(HWND hWnd, HDC hDC, HDC hDCMem, HGDIOBJ h)
91 HGDIOBJ ret = SelectObject(hDCMem, h);
93 vpProcessErrors(
"SelectObject");
100 ReleaseDC(hWnd, hDC);
105BOOL vpReleaseSemaphore(HANDLE hSemaphore, LONG IReleaseCount, LPLONG lpPreviousCount)
107 BOOL ret = ReleaseSemaphore(hSemaphore, IReleaseCount, lpPreviousCount);
110 vpProcessErrors(
"ReleaseSemaphore");
116void vpEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { EnterCriticalSection(lpCriticalSection); }
117void vpLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { LeaveCriticalSection(lpCriticalSection); }
119COLORREF vpSetPixel(HDC hdc,
int X,
int Y, COLORREF crColor)
121 COLORREF ret = SetPixel(hdc, X, Y, crColor);
123 vpProcessErrors(
"SetPixel");
127HBITMAP vpCreateBitmap(
int nWidth,
int nHeight, UINT cPlanes, UINT cBitsPerPel,
const VOID *lpvBits)
129 HBITMAP ret = CreateBitmap(nWidth, nHeight, cPlanes, cBitsPerPel, lpvBits);
131 vpProcessErrors(
"CreateBitmap");
138#elif !defined(VISP_BUILD_SHARED_LIBS)
140void dummy_vpWin32API() { }
VISP_EXPORT double measureTimeMs()