Exemple #1
0
static void do_draw_polyline(ALLEGRO_PRIM_VERTEX_CACHE* cache, const float* vertices, int vertex_stride, int vertex_count, int join_style, int cap_style, ALLEGRO_COLOR color, float thickness, float miter_limit)
{
   if (thickness > 0.0f)
   {
      _al_prim_cache_init(cache, ALLEGRO_PRIM_VERTEX_CACHE_TRIANGLE, color);
      emit_polyline(cache, vertices, vertex_stride, vertex_count, join_style, cap_style, thickness, miter_limit);
      _al_prim_cache_term(cache);
   }
   else
   {
# define VERTEX(index)  ((const float*)(((uint8_t*)vertices) + vertex_stride * ((vertex_count + (index)) % vertex_count)))

      int i;

      _al_prim_cache_init(cache, ALLEGRO_PRIM_VERTEX_CACHE_LINE_STRIP, color);

      for (i = 0; i < vertex_count; ++i) {

         if (cache->size >= (ALLEGRO_VERTEX_CACHE_SIZE - 2))
            _al_prim_cache_flush(cache);

         _al_prim_cache_push_point(cache, VERTEX(i));
      }

      _al_prim_cache_term(cache);

# undef VERTEX
   }
}
Exemple #2
0
/* Function: al_draw_filled_polygon_with_holes
 */
void al_draw_filled_polygon_with_holes(const float *vertices, int vertex_count,
   const int *holes, int hole_count, ALLEGRO_COLOR color)
{
   ALLEGRO_PRIM_VERTEX_CACHE cache;

   _al_prim_cache_init_ex(&cache, ALLEGRO_PRIM_VERTEX_CACHE_TRIANGLE, color, (void*)vertices);

   al_triangulate_polygon(
      vertices, sizeof(float) * 2, vertex_count, holes, sizeof(int), hole_count,
      polygon_push_triangle_callback, &cache);

   _al_prim_cache_flush(&cache);
}