Menu

Reducing the screen colours

Help
2006-09-13
2012-12-10
  • Nigel Symes

    Nigel Symes - 2006-09-13

    Effectively I'm just trying to tweak the example program bit by bit.

    When I try any other colour resolution than 32 bbp I get a corrupted screen. What part of the code should I be looking at to run 16bbp sucessfully?

    Thanks,

    Dingo_aus

    P.S. Bloody awesome work Nuclear!

     
    • John Tsiombikas

      John Tsiombikas - 2006-09-13

      Thank you :)
      The library works on a 32bit RGBA frame buffer internally. Eventually I'll have to implement some sort of color depth selection at initialization ala glx visuals and have the user choose the framebuffer format.

      For now, to make it work, you should convert the pixels yourself to 565 format while you feed them to SDL in a loop.
      Something like ...

      /* beware: untested, off the top of my head */
      uint16_t *dest = (uint16_t*)sdl_surf->pixels;
      uint32_t *src = fglGetFrameBuffer();
      for(i=0; i<pixel_count; i++) {
          uint32_t pix = *src++;
          *sdlptr++ = (pix & 0x1f) | ((pix & 0x3f00) >> 3) | ((pix & 0x1f0000) >> 5);
      }

      Alternatively, you could just tell SDL to work in 32bit mode and have it handle any conversions itself.

       
      • John Tsiombikas

        John Tsiombikas - 2006-09-14

        where "sdlptr" of course I meant "dest" :)
        Also note that this would assume tight scanline packing in the SDL surface.

        If that's not the case, and you get unaligned scanlines, you'll have to add something like (pitch / 2 - xsz) after each scanline , to the dest pointer.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.