Trouble creating Vertex Buffer

Started by
2 comments, last by rocknroll60s 21 years, 4 months ago
Whenever i try to create a vertex buffer I get an access violation. Here''s my function:
  
HRESULT CQuake3BSP::CreateVBBSP(LPDIRECT3DVERTEXBUFFER8 *pVB)
(		
	{m_pd3dDevice->CreateVertexBuffer(m_numOfVerts * sizeof (CUSTOMVERTEX), D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, 
		D3DPOOL_MANAGED, pVB);

        	return S_OK;
}
  
and its called by;
  
HRESULT CMyD3DApplication::InitDeviceObjects()
{
    // TODO: create device objects


    CQuake3BSP::CreateVBBSP(&m_pVB);

    return S_OK;
}

  
Any suggestions?
Advertisement
is device pointer valid?
yep
Use the DEBUG Direct3D runtime and ramp up the debug ouput level to see if D3D is unhappy about anything.

There isn''t much that could go wrong with the particular call you posted though. When you say that the device pointer is valid, do you mean you actually checked its value in the debugger after the crash happened or does it mean "it _should_ be valid because I set it up and passed it in from xyz, but haven''t actually checked at runtime" ?

Most faults with CreateVertexBuffer should return an error rather than giving an access violation (the debug runtime is essential during development). There are only really 4 things which could be bad:

1) any of the pointers are NULL or point to bad memory.
2) the size has become screwed up.
3) the device has been created for software vertex processing, but the usage doesn''t match that.
4) the vertex format is screwed.

[attempt #2, HTTP500]

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

This topic is closed to new replies.

Advertisement