0

这是 ipad 的屏幕截图 http://joxi.ru/7J9NUdg5CbCJWOM8-i0 sein http://joxi.ru/SspPUdg5CbBrLdFutis

错误:

1) 图片 ( http://joxi.ru/CYRRUdg5CbDiKIByZLo )

2)大小,不是全屏

我的着色器:

NSString *const yuvFragmentShaderString = SHADER_STRING
(
 varying highp vec2 texCoordVarying;
 uniform sampler2D s_texture_y;
 uniform sampler2D s_texture_u;
 uniform sampler2D s_texture_v;

void main()
{
 highp float y = texture2D(s_texture_y, texCoordVarying).r;
 highp float u = texture2D(s_texture_u, texCoordVarying).r - 0.5;
 highp float v = texture2D(s_texture_v, texCoordVarying).r - 0.5;

 highp float r = y +             1.402 * v;
 highp float g = y - 0.344 * u - 0.714 * v;
 highp float b = y + 1.772 * u;

 gl_FragColor = vec4(r,g,b,1.0);
}
);

我无法理解着色器或其他地方的问题是什么?我可以添加代码

更新

创建纹理

const NSUInteger widths[3]  = { width, width / 2, width / 2 };
const NSUInteger heights[3] = { height, height, height};
for (int i = 0; i < 3; ++i) {

    glBindTexture(GL_TEXTURE_2D, texture[i]);

    glTexImage2D(GL_TEXTURE_2D,
                 0,
                 GL_LUMINANCE,
                 widths[i],
                 heights[i],
                 0,
                 GL_LUMINANCE,
                 GL_UNSIGNED_BYTE,
                 //pixels[i]);
                 bytes->data[i]);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}

活性纹理

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glUniform1i(uniforms[UNIFORM_TEXTURE], 0);

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, texture[1]);
glUniform1i(uniforms[UNIFORM_TEXTURE1], 1);

glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, texture[2]);
glUniform1i(uniforms[UNIFORM_TEXTURE2], 2);

绘制纹理

GLfloat mvpMatrix[16];
[self prepareRender];
[EDMatrixTools applyIdentity:mvpMatrix];
glUniformMatrix4fv(uniforms[UNIFORM_MVP_MATRIX], 1, GL_FALSE, mvpMatrix);

glVertexAttribPointer(ATTRIB_VERTEX, 2, GL_FLOAT, 0, 0, squareVertices);
glEnableVertexAttribArray(ATTRIB_VERTEX);
glVertexAttribPointer(ATTRIB_TEXTURE_COORD, 2, GL_FLOAT, 0, 0, squareTexCoords);
glEnableVertexAttribArray(ATTRIB_TEXTURE_COORD);

[self drawArraysFirst:0 Count:4];
[self presentFramebuffer];
4

1 回答 1

0

2)大小,不是全屏

CGRect screenRect = [[UIScreen mainScreen] bounds];
CAEAGLLayer eaglLayer = (CAEAGLLayer) self.layer;
[eaglLayer setBounds:screenRect];
于 2013-03-26T05:45:44.557 回答