【问题标题】:iOS: Confusion about texture coordinates for rendering a texture on the screeniOS:关于在屏幕上渲染纹理的纹理坐标的混淆
【发布时间】:2012-02-10 09:08:58
【问题描述】:

我正在尝试在 iPhone 屏幕上渲染由相机生成的纹理。 我在 http://www.sunsetlakesoftware.com/2010/10/22/gpu-accelerated-video-processing-mac-and-ios 上从 Brad Larson 下载了颜色跟踪示例(示例代码的直接链接:http://www.sunsetlakesoftware.com/sites/default/files/ColorTracking.zip)。

在 ColorTrackingViewController 的 drawFrame 方法中,他使用以下代码生成顶点和相应的纹理坐标以渲染带纹理的正方形:

static const GLfloat squareVertices[] = {
    -1.0f, -1.0f,
    1.0f, -1.0f,
    -1.0f,  1.0f,
    1.0f,  1.0f,
};

static const GLfloat textureVertices[] = {
    1.0f, 1.0f,
    1.0f, 0.0f,
    0.0f,  1.0f,
    0.0f,  0.0f,
};

我不明白为什么这些纹理坐标可以正常工作。

在我看来,在我看到的另一个示例代码中也可以正常工作,它们应该是:

static const GLfloat textureVertices[] = {
    0.0f, 1.0f,
    1.0f, 1.0f,
    0.0f,  0.0f,
    1.0f,  0.0f,
};

我浏览了整个代码,但我不明白为什么上面的纹理坐标可以正常工作。我错过了什么?

【问题讨论】:

    标签: iphone ios opengl-es coordinates textures


    【解决方案1】:

    我相信这是因为来自 iphone 相机的图像数据总是以逆时针旋转 90 度呈现。为了抵消这种旋转,他将纹理坐标也设置为逆时针旋转 90 度。有时两个错误确实是一个正确的?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-16
      • 1970-01-01
      • 2012-05-04
      • 2013-01-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多