Original Post
void text(char* pstring,float x,float y,DWORD c)
{
if(pstring&&pdev)
{
pdev->SetTexture(0,pfontmap);/*
vertex* pverts = 0;
pvbuf->Lock(0,0,(void**)&pverts,0);
for(int x = 0; x < 2112; x++)
pverts[x].c = c;
pvbuf->Unlock();*/
int col = 0;
int row = 0;
int len = strlen(pstring);
int idx = 0;
int max = 0;
for(int i = 0; i < len; i++)
{
if(pstring[i] > 31 && pstring [i] < 127)
{
idx = (pstring[i] - 32) * 4;
D3DXMatrixTranslation(&viewmat,x+(float)col*5,y-(float)row*5,0.0f);
pdev->SetTransform(D3DTS_VIEW,&viewmat);
col++;
pdev->DrawPrimitive(D3DPT_TRIANGLESTRIP,idx,2);
if(col > max)
max = col;
}
else
if(pstring[i] == ''\t'')
col += 4;
else
if(pstring[i] == ''\n'')
{
col = 0;
row++;
}
}
}
else
{
report("Lost the device. Fix this already.");
func = 0;
}
}
// this is the code i use to create the vertex buffer if anyone is wondering
pdev->CreateVertexBuffer(sizeof(vertex)*2112,D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY,D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1,D3DPOOL_DEFAULT,&pvbuf,0)
That code works fun until the locking/unlocking gets uncommented. Why would that mess things up? There are 2112 verts in the buffer, so no overflow or anything in the loop. Can you call Lock on a vb once you''re in BeginScene? this function is called after BeginScene, and when I initialize the verts, that''s before BeginScene so that''s the only thing I can think of.
