Archived

This topic is now archived and is closed to further replies.

helix

D3DFVF_XYZRHW vertex positioning

Recommended Posts

helix    301
I have a small UI quad that I want to draw at arbitrary positions on the screen. I create it''s vertex buffer at initialization as follows:
  
struct UIVert
{
	float		x, y, z, rhw;
	D3DCOLOR	color;
	float		tu, tv;
};
#define UIVERT_FLAGS		(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1)

......

UIVert verts[] = 
	{
		{ 0.0f,				 0.0f,					0.9f, 1.0f, D3DCOLOR_ARGB(255,255,255,255), 0.0f, 0.0f },
		{ 0.0f,				 (float)DROP_HEIGHT,	0.9f, 1.0f, D3DCOLOR_ARGB(255,255,255,255), 0.0f, 1.0f },
		{ (float)DROP_WIDTH, 0.0f,					0.9f, 1.0f, D3DCOLOR_ARGB(255,255,255,255), 1.0f, 0.0f },
		{ (float)DROP_WIDTH, (float)DROP_HEIGHT,	0.9f, 1.0f, D3DCOLOR_ARGB(255,255,255,255), 1.0f, 1.0f },
	};

	g_pGame->GetDevice()->CreateVertexBuffer( 4 * sizeof(UIVert), 0, UIVERT_FLAGS, D3DPOOL_DEFAULT, &m_VBuff );

	void* pVerts = NULL;
	m_VBuff->Lock( 0, 0, (BYTE**)&pVerts, 0 );

	memcpy( pVerts, verts, sizeof(verts) );
	m_VBuff->Unlock();
  
The problem I have is that this only draws it up in the left hand corner of the screen. How would I go about drawing it at a different position? There''s gotta be a simple solution to this!

Share this post


Link to post
Share on other sites
Wreakon    121
You transform it, I can say that without even looking at the code. Use D3DXTranslation(x,y,z) and from apply that to the device->SetTransform(D3DTS_WORLD, Matrix).

-------
Homepage: http://students.washington.edu/andrey

Share this post


Link to post
Share on other sites
Meduzza    122
World transform is ignored when you''re dealing with "transformed and lit" vertices as they use screen coordinates.
You''ll need to change x''es and y''s in a vertex buffer.

Share this post


Link to post
Share on other sites