[SDL] Better performance needed - am I doing this right?

Andreas K. Foerster list at akfoerster.de
Wed Jun 6 12:09:59 PDT 2007


Hello,

I also use a bitmapped font. I use the putpixel example from the SDL 
documentation to draw directly to the software surface.
(SDL Guide / 2. Graphics and Video)

/* draws the raw char - with no interpretation */
static void
avatar_drawchar (wint_t ch)
{
  int lx, ly;
  size_t font_offset;

  font_offset = get_font_offset (ch);

  SDL_LockSurface (screen);
  for (ly = 0; ly < FONTHEIGHT; ly++)
    for (lx = 0; lx < FONTWIDTH; lx++)
      {
	if (font[font_offset + ly] & (1 << (7 - lx)))
	  putpixel (screen, cursor.x + lx, cursor.y + ly, textcolor);
      }
  SDL_UnlockSurface (screen);
}

As you can see, I don't draw the backgroud pixels. But you only have to 
add an "else"-tree to do that.

Maybe you could use the screen locks in a larger text-context.
But in my program I really want the text to be shown letter by letter,
with a SDL_Delay in between. ;-)

-- 
AKFoerster


More information about the SDL mailing list