36#include <visp3/core/vpConfig.h>
38#if (defined(_WIN32) & defined(VISP_HAVE_D3D9))
39#ifndef DOXYGEN_SHOULD_SKIP_THIS
41#include <visp3/core/vpColor.h>
42#include <visp3/core/vpMath.h>
43#include <visp3/gui/vpD3DRenderer.h>
72vpD3DRenderer::vpD3DRenderer()
78 pd3dVideoText =
nullptr;
159 hFont = CreateFont(18, 0, 0, 0, FW_NORMAL,
false,
false,
false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
160 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
nullptr);
167vpD3DRenderer::~vpD3DRenderer()
171 if (pd3dDevice !=
nullptr)
172 pd3dDevice->Release();
175 if (pd3dText !=
nullptr)
177 if (pd3dVideoText !=
nullptr)
178 pd3dVideoText->Release();
186unsigned int vpD3DRenderer::supPowerOf2(
unsigned int n)
193 return static_cast<unsigned int>(1 << (
i + 1));
203bool vpD3DRenderer::init(HWND hwnd,
unsigned int width,
unsigned int height)
211 if (
nullptr == (pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
214 D3DDISPLAYMODE d3ddm;
215 if (FAILED(pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm)))
218 D3DPRESENT_PARAMETERS d3dpp;
219 ZeroMemory(&d3dpp,
sizeof(d3dpp));
220 d3dpp.BackBufferCount = 1;
221 d3dpp.Windowed = TRUE;
222 d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
223 d3dpp.BackBufferFormat = d3ddm.Format;
226 if (FAILED(pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
227 D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, &d3dpp, &pd3dDevice)))
231 pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
234 initView(
static_cast<float>(m_rwidth),
static_cast<float>(m_rheight));
237 textWidth = supPowerOf2((m_rwidth > m_rheight) ? m_rwidth : m_rheight);
242 if (D3DXCreateTexture(pd3dDevice, textWidth, textWidth, D3DX_DEFAULT, 0, D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM,
243 &pd3dText) != D3D_OK) {
248 if (D3DXCreateTexture(pd3dDevice, textWidth, textWidth, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_X8R8G8B8,
249 D3DPOOL_DEFAULT, &pd3dVideoText) != D3D_OK) {
254 if (D3DXCreateSprite(pd3dDevice, &pSprite) != S_OK)
265void vpD3DRenderer::initView(
float WindowWidth,
float WindowHeight)
270 D3DXMatrixOrthoLH(&Ortho2D, WindowWidth, WindowHeight, 0.0f, 1.0f);
271 D3DXMatrixIdentity(&Identity);
273 if (pd3dDevice->SetTransform(D3DTS_PROJECTION, &Ortho2D) != D3D_OK ||
274 pd3dDevice->SetTransform(D3DTS_WORLD, &Identity) != D3D_OK ||
275 pd3dDevice->SetTransform(D3DTS_VIEW, &Identity) != D3D_OK)
285void vpD3DRenderer::convert(
const vpImage<vpRGBa> &I,
unsigned char *imBuffer,
unsigned int pitch)
288 for (
unsigned int i = 0;
i < m_rheight; ++
i) {
289 unsigned int ii_ =
i * pitch;
290 for (
unsigned int j = 0;
j < m_rwidth; ++
j) {
292 unsigned int index_ = ii_ +
j * 4;
293 imBuffer[index_] = val.
B;
294 imBuffer[++index_] = val.
G;
295 imBuffer[++index_] = val.
R;
296 imBuffer[++index_] = val.
A;
301 for (
unsigned int i = 0;
i < m_rheight; ++
i) {
302 unsigned int i_ =
i * m_rscale;
303 unsigned int ii_ =
i * pitch;
304 for (
unsigned int j = 0;
j < m_rwidth; ++
j) {
305 vpRGBa val = I[i_][
j * m_rscale];
306 unsigned int index_ = ii_ +
j * 4;
307 imBuffer[index_] = val.
B;
308 imBuffer[++index_] = val.
G;
309 imBuffer[++index_] = val.
R;
310 imBuffer[++index_] = val.
A;
325 for (
unsigned int i = 0;
i < m_rheight; ++
i) {
326 unsigned int ii_ =
i * pitch;
327 for (
unsigned int j = 0;
j < m_rwidth; ++
j) {
328 unsigned char val = I[
i][
j];
329 unsigned int index_ = ii_ +
j * 4;
330 imBuffer[index_] = val;
331 imBuffer[++index_] = val;
332 imBuffer[++index_] = val;
338 for (
unsigned int i = 0;
i < m_rheight; ++
i) {
339 unsigned int i_ =
i * m_rscale;
340 unsigned int ii_ =
i * pitch;
341 for (
unsigned int j = 0;
j < m_rwidth; ++
j) {
342 unsigned char val = I[i_][
j * m_rscale];
343 unsigned int index_ = ii_ +
j * 4;
344 imBuffer[index_] = val;
345 imBuffer[++index_] = val;
346 imBuffer[++index_] = val;
361void vpD3DRenderer::convertROI(
const vpImage<unsigned char> &I,
unsigned char *imBuffer,
unsigned int pitch,
int i_min,
362 int j_min,
int i_max,
int j_max)
364 int h = i_max - i_min;
365 int w = j_max - j_min;
368 for (
int i = 0;
i <
h; ++
i) {
369 unsigned int i_ = i_min +
i;
370 unsigned int ii_ =
i * pitch;
371 for (
int j = 0;
j <
w; ++
j) {
372 unsigned char val = I[i_][j_min +
j];
373 unsigned int index_ = ii_ +
j * 4;
374 imBuffer[index_] = val;
375 imBuffer[++index_] = val;
376 imBuffer[++index_] = val;
382 for (
int i = 0;
i <
h; ++
i) {
383 unsigned int i_ = (i_min +
i) * m_rscale;
384 unsigned int ii_ =
i * pitch;
385 for (
int j = 0;
j <
w; ++
j) {
386 unsigned char val = I[i_][(j_min +
j) * m_rscale];
387 unsigned int index_ = ii_ +
j * 4;
388 imBuffer[index_] = val;
389 imBuffer[++index_] = val;
390 imBuffer[++index_] = val;
405void vpD3DRenderer::convertROI(
const vpImage<vpRGBa> &I,
unsigned char *imBuffer,
unsigned int pitch,
int i_min,
406 int j_min,
int i_max,
int j_max)
408 int h = i_max - i_min;
409 int w = j_max - j_min;
412 for (
int i = 0;
i <
h; ++
i) {
413 unsigned int i_ = i_min +
i;
414 unsigned int ii_ =
i * pitch;
415 for (
int j = 0;
j <
w; ++
j) {
417 unsigned int index_ = ii_ +
j * 4;
418 imBuffer[index_] = val.
B;
419 imBuffer[++index_] = val.
G;
420 imBuffer[++index_] = val.
R;
426 for (
int i = 0;
i <
h; ++
i) {
427 unsigned int i_ = (i_min +
i) * m_rscale;
428 unsigned int ii_ =
i * pitch;
429 for (
int j = 0;
j <
w; ++
j) {
430 vpRGBa val = I[i_][(j_min +
j) * m_rscale];
431 unsigned int index_ = ii_ +
j * 4;
432 imBuffer[index_] = val.
B;
433 imBuffer[++index_] = val.
G;
434 imBuffer[++index_] = val.
R;
448 if (pd3dDevice !=
nullptr) {
449 D3DLOCKED_RECT d3dLRect;
454 r.bottom =
static_cast<signed long>(m_rheight);
455 r.right =
static_cast<signed long>(m_rwidth);
458 if (pd3dText->LockRect(0, &d3dLRect, &r, 0) != D3D_OK) {
459 std::cout <<
"D3D : Couldn't lock the texture!" << std::endl;
464 unsigned int pitch =
static_cast<unsigned int>(d3dLRect.Pitch);
465 unsigned char *buf = (
unsigned char *)d3dLRect.pBits;
468 convert(im, buf, pitch);
471 if (pd3dText->UnlockRect(0) != D3D_OK)
472 std::cout <<
"D3D : Couldn't unlock the texture!" << std::endl;
484 if (pd3dDevice !=
nullptr) {
485 D3DLOCKED_RECT d3dLRect;
487 int i_min = std::max<int>(
static_cast<int>(ceil(iP.
get_i() / m_rscale)), 0);
488 int j_min = std::max<int>(
static_cast<int>(ceil(iP.
get_j() / m_rscale)), 0);
489 int i_max = std::min<int>(
static_cast<int>(ceil((iP.
get_i() + height) / m_rscale)),
static_cast<int>(m_rheight));
490 int j_max = std::min<int>(
static_cast<int>(ceil((iP.
get_j() + width) / m_rscale)),
static_cast<int>(m_rwidth));
494 r.left = (LONG)j_min;
495 r.bottom = (LONG)i_max;
496 r.right = (LONG)j_max;
499 if (pd3dText->LockRect(0, &d3dLRect, &r, 0) != D3D_OK) {
500 std::cout <<
"D3D : Couldn't lock the texture!" << std::endl;
505 unsigned int pitch =
static_cast<unsigned int>(d3dLRect.Pitch);
506 unsigned char *buf = (
unsigned char *)d3dLRect.pBits;
509 convertROI(im, buf, pitch, i_min, j_min, i_max, j_max);
512 if (pd3dText->UnlockRect(0) != D3D_OK)
513 std::cout <<
"D3D : Couldn't unlock the texture!" << std::endl;
524 if (pd3dDevice !=
nullptr) {
525 D3DLOCKED_RECT d3dLRect;
530 r.bottom =
static_cast<LONG
>(m_rheight);
531 r.right =
static_cast<LONG
>(m_rwidth);
534 if (pd3dText->LockRect(0, &d3dLRect, &r, 0) != D3D_OK) {
535 std::cout <<
"D3D : Couldn't lock the texture!" << std::endl;
540 unsigned int pitch =
static_cast<unsigned int>(d3dLRect.Pitch);
541 unsigned char *buf = (
unsigned char *)d3dLRect.pBits;
544 convert(im, buf, pitch);
547 if (pd3dText->UnlockRect(0) != D3D_OK)
548 std::cout <<
"D3D : Couldn't unlock the texture!" << std::endl;
560 if (pd3dDevice !=
nullptr) {
561 D3DLOCKED_RECT d3dLRect;
563 int i_min = std::max<int>(
static_cast<int>(ceil(iP.
get_i() / m_rscale)), 0);
564 int j_min = std::max<int>(
static_cast<int>(ceil(iP.
get_j() / m_rscale)), 0);
565 int i_max = std::min<int>(
static_cast<int>(ceil((iP.
get_i() + height) / m_rscale)),
static_cast<int>(m_rheight));
566 int j_max = std::min<int>(
static_cast<int>(ceil((iP.
get_j() + width) / m_rscale)),
static_cast<int>(m_rwidth));
570 r.left = (LONG)j_min;
571 r.bottom = (LONG)i_max;
572 r.right = (LONG)j_max;
575 if (pd3dText->LockRect(0, &d3dLRect, &r, 0) != D3D_OK) {
576 std::cout <<
"D3D : Couldn't lock the texture!" << std::endl;
581 unsigned int pitch =
static_cast<unsigned int>(d3dLRect.Pitch);
582 unsigned char *buf = (
unsigned char *)d3dLRect.pBits;
585 convertROI(im, buf, pitch, i_min, j_min, i_max, j_max);
588 if (pd3dText->UnlockRect(0) != D3D_OK)
589 std::cout <<
"D3D : Couldn't unlock the texture!" << std::endl;
598bool vpD3DRenderer::render()
605 pd3dDevice->BeginScene();
611 r.bottom =
static_cast<LONG
>(m_rheight);
612 r.right =
static_cast<LONG
>(m_rwidth);
616 pd3dDevice->UpdateTexture(pd3dText, pd3dVideoText);
620#if (D3DX_SDK_VERSION <= 9)
622 pSprite->Draw(pd3dVideoText, &r,
nullptr,
nullptr,
nullptr,
nullptr, 0xFFFFFFFF);
625 pSprite->Draw(pd3dVideoText, &r,
nullptr,
nullptr, 0xFFFFFFFF);
630 pd3dDevice->EndScene();
632 pd3dDevice->Present(
nullptr,
nullptr,
nullptr,
nullptr);
646 if (iPscaled.
get_i() < 0 || iPscaled.
get_j() < 0 || iPscaled.
get_i() >=
static_cast<int>(m_rheight) ||
647 iPscaled.
get_j() >=
static_cast<int>(m_rwidth)) {
652 if (pd3dDevice !=
nullptr) {
653 D3DLOCKED_RECT d3dLRect;
657 r.top = (LONG)iPscaled.
get_i();
658 r.left = (LONG)iPscaled.
get_j();
659 r.bottom = (LONG)iPscaled.
get_i() + 1;
660 r.right = (LONG)iPscaled.
get_j() + 1;
663 if (pd3dText->LockRect(0, &d3dLRect, &r, 0) != D3D_OK) {
664 std::cout <<
"D3D : Couldn't lock the texture!" << std::endl;
669 unsigned int pitch =
static_cast<unsigned int>(d3dLRect.Pitch);
670 unsigned char *buf = (
unsigned char *)d3dLRect.pBits;
673 setBufferPixel(buf, pitch, 0, 0, color);
676 if (pd3dText->UnlockRect(0) != D3D_OK)
677 std::cout <<
"D3D : Couldn't unlock the texture!" << std::endl;
690 unsigned int thickness,
int style)
693 if (pd3dDevice !=
nullptr) {
698 IDirect3DSurface9 *pd3dSurf;
699 pd3dText->GetSurfaceLevel(0, &pd3dSurf);
702 pd3dSurf->GetDC(&hDCMem);
707 hPen = CreatePen(style,
static_cast<int>(thickness), colorsGDI[
color.id]);
710 hPen = CreatePen(style,
static_cast<int>(thickness), gdicolor);
714 SetBkMode(hDCMem, TRANSPARENT);
717 SelectObject(hDCMem, hPen);
722 if (thickness != 1 && style != PS_SOLID) {
726 double size = 10. * m_rscale;
728 bool vertical_line =
static_cast<int>(ip2_.
get_j()) ==
static_cast<int>(ip1_.
get_j());
731 std::swap(ip1_, ip2_);
735 std::swap(ip1_, ip2_);
738 double diff_j = vertical_line ? 1 : ip2_.
get_j() - ip1_.
get_j();
739 double deltaj = size / length * diff_j;
740 double deltai = size / length * (ip2_.
get_i() - ip1_.
get_i());
741 double slope = (ip2_.
get_i() - ip1_.
get_i()) / diff_j;
742 double orig = ip1_.
get_i() - slope * ip1_.
get_j();
745 for (
unsigned int i =
static_cast<unsigned int>(ip1_.
get_i()); i < ip2_.
get_i(); i +=
static_cast<unsigned int>(2 * deltai)) {
755 for (
unsigned int j =
static_cast<unsigned int>(ip1_.
get_j()); j < ip2_.
get_j(); j +=
static_cast<unsigned int>(2 * deltaj)) {
756 double i = slope *
j + orig;
772 pd3dSurf->ReleaseDC(hDCMem);
789void vpD3DRenderer::drawRect(
const vpImagePoint &topLeft,
unsigned int width,
unsigned int height,
const vpColor &color,
790 bool fill,
unsigned int thickness)
793 if (pd3dDevice !=
nullptr) {
795 drawLine(topLeft, topLeft +
vpImagePoint(0, width), color, thickness);
798 drawLine(topLeft +
vpImagePoint(height, 0), topLeft, color, thickness);
802 unsigned int widthScaled =
width / m_rscale;
803 unsigned int heightScaled =
height / m_rscale;
805 if (topLeftScaled.
get_i() >
static_cast<int>(m_rheight) - 1 || topLeftScaled.
get_j() >
static_cast<int>(m_rwidth) - 1 ||
806 topLeftScaled.
get_i() + height < 0 || topLeftScaled.
get_j() + width < 0) {
810 D3DLOCKED_RECT d3dLRect;
813 r.top = (LONG)((topLeftScaled.
get_i() > 0) ? topLeftScaled.
get_i() : 0);
814 r.left = (LONG)((topLeftScaled.
get_j() > 0) ? topLeftScaled.
get_j() : 0);
815 r.bottom = (LONG)((topLeftScaled.
get_i() + heightScaled <
static_cast<int>(m_rheight)) ? topLeftScaled.
get_i() + heightScaled
817 r.right = (LONG)((topLeftScaled.
get_j() + widthScaled <
static_cast<int>(m_rwidth)) ? topLeftScaled.
get_j() + widthScaled
820 int rectW =
r.right -
r.left;
821 int rectH =
r.bottom -
r.top;
824 if (pd3dText->LockRect(0, &d3dLRect, &r, 0) != D3D_OK) {
825 std::cout <<
"D3D : Couldn't lock the texture!" << std::endl;
830 unsigned int pitch =
static_cast<unsigned int>(d3dLRect.Pitch);
831 unsigned char *buf = (
unsigned char *)d3dLRect.pBits;
833 if (topLeftScaled.
get_i() >= 0 && topLeftScaled.
get_j() + widthScaled < m_rwidth &&
834 topLeftScaled.
get_i() + heightScaled < m_rheight && topLeftScaled.
get_j() >= 0) {
835 for (
int x = 0;
x < rectW; ++
x) {
836 for (
int y = 0;
y < rectH; ++
y)
837 setBufferPixel(buf, pitch, x, y, color);
842 if (pd3dText->UnlockRect(0) != D3D_OK)
843 std::cout <<
"D3D : Couldn't unlock the texture!" << std::endl;
852void vpD3DRenderer::clear(
const vpColor &color)
855 if (pd3dDevice !=
nullptr) {
856 D3DLOCKED_RECT d3dLRect;
861 r.bottom =
static_cast<LONG
>(m_rheight);
862 r.right =
static_cast<LONG
>(m_rwidth);
865 if (pd3dText->LockRect(0, &d3dLRect, &r, 0) != D3D_OK) {
866 std::cout <<
"D3D : Couldn't lock the texture!" << std::endl;
871 unsigned int pitch =
static_cast<unsigned int>(d3dLRect.Pitch);
872 long *buf = (
long *)(d3dLRect.pBits);
876 c = colors[
color.id];
880 long *end = (
long *)(buf + (pitch * m_rheight));
884 *buf++ =
static_cast<long>(c);
887 if (pd3dText->UnlockRect(0) != D3D_OK)
888 std::cout <<
"D3D : Couldn't unlock the texture!" << std::endl;
894void vpD3DRenderer::subDrawCircle(
int i,
int j,
int x,
int y,
vpColor col,
unsigned char *buf,
unsigned int pitch,
895 unsigned int maxX,
unsigned int maxY)
898 setBufferPixel(buf, pitch, i, j + y, col, maxX, maxY);
899 setBufferPixel(buf, pitch, i, j - y, col, maxX, maxY);
900 setBufferPixel(buf, pitch, i + y, j, col, maxX, maxY);
901 setBufferPixel(buf, pitch, i - y, j, col, maxX, maxY);
904 setBufferPixel(buf, pitch, i + x, j + y, col, maxX, maxY);
905 setBufferPixel(buf, pitch, i - x, j + y, col, maxX, maxY);
906 setBufferPixel(buf, pitch, i + x, j - y, col, maxX, maxY);
907 setBufferPixel(buf, pitch, i - x, j - y, col, maxX, maxY);
910 setBufferPixel(buf, pitch, i + x, j + y, col, maxX, maxY);
911 setBufferPixel(buf, pitch, i - x, j + y, col, maxX, maxY);
912 setBufferPixel(buf, pitch, i + x, j - y, col, maxX, maxY);
913 setBufferPixel(buf, pitch, i - x, j - y, col, maxX, maxY);
914 setBufferPixel(buf, pitch, i + y, j + x, col, maxX, maxY);
915 setBufferPixel(buf, pitch, i - y, j + x, col, maxX, maxY);
916 setBufferPixel(buf, pitch, i + y, j - x, col, maxX, maxY);
917 setBufferPixel(buf, pitch, i - y, j - x, col, maxX, maxY);
927void vpD3DRenderer::drawCircle(
const vpImagePoint ¢er,
unsigned int radius,
const vpColor &color,
bool ,
930 unsigned int radiusScaled = radius / m_rscale;
939 if (pd3dDevice !=
nullptr) {
940 D3DLOCKED_RECT d3dLRect;
943 int radiusScaled_ =
static_cast<int>(radiusScaled);
953 rec.bottom = (LONG)((
vpMath::round(centerScaled.
get_i() + radiusScaled_) <
static_cast<int>(m_rheight))
954 ? centerScaled.
get_i() + radiusScaled_
956 rec.right = (LONG)((
vpMath::round(centerScaled.
get_j() + radiusScaled_) <
static_cast<int>(m_rwidth))
957 ? centerScaled.
get_j() + radiusScaled_
961 unsigned int rectW =
static_cast<unsigned int>(rec.right - rleft);
962 unsigned int rectH =
static_cast<unsigned int>(rec.bottom - rtop);
965 if (pd3dText->LockRect(0, &d3dLRect, &rec, 0) != D3D_OK) {
966 std::cout <<
"D3D : Couldn't lock the texture!" << std::endl;
971 unsigned int pitch =
static_cast<unsigned int>(d3dLRect.Pitch);
972 unsigned char *buf = (
unsigned char *)d3dLRect.pBits;
977 int y =
static_cast<int>(radiusScaled);
978 int p = (3 - (
y << 1));
988 p += ((
x << 1) + 1) << 1;
992 p += (((
x -
y) << 1) + 1) << 1;
998 if (pd3dText->UnlockRect(0) != D3D_OK)
999 std::cout <<
"D3D : Couldn't unlock the texture!" << std::endl;
1009void vpD3DRenderer::drawText(
const vpImagePoint &ip,
const char *text,
const vpColor &color)
1015 IDirect3DSurface9 *pd3dSurf;
1016 pd3dText->GetSurfaceLevel(0, &pd3dSurf);
1019 pd3dSurf->GetDC(&hDCMem);
1022 SelectObject(hDCMem, hFont);
1026 SetTextColor(hDCMem, colorsGDI[
color.id]);
1029 SetTextColor(hDCMem, gdicolor);
1033 SetBkMode(hDCMem, TRANSPARENT);
1036 int length =
static_cast<int>(strlen(text));
1039 GetTextExtentPoint32(hDCMem, text, length, &size);
1045 pd3dSurf->ReleaseDC(hDCMem);
1047 pd3dSurf->Release();
1049 DeleteObject(hFont);
1059void vpD3DRenderer::drawCross(
const vpImagePoint &ip,
unsigned int size,
const vpColor &color,
unsigned int thickness)
1065 ip1.
set_i(i - size / 2);
1067 ip2.
set_i(i + size / 2);
1069 drawLine(ip1, ip2, color, thickness);
1072 ip1.
set_j(j - size / 2);
1074 ip2.
set_j(j + size / 2);
1076 drawLine(ip1, ip2, color, thickness);
1089 unsigned int h,
unsigned int thickness)
1096 if ((std::fabs(a) <= std::numeric_limits<double>::epsilon()) &&
1097 (std::fabs(b) <= std::numeric_limits<double>::epsilon())) {
1113 drawLine(ip2, ip4, color, thickness);
1119 drawLine(ip2, ip4, color, thickness);
1121 drawLine(ip1, ip2, color, thickness);
1131void TextureToRGBa(
vpImage<vpRGBa> &I,
unsigned char *imBuffer,
unsigned int pitch)
1133 unsigned int j = I.getWidth();
1136 for (
unsigned int i = 0;
i < I.getHeight() * I.getWidth(); ++i) {
1139 k += pitch - (I.getWidth() * 4);
1144 I.bitmap[
i].B = imBuffer[k + 0];
1145 I.bitmap[
i].G = imBuffer[k + 1];
1146 I.bitmap[
i].R = imBuffer[k + 2];
1147 I.bitmap[
i].A = imBuffer[k + 3];
1161 if (pd3dDevice !=
nullptr) {
1164 I.resize(m_rheight, m_rwidth);
1166 D3DLOCKED_RECT d3dLRect;
1171 r.bottom =
static_cast<LONG
>(m_rheight);
1172 r.right =
static_cast<LONG
>(m_rwidth);
1175 if (pd3dText->LockRect(0, &d3dLRect, &r, 0) != D3D_OK) {
1176 std::cout <<
"D3D : Couldn't lock the texture!" << std::endl;
1181 unsigned int pitch =
static_cast<unsigned int>(d3dLRect.Pitch);
1182 unsigned char *buf = (
unsigned char *)d3dLRect.pBits;
1185 TextureToRGBa(I, buf, pitch);
1188 if (pd3dText->UnlockRect(0) != D3D_OK)
1189 std::cout <<
"D3D : Couldn't unlock the texture!" << std::endl;
1195#elif !defined(VISP_BUILD_SHARED_LIBS)
1197void dummy_vpD3DRenderer() { }
Class to define RGB colors available for display functionalities.
static const vpColor white
static const vpColor darkGray
static const vpColor cyan
static const vpColor orange
static const vpColor darkRed
static const vpColor blue
static const vpColor lightGray
static const vpColor lightBlue
static const vpColor darkGreen
static const vpColor darkBlue
static const vpColor purple
static const vpColor lightGreen
static const vpColor yellow
static const vpColor lightRed
static const vpColor black
static const vpColor green
static const vpColor gray
Error that can be emitted by the vpDisplay class and its derivatives.
@ notInitializedError
Display not initialized.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static double distance(const vpImagePoint &iP1, const vpImagePoint &iP2)
Definition of the vpImage class member functions.
static double sqr(double x)
static int round(double x)
unsigned char B
Blue component.
unsigned char R
Red component.
unsigned char G
Green component.
unsigned char A
Additional component.