Exemplo n.º 1
0
static void
render_glyph(int32 x, int32 y, uint8 glyph, uint8 attr)
{
	// we're ASCII only
	if (glyph > 127)
		glyph = 127;

	if (sConsole.depth >= 8) {
		uint8* base = (uint8*)(sConsole.frame_buffer
			+ sConsole.bytes_per_row * y * CHAR_HEIGHT
			+ x * CHAR_WIDTH * sConsole.bytes_per_pixel);
		uint8* color = get_palette_entry(foreground_color(attr));
		uint8* backgroundColor = get_palette_entry(background_color(attr));

		for (y = 0; y < CHAR_HEIGHT; y++) {
			uint8 bits = FONT[CHAR_HEIGHT * glyph + y];
			for (x = 0; x < CHAR_WIDTH; x++) {
				for (int32 i = 0; i < sConsole.bytes_per_pixel; i++) {
					if (bits & 1)
						base[x * sConsole.bytes_per_pixel + i] = color[i];
					else {
						base[x * sConsole.bytes_per_pixel + i]
							= backgroundColor[i];
					}
				}
				bits >>= 1;
			}

			base += sConsole.bytes_per_row;
		}
	} else {
Exemplo n.º 2
0
/**
 * Convert paletted texture to color texture.
 */
static void
paletted_to_color(const struct cpal_format_info *info, const GLubyte *palette,
                  const void *indices, GLuint num_pixels, GLubyte *image)
{
   GLubyte *pix = image;
   GLuint remain, i;

   if (info->palette_size == 16) {
      /* 4 bits per index */
      const GLubyte *ind = (const GLubyte *) indices;

      /* two pixels per iteration */
      remain = num_pixels % 2;
      for (i = 0; i < num_pixels / 2; i++) {
         pix += get_palette_entry(info, palette, (ind[i] >> 4) & 0xf, pix);
         pix += get_palette_entry(info, palette, ind[i] & 0xf, pix);
      }
      if (remain) {
         get_palette_entry(info, palette, (ind[i] >> 4) & 0xf, pix);
      }
   }
   else {