Reputation: 54183
I'm drawing 2D Polygons, actually I'm drawing lots of triangles and using GLUOrtho2D. I noticed that by zooming out I got much better frame rates. I realized I was maxing out the graphics card's fill rate, not drawing too many polygons as I had initially suspected. I think this is because I'm drawing lots of overlapping polygons and using
glEnable(GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Is this the blend function I should be using? How could I minimize the filling given the nature of what I'm doing? I tried enabling the GL_DEPTH_TEST and Z ordered my polygons, but since I alpha blend, this won't help. What is the most efficient way of doing this sort of thing?
Thanks
Upvotes: 1
Views: 1752
Reputation: 195
Changing blend function leads only to changes in blending coefficients, but not in equation. Anyways, modern videocards do not use hardcoded equations. You could try to write a pixel shader that satisfies your needs.
BTW, consider using VBO's for yours "lots of triangles" if you still don't.
Upvotes: 0
Reputation: 6797
I doubt using a different blend function would help. One generally chooses the correct blend function based on desired output, not performance.
Are all the polygons you render transparent/translucent? If not, it might help to separate the rendering of those apart from the opaque polygons you have and set the proper GL states accordingly.
Also are these textured polygons? You might be able to optimize your texture handling (ex: reduce context switches, use more efficient image formats, etc).
Finally, how are you rendering these triangles? If in immediate mode or using vertex arrays, consider using VBOs.
Upvotes: 3
Reputation: 248269
avoid alpha blending on as many triangles as possible. It adds up and yes, it gets really expensive. There is no magic high-performance blend function.
The only solution is "use less blending and more z-buffering"
Upvotes: 2