All pastes #437745 Raw Edit

Stuff

public text v1 · immutable
·published 2007-04-13 07:11 UTC
rendered paste body
#include "Globals.h"

void InitVerticesNew(
				  IDirect3DDevice9* g_pDirect3DDevice,
				  IDirect3DVertexBuffer9* g_pVertexBuf
				  )
{

	struct CUSTOMVERTEX
	{
	FLOAT x , y, z ,rhw;
	DWORD color;
	};
	
	CUSTOMVERTEX triangles[]=
	{
		{0.5f,-0.5f,0.0f, 0.0f , D3DCOLOR_XRGB(0,0,255)},
		{-0.5f,-0.5f,0.0f, 0.0f, D3DCOLOR_XRGB(255,0,0)},
		{0.5f,0.5f,0.0f, 0.0f , D3DCOLOR_XRGB(255,0,0)}
	};

	g_pDirect3DDevice->CreateVertexBuffer(3*sizeof(CUSTOMVERTEX),0, D3DFVF_XYZRHW | D3DFVF_DIFFUSE , D3DPOOL_DEFAULT , & g_pVertexBuf , NULL);

	VOID* pVertices;
	g_pVertexBuf->Lock(0, sizeof(triangles), (void**)&pVertices,0);
	memcpy(pVertices , triangles , sizeof(triangles));
	g_pVertexBuf->Unlock();

	g_pDirect3DDevice->SetStreamSource(0, g_pVertexBuf,0, sizeof(CUSTOMVERTEX));
	g_pDirect3DDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
	g_pDirect3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,1);
}