
here's some sample code...it's kinda messed up right now because i got so furious that i started seeing if i could display just a quad....one quad...and g_pd3ddevice = pd3ddevice:
Quote:lpdirect3ddevice8 g_pd3ddevice;
lpdirect3dvertexbuffer8 g_pvertexbuffer = null;
lpdirect3dtexture8 g_ptexture = null;
struct customvertex
{
float x, y, z;
dword color;
float tu, tv;
};
#define d3dfvf_customvertex (d3dfvf_xyz|d3dfvf_diffuse|d3dfvf_tex1)
void drawquad()
{
void* pvertices;
customvertex cvvertices[] =
{
{100.0f, 350.0f, 0.5f, d3dcolor_xrgb(0, 0, 255), 0.0f, 1.0f}, //vertex 1 - blue (100, 350)
{100.0f, 100.0f, 0.5f, d3dcolor_xrgb(255, 0, 0), 0.0f, 0.0f}, //vertex 2 - red (250, 100)
{400.0f, 350.0f, 0.5f, d3dcolor_xrgb(0, 255, 0), 1.0f, 1.0f}, //vertex 3 - green (400, 350)
{400.0f, 100.0f, 0.5f, d3dcolor_xrgb(255, 0, 0), 1.0f, 0.0f}, //vertex 4 - red (250, 100)
};
d3dxcreatetexturefromfilea( g_pd3ddevice, "q:\\screensavers\\logo.bmp", &g_ptexture);
//create the vertex buffer from our device
g_pd3ddevice->createvertexbuffer(3 * sizeof(customvertex), 0, d3dfvf_customvertex, d3dpool_default, &g_pvertexbuffer);
//get a pointer to the vertex buffer vertices and lock the vertex buffer
g_pvertexbuffer->lock(0, sizeof(cvvertices), (byte**)&pvertices, 0);
//copy our stored vertices values into the vertex buffer
memcpy(pvertices, cvvertices, sizeof(cvvertices));
//unlock the vertex buffer
g_pvertexbuffer->unlock();
//rendering our triangle
g_pd3ddevice->setstreamsource(0, g_pvertexbuffer, sizeof(customvertex));
g_pd3ddevice->setvertexshader(d3dfvf_customvertex);
g_pd3ddevice->settexture(0,g_ptexture);
g_pd3ddevice->drawprimitive(d3dpt_trianglestrip, 0, 2);
g_pvertexbuffer->release();
g_ptexture->release();
}

Search
Help