• Advertisement
Sign in to follow this  

Need some help with Directx 9

This topic is 3028 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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 row
end 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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement