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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:24:24+00:00 2026-06-05T02:24:24+00:00

When trying to get opengl view snapshot as UIImage for multi-sampling the image colors

  • 0

When trying to get opengl view snapshot as UIImage for multi-sampling the image colors are different.

When multi-sampling is off, it is proper.
This is how I am taking the snapshot:

- (UIImage*)snapshot
{

    GLint backingWidth, backingHeight;

    backingWidth = framebufferWidth;
    backingHeight = framebufferHeight;

    NSInteger myDataLength = backingWidth * backingHeight * 4;

    GLubyte *buffer = (GLubyte *) malloc(myDataLength);
    glReadPixels(0, 0, backingWidth, backingHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

    // gl renders "upside down" so swap top to bottom into new array.
    GLubyte *buffer2 = (GLubyte *) malloc(myDataLength);

    for(int y = 0; y < backingHeight; y++) {
        for(int x = 0; x < backingWidth * 4; x++) {
            buffer2[y*4*backingWidth + x] = buffer[(backingHeight - y -1 ) * backingWidth * 4 + x];
        }
    }
    // make data provider with data.
    CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, buffer2, myDataLength, myProviderReleaseData);

    // prep the ingredients
    int bitsPerComponent = 8;
    int bitsPerPixel = 32;
    int bytesPerRow = 4 * backingWidth;
    CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
    CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast ;
    CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;

    // make the cgimage
    CGImageRef imageRef = CGImageCreate(backingWidth, backingHeight, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent);

    // then make the uiimage from that
    UIImage *image1 = [UIImage imageWithCGImage:imageRef];

    CGImageRelease(imageRef);
    CGColorSpaceRelease(colorSpaceRef);
    CGDataProviderRelease(provider);
    free(buffer);

    return image1;
}

Here are the result of taking the snapshot :

opengl view

snapshot of the same view

First one is the opengl view I am drawing and second image is the snapshot of the image I am getting for the above mentioned code.

I am not using GLKit framework. want to know why multisampling is messing up the snapshot.

  • 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-05T02:24:26+00:00Added an answer on June 5, 2026 at 2:24 am

    check whether you are calling [EAGLContext : presentRenderBuffer] method before taking the snapshot of opengl view

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

Sidebar

Related Questions

I am currently trying to get into OpenGL shading and lighting to display a
I'm trying to get MRT working in OpenGL to try out deferred rendering. Here's
I am trying to get started on opengl programming from the videotutorialsrock.com site. It
I'm trying to get a handle on OpenGL VAOs/VBOs, and conceptually I'm there, but
I'm trying to get multisampling to work in my OpenGL ES app. Framebuffer setup
i'm trying to get into opengl programming, but fail to compile my first very
I'm stuck trying to get multiple textures working in OpenGL using Haskell. I've been
I am trying to get some circles drawn onscreen using OpenGL ES 1.5 for
I am trying to draw a background image in my UIView. This is in
Hey - just starting out trying to get some openGL into my iphone app

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.