Archived

This topic is now archived and is closed to further replies.

xstreme2000

D3D: work this out....HELP

Recommended Posts

In my code I render a index buffer and thats all, my problem is Nothing is diplayed unless I use a DrawPrimitive on the vertices before calling the DrawIndexedPrimitive. I assume I have fogotten do something which Draw primitive is doing for me...but what. I REALLY want (read NEED) to get rid of the DrawPrimitive call. (see the line with comments below) PLEASE HELP!!! Cheers X2K
lpD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
lpD3DDevice->SetStreamSource(0, lpVB, sizeof(bsp_vertex));
lpD3DDevice->SetVertexShader(D3DFVF_BSPVERTEX);

D3DMATERIAL8 mat;
D3DUtil_InitMaterial(mat, 1.0f, 1.0f, 1.0f, 1.0f);
lpD3DDevice->SetMaterial(&mat);

for (int f=0; f<face_count; f++) {
	lpD3DDevice->SetTexture(0, lpTextures[faces[f].texture]);
	lpD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
	lpD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
	lpD3DDevice->SetIndices(lpIB, faces[f].start_vertex);

/////////////
// If this line is here it works otherwise the screen is bank
	lpD3DDevice->DrawPrimitive(D3DPT_POINTLIST, faces[f].start_vertex, faces[f].vertex_count);
/////////////

	lpD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0,
	       faces[f].vertex_count, faces[f].start_element, faces[f].element_count/3);
}
  
Edited by - xstreme2000 on November 14, 2001 4:45:07 PM

Share this post


Link to post
Share on other sites
Try doing as follows:

HRESULT hr;

hr = lpD3DDevice->DrawIndexedPrimitive(...);
//(...) is the parameter list
then you have to write
if (hr == D3D_OK){
//do something
}
else{
//show a message box indicating the error code, that will be
D3DERR_INVALIDCALL.}

Share this post


Link to post
Share on other sites
I feel my explanation isn''t too good so I''ll explain properly. If I execute the code with just the DrawPrimitive call I get all my vertices drawn as dots, if I execute it with both the DrawPrimitive & DrawIndexedPrimitive calls I get a nice rendered level with textures, but when I execute with only the DrawIndexedPrimitive call I get nothing!!!

In all cases all functions return successfully!

It would seem that the DrawPrimitive call is selecting/enabling something which I have fogotten to do.

HELP!

Cheers Tom

Share this post


Link to post
Share on other sites
Tomorrow I''m going to try recreating all resource. If that cures it, it''s a bug in the SDK - which I doubt...only DEFAULT resources should need recreating on Reset()...

I''ll let u know how I get on...

-Spiral

Share this post


Link to post
Share on other sites