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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:41:17+00:00 2026-05-25T14:41:17+00:00

I am attempting to render to a texture in ios with multisampling enabled and

  • 0

I am attempting to render to a texture in ios with multisampling enabled and then use that texture in my final output. Is this possible?

So far I have only gotten black textures or aliased images. The code I am using is:

  glGenTextures(1, &texture);
  glBindTexture(GL_TEXTURE_2D, texture);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA4, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);

  glGenFramebuffers(1, &framebuffer);
  glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);

  glGenRenderbuffers(1, &colorRenderbuffer);
  glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
  //glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8_OES, width, height);
  glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER, 4, GL_RGBA4, width, height);
  glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer);
  glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);

  glGenRenderbuffers(1, &depthRenderbuffer);
  glBindRenderbuffer(GL_RENDERBUFFER, depthRenderbuffer);
  //glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, self.view.bounds.size.height);
  glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT16, width, height);
  glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderbuffer);

  GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER) ;
  if(status != GL_FRAMEBUFFER_COMPLETE) {
    NSLog(@"failed to make complete framebuffer object %x", status);
  }

  // Render my scene

  glBindFramebuffer( GL_FRAMEBUFFER, framebuffer );
  glViewport(0,0,width,height);
  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

  // Draw scene

  // Then bind default framebuffer

  glBindFramebuffer( GL_FRAMEBUFFER, 1 );

  // Draw other things

  // Now resolve the multisampling and draw texture

  glResolveMultisampleFramebufferAPPLE();

  glUseTexture( GL_TEXTURE_2D, texture );

  // Draw with texture

This code does not work. It fails if I make the depth render buffer multisampled. If I just use a normal fbo for the depth then it works, but produces an aliased image.

Anyone know where I am going wrong?

Thanks!

  • 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-05-25T14:41:18+00:00Added an answer on May 25, 2026 at 2:41 pm

    Yes! I found what I was doing wrong. I wrongly thought that I could have the following:

    Framebuffer

    • Multisampled colour render buffer attached to a texture

    • Multisampled depth buffer

    But you cannot do this. D: You have to have the following:

    Multisampled framebuffer:

    • Multisampled colour render buffer (Not attached to a texture)

    • Multisampled depth render buffer

    Normal framebuffer:

    • Colour render buffer attached to a texture. This is what will be written to by glResolveMultisampleFramebufferAPPLE() and what we will use to render the result.

    • No depth buffer.

    I.e. you have to copy the results of the multisampled render to a whole new framebuffer.

    Some code:

      glGenTextures(1, &texture);
      glBindTexture(GL_TEXTURE_2D, texture);
      glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA4, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
    
      glGenFramebuffers(1, &resolved_framebuffer);
      glBindFramebuffer(GL_FRAMEBUFFER, resolved_framebuffer);
      glGenRenderbuffers(1, &resolvedColorRenderbuffer);
      glBindRenderbuffer(GL_RENDERBUFFER, resolvedColorRenderbuffer);
      glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
    
      glGenFramebuffers(1, &framebuffer);
      glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
    
      glGenRenderbuffers(1, &colorRenderbuffer);
      glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
      glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER, 4, GL_RGBA8_OES, width, height);
      glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer);
    
      glGenRenderbuffers(1, &depthRenderbuffer);
      glBindRenderbuffer(GL_RENDERBUFFER, depthRenderbuffer);
      glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT16, width, height);
      glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderbuffer);
    
      GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER) ;
      if(status != GL_FRAMEBUFFER_COMPLETE) {
        NSLog(@"failed to make complete framebuffer object %x", status);
      }
    
      // Render my scene
    
      glBindFramebuffer( GL_FRAMEBUFFER, framebuffer );
      glViewport(0,0,width,height);
      glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    
      // Draw scene
    
      // Then bind default framebuffer
    
      glBindFramebuffer( GL_FRAMEBUFFER, 1 );
    
      // Draw other things
    
      // Now resolve the multisampling into the other fbo
    
      glBindFramebuffer( GL_READ_FRAMEBUFFER_APPLE, framebuffer );
      glBindFramebuffer( GL_DRAW_FRAMEBUFFER_APPLE, resolved_framebuffer );
    
      glResolveMultisampleFramebufferAPPLE();
    
      glBindTexture( GL_TEXTURE_2D, texture );
    
      // Draw with texture
    

    Thanks Goz, you got me in the right direction!

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

Sidebar

Related Questions

Attempting to use the data series from this example no longer passes the JSONLint
I'm currently passing an array to a function, then attempting to use glGenBuffers with
Although this syntax does not render, this is basically what I am attempting to
I'm attempting to render RTF documents using the WPF RichTextBox control. So far, the
I have been attempting to use OpenGL with C++ lately and I have come
EDIT: SOLVED I encountered a problem while attempting to render into a texture. I
attempting to use this railscast as a guide: http://railscasts.com/episodes/197-nested-model-form-part-2?view=asciicast and running into this error:
I'm new to node.js, and attempting to use weld to render templates on the
Attempting to print out a list of values from 2 different variables that are
Attempting to make a NSObject called 'Person' that will hold the login details for

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.