Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

juggerp

Drawing Multiple Hexagons w/ Textures

This topic is 5227 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

Hello, I''ve recently started learning DirectX by buying a book that stepped through the development of a game using DirectX. Now that I have finished it, I''ve decided to create my own turn-based strategy game....however I have hit a snag when it comes to drawing multiple hexagons with textures onto the screen. I am able to draw a single texture-filled hexagon by creating a TriangleStrip with 7 vertices to represent the hexagon, but I am completely confused about how I can get more than one texture-filled hexagon onto the screen at the same time. Can anybody help? Greg

Share this post


Link to post
Share on other sites
Advertisement
Device->SetTexture(0,FirstTexture);
Device->DrawPrimitive();
Device->SetTexture(0,SecondTexture);
Device->DrawPrimitive();

Of course, you''d actually want to draw all the hexagons that use the same texture with a single draw primitive call, but you get the idea.

Share this post


Link to post
Share on other sites
Depending on how you go about it you may need to drop the strip approach. Using a strip to build a single hex is a bad idea. Why? because unless you directly link the adjacent hex to the strip so that it is a continous strip you will have to resort to using alot fo DrawPrimitive or DrawIndexPrimitive calls. One for each hex.
Why is this bad? Because there is alot of overhead for calling DP or DIP especially considering that you are only drawing a tiny number of vertices. Instead you should make you vertex structure in the form of plain list triangles or, even better, indexed triangles. The only other way to use the strip method is to build your map in a scanline type fashion.

IMO strips have there places, but they can be a pain to use. Since you are a beginner drop the pain and use plain lists.

If you use lists what you want to do is populate your entire buffer with all of the hexes, not just one. Then, preferably, use an index buffer to draw the hexes with DIP, else just send the vertex buffer to DP. You will need to group all those hexes that use one texture together for one call, then make another call to draw the other hexes using the other texture.
There are a whole host of methods for optimising and speeding up your draw process but for now don''t worry about optimisation just do the implementation. Once you have figured the ins and outs of DX you can then go into optimisation. You will probably do a complete rewrite of your gfx code when you get to optimisation anyway.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!