Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Direct3D


  • Please log in to reply

#1
f4cepl4nt

f4cepl4nt

    New Member

  • Member
  • Pip
  • 1 posts
Ok heres some code for my render function
				D3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 0, 0);
	D3DDevice->BeginScene();
	D3DDevice->SetFVF(tri_fvf);
	D3DDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
			   //Bind our Vertex Buffer
				 D3DDevice->SetStreamSource(0,				   //StreamNumber
													 VBuffer,		   //StreamData
															 0,				   //OffsetInBytes
														  sizeof(TRIVERTEX)); //Stride

				  //Render from our Vertex Buffer
				D3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, //PrimitiveType
							   0,				  //StartVertex
							   g_list_count);	  //PrimitiveCount
	
	D3DDevice->EndScene();
	D3DDevice->Present(NULL, NULL, NULL, NULL);
and heres the code that initializes the vertex buffer and fills a TRIVERTEX variable with some data (note the initvertices function IS called before i render hahah):
IDirect3DVertexBuffer9 *VBuffer=NULL;
const DWORD tri_fvf=D3DFVF_XYZRHW|D3DFVF_DIFFUSE;
int g_list_count;
void InitVertices()
{
	struct TRIVERTEX
	{
		float x, y, z, rhw;
		DWORD colour;
	};
	TRIVERTEX vertices[] = 
	{
		{100,100,1,1,0xFF000000},{  0,  0,1,1,0xFFFF0000},{200,  0,1,1,0xFF00FF00},
		{100,100,1,1,0xFF000000},{200,  0,1,1,0xFF00FF00},{200,200,1,1,0xFF0000FF},
		{100,100,1,1,0xFF000000},{200,200,1,1,0xFF0000FF},{  0,200,1,1,0xFFFFFFFF},
		{100,100,1,1,0xFF000000},{  0,200,1,1,0xFFFFFFFF},{  0,  0,1,1,0xFFFF0000},
	};

	int vert_count=sizeof(vertices)/sizeof(TRIVERTEX);
	int byte_count=vert_count*sizeof(TRIVERTEX);
	void *vb_vertices;
	g_list_count=vert_count/3;

	D3DDevice->CreateVertexBuffer(byte_count,		//Length
									   D3DUSAGE_WRITEONLY,//Usage
									   tri_fvf,		   //FVF
									   D3DPOOL_MANAGED,   //Pool
									   &VBuffer,		//ppVertexBuffer
									   NULL);			 //Handle


   VBuffer->Lock(0, //Offset
					  0, //SizeToLock
					  &vb_vertices, //Vertices
					  0);  //Flags

   memcpy( vb_vertices, vertices ,byte_count);

   VBuffer->Unlock();
}

can anyone spot anything wrong? When i run the program that goes through this code (ive narrowed it down to this, something has to be wrong with either of these two code bits) nothing happens. D3D initializes ok, clears the back buffer to black, and presents it fine, but no triangles appear. Whats wrong?

Thanks

Edited by f4cepl4nt, 02 November 2005 - 09:49 PM.

  • 0

Advertisements







Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP