[SDL] sdl_ttf font sizes

Chris Thielen chris at luethy.net
Mon Jul 29 15:08:00 PDT 2002

> What you can do instead is find your initial pixel,
> then move incrementally relative to it... For example,
> to draw a line, you are generally moving from one
> pixel in one of 8 directions to an adjecent pixel. to
> move up a row, subtract pitch. to move over (left or
> right) ad or subtract sizeof(pixel), and to move down
> add pitch... so now you're adding/subtracting instead
> or multiplying....Understand?

Definitely good advice.

Another bit of advice I'd like to give people is to not use a generic,
single function to put single pixels of all color depths (or all
endianness for that matter), especially if lots of individual dots are
being drawn.

Instead, create a function pointer, and set whatever pixel
depth/endianness your given target uses :

static void (*PutPixel)(UINT32 u32X, UINT32 u32Y, UINT32 u32Pixel) = NULL;

	switch (u8Depth)
		case 8:
			PutPixel = PutPixel8bpp;
		case 16:
			if (bBigEndian)
				PutPixel = PutPixel16bppBigEndian;
				PutPixel = PutPixel16bppLittleEndian;
		case 32:
			if (bBigEndian)
				PutPixel = PutPixel32bppBigEndian;
				PutPixel = PutPixel32bppLittleEndian;



And in the code:

		PutPixel(x, y, 0x34); // Or whatever...

It seems optimization is a lost art. I really wish software developers had
to go through the equivalent of boot camp where they had almost no memory
nor code space to accomplish tasks to give them some respect for


Neil Bradley            What are burger lovers saying
Synthcom Systems, Inc.  about the new BK Back Porch Griller?
ICQ #29402898	        "It tastes like it came off the back porch." - Me

More information about the SDL mailing list