Jump to content
  • Advertisement
Sign in to follow this  
DarkZoulz

Indexed primitive won't render

This topic is 5136 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What is wrong with this:
	ftVertex	vtest[8];
	vtest[0] = ftVertex(-1.0f, 1.0f, -1.0f, D3DCOLOR_COLORVALUE(1.0, 0.0, 0.0, 1.0));
	vtest[1] = ftVertex(1.0f, 1.0f, -1.0f, D3DCOLOR_COLORVALUE(0.0, 1.0, 0.0, 1.0));
	vtest[2] = ftVertex(-1.0f, -1.0f, -1.0f, D3DCOLOR_COLORVALUE(0.0, 0.0, 1.0, 1.0));
	vtest[3] = ftVertex(1.0f, -1.0f, -1.0f, D3DCOLOR_COLORVALUE(1.0, 1.0, 0.0, 1.0));
	vtest[4] = ftVertex(-1.0f, 1.0f, 1.0f, D3DCOLOR_COLORVALUE(1.0, 0.0, 1.0, 1.0));
	vtest[5] = ftVertex(-1.0f, -1.0f, 1.0f, D3DCOLOR_COLORVALUE(0.0, 1.0, 1.0, 1.0));
	vtest[6] = ftVertex(1.0f, 1.0f, 1.0f, D3DCOLOR_COLORVALUE(1.0, 1.0, 1.0, 1.0));
	vtest[7] = ftVertex(1.0f, -1.0f, 1.0f, D3DCOLOR_COLORVALUE(1.0, 0.0, 0.0, 1.0));

	unsigned short	itest[] = {
		0, 1, 2, 3,
		4, 5, 6, 7,
		4, 6, 0, 1,
		5, 2, 7, 3,
		1, 6, 3, 7,
		0, 2, 4, 5
	};

	vertexCount = 8;
	faceCount = 24;

	void *pTmp;

	if(FAILED(pDevice->CreateVertexBuffer(8 * sizeof(ftVertex), D3DUSAGE_WRITEONLY, VERTEX_FVF, D3DPOOL_MANAGED, &pVB)))
		return;
	if(FAILED(pVB->Lock(0, sizeof(pTmp), (BYTE**)&pTmp, 0)))
		return;
	memcpy(pTmp, vtest, 8 * sizeof(ftVertex));
	pVB->Unlock();

	if(FAILED(pDevice->CreateIndexBuffer(24 * sizeof(unsigned short), D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_MANAGED, &pIB)))
		return;
	if(FAILED(pIB->Lock(0, sizeof(pTmp), (BYTE**)&pTmp, 0)))
		return;
	memcpy(pTmp, itest, 24 * sizeof(unsigned short));
	pIB->Unlock();

	// Render...

	pDevice->SetStreamSource(0, pVB, 0);
	pDevice->SetVertexShader(VERTEX_FVF);
	pDevice->SetIndices(pIB, 0);
	pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, vertexCount, 0, faceCount / 3);


I just want to render the triangles with my vertex and index buffers. The problem is that nothing is rendered, or at least it looks like nothing is rendered. Btw, i'm using directx 8, as I am planning on porting the code to the X-box.

Share this post


Link to post
Share on other sites
Advertisement
If this is the first thing you want to render with that program, you might try to do following things to get ANYTHING on screen:

disable culling
disable z-buffering
check your view / projection matrix
setup a simple texture stage configuration (like D3DTA_DIFFSE & D3DTOP_SELECTARGx)

Once that works you can start doing more complex stuff. At least that's the way I start my engines.

And if you want to port to XBOX - do yourself a favor and start the port right now. Although the differences are rather subtle there ARE differences - and finding those in a fully blown engine might end up being a really huge pain.

Cheers,
Alex

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!