|
Allegro.pas - Problems with Using a Bitmap Font |
RPG Hacker
Member #12,492
January 2011
|
Hi there, The pink part is color 0, the yellow part color 255 and it's saved as 256-color-BMP-image (even though ImageShack seems to automatically convert it to PNG when uploading). At first I tried the "simple" version: FUNCTION al_load_bitmap_font (filename: STRING; palette: AL_PALETTEptr; p: POINTER): POINTER; Here I had the problem that I didn't even know what the pointer p is supposed to be. It's not mentioned in the documentation. Additionally it crashed (I just tried to use "nil" for p). Next I tried the method with first loading a bmp and then grabbing a font from it. FUNCTION al_load_bmp (filename: STRING; palette: AL_PALETTEptr): AL_BITMAPptr; CDECL; EXTERNAL ALLEGRO_SHARED_LIBRARY_NAME NAME 'load_bmp'; Loading the BMP file works just fine. Even displaying it using the al_blit function works as expected. However, whenever my program gets to the grab_font part of my code it crashes, displaying random errors messages I don't understand. I've read the according entries in the documentation over and over again, but I just couldn't find the mistake. Can someone help out? Here are the portions of my code that (I think) matter. 1program RPGHacker_LPYGEntry;
2
3uses
4 sysutils,
5 allegro,
6 alfile;
7
8var
9 FontRMG2000 : AL_FONTptr;
10
11
12
13function GameInit : boolean; {Game initilization function}
14 var [...]
15 BitmapPtr : AL_BITMAPptr;
16
17begin
18 [Allegro initilization routines, including al_set_gfx_mode, go here]
19 [...]
20
21 Path := ExtractFilePath(ParamStr(0)) + '\bitmap\RPG_Hacker-Font_RMG2000.bmp';
22 BitmapPtr := al_load_bmp(Path,@al_default_palette);
23(* This here is where the crash occures *)
24 FontRMG2000 := al_grab_font_from_bitmap(BitmapPtr);
25end;
26
27[...]
EDIT: EDIT:
|
J-Gamer
Member #12,491
January 2011
|
SIGSEGV isn't the default error. It is a very common one. It means that you've tried to access something you shouldn't. Like going out of bounds in an array. " There are plenty of wonderful ideas in The Bible, but God isn't one of them." - Derezo |
RPG Hacker
Member #12,492
January 2011
|
I forgot to add "The default error I get". What I meant is that this always seems to be the cause when something goes wrong for me. Anyways, as mentioned in the EDIT, the problem is fixed now. After exporting the font with the font editor, editing it with any graphics editor seems to break it for Allegro. However, I've found out that increasing the color depth of the image to 24-Bit fixes it again.
|
|