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 8407895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:29:43+00:00 2026-06-09T23:29:43+00:00

I am trying to start using framebuffers in my app. I fallowed Apple tutorial

  • 0

I am trying to start using framebuffers in my app. I fallowed Apple tutorial Using a Framebuffer Object as a Texture. And my code looks like this:

Somewhere in header file:

GLuint framebuffer, texture;
GLenum status;

And .m file:

-(void)initFBO {
    glGenFramebuffersEXT(1, &framebuffer);
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer);
    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0,
                 GL_RGBA, GL_UNSIGNED_BYTE, NULL);
    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
                              GL_TEXTURE_2D, texture, 0);
    status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
    if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
        NSLog(@"failed");
    } else {
        NSLog(@"success");
    }
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}

-(void)someDrawingFunc {
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer);
glClearColor(0.0, 0.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
    glEnable(GL_BLEND);
    glBlendFunc(GL_ONE, GL_ZERO);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, someTexture);
    glBegin(GL_QUADS);
    glTexCoord2f(0.0f, 0.0f);
    glVertex2f(0.0, height);
    glTexCoord2f(0.0f, 1.0f);;
    glVertex2f(0.0, 0.0);
    glTexCoord2f(1.0f, 1.0f);
    glVertex2f(width, 0.0);
    glTexCoord2f(1.0f, 0.0f);
    glVertex2f(width, height);
    glEnd();
glFlush();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

    [self drawFBO];
}

-(void)drawFBO {
glClearColor(1.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColor4f(1.0, 1.0, 1.0, 1.0);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, 0.0f);
glEnd();
glFlush();
glBindTexture(GL_TEXTURE_2D, 0);
}

In console I see "success", but in my app window I see:
enter image description here

And when I do glReadPixels and save them to image I get:
enter image description here

The size of saved image is as it should be, everything is OK, but I just get the glClearColor filled image with mysterious black line, and not what I have drawn to framebuffer

While with same code just without using framebuffer at all, in my app I see:
enter image description here

And when I save then, I see:
enter image description here

What am I doing wrong?


So, framebuffer refuses textured GL_QUAD, that I am trying to draw, for some reason. So I guess problem has to be somewhere at framebuffer usage.


EDIT

Strange thing. When drawing fbo to screen now I see only red color (glClearColor where drawing FBO to screen), but when I do glReadPixels it reads pixels good. It saves image with my texture.

Default image (texture image, drawn to FBO):
enter image description here

What I see in my app window:
enter image description here

glReadPixels result image (texture readed from FBO and saved to file):
enter image description here

Yes, its upside down. Its normal for reading pixels from OpenGL. I updated code in question with that how my code looks like now

  • 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-09T23:29:45+00:00Added an answer on June 9, 2026 at 11:29 pm

    I have solved it. The problem was with my glTranslatef. I done glPushMatrix() and setted needed matrix parameters when rendering to FBO, and everything works fine now.

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

Sidebar

Related Questions

I just now start using knockoutjs. In below code am just trying to bind
I am trying to start a server using CreateProcess(). Here is the Code: int
I'm trying to start using lucene. The code, I'm using to index documents is:
I'm trying to start off using FBJS, and I can't figure this out. The
I am trying to start Nant using C# code. The same string entered in
I'd like to start using my localhost to develop from. I am trying to
I am trying to start using cython and and attempting to compile my first
I'm trying to start using Sphinx to document some little projects of mine, but
I'm trying to start Microsoft word using QProcess as following: QString program = WINWORD.EXE;
I'm trying to start a service using Alarmmanager with pendingIntent. I stuck with Unable

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.