Original Post
I recently re-coded my Tile Engine so its faster as it draws thousands of polygons on the screen at once rather than two at a time. But I've run into problems. I updated my Layer class which contains the code to Add a Tile to the layers array: And then to Render all the Tiles to the screen: But when I put this into practice nothing at all is rendered. I'm sure I coded everything OK but I was wondering if anyone could check if there are any mistakes or anything I've missed out.
int LAYER::AppendTile(float x, float y, float u, float v)
{
//Define the Tiles Co-ordinates in model space
Tile[0][0] = 0.0f;
Tile[0][1] = 0.0f;
Tile[0][2] = 0.0f;
Tile[0][3] = 0.0f;
Tile[0][4] = 0.0f;
Tile[1][0] = 1.0f;
Tile[1][1] = 0.0f;
Tile[1][2] = 0.0f;
Tile[1][3] = u;
Tile[1][4] = 0.0f;
Tile[2][0] = 0.0f;
Tile[2][1] = -1.0f;
Tile[2][2] = 0.0f;
Tile[2][3] = 0.0f;
Tile[2][4] = v;
Tile[3][0] = 1.0f;
Tile[3][1] = 0.0f;
Tile[3][2] = 0.0f;
Tile[3][3] = u;
Tile[3][4] = 0.0f;
Tile[4][0] = 1.0f;
Tile[4][1] = -1.0f;
Tile[4][2] = 0.0f;
Tile[4][3] = u;
Tile[4][4] = v;
Tile[5][0] = 0.0f;
Tile[5][1] = -1.0f;
Tile[5][2] = 0.0f;
Tile[5][3] = 0.0f;
Tile[5][4] = v;
//Convert the model space Co-ordinates into world Co-ordinates by transforming the
//world matrix using the X and Y values given by the function
D3DXMatrixTranslation(&WorldMat, x, y, 0.0f);
d3ddevice->SetTransform(D3DTS_WORLD, &WorldMat);
//This is the actual Co-ordinate conversion
D3DXVec3TransformCoord(&WTiles[numtiles][0], &D3DXVECTOR3(Tile[0][0], Tile[0][1], Tile[0][2]), &WorldMat);
D3DXVec3TransformCoord(&WTiles[numtiles][1], &D3DXVECTOR3(Tile[1][0], Tile[1][1], Tile[1][2]), &WorldMat);
D3DXVec3TransformCoord(&WTiles[numtiles][2], &D3DXVECTOR3(Tile[2][0], Tile[2][1], Tile[2][2]), &WorldMat);
D3DXVec3TransformCoord(&WTiles[numtiles][3], &D3DXVECTOR3(Tile[3][0], Tile[3][1], Tile[3][2]), &WorldMat);
D3DXVec3TransformCoord(&WTiles[numtiles][4], &D3DXVECTOR3(Tile[4][0], Tile[4][1], Tile[4][2]), &WorldMat);
D3DXVec3TransformCoord(&WTiles[numtiles][5], &D3DXVECTOR3(Tile[5][0], Tile[5][1], Tile[5][2]), &WorldMat);
TileVb->Lock(0, 0, &TileVerts, D3DLOCK_NOOVERWRITE);
memcpy(&TileVerts, &Tile, sizeof(Tile));
TileVb->Unlock();
//Increase the Number of tiles in the Layer by one
numtiles++;
return 1;
}
int LAYER::Render()
{
d3ddevice->SetStreamSource(0, TileVb, 0, sizeof(VTile));
d3ddevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, numtiles*2);
return 1;
}