Need some help with Directx 9

Started by
0 comments, last by Buckeye 14 years, 6 months ago
I have just started working with directx, but have used c++ for years. I want to create a program that generates a full checkerboard pattern on the screen then alterates between black and white by flipping ( an alternating checkerboard pattern at some set speed. After looking at many tutorials, I am need of asking for help. I have created 1 Black and White Check Pair by using 4 triangles and g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 4 ); There has to be an easier way I can do the entire screen without setting vertices for each and every Check on the board. Can i "copy" the pair and just paste it across and down the board? Then I will create another image but have the white/blacks reversed. Can someone help me out, even a flow chart of what I should do will help me alot, so I knew what tutorials to search for. Thanks alot
Advertisement
You're correct in assuming a single vertex buffer for a single square should be adequate.

In pseudo-code:
loop for 8 squares:   loop for 8 squares:     set the world transform     draw rectangle (two triangles) at row,column     bump the column number     change the color   end loop   back to column 0   bump to next rowend loop

For each "draw," set the world transform for the current row,column pair. Something like:

D3DXMATRIX mat;

D3DXMatrixTranslation(&mat, row*squareWidth, 0, column*squareHeight);
device->SetTransform(D3DTS_WORLD,&mat);
//draw

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This topic is closed to new replies.

Advertisement