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

  • Home
  • SEARCH
  • 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 8130713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:49:28+00:00 2026-06-06T08:49:28+00:00

I am using pixel colour picking to work out which OpenGL object I have

  • 0

I am using pixel colour picking to work out which OpenGL object I have clicked on and it works brilliantly

As soon as I turn GLKViewDrawableMultisample4X on in the view, the picking stops working?

I have tried turning this on and off when I touch the screen but only works once.

Picking code:

  GLKView *glkView = (GLKView*)[self view];
  UIImage *snapshot = [glkView snapshot];
  GLKVector4 colour = [snapshot pickPixelAtX:xPos Y:yPos];

@implementation UIImage (NDBExtensions)

- (GLKVector4)pickPixelAtX:(NSUInteger)x Y:(NSUInteger)y {

    CGImageRef cgImage = [self CGImage];
    size_t width = CGImageGetWidth(cgImage);
    size_t height = CGImageGetHeight(cgImage);

    if ((x < width) && (y < height))
    {
        CGDataProviderRef provider = CGImageGetDataProvider(cgImage);
        CFDataRef bitmapData = CGDataProviderCopyData(provider);
        const UInt8* data = CFDataGetBytePtr(bitmapData);
        size_t offset = ((width * y) + x) * 4;

        UInt8 b = data[offset+0];
        UInt8 g = data[offset+1];
        UInt8 r = data[offset+2];
        UInt8 a = data[offset+3];

        CFRelease(bitmapData);

        return GLKVector4Make(r, g, b, a );

    }
    return GLKVector4Make(0,0,0,0);
}
  • 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-06T08:49:31+00:00Added an answer on June 6, 2026 at 8:49 am

    I managed to fix this using the code from this

    OpenGL ES 2.0 Object Picking on iOS

    Very good answer, basically GLKViewDrawableMultisample4X does not work with picking and so you need to make another render buffer

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

Sidebar

Related Questions

I have an OpenGL program in which I am doing some augmented reality work.
I have created web pages where am using pixel to position various html elements.
I'm using SlimDX, targeting DirectX 11 with shader model 4. I have a pixel
Is it possible to get the RGB color of a pixel using PIL? I'm
I'm drawing an image using rgb pixel data. I need to set transparent background
I usually create a pixel format using wglChoosePixelFormatARB() with these arguments (among others): WGL_DOUBLE_BUFFER_ARB
How can i adjust the contrast of an image using HTML5 Canvas pixel manipulation
I'm looking to filter a 1 bit per pixel image using a 3x3 filter:
I want retrieve the width and height of browser in pixel(px) using ruby code.
I'm writing a game using android ndk. I'm using picking to select objects in

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.