0

here's a screenshot screen with the ipad http://joxi.ru/7J9NUdg5CbCJWOM8-i0 sein http://joxi.ru/SspPUdg5CbBrLdFutis

error:

1) picture (http://joxi.ru/CYRRUdg5CbDiKIByZLo)

2) size, not full screen

My shader:

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);
}
);

I can not understand what the problem is in the shader, or somewhere else? I can add code

Update

Create texture

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);
}

activite texture

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);

draw texture

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];
user1881371
  • 129
  • 11
  • 1
    It might help if you describe what it is you're trying to do, and what you've tried already. Your code is doing all sorts of whacky things. I would start by simply rendering the texture completely as is without the transformations, and then you can step forward and add the y/u/v bits. – mobob Mar 23 '13 at 17:25
  • I draw a texture that comes from the stream. comes to yuv, when I convert to rgb using swscale, everything works. I want to optimize, do the conversion in shader – user1881371 Mar 24 '13 at 07:38
  • It looks like the issue is in how you're uploading the texture, not in the color conversion. It looks like you have the wrong width for your data. – user1118321 Mar 24 '13 at 16:15
  • In that case try emitting r/g/b as just the "y" variable to verify the texture. That way you can see if the image is even coming through correctly, more often than not its the texture that isn't being passed through correctly. – mobob Mar 24 '13 at 16:16
  • did for example https://github.com/kolyvan/kxmovie. size: const NSUInteger widths [3] = {width, width / 2, width / 2}; const NSUInteger heights [3] = {height, height / 2, height / 2}; – user1881371 Mar 25 '13 at 03:55
  • and the fact that I yuv422, what does it change? – user1881371 Mar 26 '13 at 07:19

1 Answers1

0

2) size, not full screen

CGRect screenRect = [[UIScreen mainScreen] bounds];
CAEAGLLayer eaglLayer = (CAEAGLLayer) self.layer;
[eaglLayer setBounds:screenRect];
user1881371
  • 129
  • 11