I've only just started with Allegro and I'm loving it so far, so this might be something which is easy to write myself, but I was wondering if it'd be possible to make versions of the blitting commands which take the graphical data from bitmap, but the mask data from another bitmap. So you could have a font as a series of masks, and then just draw it in any texture you liked?
Or is it fairly easy to find the genuine allegro code that does the blitting and make my own version of it? Bare in mind, kinda' beginner here.
Thanks,
Graham Goring
]]>That's one of the features most of would like to see
Guess it's time somebody writes that function in a correct way now. I know that a couple of people here have written small hack doing that thing (including) me, but I doubt one wrote an optimized and clean version of it yet.
You could have a look at my last years speedhack entry "love&peace" which did something like this for the screen transition effects.
]]>Most likely the easiest way to do it is to make a 2 color bitmap for your mask, and program your own function to do the blitting. I don't think there is really a way around it..
]]>Thanks muchly. I suspected I'd have to do it myself. Y'know given that the source to Allegro is included how difficult would it be write your own function parrot-fashion? I'd have thought it couldn't be too difficult... I mean can you access the innards BITMAP structures fairly easily?
I might well have a looksee later.
Well, I just had a look and, um, I think I'll see what you did, Spellcaster, and use that. Ta'.
]]>I mean can you access the innards BITMAP structures fairly easily?
It's in the docs: clicky
]]>Welcome to the world of Allegro Graham!
Hope you have fun and looking forward to seeing some great games from you.
]]>Most likely the easiest way to do it is to make a 2 color bitmap for your mask, and program your own function to do the blitting. I don't think there is really a way around it..
According to someone or another on #allegro the other day, RLE sprites don't run length encode everything, just the blank space. They still blit the visible pixels from the pixel buffer source. If that information is accurate (and I can't remember who said it, so don't ask me...) the very easiest way would be to build an RLE sprite of the mask, then flip the (BITMAP *)->line pointers to the actual bitmap...
Just be careful before you destroy_bitmap!
P.s. the c.s.s. Graham Goring? You Retrospec'ing nowadays?
]]>I had the same idea come up and wanted to impliment it... only I need a version that was close to masked_stretch_blit as well and of course I haven't even began breaking ground on that one. When I get the time sometime soon (hopefully) I'll take a whack at it. The approach I'd take is the standard magic pink for transparency and gray (128, 128, 128) for drawing magic_pink onto the destination bitmap, which would be masked_blit to the screen.... or gray would draw from a third bitmap... or something
]]>I had a look at my code from speedhack2003 (why isn't there an speedhack archive / shrine? Took me some time to find l&p in my back-ups) and what I did was using getpixel/ putpixel in the init routine to build another sprite before the actual game starts.
]]>gnolam - thanks, I had a read of that and quite frankly it scared me. Scared me like when a moth lands on your face a night... That said, if I'm just creating memory bitmaps it might not be so bad... Anyhoo, ta' for the link!
Richard, thanks muchly. I'm hoping I manage to get some decent stuff done myself. Luckily I come from Blitz 2D and it ports over to C/Allegro really quite painlessly. Plus now I have the lovely scaling, rotation and transparency that B2D doesn't offer.
Thomas, that's me, yeah. I don't go to CSS any more just because it's a hassle using Outlook Express or any other newsreader in addition to regular Outlook and I get plenty of retro-nostalgia just waxing lyrical on the Retro Remakes forums. As for Retrospec I'm just finishing off the Head Over Heels graphics for Tomaz Kac.
Steve, I suspect I'll do something very similar, just create a nice tall bitmap with all the blocks of colour in it, then go over it letter by letter sticking the font onto it. You know, it'd be a shedload less hassle if we could just blimmin' specify a mask colour for non 8-bit modes because then it'd just be a case of drawing one image over another and then plonking that image to the screen. Now there's something Blitz actually did better than Allegro.
Spellcaster - Actually I think pre-processing might be a bit limiting as I want LOADS of different effects and tying up memory is a bit much considering the amount I'll need.
]]>I get plenty of retro-nostalgia just waxing lyrical on the Retro Remakes forums. As for Retrospec I'm just finishing off the Head Over Heels graphics for Tomaz Kac
Hmmm. Retro Remakes used to host me, but now they don't host anyone.... congratulations on being involved in game of the year! (even if the Edge Retro House was a bit dull)
Anyway, my useful addition. You can achieve an arbitrary (single) mask colour without delving into the BITMAP struct with a few extra function calls. I will consider that you have a 'mask' bitmap, and an 'image' bitmap.
Take your two source BITMAPs, and create an intermediate one big enough to fit the largest.
Set DRAW_MODE_XOR for both the intermediate BITMAP and the one that contains the mask.
Blit the image bitmap to the intermediate one.
Calculate the exclusive or of the mask colour you want to use and the Allegro pre-defined mask colour. So, e.g. in high or true colour:
xormask = makecol(maskr, maskg, maskb) ^ makecol(255, 0, 255);
Obviously in 8bpp:
xormask = maskcol;
Use rectfill to a rectangle of colour xormask to the intermediate and mask bitmaps.
Masked blit the mask bitmap to the intermediate bitmap.
Use rectfill again to draw a rectangle of colour xormask to the intermediate bitmap.
Blit the intermediate bitmap to the screen.
If you really want to return the mask bitmap to its original state, draw an xormask coloured rectangle to it as well.
You can set the drawing mode at load time because it only affects geometric drawing operations (i.e. rectfill but not blit) and obviously preallocate your intermediate bitmap and pre rectfill your mask bitmap if that is an option.
]]>Ta' Thomas that seems like a pretty nifty way of doing things, although perhaps more graphic passes than I'd prefer. I'm gonna' look into delving into the BITMAP structure itself to see which is gonna' be fastest.
Thinking about it, I've been an idiot. All I need to do is draw my font in Magenta on black, then I draw all the bits of texture to an image I create, mask_blit all the letters over it and then output the result to the screen. What an idiot I've been. I was just hung up because my original Blitz version used White fonts so that I could just output them to the screen as-is for better speed if I wanted. Idiot idiot idiot! Sorry folks!
Nope, wait, changed my mind again. That'll result in a letter with a black mask and that won't work. Darn darn darn.
]]>