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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:45:09+00:00 2026-06-14T14:45:09+00:00

glGenFramebuffers doesn’t allocate framebuffer object! I can’t get this small program to work. The

  • 0

glGenFramebuffers doesn’t allocate framebuffer object! I can’t get this small program to work.

The code:

/* ----- AppDelegate.h ----- */
#import <UIKit/UIKit.h>

#import "GLView.h"

@interface AppDelegate : NSObject <UIApplicationDelegate>{
@private
    UIWindow *window;
    GLView *view;
}

@end

/* ----- AppDelegate.h ----- */

#import "AppDelegate.h"

@implementation AppDelegate

- (void)dealloc
{
    [view release];
    [window release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    CGRect frame = [[UIScreen mainScreen] bounds];

    window = [[UIWindow alloc] initWithFrame:frame];
    view = [[GLView alloc] initWithFrame:frame];

    [window addSubview:view];
    [window makeKeyAndVisible];
    return YES;
}

@end

/* ----- GLView.h ----- */

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import <OpenGLES/EAGL.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>

@interface GLView : UIView{
@private
    EAGLContext* context;
    GLuint color_render_buffer;
    GLuint depth_render_buffer;
    GLuint frame_buffer;
}

-(void)render:(CADisplayLink*)displayLink;

@end

/* ----- GLView.mm ----- */

#import "GLView.h"

@implementation GLView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        CAEAGLLayer* eaglLayer = (CAEAGLLayer*)self.layer;
        eaglLayer.opaque = YES;

        context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
        if(!context && ![EAGLContext setCurrentContext:context]){
            [self release];
            return nil;
        }

        int width = (int)frame.size.width;
        int height = (int)frame.size.height;

        glGenFramebuffers(1, &frame_buffer);
        glBindFramebuffer(GL_FRAMEBUFFER, frame_buffer);
        if(glIsFramebuffer(frame_buffer) == GL_FALSE){
            //NSLog(@"%i", frame_buffer);
            NSLog(@"frame_buffer is GL_FALSE!");
        }

        glGenRenderbuffers(1, &color_render_buffer);
        glBindRenderbuffer(GL_RENDERBUFFER, color_render_buffer);
        [context renderbufferStorage:GL_RENDERBUFFER fromDrawable:eaglLayer];

        if(glIsRenderbuffer(color_render_buffer) == GL_FALSE){
            NSLog(@"%i", color_render_buffer);
            NSLog(@"color_render_buffer is GL_FALSE");
        }

        glGenRenderbuffers(1, &depth_render_buffer);
        glBindRenderbuffer(GL_RENDERBUFFER, depth_render_buffer);
        glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);

        if(glIsRenderbuffer(depth_render_buffer) == GL_FALSE){
            NSLog(@"depth_render_buffer is GL_FALSE");
        }


        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, color_render_buffer);
        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth_render_buffer);

        if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE){
#ifdef DEBUG_LOG
            NSLog(@"Framebuffer is not complete!");
            exit(1);
#endif
        }

        [[CADisplayLink displayLinkWithTarget:self selector:@selector(render:)] addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
    }
    return self;
}

+(Class)layerClass{
    return [CAEAGLLayer class];
}

-(void)dealloc{
    if([EAGLContext currentContext] == context){
        [EAGLContext setCurrentContext:nil];
    }

    [context release];
    [super dealloc];
}

-(void)render:(CADisplayLink*)displayLink{
    /* Rendering */

    [context presentRenderbuffer:GL_RENDERBUFFER];
}

@end

I always get “frame_buffer is GL_FALSE!” printed to console… frame_buffer is always 0 (window-system default framebuffer)
Is there any settings that need to be added to plist? Or am I missing something?

Please help.

  • 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-14T14:45:10+00:00Added an answer on June 14, 2026 at 2:45 pm

    You never call setCurrentContext: when context != nil.
    Change:

    if(!context && ![EAGLContext setCurrentContext:context]){
    

    To:

    if(!context || ![EAGLContext setCurrentContext:context]){
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With the following code: GLuint viewRenderbuffer, viewFramebuffer, viewDepthbuffer, stencilBuffer; // Create the framebuffer object
I use this code: context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; if (!context || ![EAGLContext setCurrentContext:context]
I'm confused. To use the Framebuffer Object extension (FBO) in OpenGL 1.x on Windows,
I get an error GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT after I try to create a framebuffer that renders
I'm trying to work with framebuffer objects in PyOpenGL and have found some tutorials
I am getting into FBOs (Framebuffer Objects) in openGL. Right now, I'm simply trying
I am trying to switch my application over to using framebuffer/renderbuffer objects (looking to
I am using JOGL, but this question applies to OpenGL in general. There seem
Since nothing but the size of the window evolve, is it normal my program
I'm using opengl ES 2.0 I'm using a framebuffer linked to a texture to

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.