Results 1 to 4 of 4

Thread: 32 bit textures on 16 bit framebuffer

  1. #1

    32 bit textures on 16 bit framebuffer

    I have an MBX lite chip mounted on a iMX31. Display is 16bpp, so window surfaces and context can be opened only in 565 (without alpha channel). If i create a 32bit texture with glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels32) the driver seems to upload pixels inside its dedicated texture ram in a 4444 format, resulting (when the texture is used) in an ugly/low color block artifacts.

    If i upload pixels in 5551 format, like this glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, pixels16) the driver seems to hold the pixels as they are, without downsampling they in an internal 4444 format like in the case above.

    How can i make the OpenGL|ES driver use a full 32bit texture? i think that the screen format conversion must be done only when a pixel is going to be written, so if i use a 32bit texture, then a conversion to the framebuffer 565 format is done only in the final stage, not when texture is loaded...am i right?

    In addition the driver seems to report an extension called GL_IMG_texture_format_BGRA8888, that seems not be documented. Is that extension the thing i miss to make the chip use internal 32bit textures/calculations? Can someone tell me how that extension can be used? Can someone tell me if it refers to an additional texture format (like for example GL_RGBA). In this case can someone give me the correct enumerated value correspoinding to that format?

    Thanks in advance.
    AmanithVG Lead Programmer

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    353
    GL_IMG_texture_format_BGRA8888 defines a new token, GL_BGRA, as 0x80E1. (That's the same value as in GL_EXT_bgra, btw). This token can be used as <internalformat> and <format> argument to glTexImage2D/glTexSubImage2D in combination with GL_UNSIGNED_BYTE.

    In your code that would be:
    Code :
    #ifndef GL_BGRA
    #define GL_BGRA 0x80E1
    #endif
     
    // convert pixels32 from RGBA to BGRA
     
    glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, 128, 128, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels32);
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  3. #3
    Thank you very much, it seems to work perfectly.
    Anyway, i was wondering why using GL_RGBA format, the driver must upload (the given 32bit pixels) in its texture ram in 4444 format.

    The common sense would say that if GL_BGRA (0x80E1) works, it's dual (GL_RGBA, that is in the OpenGL|ES 1.x baseline, so it's official and *more* common for developers and applications) must works too (at least it must have the same behavior respect to the internal format storage, not considering the byte ordering).
    AmanithVG Lead Programmer

  4. #4
    Junior Member
    Join Date
    Aug 2008
    Posts
    1

    Re:

    Quote Originally Posted by Xmas
    GL_IMG_texture_format_BGRA8888 defines a new token, GL_BGRA, as 0x80E1. (That's the same value as in GL_EXT_bgra, btw). This token can be used as <internalformat> and <format> argument to glTexImage2D/glTexSubImage2D in combination with GL_UNSIGNED_BYTE.
    On Apple's iPhone SDK, RGBA must be used as the internalformat when passing in BGRA data. So an example texture upload becomes:

    Code :
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels32);

    This might help other iPhone developers who stumble onto this page via a search, since there is no other documentation of this extension.

Similar Threads

  1. Replies: 0
    Last Post: 08-02-2012, 09:18 AM
  2. 16 bit integer Atomics
    By thesmileman in forum Suggestions for next release
    Replies: 5
    Last Post: 12-15-2011, 03:22 PM
  3. Support for bit-fields
    By ivalylo in forum Suggestions for next release
    Replies: 1
    Last Post: 05-13-2011, 06:51 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
  •