Pixels vs blit

Hello Everyone,

I wonder if that question was already discussed or not. I’m working
on my own minimalistic lib to show font on the screen. I’ve already
implemented a lot of stuff I need but now I have following question:

What’s faster:

  1. Lock the surface and draw pixels directly to surface.

or

  1. Create a surface with a font out of the font array and then blit
    rectangles wherever I need to show text.

?–
Lynx,
http://dotNet.lv mailto:@Anatoly_R

Hello Everyone,

I wonder if that question was already discussed or not. I’m working
on my own minimalistic lib to show font on the screen. I’ve already
implemented a lot of stuff I need but now I have following question:

What’s faster:

  1. Lock the surface and draw pixels directly to surface.

or

  1. Create a surface with a font out of the font array and then blit
    rectangles wherever I need to show text.

The winner is… #2!

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

I’m fairly certain that this is the faster option.On Mon, 2003-01-20 at 05:46, Anatoly R. wrote:

  1. Create a surface with a font out of the font array and then blit
    rectangles wherever I need to show text.

I wonder if that question was already discussed or not. I’m working
on my own minimalistic lib to show font on the screen. I’ve already
implemented a lot of stuff I need but now I have following question:

What’s faster:

  1. Lock the surface and draw pixels directly to surface.

or

  1. Create a surface with a font out of the font array and then blit
    rectangles wherever I need to show text.

The winner is… #2!

Doesn’t that mean that you can’t draw text in different colours though?
(Not the original question I know, but still of interest maybe.)

Unless you can somehow apply a bitmask while blitting. If your font was
stored as white (0xFFFFFF), you could AND with 0xFF0000 while blitting to
get red text, for example. Is this possible? Otherwise, how would you draw
text of arbitrary colours without plotting pixels individually?

Explore Winning Strategies for CIOs
At IDC’s Asia/Pacific IT Forum 2003:
"Beating Bottlenecks – Key Priorities for CIOs"
January 21, 2003 – Singapore
January 23, 2003 – Beijing
For more information, visit http://www.idc.com.sg/apit2003

Hello James,

Wednesday, January 22, 2003, 2:29:42 PM, you wrote:

JE> Doesn’t that mean that you can’t draw text in different colours though?
JE> (Not the original question I know, but still of interest maybe.)

JE> Unless you can somehow apply a bitmask while blitting. If your font was
JE> stored as white (0xFFFFFF), you could AND with 0xFF0000 while blitting to
JE> get red text, for example. Is this possible? Otherwise, how would you draw
JE> text of arbitrary colours without plotting pixels individually?

Yes, that’s the only problem I’m aware of. However I don’t need
multiple font colors right now so I’m thinking what should I do…–
Lynx,
http://dotNet.lv mailto:@Anatoly_R

At 2003-01-23 11:35, you wrote:

Hello James,

Wednesday, January 22, 2003, 2:29:42 PM, you wrote:

JE> Doesn’t that mean that you can’t draw text in different colours though?
JE> (Not the original question I know, but still of interest maybe.)

JE> Unless you can somehow apply a bitmask while blitting. If your font was
JE> stored as white (0xFFFFFF), you could AND with 0xFF0000 while blitting to
JE> get red text, for example. Is this possible? Otherwise, how would you draw
JE> text of arbitrary colours without plotting pixels individually?

Yes, that’s the only problem I’m aware of. However I don’t need
multiple font colors right now so I’m thinking what should I do…

Actually, I use the technique too. If you don’t mind using a bit of extra
memory, some preparation and don’t want to use all color possibilities you
can do this: I have stored the font in white in a bitmap. When the game
starts I then simply load the bitmap four times, and go along the surfaces
pixel by pixel once to change the color (the masking takes into account the
brightness of each pixel, so that my fonts do display reasonably
anti-aliassed as long as the background is dark ;-).

I know it takes up a lot of video (or system) memory, but it seemed the
best solution at the time for me since I did not have access to any
(useable) font-routines. The main disadvantage I am running into at the
moment though, is that it’s almost impossible to add support for other
charactersets (e.g. russian, chinese, etc.) without rewriting large parts
of my code. Fortunately I already have most accented characters so that
translation to languages like english, french, german, spanish are possible…

Just pointing out a completely different method:

StepMania uses SDL+OpenGL, using texture fonts. We can get arbitrary
coloring, blending, and alpha shadows very quickly. Fonts are usually
full RGBA, so the font can have color in it directly (for fullcolor
fonts or simple borders; we use diffuse color on top of that). Fonts
are antialiased on the alpha channel. We could even fit a 2000-glyph
grayscale Kanji font in memory in less than a meg (using a 4-bit alpha
texture, 2048 glyphs at 24x24 pixels each is 576k).On Thu, Jan 23, 2003 at 08:39:03PM +0100, M. Egmond wrote:

I know it takes up a lot of video (or system) memory, but it seemed the
best solution at the time for me since I did not have access to any
(useable) font-routines. The main disadvantage I am running into at the
moment though, is that it’s almost impossible to add support for other
charactersets (e.g. russian, chinese, etc.) without rewriting large parts
of my code. Fortunately I already have most accented characters so that
translation to languages like english, french, german, spanish are
possible…


Glenn Maynard

Hello M.,

Thursday, January 23, 2003, 9:39:03 PM, you wrote:

JE> Doesn’t that mean that you can’t draw text in different colours though?
JE> (Not the original question I know, but still of interest maybe.)

JE> Unless you can somehow apply a bitmask while blitting. If your font was
JE> stored as white (0xFFFFFF), you could AND with 0xFF0000 while blitting to
JE> get red text, for example. Is this possible? Otherwise, how would you draw
JE> text of arbitrary colours without plotting pixels individually?

Yes, that’s the only problem I’m aware of. However I don’t need
multiple font colors right now so I’m thinking what should I do…

ME> Actually, I use the technique too. If you don’t mind using a bit of extra
ME> memory, some preparation and don’t want to use all color possibilities you
ME> can do this: I have stored the font in white in a bitmap. When the game
ME> starts I then simply load the bitmap four times, and go along the surfaces
ME> pixel by pixel once to change the color (the masking takes into account the
ME> brightness of each pixel, so that my fonts do display reasonably
ME> anti-aliassed as long as the background is dark ;-).
ME> I know it takes up a lot of video (or system) memory, but it seemed the
ME> best solution at the time for me since I did not have access to any
ME> (useable) font-routines.

Well, my pixel-by-pixel font drawing routine seems to be much more
customisable… It’s possible to create any color font surfaces out of
internal fonts which are stored as arrays. And destroy them… I think
I’ll leave both options or combine that together, that seems to be
very interesting.

ME> The main disadvantage I am running into at the
ME> moment though, is that it’s almost impossible to add support for other
ME> charactersets (e.g. russian, chinese, etc.) without rewriting large parts
ME> of my code. Fortunately I already have most accented characters so that
ME> translation to languages like english, french, german, spanish are possible…

I’m storing characters in array (ASCII 30-127). I can fill that array
with anything I want ;)–
Lynx,
http://dotNet.lv mailto:@Anatoly_R

Hello Glenn,

Thursday, January 23, 2003, 9:57:57 PM, you wrote:

GM> Just pointing out a completely different method:

GM> StepMania uses SDL+OpenGL, using texture fonts. We can get arbitrary
GM> coloring, blending, and alpha shadows very quickly. Fonts are usually
GM> full RGBA, so the font can have color in it directly (for fullcolor
GM> fonts or simple borders; we use diffuse color on top of that). Fonts
GM> are antialiased on the alpha channel. We could even fit a 2000-glyph
GM> grayscale Kanji font in memory in less than a meg (using a 4-bit alpha
GM> texture, 2048 glyphs at 24x24 pixels each is 576k).

Ehm, I don’t want to use OpenGL. I’m working with 2D apps for now and
don’t like the idea of moving to OpenGL.

BTW StepMania is great, we’ve spent hunderds of hours playing it.–
Lynx,
http://dotNet.lv mailto:@Anatoly_R

“Anatoly R.” wrote:

ME> The main disadvantage I am running into at the
ME> moment though, is that it’s almost impossible to add support for
ME> other charactersets (e.g. russian, chinese, etc.) without
ME> rewriting large parts of my code. Fortunately I already have most
ME> accented characters so that translation to languages like english,
ME> french, german, spanish are possible…

I’m storing characters in array (ASCII 30-127). I can fill that array
with anything I want :wink:

hmm, how do you store 10000 chinese characters in that array?

just woders
clemens (SCNR)

I’m storing characters in array (ASCII 30-127). I can fill that array
with anything I want :wink:

hmm, how do you store 10000 chinese characters in that array?

just woders

Ehm, most of my fonts are 8x8 :slight_smile: I don’t need to support china, they are
self-supported
;)---------------------------------------------
This message was sent using Endymion MailMan.
http://www.endymion.com/products/mailman/