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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:15:41+00:00 2026-05-18T03:15:41+00:00

Just getting started with OpenFrameworks and I’m trying to do something that should be

  • 0

Just getting started with OpenFrameworks and I’m trying to do something that should be simple : test the colour of the pixel at a particular point on the screen.

I find there’s no nice way to do this in openFrameworks, but I can drop down into openGL and glReadPixels. However, I’m having a lot of trouble with it.

Based on http://www.opengl.org/sdk/docs/man/xhtml/glReadPixels.xml I started off trying to do this:

glReadPixels(x,y, 1,1, GL_RGB, GL_INT, &an_int);

I figured that as I was checking the value of a single pixel (width and height are 1) and giving it a GL_INT as type GL_RGB as format, a single pixel should take up a single int (4 bytes) Hence I passed a pointer to an int as the data argument.

However, the first thing I noticed was that glReadPixels seemed to be clobbering some other local variables in my function, so I changed to making an array of 10 ints and now pass that. This has stopped any weird side-effect, but I still have no idea how to interpret what it’s returning.

So … what’s the right combination of format and type arguments that I should be passing to safely get something that can easily be unpacked into its RGB values? (Note that I’m doing this through openFrameworks so I’m not explicitly setting up openGL myself. I guess I’m just getting the openFramework / openGL defaults. The only bit of configuration I know I’m doing is NOT setting up alpha-blending, which I believe means that pixels are represented by 3 bytes (R,G,B but no alpha)). I assume that GL_RGB is the format that corresponds to this.

  • 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-18T03:15:41+00:00Added an answer on May 18, 2026 at 3:15 am

    If you do so, you need three int: one for R, one for G, one for B. If think you should use:

    unsigned char RGB[3];
    glReadPixels(x,y, 1,1, GL_RGB, GL_UNSIGNED_BYTE, rgb);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just getting started on Prototypes, and I'm trying to test different things on
I'm just getting started with flask and I've hit a snag. I'm trying to
Just getting started with Obj-C and iOS programming. I have some code that loads
I'm just getting started with CruiseControl .NET (using the Manning Continuous integration book that
I am just getting started with .NET ORMs, to the point where I haven't
Just getting started with Linq to SQL so forgive the newbie question. I'm trying
Just getting started with Backbone. I have a generic view that can render a
Just getting started with Powershell and have a quick question. Trying to run this
Just getting started with backbone.js, and one of the things I've noticed is that
Just getting started with C++ here. I am working on OSX with Eclipse CDT.

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.