Better way to draw a hexagon?

Accname

2D-Graphics enthusiast
Reaction score
1,462
Hi guys.

Just a question about performance of draw calls to a graphics card.
Which is the faster way to draw a hexagon with triangles?

Version 1).
Using a triangle strip and 6 vertices. [Look at picture]

Version 2).
Using a triangle fan and 7 vertices. [Look at picture]

Triangle Ex.png


I know the second version needs one more vertice but maybe it might be faster. I dont know, maybe its more efficient or something.

Any help is greatly appreciated.

Edit: On a sidenote; what would be the best way to wrap a quadratic texture around these? I really dont like the idea to have hexagon-shaped textures, there is too much cutoff.
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
In the end you can only be sure by testing it out. The result might be different for different kinds of graphics cards or drivers.

But in general I would say you're better off with V1. Less vertex data can never be bad and a drawing triangle strips is much more common than drawing fans (I think) so they are more likely to be well optimized.
Also, you end up with 2 triangles less, which means less work for the GPU in certain cases (for example clipping).

Regarding the texture: You can take the triangle edges and put them together to form a second rectangle. Rotate this rect to align with the other and you have saved as much space as I think it possible.

3lx3ultk.png

^ Just turn the orange-teal rectangle by 45° to align it with the purple-green one. Paint is too stupid to do that :/
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Yeah, you are probably right. This hardware stuff is so hard to rate. I never know what i should do. (or rather what is the better way to do it.)
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Yeah, you are probably right. This hardware stuff is so hard to rate. I never know what i should do. (or rather what is the better way to do it.)

See rules of optimization. If it were me, i would just choose one version and stick with it, unless I already knew this was the bottleneck of the program (very rarely do you truly know this until you've actually implemented it). Optimize later, when it's actually a problem! :)
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Oh i am not writing a programme using hexagon-shaped tiles or anything. This was more of a theoretical question. I prefer quadratic tiles.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top