Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Issue reading OpenGL double buffer on Harmattan device
Qt 6.11 is out! See what's new in the release blog

Issue reading OpenGL double buffer on Harmattan device

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 2 Posters 4.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    While implementing color based picking (http://www.lighthouse3d.com/opengl/picking/index.php3?color1) I ran across a difference between the device and desktop environment when reading colors from the double buffer. Whenever I read a pixel from the double buffer on the device I get a 0,0,0 color (= my fill color). It works properly on the desktop with the same code. Any ideas?

    The device in question is N9. The app is a QGLWidget based one with the following setup:

    @
    setAutoFillBackground(false);
    setAttribute(Qt::WA_OpaquePaintEvent);
    setAttribute(Qt::WA_NoSystemBackground);
    setAttribute(Qt::WA_NativeWindow);
    setAttribute(Qt::WA_PaintOnScreen, true);
    setAttribute(Qt::WA_StyledBackground,false);
    setAutoBufferSwap(false);

    glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glClearColor(0, 0, 0, 0);
    glClearStencil(0);
    glDepthFunc(GL_LEQUAL);
    

    @

    Reading the pixel data is done as follows:

    @
    GLint viewport[4];
    glGetIntegerv(GL_VIEWPORT, viewport);

    // OpenGL handles y coordinated inverted; calculate it from viewport info
    int invertedY = viewport[3] - y;
    
    // read the 3-byte RGB pixel
    GLubyte pixel[3];
    glReadPixels(x, invertedY, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)pixel);
    

    @

    Cheers,

    • Matti
    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Okay a bit of a RTFM issue on my part, glReadPixels() format should have been GL_RGBA .. but another issue remains, the pixel data read back does not match what was written: I render an object with color 255,255,192 and when I read a pixel back it becomes 255,255,198? Isn't the buffer natively 32bit color or how come this change in the color? Going to have to do some precicion downshifting I guess to distinguish my pick colors..

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        In OpenGL you have no control over how the actual implementation deals with colors. The vendor may have made some tweaks in their drivers to gain some performance on their specific hardware, especially on embedded devices.
        The internal color representation might not be full precision 32 bits RGBA and your read back can therefore be slightly off. There are some GL extensions (on the desktop) that allow you to require a full precision 32 bits buffer but I am not sure that this is available with OpenGL ES.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Right, suspected something like this. Well, I'm going to shift things down to 5-bit precision, that should do it while still giving plenty of pick color choices.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved