Results 1 to 3 of 3

Thread: GL_FLOAT_RG16_NV + glDrawPixels

  1. #1
    Senior Member Regular Contributor
    Join Date
    Aug 2004
    Location
    Palo Alto, CA
    Posts
    111

    GL_FLOAT_RG16_NV + glDrawPixels

    I'm trying to load data into a texture with internal format = GL_FLOAT_RG16_NV
    Code :
    g_poFbo->BindFramebufferObject(true);
    glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
    glClear(GL_COLOR_BUFFER_BIT);
     
    glWindowPos2i(0, 0);
    glPixelZoom(1.0f, 1.0f);
     
    glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
    glDrawPixels(g_iWidth, g_iHeight, GL_RED, GL_FLOAT, pfRed);
     
    glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE);
    glDrawPixels(g_iWidth, g_iHeight, GL_GREEN, GL_FLOAT, pfGreen);
     
    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
    g_poFbo->BindFramebufferObject(false);
    When I read the values out they are off in the 4th decimal place. Is this normal ?

    When I use GL_FLOAT_RG32_NV everything is fine.

  2. #2
    V-man
    Guest

    Re: GL_FLOAT_RG16_NV + glDrawPixels

    glDrawPixels(g_iWidth, g_iHeight, GL_RED, GL_FLOAT, pfRed);

    writes 32 bit floating point values and you seem to be using a 16 bit float texture.

    When I use GL_FLOAT_RG32_NV everything is fine.
    In that case, it is something like a memcpy

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,651

    Re: GL_FLOAT_RG16_NV + glDrawPixels

    dimensionX:
    I'm trying to load data into a texture with internal format = GL_FLOAT_RG16_NV ... I read the values out they are off in the 4th decimal place. Is this normal ? When I use GL_FLOAT_RG32_NV everything is fine.
    Yes, this is normal. As V-man alluded, that's about as good as you can expect using half-float components (e.g. RG16).
    • 16-bit half-floats (e.g. RG16) = s10e5
      ...so 2^-10 = ~1e-3, so about 3 sigfigs
    • 32-bit full-floats (i.e. IEEE single precision, e.g. RG32) = s23.8
      ...so 2^-23 = ~1e-7, so about 7 sigfigs

    If you don't want the values to change at all during the upload, pre-encode them in half-float and then upload them to the GPU in that format.

Similar Threads

  1. glDrawPixels and FBO
    By nachovall in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-05-2010, 02:58 AM
  2. using glDrawPixels with MFC
    By tec in forum OpenGL: Windows
    Replies: 0
    Last Post: 11-24-2004, 06:59 AM
  3. glDrawPixels
    By jvff in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-12-2003, 05:33 PM
  4. glDrawPixels
    By in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 06-10-2003, 07:43 AM
  5. glDrawPixels help; glDrawPixels vs. Texture Mapping for bitmaps
    By vorbisus in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-11-2001, 10:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean