Reputation: 173
I want to draw a very large amount of triangles (up to 600000). What I did first was to:
al_init();
display = al_create_display();
and then loop through my triangles and
al_draw_triangle(); each one.
Finally I did
al_flip_display();
This was not very fast though. I read that it helps to draw to a bitmap on hold first and then draw that bitmap to the display. I tried to do this in the following fashion (sketched):
al_init();
display = al_create_display();
bitmap = al_create_bitmap();
al_set_target_bitmap(bitmap);
al_hold_bitmap_drawing(1);
for every triangle:
al_draw_triangle();
al_hold_bitmap_drawing(0);
al_set_target_bitmap(al_get_backbuffer(display));
al_draw_bitmap(bitmap, 0, 0, 0);
al_flip_display();
This is just as fast as the previous method though. How can I correctly buffer my triangles to reduce the amount of draws? What is the most efficient way to draw many primitives in Allegro 5?
Thanks for all answers
Upvotes: 1
Views: 519
Reputation: 7218
al_hold_bitmap_drawing
does nothing for primitives. This thread has some discussion on the topic, including a suggestion to buffer all of your primitives and make one call to al_draw_prim
:
The difference is that I only call al_draw_prim once, after buffering possibly hundreds of primitives. The primitive drawing functions will kick off a batch every time.
Upvotes: 1