SetStreamSource , CreateVertexBuffer , CreateTexture function error

Started by
3 comments, last by Sdfsdf Sdfsdf 10 years, 3 months ago

I'm making the transition from directx8 DirectX9.

but a fault, I would appreciate if you could not figure it help thank you.


BUILD ERROR:
------------

HanText.cpp
D:\SuddenAttack\Johnson_Code\Johnson_Client\CLIENTSHELLDLL\ClientShellShared\HanText.cpp(333) : error C2660: 'SetStreamSource' : function does not take 3 parameters
D:\SuddenAttack\Johnson_Code\Johnson_Client\CLIENTSHELLDLL\ClientShellShared\HanText.cpp(558) : error C2660: 'CreateVertexBuffer' : function does not take 5 parameters
D:\SuddenAttack\Johnson_Code\Johnson_Client\CLIENTSHELLDLL\ClientShellShared\HanText.cpp(600) : error C2660: 'CreateTexture' : function does not take 7 parameters
D:\SuddenAttack\Johnson_Code\Johnson_Client\CLIENTSHELLDLL\ClientShellShared\HanText.cpp(607) : error C2660: 'CreateTexture' : function does not take 7 parameters
D:\SuddenAttack\Johnson_Code\Johnson_Client\CLIENTSHELLDLL\ClientShellShared\HanText.cpp(614) : error C2660: 'CreateTexture' : function does not take 7 parameters
D:\SuddenAttack\Johnson_Code\Johnson_Client\CLIENTSHELLDLL\ClientShellShared\HanText.cpp(621) : error C2660: 'CreateTexture' : function does not take 7 parameters
D:\SuddenAttack\Johnson_Code\Johnson_Client\CLIENTSHELLDLL\ClientShellShared\HanText.cpp(953) : error C2660: 'SetStreamSource' : function does not take 3 parameters

ERROR LINE'S:
-------------

bool CSAD3DText::Render()
{
	if( !m_pVertexBuffer || !m_ppTexture || !m_pszTextBuffer || m_nTextLen <= 0 ) return true;

	int	i;

	m_pd3dDevice->SetFVF( D3DFVF_TEXT_VERTEX );
	m_pd3dDevice->SetStreamSource( 0, m_pVertexBuffer, sizeof(T_TEXT_VERTEX) );

	for( i=0 ; i<m_nTextureCount ; ++i )
	{
		m_pd3dDevice->SetTexture( 0, m_ppTexture[i] );
		m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, i*4 , 2 );
		m_pd3dDevice->SetTexture( 0, NULL );
	}

	return true;
}
---
	hResult = m_pd3dDevice->CreateVertexBuffer( m_nTextureCount*4*sizeof(T_TEXT_VERTEX),
                                                0, D3DFVF_TEXT_VERTEX,
                                                D3DPOOL_MANAGED,
												&m_pVertexBuffer );
---
			hResult = m_pd3dDevice->CreateTexture(	nRight-nLeft, nBottom-nTop, 1, 0,	
													g_D3DFormat,
													D3DPOOL_MANAGED,
													&m_ppTexture[nIndex] );
			if ( FAILED(hResult) )
			{
				g_D3DFormat = D3DFMT_A8R8G8B8;
				hResult = m_pd3dDevice->CreateTexture(	nRight-nLeft, nBottom-nTop, 1, 0,	
														g_D3DFormat,
														D3DPOOL_MANAGED,
														&m_ppTexture[nIndex] );
				if ( FAILED(hResult) )
				{
					g_D3DFormat = D3DFMT_A1R5G5B5;
					hResult = m_pd3dDevice->CreateTexture(	nRight-nLeft, nBottom-nTop, 1, 0,	
															g_D3DFormat,
															D3DPOOL_MANAGED,
															&m_ppTexture[nIndex] );
					if ( FAILED(hResult) )
					{
						g_D3DFormat = D3DFMT_R5G6B5;
						hResult = m_pd3dDevice->CreateTexture(	nRight-nLeft, nBottom-nTop, 1, 0,	
																g_D3DFormat,
																D3DPOOL_MANAGED,
																&m_ppTexture[nIndex] );
---
bool CSAD3DTextEx::Render()
{
	if( !m_pd3dDevice || !m_pVertexBuffer || !m_ppTexture || !m_pszTextBuffer || m_nTextLen <= 0 ) return true;

	int		i;
	
	m_pd3dDevice->SetFVF( D3DFVF_TEXT_VERTEX );
	m_pd3dDevice->SetStreamSource( 0, m_pVertexBuffer, sizeof(T_TEXT_VERTEX) );
	
	for( i=0 ; i<m_nTextureCount ; ++i )
	{
		m_pd3dDevice->SetTexture( 0, m_ppTexture[i] );		
		m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, i*4 , 2 );
		m_pd3dDevice->SetTexture( 0, NULL );
	}

	return true;
}

Advertisement

The errors are spot on. SetStreamSource method has four parameters, CreateVertexBuffer has six parameters and CreateTexture has 8 parameters.

Niko Suni

What should I do, what should I change?

It looks as though you "migrated" to D3D9 by just changing the "8"s to "9"s on the relevant data types, then compiling and hoping for the best. D3D doesn't work that way; D3D9 was a new redesigned API that had a strong resemblance to D3D8 but was not the same thing.

To help you get started, here was the prototype for SetStreamSource in D3D8:


HRESULT SetStreamSource (UINT StreamNumber, IDirect3DVertexBuffer8 *pStreamData, UINT Stride);

And here it is in D3D9:


HRESULT SetStreamSource (UINT StreamNumber, IDirect3DVertexBuffer9 *pStreamData, UINT OffsetInBytes, UINT Stride);

Right away you can see the extra parameter - "UINT OffsetInBytes" - which is causing you errors. If you read the DirectX SDK documentation you'll see the purpose of this parameter:

Offset from the beginning of the stream to the beginning of the vertex data, in bytes.

To fix it you need to supply values for the extra parameters. So for SetStreamSource you need an offset parameter; however since you're porting from D3D8, and since D3D8 didn't support stream offset, you can just use 0 for this and get the same behaviour.

For your Create* calls, the extra parameter is a pSharedHandle parameter, which actually means nothing in standard D3D9 but was added for future use - it can have meaning in 9Ex. So you set it to NULL. Again, from the documentation (this time for CreateVertexBuffer):

Reserved. Set this parameter to NULL. This parameter can be used in Direct3D 9 for Windows Vista to share resources.

If by now you're getting the idea that you really should be downloading the DirectX SDK and working with the documentation (which would have answered this question for you) you'd be right.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

thank you MHAGAIN the error has been corrected.

This topic is closed to new replies.

Advertisement