|
我想渲染47*47的图标,原图是TGA 96*96,但是渲染出来是32*32,好诡异啊,求解决方法:
渲染代码:
g_pd3dDevice->SetTexture(0,pTexture);
if(_dwColor)
{
g_pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR,_dwColor);
g_pd3dDevice->SetTextureStageState(0,D3DTSS_ALPHAARG2,D3DTA_TEXTURE);
g_pd3dDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG2);
g_pd3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE2X);
g_pd3dDevice->SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_TFACTOR);
}
VERTEX_XYZUV Vertices[] =
{
{ ((float)_rcDraw.left-0.5f), -((float)_rcDraw.top-0.5f), 0, 0.0f, 0.0f },
{ ((float)_rcDraw.right-0.5f), -((float)_rcDraw.top-0.5f), 0, 1.0f, 0.0f },
{ ((float)_rcDraw.left-0.5f), -((float)_rcDraw.bottom-0.5f), 0, 0.0f, 1.0f },
{ ((float)_rcDraw.right-0.5f), -((float)_rcDraw.bottom-0.5f), 0, 1.0f, 1.0f },
};
VERTEX_XYZUV* pVertices = NULL;
m_pVB->Lock( 0, sizeof(Vertices), (void**)&pVertices, D3DLOCK_DISCARD );
memcpy( pVertices,Vertices, sizeof(Vertices) );
m_pVB->Unlock();
g_pd3dDevice->SetStreamSource( 0, m_pVB, 0, SIZE_XYZUV ); // SIZE_XYZUV = 50
g_pd3dDevice->SetFVF(FVF_XYZUV); // FVF_XYZUV = 258
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
if(_dwColor)
{
g_pd3dDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG1 );
g_pd3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1);
}
创建顶点缓冲代码:
if( FAILED( g_pd3dDevice->CreateVertexBuffer(8*sizeof(VERTEX_XYZUV),
D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC,
D3DFVF_XYZ | D3DFVF_TEX1,
D3DPOOL_DEFAULT,
&m_pVB, NULL ) ) )
{//创建空间所用的顶点缓冲区,最多8个点
return false;
}
谢大神帮忙,在线等很急的
|
|