Sprites problems in Direct3D

Started by
1 comment, last by Sfpiano 21 years, 2 months ago
I was following along with the 2D in 3D tutorial at this site. A problem occurred when I realized that it was using some DX8 functions that no longer exist in DX9. So I switched them to their DX9 equivilants, however some of the parameters are completely different, and I''m not sure what to use for them. If I run the below function in my program, it crashes:

LPDIRECT3DVERTEXSHADER9 g_pVertexShader = NULL;
//Actually put in my InitD3D() function
g_pD3DDevice->GetVertexShader(&g_pVertexShader);

void InitBlit()
{
	// Turn off culling, so we see the front and back of primitives
	g_pD3DDevice->SetRenderState(D3DRS_CULLMODE, 
								D3DCULL_NONE);

	// Enable alpha blended transparency.
	g_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
	g_pD3DDevice->SetRenderState(
		D3DRS_SRCBLEND,  D3DBLEND_SRCALPHA);
	g_pD3DDevice->SetRenderState(
		D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

	g_pD3DDevice->SetVertexShader(g_pVertexShader);

}
 
In this case, the difference was the SetVertexShader parameter. In DX9 it''s listed as, ''IDirect3DVertexShader9* pShader'', whereas in DX8 it''s listed as,''DWORD Handle''.
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
Advertisement
Instead of SetVertexShader, use SetFVF. You might want to take a look at the link below for more info:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/convertingtodirectx9.asp
I tried that, and it still didn''t work.
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."

This topic is closed to new replies.

Advertisement