I'm having problems with displaying fonts in a program i'm writing.
When I try to compile the program DEVC++ throws up the following error message:
C:\Documents and Settings\GFSmith\Desktop\blank\blank.cpp cannot convert `DATAFILE' to `const FONT*' for argument `2' to `void textout_ex(BITMAP*, const FONT*, const char*, int, int, int, int)'
I've written programs in the past using RHIDE and allegro and haven't had any problems displaying my own fonts, so is there anything obvious i'm missing or is it something else. 
| 1 | main.cpp |
| 2 | #include <allegro.h> |
| 3 | #include "FONTS.H" |
| 4 | DATAFILE *data; |
| 5 | |
| 6 | int main(void) |
| 7 | { |
| 8 | /* you should always do this at the start of Allegro programs */ |
| 9 | if (allegro_init() != 0) |
| 10 | return 1; |
| 11 | |
| 12 | /* set up the keyboard handler */ |
| 13 | install_keyboard(); |
| 14 | /* set colour depth to 16 bits */ |
| 15 | set_color_depth(16); |
| 16 | /* set a graphics mode */ |
| 17 | set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0) != 0; |
| 18 | |
| 19 | data=load_datafile("FONTS.DAT"); |
| 20 | |
| 21 | textout_ex(screen, font, "NORMAL FONT", 10, 10,makecol(255, 255, 255), -1); |
| 22 | textout_ex(screen, data[slip22], "NEW FONT", 10, 50,makecol(255, 255, 255), -1); |
| 23 | |
| 24 | /* wait for a keypress */ |
| 25 | readkey(); |
| 26 | return 0; |
| 27 | } |
| 28 | |
| 29 | END_OF_MAIN() |
FONTS.DAT was created using grabber.
Many thanks.
Try this:
textout_ex(screen, (FONT*)data[slip22].dat, "NEW FONT", 10, 50,makecol(255, 255, 255), -1);
When accessing datafile objects, you need to type cast and you also need to access the .dat member of the array.
--- Kris Asick (Gemini)
--- http://www.pixelships.com
Thanks for your help Kris, it now works.