Sign in to follow this  

problem drawing one quad after another

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

i draw one quad to represent a mouse pointer that is similar to the windows pointer and have also implemented code to draw a fps crosshair in the center of the screen when the f key is pressed, however when i press the f key the old cursor, the classic one is removed but the new crosshair is not drawn. i know that when i press the f key the way the cursor is handled is changed since in FPS mode the windows cursor is stuck in the center, but in third person the windows cursor can move around freely, this is the drawing code, im 99% sure the problem is in it, i just cant locate it :S

	if( m_CameraType == THIRDPERSON )
	{
		if( !pTPCursorVb )
		{
			ID3D9Device->CreateVertexBuffer( 6 * sizeof(VertexCursor), D3DUSAGE_WRITEONLY, D3DFVF_VERTEXCURSOR, D3DPOOL_MANAGED, 
									&pTPCursorVb, 0 );
		}
		
		VertexCursor* TPvertices;

		/*	 Must lock before carrying out operations	*/
		pTPCursorVb->Lock(0, 0, (void**)&TPvertices, 0);
		
		/*  vertices of the Crosshair	*/
		TPvertices[0] = VertexCursor( m_MouseCurrentx - m_TPCursorHotspot_x, m_MouseCurrenty + m_TPCursorHeight - m_TPCursorHotspot_y, 0.0f, 1.0f, 0xffffffff, 0.0f, 1.0f);
		TPvertices[1] = VertexCursor( m_MouseCurrentx - m_TPCursorHotspot_x, m_MouseCurrenty - m_TPCursorHotspot_y, 0.0f, 1.0f, 0xffffffff,  0.0f, 0.0f);
		TPvertices[2] = VertexCursor( m_MouseCurrentx + m_TPCursorWidth - m_TPCursorHotspot_x, m_MouseCurrenty - m_TPCursorHotspot_y, 0.0f, 1.0f, 0xffffffff,  1.0f, 0.0f);
		TPvertices[3] = VertexCursor( m_MouseCurrentx - m_TPCursorHotspot_x, m_MouseCurrenty  + m_TPCursorHeight - m_TPCursorHotspot_y, 0.0f, 1.0f, 0xffffffff,  0.0f, 1.0f);
		TPvertices[4] = VertexCursor( m_MouseCurrentx + m_TPCursorWidth - m_TPCursorHotspot_x, m_MouseCurrenty - m_TPCursorHotspot_y, 0.0f, 1.0f, 0xffffffff,  1.0f, 0.0f);
		TPvertices[5] = VertexCursor( m_MouseCurrentx + m_TPCursorWidth - m_TPCursorHotspot_x, m_MouseCurrenty + m_TPCursorHeight - m_TPCursorHotspot_y, 0.0f, 1.0f, 0xffffffff,  1.0f, 1.0f);

		pTPCursorVb->Unlock();

		ID3D9Device->SetTexture( 0, m_pTPCursorTexture );

		ID3D9Device->SetStreamSource(0, pTPCursorVb, 0, sizeof(VertexCursor));
		ID3D9Device->SetFVF(D3DFVF_VERTEXCURSOR);

		/*	 Draw primitives using presently enabled texture.	*/
		ID3D9Device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
	}

	if( m_CameraType == FPS )
	{		
		if( !pFPSCursorVb )
		{
			
			ID3D9Device->CreateVertexBuffer( 6 * sizeof(VertexCursor), D3DUSAGE_WRITEONLY, D3DFVF_VERTEXCURSOR, D3DPOOL_MANAGED, 
									&pFPSCursorVb, 0 );
		}

		VertexCursor* FPSvertices;

		/*	 Must lock before carrying out operations	*/
		pFPSCursorVb->Lock(0, 0, (void**)&FPSvertices, 0);

		FPSvertices[0] = VertexCursor( m_FPSCursorx - m_FPSCursorHotspot_x, m_FPSCursory - ( m_FPSCursorHeight - m_FPSCursorHotspot_y ), 0.0f, 1.0f, 0xffffffff, 0.0f, 1.0f);
		FPSvertices[1] = VertexCursor( m_FPSCursorx - m_FPSCursorHotspot_x, m_FPSCursory + m_FPSCursorHotspot_y, 0.0f, 1.0f, 0xffffffff,  0.0f, 0.0f);
		FPSvertices[2] = VertexCursor( m_FPSCursorx + ( m_FPSCursorWidth - m_FPSCursorHotspot_x ), m_FPSCursory + m_FPSCursorHotspot_y, 0.0f, 1.0f, 0xffffffff,  1.0f, 0.0f);
		FPSvertices[3] = VertexCursor( m_FPSCursorx - m_FPSCursorHotspot_x, m_FPSCursory - ( m_FPSCursorHeight - m_FPSCursorHotspot_y ), 0.0f, 1.0f, 0xffffffff,  0.0f, 1.0f);
		FPSvertices[4] = VertexCursor( m_FPSCursorx + ( m_FPSCursorWidth - m_FPSCursorHotspot_x ), m_FPSCursory + m_FPSCursorHotspot_y, 0.0f, 1.0f, 0xffffffff,  1.0f, 0.0f);
		FPSvertices[5] = VertexCursor( m_FPSCursorx + ( m_FPSCursorWidth - m_FPSCursorHotspot_x ), m_FPSCursory - ( m_FPSCursorHeight - m_FPSCursorHotspot_y ), 0.0f, 1.0f, 0xffffffff,  1.0f, 1.0f);


		pFPSCursorVb->Unlock();

		ID3D9Device->SetTexture( 0, m_pFPSCursorTexture );

		ID3D9Device->SetStreamSource(0, pFPSCursorVb, 0, sizeof(VertexCursor));
		ID3D9Device->SetFVF(D3DFVF_VERTEXCURSOR);

		/*	 Draw primitives using presently enabled texture.	*/
		ID3D9Device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
	}

Share this post


Link to post
Share on other sites

This topic is 4039 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this