Archived

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

DrawIndexedPrimitive problem

This topic is 5965 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

ok, here is the prob: i am trying to draw a white rectangle on my black screen. i am using following approach: -> FVF: ( D3DFVF_XYZRHW | D3DFVF_COLOR ) -> Vertex Structure:
      
typedef struct
{

	float x, y, z, rhw;
	DWORD color;

}GUICUSTOMVERTEX;
  

-> Initcode
      
		_x = 1;
		_y = 1;
		_width = 500;
		_height = 500;

		GUICUSTOMVERTEX		verts[] = { {(float)_x, (float)_y, 0.5f, 1.0f, 0xffffffff},
										{(float)(_x+_width), (float)_y, 0.5f, 1.0f, 0xffffffff},
										{(float)(_x+_width), (float)(_y+_height), 0.5f, 1.0f, 0xffffffff}, 
										{(float)_x, (float)(_y+_height), 0.5f, 1.0f, 0xffffffff } };
		DWORD				indic[] = { 0, 1, 2, 0, 2, 3 };
		DWORD				dwSizeVerts = sizeof(verts);
		DWORD				dwSizeInd = sizeof(indic);
		
		// create vertex buffer:

		if ( FAILED ( m_d3dDevice->CreateVertexBuffer( dwSizeVerts, 0, dwCustomFVF, D3DPOOL_MANAGED, &m_lpVertices ) ) )
			return false;	// failed !

		// fill it with data

		VOID* pVertices;
		if( FAILED ( m_lpVertices->Lock ( 0, dwSizeVerts, (BYTE**)&pVertices, 0) ) )
			return false;
		memcpy ( pVertices, verts, dwSizeVerts );
		m_lpVertices->Unlock ();


		// create index buffer:

		if ( FAILED ( m_d3dDevice->CreateIndexBuffer( dwSizeInd, 0, D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_lpIndices ) ) )
			return false;
		// fill it with data

		VOID* pIndices;
		if ( FAILED ( m_lpIndices->Lock(0, dwSizeInd, (BYTE**)&pIndices, 0 ) ) )
			return false;
		memcpy( pIndices, indic, dwSizeInd );
		m_lpIndices->Unlock();
  

->Drawing code
      
		m_d3dDevice->SetStreamSource( 0, m_lpVertices, sizeof(GUICUSTOMVERTEX) );
		m_d3dDevice->SetIndices( m_lpIndices, 0 );
		m_d3dDevice->SetVertexShader( D3DFVF_XYZRHW | D3DFVF_DIFFUSE );
		m_d3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 4, 0, 2);
      
the strange thing is, that nothing gets displayed. i have done such a thing more than one time, successfull. but this time i can't get this thing working. i have no clue where the problem could be. i tried to switch the cullmode to the following states: NONE, CW, CCW with no changes please, i really need your help. i am lost. thanks in advance - S O R R Y - i found the problem .... sorry, no need for answers anymore i should have known that DWORD is a 32bit datatype not 16bit :D ok, thanks anyway. sorry.
>>N E W<< Homepage LittleTaz Edited by - LittleTaz on August 14, 2001 6:12:01 PM Edited by - LittleTaz on August 14, 2001 6:15:09 PM

Share this post


Link to post
Share on other sites
The portion of the code you have displayed is correct, so the fault you must have must be somewhere else. I would go through your program in debug mode line by line (since its not a very large program) by using F11 in VC++ and watch what the value of all your variables are as they are being used. Something maybe not be being initalized correctly.

Possibility

Share this post


Link to post
Share on other sites