NVSterEX text drawing problem DrawTextA draws ghost text
Dear Folks,

Created an application to display stereo image pairs - works fine.

Tried using DrawTextA function to add title line to display image name, etc.

Instead of title in left eye only, which I expected, or title in both eyes, which I hoped for; left eye title is correctly placed but right eye title line is shifted a few
hundred pixels to the left and totally messes up the title line.

How can I write text into the double wide helper surface, as writing into the
backbuffer does not seem to work.

Following is a code sample that has the problem:
Somehow the posting process removed the indentation from the code sample!

// create the rendering surface
if ((*ppD3DDevice)->CreateImageSurface(
lnWidth * 2, // double wide for flipping
lnHeight,
d3dSurfaceDesc.Format,
&pD3DHelpSurface) != D3D_OK) {
lnReturn = 300;
goto EXIT;
}

// load left image into surface
rectSrc.top = 0;
rectSrc.bottom = lnHeight;
rectSrc.left = 0;
rectSrc.right = lnWidth;

rectTmpDst = rectSrc;

if (D3DXLoadSurfaceFromMemory(
pD3DHelpSurface, // LPDIRECT3DSURFACE8 pDestSurface
NULL, // CONST PALETTEENTRY* pDestPalette,
&rectTmpDst, // CONST RECT* pDestRect,
pbLeftImage, // LPCVOID pSrcMemory,
D3DFMT_R8G8B8, // D3DFORMAT SrcFormat
lnScanLineWidth, // UINT SrcPitch,
NULL, // CONST PALETTEENTRY* pSrcPalette,
&rectSrc, // CONST RECT* pSrcRect,
D3DX_FILTER_NONE, // DWORD Filter,
0) != D3D_OK) { // D3DCOLOR ColorKey
lnReturn = 310;
goto EXIT;
}

// load right image into surface
if (boWindowed == FALSE) {

rectTmpDst.left = lnWidth;
rectTmpDst.right = lnWidth * 2;

if (D3DXLoadSurfaceFromMemory(
pD3DHelpSurface, // LPDIRECT3DSURFACE8 pDestSurface
NULL, // CONST PALETTEENTRY* pDestPalette,
&rectTmpDst, // CONST RECT* pDestRect,
pbRightImage, // LPCVOID pSrcMemory,
D3DFMT_R8G8B8, // D3DFORMAT SrcFormat
lnScanLineWidth, // UINT SrcPitch,
NULL, // CONST PALETTEENTRY* pSrcPalette,
&rectSrc, // CONST RECT* pSrcRect,
D3DX_FILTER_NONE, // DWORD Filter,
0) != D3D_OK) { // D3DCOLOR ColorKey
lnReturn = 320;
goto EXIT;
}
}

// setup page-flipping
if (pD3DHelpSurface->LockRect(
&d3dLockedRect,
NULL,
NULL) == D3D_OK) {

lpStereoImageHeader
= (LPNVSTEREOIMAGEHEADER)(((unsigned char *) d3dLockedRect.pBits)
+ (d3dLockedRect.Pitch * (lnHeight - 1)));
lpStereoImageHeader->dwSignature = NVSTEREO_IMAGE_SIGNATURE;
lpStereoImageHeader->dwBPP = 32;
lpStereoImageHeader->dwFlags = 0;
lpStereoImageHeader->dwHeight = lnHeight;

if (boWindowed == FALSE) {
lpStereoImageHeader->dwWidth = lnWidth * 2;
} else {
lpStereoImageHeader->dwWidth = lnWidth;
}

pD3DHelpSurface->UnlockRect();
} else {
lnReturn = 330;
goto EXIT;
}

// copy render surface to backbuffer
cDxFun.Clear(*ppD3DDevice);
if ((*ppD3DDevice)->BeginScene() == D3D_OK) {

if ((*ppD3DDevice)->CopyRects(
pD3DHelpSurface,
&rectDisplay,
1,
pD3DBackBuffer,
NULL) != D3D_OK) {
lnReturn = 340;
goto EXIT;
}

// draw title
if (pcstrTitle != NULL) {
rectFont.left = 0;
rectFont.top = 0;
rectFont.right = 0;
rectFont.bottom = 0;

if ((*ppD3DFont)->Begin() != D3D_OK) {
lnReturn = 360;
goto EXIT;
}
if ((*ppD3DFont)->DrawTextA(
LPCTSTR(*pcstrTitle),
-1,
&rectFont,
DT_CALCRECT,
0) != D3D_OK) {
}
if ((*ppD3DFont)->DrawTextA(
LPCTSTR(*pcstrTitle),
-1,
&rectFont,
DT_LEFT,
D3DCOLOR_XRGB(255,255,255)) != D3D_OK) {
}
if ((*ppD3DFont)->End() != D3D_OK) {
lnReturn = 390;
goto EXIT;
}
}


Can anyone help???

Thanks,

Dennis
Dear Folks,



Created an application to display stereo image pairs - works fine.



Tried using DrawTextA function to add title line to display image name, etc.



Instead of title in left eye only, which I expected, or title in both eyes, which I hoped for; left eye title is correctly placed but right eye title line is shifted a few

hundred pixels to the left and totally messes up the title line.



How can I write text into the double wide helper surface, as writing into the

backbuffer does not seem to work.



Following is a code sample that has the problem:

Somehow the posting process removed the indentation from the code sample!



// create the rendering surface

if ((*ppD3DDevice)->CreateImageSurface(

lnWidth * 2, // double wide for flipping

lnHeight,

d3dSurfaceDesc.Format,

&pD3DHelpSurface) != D3D_OK) {

lnReturn = 300;

goto EXIT;

}



// load left image into surface

rectSrc.top = 0;

rectSrc.bottom = lnHeight;

rectSrc.left = 0;

rectSrc.right = lnWidth;



rectTmpDst = rectSrc;



if (D3DXLoadSurfaceFromMemory(

pD3DHelpSurface, // LPDIRECT3DSURFACE8 pDestSurface

NULL, // CONST PALETTEENTRY* pDestPalette,

&rectTmpDst, // CONST RECT* pDestRect,

pbLeftImage, // LPCVOID pSrcMemory,

D3DFMT_R8G8B8, // D3DFORMAT SrcFormat

lnScanLineWidth, // UINT SrcPitch,

NULL, // CONST PALETTEENTRY* pSrcPalette,

&rectSrc, // CONST RECT* pSrcRect,

D3DX_FILTER_NONE, // DWORD Filter,

0) != D3D_OK) { // D3DCOLOR ColorKey

lnReturn = 310;

goto EXIT;

}



// load right image into surface

if (boWindowed == FALSE) {



rectTmpDst.left = lnWidth;

rectTmpDst.right = lnWidth * 2;



if (D3DXLoadSurfaceFromMemory(

pD3DHelpSurface, // LPDIRECT3DSURFACE8 pDestSurface

NULL, // CONST PALETTEENTRY* pDestPalette,

&rectTmpDst, // CONST RECT* pDestRect,

pbRightImage, // LPCVOID pSrcMemory,

D3DFMT_R8G8B8, // D3DFORMAT SrcFormat

lnScanLineWidth, // UINT SrcPitch,

NULL, // CONST PALETTEENTRY* pSrcPalette,

&rectSrc, // CONST RECT* pSrcRect,

D3DX_FILTER_NONE, // DWORD Filter,

0) != D3D_OK) { // D3DCOLOR ColorKey

lnReturn = 320;

goto EXIT;

}

}



// setup page-flipping

if (pD3DHelpSurface->LockRect(

&d3dLockedRect,

NULL,

NULL) == D3D_OK) {



lpStereoImageHeader

= (LPNVSTEREOIMAGEHEADER)(((unsigned char *) d3dLockedRect.pBits)

+ (d3dLockedRect.Pitch * (lnHeight - 1)));

lpStereoImageHeader->dwSignature = NVSTEREO_IMAGE_SIGNATURE;

lpStereoImageHeader->dwBPP = 32;

lpStereoImageHeader->dwFlags = 0;

lpStereoImageHeader->dwHeight = lnHeight;



if (boWindowed == FALSE) {

lpStereoImageHeader->dwWidth = lnWidth * 2;

} else {

lpStereoImageHeader->dwWidth = lnWidth;

}



pD3DHelpSurface->UnlockRect();

} else {

lnReturn = 330;

goto EXIT;

}



// copy render surface to backbuffer

cDxFun.Clear(*ppD3DDevice);

if ((*ppD3DDevice)->BeginScene() == D3D_OK) {



if ((*ppD3DDevice)->CopyRects(

pD3DHelpSurface,

&rectDisplay,

1,

pD3DBackBuffer,

NULL) != D3D_OK) {

lnReturn = 340;

goto EXIT;

}



// draw title

if (pcstrTitle != NULL) {

rectFont.left = 0;

rectFont.top = 0;

rectFont.right = 0;

rectFont.bottom = 0;



if ((*ppD3DFont)->Begin() != D3D_OK) {

lnReturn = 360;

goto EXIT;

}

if ((*ppD3DFont)->DrawTextA(

LPCTSTR(*pcstrTitle),

-1,

&rectFont,

DT_CALCRECT,

0) != D3D_OK) {

}

if ((*ppD3DFont)->DrawTextA(

LPCTSTR(*pcstrTitle),

-1,

&rectFont,

DT_LEFT,

D3DCOLOR_XRGB(255,255,255)) != D3D_OK) {

}

if ((*ppD3DFont)->End() != D3D_OK) {

lnReturn = 390;

goto EXIT;

}

}





Can anyone help???



Thanks,



Dennis

#1
Posted 08/17/2005 06:53 PM   
Sounds like its interpreting the text as a 3d object. If you change the view frustrum (ctrl-6/7 etc.) does the text move closer together ?

Steve
Sounds like its interpreting the text as a 3d object. If you change the view frustrum (ctrl-6/7 etc.) does the text move closer together ?



Steve

#2
Posted 08/19/2005 08:57 AM   
Dear Folks,

Solved problem as follows:

if ((*ppD3DDevice)->BeginScene() == D3D_OK) {

// load left image into BackBuffer
if (D3DXLoadSurfaceFromMemory(
pD3DBackBuffer, // LPDIRECT3DSURFACE8 pDestSurface
NULL, // CONST PALETTEENTRY* pDestPalette,
&rectDisplay, // CONST RECT* pDestRect,
pbLeftImage, // LPCVOID pSrcMemory,
D3DFMT_R8G8B8, // D3DFORMAT SrcFormat
lnScanLineWidth, // UINT SrcPitch,
NULL, // CONST PALETTEENTRY* pSrcPalette,
&rectSrc, // CONST RECT* pSrcRect,
D3DX_FILTER_NONE, // DWORD Filter,
0) != D3D_OK) { // D3DCOLOR ColorKey
lnReturn = 310;
goto EXIT;
}

// draw left title
if (boWindowed == FALSE) {
cDxFun.DrawTitle(
ppD3DDevice,
ppD3DFont,
pcstrTitle,
150,
0);
}

// copy left image to HelpSurface
if ((*ppD3DDevice)->CopyRects(
pD3DBackBuffer,
&rectTmpDst,
1,
pD3DHelpSurface,
NULL) != D3D_OK) {
lnReturn = 320;
goto EXIT;
}

if (boWindowed == FALSE) {

// load right image into BackBuffer
if (D3DXLoadSurfaceFromMemory(
pD3DBackBuffer, // LPDIRECT3DSURFACE8 pDestSurface
NULL, // CONST PALETTEENTRY* pDestPalette,
&rectDisplay, // CONST RECT* pDestRect,
pbRightImage, // LPCVOID pSrcMemory,
D3DFMT_R8G8B8, // D3DFORMAT SrcFormat
lnScanLineWidth, // UINT SrcPitch,
NULL, // CONST PALETTEENTRY* pSrcPalette,
&rectSrc, // CONST RECT* pSrcRect,
D3DX_FILTER_NONE, // DWORD Filter,
0) != D3D_OK) { // D3DCOLOR ColorKey
lnReturn = 330;
goto EXIT;
}

// draw right title
cDxFun.DrawTitle(
ppD3DDevice,
ppD3DFont,
pcstrTitle,
150,
0);

// copy right image to HelpSurface
pointDst.x = lnWidth;
pointDst.y = 0;
if ((*ppD3DDevice)->CopyRects(
pD3DBackBuffer,
&rectTmpDst,
1,
pD3DHelpSurface,
&pointDst) != D3D_OK) {
lnReturn = 340;
goto EXIT;
}
}

// setup page-flipping
if (pD3DHelpSurface->LockRect(
&d3dLockedRect,
NULL,
NULL) == D3D_OK) {

lpStereoImageHeader
= (LPNVSTEREOIMAGEHEADER)(((unsigned char *) d3dLockedRect.pBits)
+ (d3dLockedRect.Pitch * (lnHeight - 1)));
lpStereoImageHeader->dwSignature = NVSTEREO_IMAGE_SIGNATURE;
lpStereoImageHeader->dwBPP = 32;
lpStereoImageHeader->dwFlags = 0;
lpStereoImageHeader->dwHeight = lnHeight;

if (boWindowed == FALSE) {
lpStereoImageHeader->dwWidth = lnWidth * 2;
} else {
lpStereoImageHeader->dwWidth = lnWidth;
}

pD3DHelpSurface->UnlockRect();
} else {
lnReturn = 350;
goto EXIT;
}

// copy HelpSurface to backbuffer
rectDisplay.top = 0; // remove offset for title
if ((*ppD3DDevice)->CopyRects(
pD3DHelpSurface,
&rectDisplay,
1,
pD3DBackBuffer,
NULL) != D3D_OK) {
lnReturn = 360;
goto EXIT;
}

(*ppD3DDevice)->EndScene();


Sorry about loss of indentation when posting code sample.

Dennis
Dear Folks,



Solved problem as follows:



if ((*ppD3DDevice)->BeginScene() == D3D_OK) {



// load left image into BackBuffer

if (D3DXLoadSurfaceFromMemory(

pD3DBackBuffer, // LPDIRECT3DSURFACE8 pDestSurface

NULL, // CONST PALETTEENTRY* pDestPalette,

&rectDisplay, // CONST RECT* pDestRect,

pbLeftImage, // LPCVOID pSrcMemory,

D3DFMT_R8G8B8, // D3DFORMAT SrcFormat

lnScanLineWidth, // UINT SrcPitch,

NULL, // CONST PALETTEENTRY* pSrcPalette,

&rectSrc, // CONST RECT* pSrcRect,

D3DX_FILTER_NONE, // DWORD Filter,

0) != D3D_OK) { // D3DCOLOR ColorKey

lnReturn = 310;

goto EXIT;

}



// draw left title

if (boWindowed == FALSE) {

cDxFun.DrawTitle(

ppD3DDevice,

ppD3DFont,

pcstrTitle,

150,

0);

}



// copy left image to HelpSurface

if ((*ppD3DDevice)->CopyRects(

pD3DBackBuffer,

&rectTmpDst,

1,

pD3DHelpSurface,

NULL) != D3D_OK) {

lnReturn = 320;

goto EXIT;

}



if (boWindowed == FALSE) {



// load right image into BackBuffer

if (D3DXLoadSurfaceFromMemory(

pD3DBackBuffer, // LPDIRECT3DSURFACE8 pDestSurface

NULL, // CONST PALETTEENTRY* pDestPalette,

&rectDisplay, // CONST RECT* pDestRect,

pbRightImage, // LPCVOID pSrcMemory,

D3DFMT_R8G8B8, // D3DFORMAT SrcFormat

lnScanLineWidth, // UINT SrcPitch,

NULL, // CONST PALETTEENTRY* pSrcPalette,

&rectSrc, // CONST RECT* pSrcRect,

D3DX_FILTER_NONE, // DWORD Filter,

0) != D3D_OK) { // D3DCOLOR ColorKey

lnReturn = 330;

goto EXIT;

}



// draw right title

cDxFun.DrawTitle(

ppD3DDevice,

ppD3DFont,

pcstrTitle,

150,

0);



// copy right image to HelpSurface

pointDst.x = lnWidth;

pointDst.y = 0;

if ((*ppD3DDevice)->CopyRects(

pD3DBackBuffer,

&rectTmpDst,

1,

pD3DHelpSurface,

&pointDst) != D3D_OK) {

lnReturn = 340;

goto EXIT;

}

}



// setup page-flipping

if (pD3DHelpSurface->LockRect(

&d3dLockedRect,

NULL,

NULL) == D3D_OK) {



lpStereoImageHeader

= (LPNVSTEREOIMAGEHEADER)(((unsigned char *) d3dLockedRect.pBits)

+ (d3dLockedRect.Pitch * (lnHeight - 1)));

lpStereoImageHeader->dwSignature = NVSTEREO_IMAGE_SIGNATURE;

lpStereoImageHeader->dwBPP = 32;

lpStereoImageHeader->dwFlags = 0;

lpStereoImageHeader->dwHeight = lnHeight;



if (boWindowed == FALSE) {

lpStereoImageHeader->dwWidth = lnWidth * 2;

} else {

lpStereoImageHeader->dwWidth = lnWidth;

}



pD3DHelpSurface->UnlockRect();

} else {

lnReturn = 350;

goto EXIT;

}



// copy HelpSurface to backbuffer

rectDisplay.top = 0; // remove offset for title

if ((*ppD3DDevice)->CopyRects(

pD3DHelpSurface,

&rectDisplay,

1,

pD3DBackBuffer,

NULL) != D3D_OK) {

lnReturn = 360;

goto EXIT;

}



(*ppD3DDevice)->EndScene();





Sorry about loss of indentation when posting code sample.



Dennis

#3
Posted 08/19/2005 04:27 PM   
Scroll To Top