本文整理汇总了C++中AllocatedArray::grow_discard方法的典型用法代码示例。如果您正苦于以下问题:C++ AllocatedArray::grow_discard方法的具体用法?C++ AllocatedArray::grow_discard怎么用?C++ AllocatedArray::grow_discard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AllocatedArray
的用法示例。
在下文中一共展示了AllocatedArray::grow_discard方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: glVertexPointer
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);
}
}
}
}
示例2:
/**
* Obtains an array. Its values are undefined.
*/
T *get(unsigned _length) {
array.grow_discard(_length);
return array.begin();
}