Click here to Skip to main content
15,907,910 members

Comments by zoltrix61 (Top 4 by date)

zoltrix61 8-Apr-12 1:52am View    
I have a multi-texture square vertex composed of three different .png files. I want to draw a variable length line on this surface. Drawing of line is triggered by mouse move event and the line connects a predefined point on the surface to the current mouse position. I know that it is possible to redraw the background to clear the trace of the old line and then draw a new line but I want to use a different method being independent from the background texture.

How can I write this program with multi-texture technique?
Can you put on example for me,please...
zoltrix61 1-Nov-11 3:40am View    
I appreciate that you helped me.
With adding 3 line code:

g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

the points got transparent,but the problem is that the color of Quad vertices(here is for example white) affect on transparency and reduce the quality of picture,as you feel you are looking to picture through a white
cover.


having your sample code would help me so much.
zoltrix61 31-Oct-11 2:44am View    
m_pDirect3DDevice->SetTextureStageState(2,D3DTSS_TEXCOORDINDEX,2);
m_pDirect3DDevice->SetTextureStageState(2,D3DTSS_COLORARG1,D3DTA_TEXTURE);
m_pDirect3DDevice->SetTextureStageState(2,D3DTSS_COLORARG2,D3DTA_CURRENT);
m_pDirect3DDevice->SetTextureStageState(2,D3DTSS_COLOROP,D3DTOP_MODULATE);
m_pDirect3DDevice->SetTextureStageState(2,D3DTSS_COLORARG1,D3DTA_CURRENT);
m_pDirect3DDevice->SetTextureStageState(2,D3DTSS_COLOROP,D3DTOP_SELECTARG1);
m_pDirect3DDevice->SetTextureStageState(2,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);
m_pDirect3DDevice->SetTextureStageState(2,D3DTSS_ALPHAARG2,D3DTA_CURRENT);
m_pDirect3DDevice->SetTextureStageState(2,D3DTSS_ALPHAOP,D3DTOP_MODULATE);

}//InitScene


////////////////////////////////////////////

if(g_App.CheckDevice())
{
g_App.GetDevice()->Clear(0,NULL,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,D3DCOLOR_XRGB(128,128,128),1.0f,0);
g_App.GetDevice()->BeginScene();

g_App.GetDevice()->SetTexture(0,pMap1);
g_App.GetDevice()->SetTexture(1,pMap2);


g_App.GetDevice()->SetFVF(D3DFVF_CUSTOMVERTEX);
g_App.GetDevice()->SetStreamSource(0,pQuadVB,0,sizeof(D3DVERTEX));
g_App.GetDevice()->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);

g_App.GetDevice()->SetFVF(D3DFVF_CUSTOMVERTEX2);
g_App.GetDevice()->SetStreamSource(0,pPointsVB,0,sizeof(D3DVERTEX2));
g_App.GetDevice()->DrawPrimitive(D3DPT_POINTLIST,0,12);



g_App.GetDevice()->EndScene();
g_App.GetDevice()->Present(NULL,NULL,NULL,NULL);
}
zoltrix61 31-Oct-11 2:40am View    
Thank you for your response but I can not exactly comprehend your means.
In my codes that have been copied under these lines, I first combine two images with using of Alpha Blending Technique, and then 12 points in various sizes are drawn over the combined images. I want to draw these points transparently. How it is possible?
Any help is appreciated.
Bests



#define D3DFVF_CUSTOMVERTEX (D3DFVF_DIFFUSE | D3DFVF_XYZ | D3DFVF_TEX2 )

//structures
struct D3DVERTEX
{
float fX,
fY,
fZ;
DWORD color;
float fU1,
fV1;
float fU2,
fV2;

};

#define D3DFVF_CUSTOMVERTEX2 (D3DFVF_XYZ | D3DFVF_PSIZE | D3DFVF_DIFFUSE)

//structures
struct D3DVERTEX2
{
float fX,
fY,
fZ,
fSize;
DWORD dwColor;
};

D3DVERTEX aQuad[] =
{
{-1.0f, 1.0f, 2.5f, D3DCOLOR_ARGB(255,255,255,255), 0.0f,0.0f,0.0f,0.0f},
{-1.0f, -1.0f, 2.5f, D3DCOLOR_ARGB(255,255,255,255), 0.0f,1.0f,0.0f,1.0f
{1.0f, 1.0f, 2.5f, D3DCOLOR_ARGB(255,255,255,255), 1.0f,0.0f,1.0f,0.0f
{1.0f, -1.0f, 2.5f, D3DCOLOR_ARGB(255,255,255,255), 1.0f,1.0f,1.0f,1.0f}
};



D3DVERTEX2 aPoints[] =
{
{-0.5f,0.005f,1.5f, 10.0f, D3DCOLOR_ARGB(220,255,0,0)},
{-0.5f,0.055f,1.5f, 20.0f, D3DCOLOR_ARGB(220,255,0,0)},
{-0.5f,0.55f,1.5f, 20.0f, D3DCOLOR_ARGB(220,255,0,0)},
{-0.5f,0.45f,1.5f, 20.0f, D3DCOLOR_ARGB(220,255,0,0)},
{-0.5f,0.40f,1.5f, 20.0f, D3DCOLOR_ARGB(220,255,0,0)},
{-0.5f,0.35f,1.5f, 10.0f, D3DCOLOR_ARGB(220,255,0,0)},
{-0.5f,0.30f,1.5f, 20.0f, D3DCOLOR_ARGB(220,255,0,0)},
{-0.5f,0.25f,1.5f, 20.0f, D3DCOLOR_ARGB(220,255,0,0)},
{-0.5f,0.20f,1.5f, 5.0f, D3DCOLOR_ARGB(220,255,0,0)},
{-0.5f,0.15f,1.5f, 20.0f, D3DCOLOR_ARGB(100,128,128,128)},
{-0.5f,0.10f,1.5f, 20.0f, D3DCOLOR_ARGB(255,128,128,128)},
{-0.5f,0.50f,1.5f, 5.0f, D3DCOLOR_ARGB(220,0,0,0)}
};



g_App.GetDevice()->CreateVertexBuffer(sizeof(aQuad),D3DUSAGE_WRITEONLY,D3DFVF_CUSTOMVERTEX,D3DPOOL_MANAGED,&pQuadVB,NULL);

g_App.GetDevice()->CreateVertexBuffer(sizeof(aPoints),D3DUSAGE_POINTS | D3DUSAGE_WRITEONLY,D3DFVF_CUSTOMVERTEX2,D3DPOOL_MANAGED,&pPointsVB,NULL);


pPointsVB->Lock(0,sizeof(aPoints),&pData,0);
memcpy(pData,aPoints,sizeof(aPoints));
pPointsVB->Unlock();


pQuadVB->Lock(0,sizeof(aQuad),(void**)&pData,0);
memcpy(pData,aQuad,sizeof(aQuad));
pQuadVB->Unlock();

D3DXCreateTextureFromFileA(g_App.GetDevice(),"Text1.bmp",&pMap1);
D3DXCreateTextureFromFileA(g_App.GetDevice(),"Text2.bmp",&pMap2);


////////////////////////////////////////////////////////////////////
void CApplication::InitScene(void)
{
D3DXMatrixPerspectiveFovLH(&m_matProjection,m_fFieldOfView,m_fAspectRatio,m_fNearPlane,m_fFarPlane);
m_pDirect3DDevice->SetTransform(D3DTS_PROJECTION,&m_matProjection);

m_pDirect3DDevice->SetRenderState(D3DRS_AMBIENT,RGB(255,255,255));
m_pDirect3DDevice->SetRenderState(D3DRS_LIGHTING,false);
m_pDirect3DDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
m_pDirect3DDevice->SetRenderState(D3DRS_ZENABLE,D3DZB_FALSE);


for(unsigned i = 0;i < 8;++i)
{
m_pDirect3DDevice->SetSamplerState(i,D3DSAMP_MINFILTER,D3DTEXF_LINEAR);
m_pDirect3DDevice->SetSamplerState(i,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR);
m_pDirect3DDevice->SetSamplerState(i,D3DSAMP_MIPFILTER,D3DTEXF_ANISOTROPIC);
m_pDirect3DDevice->SetSamplerState(i,D3DSAMP_MAXANISOTROPY,m_dwAnisotropy);
}


m_pDirect3DDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_DIFFUSE);
m_pDirect3DDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG1);

m_pDirect3DDevice->SetTextureStageState(1,D3DTSS_TEXCOORDINDEX,1);
m_pDirect3DDevice->SetTextureStageState(1,D3DTSS_COLORARG1,D3DTA_TEXTURE);
m_pDirect3DDevice->SetTextureStageState(1,D3DTSS_COLORARG2,D3DTA_CURRENT);
m_pDirect3DDevice->SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_MODULATE);
m_pDirect3DDevice->SetTextureStageState(1,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);
m_pDirect3DDevice->SetTextureStageState(1,D3DTSS_ALPHAARG2,D3DTA_CURRENT);
m_pDirect3DDevice->SetTextureStageState(1,D3DTSS_ALPHAOP,D3DTOP_MODULATE);


m_pDirect3DDevice->SetTextureStageState(2,D3DTSS_TEXCOORD