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

Render Object Question

This topic is 5110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi.... Object with Vertexbuffer:
HRESULT IntilGeometry()
	CUSTOMVERTEX vertex[] =	{
								{-1.0f, -1.0f, 0.0f, D3DXCOLOR( 255.0f,   0.0f,   0.0f, 0.0f)},
								{ 1.0f, -1.0f, 0.0f, D3DXCOLOR(   0.0f, 255.0f,   0.0f, 0.0f)},
								{ 0.0f,  1.0f, 0.0f, D3DXCOLOR(   0.0f,   0.0f, 255.0f, 0.0f)}							
		return E_FAIL;
	VOID *pVertex;
	if(FAILED(g_d3dvb8->Lock(0, sizeof(vertex), (BYTE**)&pVertex, 0)))
		return E_FAIL;
	memcpy(pVertex, vertex, sizeof(vertex));

	return S_OK;
Matrix world:
VOID SetupMatrix()
	D3DXMATRIX matView;
	D3DXMatrixLookAtLH(&matView, &D3DXVECTOR3( 0.0f, 3.0f,-5.0f),
                                 &D3DXVECTOR3( 0.0f, 0.0f, 0.0f),
                                 &D3DXVECTOR3( 0.0f, 1.0f, 0.0f));

	g_d3ddevice8->SetTransform(D3DTS_VIEW, &matView);
	D3DXMATRIX matProj;
	D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );

	g_d3ddevice8->SetTransform(D3DTS_PROJECTION, &matProj);
and lastly the render:
VOID Render()
						D3DCOLOR_XRGB(0, 0, 0),



	g_d3ddevice8->SetStreamSource(0, g_d3dvb8, sizeof(CUSTOMVERTEX));
	g_d3ddevice8->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 1);


	g_d3ddevice8->Present(NULL, NULL, NULL, NULL);	
ok.... now my question is how does Direct X know where is my triangle coordinate and its color...... since I''m not using
                                 0,							         D3DFVF_CUSTOMVERTEX,						 D3DPOOL_DEFAULT,

Share this post

Link to post
Share on other sites
I''ve never truly known this either, but here''s my guess at what''s going on.

When you call Lock you send (BYTE**)&pVertex as a parameter. When you unlock, the vertex buffer will be filled with whatever data is in pVertex, since that''s the parameter you specified. Between locking and unlocking, you memcpy the vertex data to pVertex. So the vertex buffer gets filled with your vertices.

Proceeding on a brutal rampage is the obvious choice.

Share this post

Link to post
Share on other sites
It knows because you used this:


What you won't be able to do is use a non-FVF vertex buffer as a destination for ProcessVertices(). The D3D docs aren't very clear on which FVF (the one in the VB and one specified in SetVertexShader/SetFVF calls) is used for what.

edit: Wait, you ARE specifying the FVF in the CreateVertexBuffer... What part is confusing you? You've told D3D what the vertex looks like. *Twice*.

[edited by - namethatnobodyelsetook on December 15, 2003 3:24:40 PM]

Share this post

Link to post
Share on other sites