Original Post
I'm working on a program titled "MyBlockGame," and I'm having trouble rendering the blocks. The 2D blocks, generated from four-point trianglestrips, show up, but they're not totally filled in. They show up as a bunch of dots, like pointillism. Also, as the blocks move down the grid that they're supposed to be in, horizontal strips of the blocks disappear and reappear. Lastly, the leftmost block doesn't show up at all. This is some of the source code. Note that I'm only working with red blocks atm. #define RED 0xff0000 . . . void renderFrame() { . . . // translation matrix D3DXMATRIX matTranslate; // repeatedly call D3DXMatrixTranslation on the matTranslate matrix, // SetTransform to that matrix, and draw a square int firstPoint; // the index of first point in a primitive for (int row = 0; row < GRID_HEIGHT; ++row) { for (int cell = 0; cell < GRID_WIDTH; ++cell) { int col = pController->GetColor(row, cell); switch (col) { case(RED): firstPoint = 0; break; case(GREEN): firstPoint = 4; break; case(BLUE): firstPoint = 8; break; case(YELLOW): firstPoint = 12; break; default: firstPoint = -1; break; } if (firstPoint != -1) { D3DXMatrixTranslation(&matTranslate, (float)(20 * cell - SCREEN_WIDTH / 256), (float)(-20 * row + SCREEN_HEIGHT / 256), 0.0f); pd3ddev->SetTransform(D3DTS_WORLD, &matTranslate); pd3ddev->DrawPrimitive(D3DPT_TRIANGLESTRIP, firstPoint, 2); } } void initGraphics() { // create the vertices using the CUSTOMVERTEX struct CUSTOMVERTEX t_vert[] = { // a red square { -10.0f, 10.0f, 0.0f, D3DCOLOR_XRGB(0xff, 0x00, 0x00), }, { 10.0f, 10.0f, 0.0f, D3DCOLOR_XRGB(0xff, 0x00, 0x00), }, { -10.0f, -10.0f, 0.0f, D3DCOLOR_XRGB(0xff, 0x00, 0x00), }, { 10.0f, -10.0f, 0.0f, D3DCOLOR_XRGB(0xff, 0x00, 0x00), }, // a green square . . . // a blue square . . . // a yellow square . . . }; // create a vertex buffer interface called pt_buffer pd3ddev->CreateVertexBuffer(16 * sizeof(CUSTOMVERTEX), 0, CUSTOMFVF, D3DPOOL_MANAGED, &pt_buffer, NULL); VOID *pVoid; // lock pt_buffer and load the vertices into it pt_buffer->Lock(0, 0, (void**) &pVoid, 0); memcpy(pVoid, t_vert, sizeof(t_vert)); pt_buffer->Unlock(); }