void Canvas::polygon(const RasterPoint *points, unsigned num_points) { if (brush.is_hollow() && !pen.defined()) return; glVertexPointer(2, GL_VALUE, 0, points); if (!brush.is_hollow() && num_points >= 3) { brush.set(); static AllocatedArray<GLushort> triangle_buffer; triangle_buffer.grow_discard(3 * (num_points - 2)); unsigned idx_count = polygon_to_triangle(points, num_points, triangle_buffer.begin()); if (idx_count > 0) glDrawElements(GL_TRIANGLES, idx_count, GL_UNSIGNED_SHORT, triangle_buffer.begin()); } if (pen_over_brush()) { pen.set(); if (pen.get_width() <= 2) { glDrawArrays(GL_LINE_LOOP, 0, num_points); } else { vertex_buffer.grow_discard(2 * (num_points + 1)); unsigned vertices = line_to_triangle(points, num_points, vertex_buffer.begin(), pen.get_width(), true); if (vertices > 0) { glVertexPointer(2, GL_VALUE, 0, vertex_buffer.begin()); glDrawArrays(GL_TRIANGLE_STRIP, 0, vertices); } } } }
/** * Obtains an array. Its values are undefined. */ T *get(unsigned _length) { array.grow_discard(_length); return array.begin(); }