Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8535439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:25:53+00:00 2026-06-11T10:25:53+00:00

i like to render a simple texture with my fragment shader to 4 vertices

  • 0

i like to render a simple texture with my fragment shader to 4 vertices and read the image resolution with glReadPixels. I set the (readPixel) size like the (source)picture size but i didn’t get a complete image back. There is always a black bar on the right side. And the image seems to be compressed.

The returned part of the image is correct. It shows the resolution of my sobel shader. So i didn’t think that there are some errors on the ReadPixel part or the SetImage part. But i don’t know…

Here is my method to set the image source:

-(void)setImageSource : (unsigned char*) image
{
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);
}

Here the part to render the texture:

-(void)render
{
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    glViewport(0, 0, imageHeight, imageWidth);

    [self presentFramebuffer];
}

And here is the part to read the resolution back:

-(void)readPixels : (unsigned char*) dest
{            
    glReadPixels(0, 0, imageHeight, imageWidth, GL_RGBA, GL_UNSIGNED_BYTE, dest);

    glDeleteTextures(1, &pictureTexture);
}

I don’t have any idea where i make the error. I’ve searched on this forum and on the khronos group forum but i didn’t get a solution for this (and i didn’t find a case with the same error description).

Maybe another important or confusing information – I’ve also tried to put the code to a c++ class. But when i go outside the Objective C class with the EAGLContext i got the correct picture size back but the resolution is wrong the resolution image contains just snow but without the black bar on the side.

Did someone knew a solution for this error?

Regards,
krikit

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:25:54+00:00Added an answer on June 11, 2026 at 10:25 am

    i have solved the problem. The error was in the initialization of the OpenGL ES view. The part where i create the rectangle for the initWithFrame.

    CGRectMake(0.0f, 0.0f, applicationFrame.size.width, applicationFrame.size.height)
    

    There is the wrong size when i set the size by myself i get a complete picture in the destination.

    The other part with the snow on my rendered picture comes from the wrong datatype. When i cast an variable to GLuint it’s not the same then initialize a new GLuint variable and set it with the value… but i don’t know why.

    unsigned int j = 20
    GLuint i = 20;
    

    glReadPixels(0, 0, j, (GLuint)j, GL_RGBA, GL_UNSIGNED_BYTE, pictureDest);
    When i work with the GLuint variables instead of the casted elements everything works fine.

    krikit

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HI, I want to create simple floor plans like this and render it on
I installed PDFKit and wkhtmltopdf. In one action I render a simple html like:
I'm trying to write some code that will render a texture onto a simple
I would like to render a simple list of - Controls. My ASP.NET Code-behind
I would like to render a list of HTML links in ASP.NET MVC. Note
I would like to render the 3D volume data: Density(can be mapped to Alpha
I would like to render a constructions like: <a href='/home'>Home</a> <span class='active'>Community</span> <a href='/about'>About</a>
I have 2 arrays that I would like to render in a template, one
I have a ruby hash that I'd like to render using RABL . The
I would like to re-render a list made using Marionette.ItemView when the corresponding model

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.