Results 1 to 2 of 2

Thread: glReadPixels - wrong picture Size

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Location
    Bavaria Germany
    Posts
    12

    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.

    Code :
    -(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

  2. #2
    Junior Member
    Join Date
    Mar 2012
    Location
    Bavaria Germany
    Posts
    12

    Re: glReadPixels - wrong picture Size

    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.
    Code :
        _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

Similar Threads

  1. OpenCL Ndrange Global Size/Local Size
    By BiS in forum OpenCL
    Replies: 4
    Last Post: 01-04-2013, 07:52 AM
  2. glReadPixels on Android
    By gadget in forum OpenGL ES general technical discussions
    Replies: 3
    Last Post: 12-23-2012, 05:57 PM
  3. glReadPixels too slow
    By e7fendy in forum OpenGL ES 2X - for programmable 3D graphics pipelines
    Replies: 1
    Last Post: 09-05-2011, 02:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •