Skip to main content
GameDev.net gamedev.net
🔒 Locked

My Buffer implementations renders nothing

Started by m4gnus Jan 23, 2006 at 11:59 AM 1 replies 550+ views
Original Post
m4gnus
m4gnus
Hi Recently i created a vertex-,indexbuffer- and vertexbufferclass but for some reason my screen just rests empty. Before i started to write those classes i just used the usual Direct3D Buffers(which are now wrapped by my classes) and it worked without a problem. As i reworked that whole vertex,index part of my engine i also changed from calling mesh.render() to renderer.render(Mesh); and that is all i changed. I thought that somebody with my buffer classes is wrong BUT the D3DBuffers that my own Buffer classes pass to SetStreamSource are the same in memory. Btw. what is LPDIRECT3DVERTEXBUFFER9? is it just a pointer? but why can 2 vertexbuffer than point to the same buffer? does DirectX look if there's already a buffer with the exact same size? that would be a very rare case. So has anybody an idea where the problem could lie? When the buffers are exactly the same in memory does the error have to be caused by the change from mesh.render(); to renderer.render(mesh);?(because that's the only thing i changed apart from the vertex,index stuff) mesh.render();

void ngMesh::render() 
{
	m_pEngine->g_pD3DDevice->SetFVF(FVF);                      m_pEngine->g_pD3DDevice->SetStreamSource(0,pVBuffer,0,sizeof(complVertex));
	m_pEngine->g_pD3DDevice->SetIndices(pIBuffer);
	int VertSize=complVertices.size();
	int IndSize=Indices.size();
	LPDIRECT3DVERTEXBUFFER9 ngVBuff;
	LPDIRECT3DINDEXBUFFER9 ngIBuff;
	ngVBuff=pVBuff->getD3DVBuffer();
	ngIBuff=pIBuff->getD3DIBuffer();
	int vsize=sizeof(pVBuffer);
	int isize=sizeof(pVBuffer);

	m_pEngine->g_pD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,complVertices.size(),0,Indices.size()/3);
}


renderer.render(mesh)

void Draw(ngVertexBuffer *pvbuffer,ngIndexBuffer *pibuffer)
{
	int size=D3DXGetFVFVertexSize(pvbuffer->getFVF());
	int size2=pvbuffer->getVertexsize();
	D3DVERTEXBUFFER_DESC desc;
	pvbuffer->getD3DVBuffer()->GetDesc(&desc);
	ngEngine &engine=ngEngine::getInstance();
	int triangleCount=pibuffer->getLength()/3;
	DWORD fvf=pvbuffer->getFVF();
	engine.g_pD3DDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
	engine.g_pD3DDevice->SetFVF(pvbuffer->getFVF());
	engine.g_pD3DDevice->SetStreamSource(0,pvbuffer->getD3DVBuffer(),0,pvbuffer->getVertexsize());
	engine.g_pD3DDevice->SetIndices(pibuffer->getD3DIBuffer());
	engine.g_pD3DDevice->DrawIndexedPrimitive(pvbuffer->getPrimType(),0,0,pvbuffer->getLength(),0,triangleCount);


}


PS: i also checked the FVF and the Prim Type which are identical in both cases regards, m4gnus
"There are 10 types of people in the world... those who understand binary and those who don't."
jollyjeffers
jollyjeffers
Have you checked the debug output? I notice you're not checking the return codes on any of your functions. For a shared/common library, you should try and make it robust and (reasonably) fault tolerant [wink]

I've managed to mess up a number of parameters before via simple refactoring - and the debug output is usually sitting there screaming and shouting about an invalid parameter [smile]


LPDIRECT3D{VERTEXBUFFER|INDEXBUFFER|TEXTURE|SURFACE}9 are just typedef's of pointers to the interface. The documentation shows the typedef or you can just do a "go to declaration" (or "go to definition") and it'll be in one of the d3d9*.h headers.

Having multiple variables point to the same VB is perfectly valid provided thats what you want. The above alias is simply a convenience to simplify code and reduce stupid errors (like passing a IDirect3DDevice9* instead of an IDirect3DDevice9**) - it's not there to stop you doing stuff.

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
m4gnus
m4gnus
i never let my functions return codes. The reason for that is a mix of laziness and the thinking that i don't need them as i will be the only person who will ever use these functions...

The debug output just says something about "Ignoring redundant SetSamplerState Sampler: 0, State: 21" which couldn't cause the problem(right?)

I knew that i can have multiple pointers to the same interface but i was suprised that if i create 2 identical vertexbuffers(one through my classes and one the direct way) they point to the same data(that would mean that D3D checks for identical vertexbuffers before creating one)

thx for the response.

if anyone wants some code i will post it but all classes together would be a little much...


regards,
m4gnus
"There are 10 types of people in the world... those who understand binary and those who don't."

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.