glReadPixels - wrong picture Size

Hello everybody,

i have a little problem to read my pixels back from the GPU. I use the following code element.

-(void)readPixels : (unsigned char*) image pictureDest: (unsigned char*) dest
{    
    static const GLfloat textureVertices[] = 
    {
        0.0f, 1.0f,
        0.0f, 0.0f,
        1.0f, 1.0f,
        1.0f, 0.0f,
    };
    
    static const GLfloat squareVertices[] = 
    {
        -1.0f, -1.0f,
        1.0f, -1.0f,
        -1.0f, 1.0f,
        1.0f, 1.0f
    };
    
    glGenTextures(1, &pictureTexture);
    glActiveTexture(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, pictureTexture);
    
    glUniform1i(uniforms[UNIFORM_VIDEOFRAME], 0);
    
    glVertexAttribPointer(ATTRIB_VERTEX, 2, GL_FLOAT, 0, 0, squareVertices);
    glEnableVertexAttribArray(ATTRIB_VERTEX);
    glVertexAttribPointer(ATTRIB_TEXTUREPOSITON, 2, GL_FLOAT, 0, 0, textureVertices);
    glEnableVertexAttribArray(ATTRIB_TEXTUREPOSITON);
    
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imageHeight, imageWidth, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
        
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    glViewport(0, 0, imageHeight, imageWidth);
  
    [self presentFramebuffer];
    
    glReadPixels(0, 0, imageHeight, imageWidth, GL_RGBA, GL_UNSIGNED_BYTE, dest);
    
    glDeleteTextures(1, &pictureTexture);
}

I call this method with the same data element as source and destination and show it on the screen. But i got a picture from glReadPixels() which is much smaller then the original image. There is a bar on the right side with the original pixels from the source image).

Can someone help me with this problem?

Greets
krikit

Hello,

i found my mistake. The initialization of the view was wrong. I used a rectangle with a size which was too small to render the complete image.

So i tried to change the rectangle size and everything works fine.


    _instance = [super initWithFrame:CGRectMake(0.0f, 0.0f, 2000, 2860)];

In the wrong case i’ve initialized the rectangle with the application.frame.size.width / height which was too small.

best regards
krikit

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.