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


C++ PixelRect::GetTopLeft方法代码示例

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


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

示例1: vp

void
GLTexture::DrawFlipped(PixelRect dest, PixelRect src) const
{
#ifdef HAVE_OES_DRAW_TEXTURE
  if (OpenGL::oes_draw_texture) {
    DrawFlippedOES(dest, src);
    return;
  }
#endif

  const RasterPoint vertices[] = {
    dest.GetTopLeft(),
    dest.GetTopRight(),
    dest.GetBottomLeft(),
    dest.GetBottomRight(),
  };

  const ScopeVertexPointer vp(vertices);

  const PixelSize allocated = GetAllocatedSize();
  GLfloat x0 = (GLfloat)src.left / allocated.cx;
  GLfloat y0 = (GLfloat)src.top / allocated.cy;
  GLfloat x1 = (GLfloat)src.right / allocated.cx;
  GLfloat y1 = (GLfloat)src.bottom / allocated.cy;

  const GLfloat coord[] = {
    x0, y1,
    x1, y1,
    x0, y0,
    x1, y0,
  };

#ifdef USE_GLSL
  glEnableVertexAttribArray(OpenGL::Attribute::TEXCOORD);
  glVertexAttribPointer(OpenGL::Attribute::TEXCOORD, 2, GL_FLOAT, GL_FALSE,
                        0, coord);
#else
  glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  glTexCoordPointer(2, GL_FLOAT, 0, coord);
#endif

  glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

#ifdef USE_GLSL
  glDisableVertexAttribArray(OpenGL::Attribute::TEXCOORD);
  OpenGL::solid_shader->Use();
#else
  glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
}
开发者ID:Adrien81,项目名称:XCSoar,代码行数:50,代码来源:Texture.cpp

示例2: defined

void
DrawVerticalGradient(Canvas &canvas, const PixelRect &rc,
                     Color top_color, Color bottom_color, Color fallback_color)
{
#if defined(EYE_CANDY) && defined(ENABLE_OPENGL)
  const RasterPoint vertices[] = {
    rc.GetTopLeft(),
    rc.GetTopRight(),
    rc.GetBottomLeft(),
    rc.GetBottomRight(),
  };

  glVertexPointer(2, GL_VALUE, 0, vertices);

  const Color colors[] = {
    top_color,
    top_color,
    bottom_color,
    bottom_color,
  };

  glEnableClientState(GL_COLOR_ARRAY);

#ifdef HAVE_GLES
  glColorPointer(4, GL_FIXED, 0, colors);
#else
  glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors);
#endif

  static_assert(ARRAY_SIZE(vertices) == ARRAY_SIZE(colors),
                "Array size mismatch");

  glDrawArrays(GL_TRIANGLE_STRIP, 0, ARRAY_SIZE(vertices));

  glDisableClientState(GL_COLOR_ARRAY);
#else
  canvas.DrawFilledRectangle(rc, fallback_color);
#endif
}
开发者ID:DRIZO,项目名称:xcsoar,代码行数:39,代码来源:GradientRenderer.cpp

示例3: DrawFlippedOES

void
GLTexture::DrawFlipped(PixelRect dest, PixelRect src) const
{
#ifdef HAVE_OES_DRAW_TEXTURE
  if (OpenGL::oes_draw_texture) {
    DrawFlippedOES(dest, src);
    return;
  }
#endif

  const RasterPoint vertices[] = {
    dest.GetTopLeft(),
    dest.GetTopRight(),
    dest.GetBottomLeft(),
    dest.GetBottomRight(),
  };

  glVertexPointer(2, GL_VALUE, 0, vertices);

  const PixelSize allocated = GetAllocatedSize();
  GLfloat x0 = (GLfloat)src.left / allocated.cx;
  GLfloat y0 = (GLfloat)src.top / allocated.cy;
  GLfloat x1 = (GLfloat)src.right / allocated.cx;
  GLfloat y1 = (GLfloat)src.bottom / allocated.cy;

  const GLfloat coord[] = {
    x0, y1,
    x1, y1,
    x0, y0,
    x1, y0,
  };

  glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  glTexCoordPointer(2, GL_FLOAT, 0, coord);
  glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
  glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
开发者ID:j-konopka,项目名称:XCSoar-TE,代码行数:37,代码来源:Texture.cpp


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