当前位置: 首页>>代码示例>>C++>>正文


C++ AllocatedArray类代码示例

本文整理汇总了C++中AllocatedArray的典型用法代码示例。如果您正苦于以下问题:C++ AllocatedArray类的具体用法?C++ AllocatedArray怎么用?C++ AllocatedArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AllocatedArray类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AllocatedArray

  explicit AllocatedArray(const AllocatedArray &other)
    :buffer{new T[other.buffer.size], other.buffer.size} {
    assert(size() == 0 || buffer.data != nullptr);
    assert(other.size() == 0 || other.buffer.data != nullptr);

    std::copy_n(other.buffer.data, buffer.size, buffer.data);
  }
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:7,代码来源:AllocatedArray.hpp

示例2: vp

void
Canvas::DrawPolygon(const RasterPoint *points, unsigned num_points)
{
  if (brush.IsHollow() && !pen.IsDefined())
    return;

#ifdef USE_GLSL
  OpenGL::solid_shader->Use();
#endif

  ScopeVertexPointer vp(points);

  if (!brush.IsHollow() && num_points >= 3) {
    brush.Bind();
    
    std::unique_ptr<const GLBlend> blend; 
    if(!brush.IsOpaque()) {
      blend = std::make_unique<const GLBlend>(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    }
    
    static AllocatedArray<GLushort> triangle_buffer;
    unsigned idx_count = PolygonToTriangles(points, num_points,
                                            triangle_buffer);
    if (idx_count > 0)
      glDrawElements(GL_TRIANGLES, idx_count, GL_UNSIGNED_SHORT,
                     triangle_buffer.begin());
  }

  if (IsPenOverBrush()) {
    pen.Bind();

    if (pen.GetWidth() <= 2) {
      glDrawArrays(GL_LINE_LOOP, 0, num_points);
    } else {
      unsigned vertices = LineToTriangles(points, num_points, vertex_buffer,
                                          pen.GetWidth(), true);
      if (vertices > 0) {
        vp.Update(vertex_buffer.begin());
        glDrawArrays(GL_TRIANGLE_STRIP, 0, vertices);
      }
    }

    pen.Unbind();
  }
}
开发者ID:jaaaaf,项目名称:LK8000,代码行数:45,代码来源:Canvas.cpp

示例3: 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);
      }
    }
  }
}
开发者ID:macsux,项目名称:XCSoar,代码行数:36,代码来源:Canvas.cpp

示例4: glVertexPointer

void
Canvas::DrawPolygon(const RasterPoint *points, unsigned num_points)
{
  if (brush.IsHollow() && !pen.IsDefined())
    return;

  glVertexPointer(2, GL_VALUE, 0, points);

  if (!brush.IsHollow() && num_points >= 3) {
    brush.Set();

    static AllocatedArray<GLushort> triangle_buffer;
    unsigned idx_count = PolygonToTriangles(points, num_points,
                                            triangle_buffer);
    if (idx_count > 0)
      glDrawElements(GL_TRIANGLES, idx_count, GL_UNSIGNED_SHORT,
                     triangle_buffer.begin());
  }

  if (pen_over_brush()) {
    pen.Bind();

    if (pen.GetWidth() <= 2) {
      glDrawArrays(GL_LINE_LOOP, 0, num_points);
    } else {
      unsigned vertices = LineToTriangles(points, num_points, vertex_buffer,
                                          pen.GetWidth(), true);
      if (vertices > 0) {
        glVertexPointer(2, GL_VALUE, 0, vertex_buffer.begin());
        glDrawArrays(GL_TRIANGLE_STRIP, 0, vertices);
      }
    }

    pen.Unbind();
  }
}
开发者ID:damianob,项目名称:xcsoar,代码行数:36,代码来源:Canvas.cpp

示例5: LineToTriangles

unsigned
LineToTriangles(const PT *points, unsigned num_points,
                AllocatedArray<PT> &strip,
                unsigned line_width, bool loop, bool tcap)
{
  // A line has to have at least two points
  if (num_points < 2)
    return 0;

  // allocate memory for triangle vertices
  // max. size: 2*(num_points + (int)(loop || tcap))
  strip.GrowDiscard(2 * (num_points + 1));

  // A closed line path needs to have at least three points
  if (loop && num_points < 3)
    // .. otherwise don't close it
    loop = false;

  float half_line_width = line_width * 0.5f;

  // strip will point to the start of the output array
  // s is the working pointer
  PT *s = strip.begin();

  // a, b and c point to three consecutive points which are used to iterate
  // through the line given in 'points'. Where b is the current position,
  // a the previous point and c the next point.
  const PT *a, *b, *c;

  // pointer to the end of the original points array
  // used for faster loop conditions
  const auto points_end = points + num_points;

  // initialize a, b and c vertices
  if (loop) {
    b = points + num_points - 1;
    a = b - 1;

    // skip identical points before b
    while (a >= points && *a == *b)
      a--;

    if (a < points)
      // all points in the array are identical
      return 0;

    c = points;
  } else  {
    a = points;
    b = a + 1;

    // skip identical points after a
    while (b != points_end && *a == *b)
      b++;

    if (b == points_end)
      // all points in the array are identical
      return 0;

    c = b + 1;
  }

  // skip identical points after b
  while (c != points_end && *b == *c)
    c++;

  if (!loop) {
    // add flat or triangle cap at beginning of line
    PT ba = *a - *b;
    Normalize(&ba, half_line_width);

    if (tcap)
      // add triangle cap coordinate to the output array
      AppendPoint(s, a->x + ba.x, a->y + ba.y);

    // add flat cap coordinates to the output array
    PT p;
    p.x = ba.y;
    p.y = -ba.x;
    AppendPoint(s, a->x - p.x, a->y - p.y);
    AppendPoint(s, a->x + p.x, a->y + p.y);
  }

  // add points by calculating the angle bisector of ab and bc
  int sign = 1;
  if (num_points >= 3) {
    while (c != points_end) {
      // skip zero or 180 degree bends
      // TODO: support 180 degree bends!
      if (!TriangleEmpty(*a, *b, *c)) {
        PT g = *b - *a, h = *c - *b;
        Normalize(&g, 1000.);
        Normalize(&h, 1000.);
        typename PT::product_type bisector_x = -g.y - h.y;
        typename PT::product_type bisector_y = g.x + h.x;

        float projected_length = (-g.y * bisector_x + g.x * bisector_y) *
                                 (1.f / 1000.f);
        if (projected_length < 400.f) {
          // acute angle, use the normal of the bisector instead
//.........这里部分代码省略.........
开发者ID:LK8000,项目名称:LK8000,代码行数:101,代码来源:Triangulate.cpp

示例6:

 /**
  * Obtains an array.  Its values are undefined.
  */
 T *get(unsigned _length) {
   array.grow_discard(_length);
   return array.begin();
 }
开发者ID:Mrdini,项目名称:XCSoar,代码行数:7,代码来源:ReusableArray.hpp

示例7:

 const short *GetRow(unsigned y) const {
   return data.begin() + y * width;
 }
开发者ID:Adrien81,项目名称:XCSoar,代码行数:3,代码来源:HeightMatrix.hpp

示例8:

 const TerrainHeight *GetRow(unsigned y) const {
   return data.begin() + y * width;
 }
开发者ID:Advi42,项目名称:XCSoar,代码行数:3,代码来源:HeightMatrix.hpp

示例9: IsEmpty

 bool IsEmpty() const {
   return shapes.empty();
 }
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:3,代码来源:TopographyFile.hpp


注:本文中的AllocatedArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。