Thank you guys for your replies.
Krohm : yes, we use this VIA EPIA-CN because we want to lower down our product cost. but at same time, we have to realize the functionalities, so i have no choice but to go ahead with it. my application is not a game, but directx can significantly make display faster, so i adopted. (the pity is i am a newbie to this directx)
Namethatnobodyelsetook and C0D1F1ED:
i am not fully familiar what you told, but indeed i am using alpha test to do it. now my problem is I can sucessifully make the cover texture transparent, but without the pixel shader, I can not make the graphics I draw on the texture to show, all things, including the graphics on the texture, are totally transparent, I can not draw, that is not what I wanted.
I am here include some code snippet to explain:
code piece 1:
Quote:
// omitted are d3d creations and first 3d scene creation
// create a m_pTransTexture, it will become transparent, so I
// can draw graphics using mouse
if(FAILED(D3DXCreateTexture(m_pIDirect3DDevice,800,600,1,0, D3DFMT_X8R8G8B8,D3DPOOL_MANAGED,&m_pGunTexture) )) {
AfxMessageBox("Create cover texture failed.");
return false;
}
// filled the texture with color 0xffffff00;
// lock the surface, filled the data, unlock it. codes omitted
then I draw graphics on the m_pTransTexture, some lines and ellipse
code piece 2:
Quote:
D3DSURFACE_DESC desc;
ZeroMemory( &desc , sizeof( D3DSURFACE_DESC ) );
if( pTex )
{
LPDIRECT3DSURFACE9 pSur;
pTex->GetSurfaceLevel ( 0 , &pSur );
pSur->GetDesc ( &desc );
HDC hDC;
TCHAR* str = "Try to write on the screen ";
pSur->GetDC(&hDC);
CDC *pDC = CDC::FromHandle(hDC);
pDC->SetTextColor(0x00FF0000); // blue text
pDC->SetBkMode(TRANSPARENT);
pDC->TextOut(50, 100, str, strlen(str));
CPen Pen;
Pen.CreatePen(PS_SOLID, 1, RGB(255,255,255));
CPen* Poldpen=pDC->SelectObject(&Pen);
pDC->MoveTo(0,280);
pDC->LineTo(180,280); // horizontal line
CBrush BKBrush,*pOldBrush;
pOldBrush = (CBrush *)pDC->SelectStockObject(HOLLOW_BRUSH);
pDC->Ellipse(200,200,500,500);
pDC->SelectObject(pOldBrush);
pDC->SelectObject(Poldpen);
Pen.DeleteObject();
pSur->ReleaseDC(hDC);
pSur->Release();
}
Why I still use GDI, it's that my software use have to use mouse to draw on screen, some random line, curves, or tracing line, etc. GDI is comvienent thought slow...
in Render():
code piece 3:
Quote:
m_pIDirect3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
m_pIDirect3DDevice->BeginScene();
// the scene to be see trough the covered m_pTransTexture
m_pIDirect3DDevice->SetStreamSource(0,m_pTigerVertexBuffer,0,sizeof(CUSTOMVERTEX));
m_pIDirect3DDevice->SetFVF(CUSTOMVERTEX_FVF);
m_pIDirect3DDevice->SetTexture(0,m_pTigerTexture);
m_pIDirect3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2); // (1)
m_pIDirect3DDevice->SetStreamSource(0,m_pGunVertexBuffer,0,sizeof(CUSTOMVERTEX));
m_pIDirect3DDevice->SetTexture(0,m_pGunTexture);
m_pIDirect3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE,TRUE);
m_pIDirect3DDevice->SetRenderState(D3DRS_ALPHAREF,0xffffff00);
m_pIDirect3DDevice->SetRenderState(D3DRS_ALPHAFUNC,D3DCMP_NOTEQUAL);//(2)
m_pIDirect3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2); // (3)
m_pIDirect3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE,FALSE);
m_pIDirect3DDevice->EndScene();
m_pIDirect3DDevice->Present(NULL, NULL, NULL, NULL);
}
Now the result is: because I filled the m_pTransTexure with color 0xffffff00;
if in code piece 3, sentence (2), i use D3DCMP_EQUAL, then I can make the cover m_pTransTexture transparent, see through the 3d scene undercovered. but the graphics( a text, a line and a ellipse ) drawn by code piece 2 are also gone!
if in code piece 3, sentence (2), I use D3DCMP_NOTEQUAL, then I can see the yellow m_pTransTexture not transparent,(thought all the graphics, line, ellipse on it to be seen ). the undercovered 3d scene is covered. which is not what i wanted.
is it possible that I can make the m_pTransparent transparent, so the undercovered 3d scene can be see, but also the graphics on the m_pTransparent can be seen?
with pixel shader, I can do it. but now the hardware don't support ps, can I do it?
Thank you very much..