I'm brand new at allegro....like less than a week old. I'm using the library for its bitmap editing functions, I have no use for the game programming aspect. I figured out how to use the standard allegro font, but I can't figure out how link up other fonts, I'm not sure if they have to be individual bitmaps for each letter, or if it supports trueType fonts. I really don't even know how to declare a FONT variable, I can't find a tutorial anywhere on the topic. The real reason why I'm here is to figure out how to increase and decrease the font size of text, I can solve the different fonts problem later. If anyone can shed some light on the topic, I'd be very greatful, because I can't figure it out.
Allegro natively only supports bitmap fonts and some other types of fonts. In 4.1.18 there's a function called load_font(), what it does should be obvious, but in older versions you have to pack your fonts in a datafile and load that. Check the manual to see how that's done. In my sig there's a link to my font editor program that can be used to make bitmap fonts from scratch and also convert true type and other types of fonts to the format Allegro supports. If you want TTF support in your program, you can get that with an add-on library. There are at least three available: AllegTTF, AllegroFont and GlyphKeeper. The first two are old and unsupported so I suggest you get GlyphKeeper. I think you should find it in the libraries section of this site. If not, see the recent threads or search the forums...
Allegro's font subsystem is rather old and in some ways a weak point. Be sure to check out the docs for the latest version and to use the latest WIP if you don't already. You may also want to get a copy of the Glyph Keeper addon-library for working with fonts.
I figured out how to use the standard allegro font, but I can't figure out how link up other fonts, I'm not sure if they have to be individual bitmaps for each letter, or if it supports trueType fonts.
Allegro natively works with bitmapped fonts. These can be taken from a bitmap image, or .grx or BIOS font files. These latter two are probably not that interesting from a present day perspective. The format for the bitmap image is outlined in the documentation I linked to above.
I really don't even know how to declare a FONT variable, I can't find a tutorial anywhere on the topic.
Font loading is in some sense a recent addition. Until recently, the only way to load fonts with Allegro was to use the grabber programme to put the font in a datafile and load that, or to use addons. That would explain the lack of a tutorial. The documentation contains example code of the load_font() function.
The real reason why I'm here is to figure out how to increase and decrease the font size of text
That, alas, you cannot do with Allegro fonts directly: Allegro's fonts are always fixed size. That said, I think that you actually can do this if you use Glyph Keeper and TrueType fonts.
So, in other words, have a quick look at Allegro's docs regarding fonts to familiarize yourself with it, then get Glyph Keeper and the latest version of Allegro.
Good luck.
That utility is incredible. The problem now is getting the program to compile. Here's the code I'm using...
PALETTE pal; get_palette(pal); FONT * f; f = load_bitmap_font("myFont.bmp", pal, NULL);
myFont is the exported font file that I have in the same directory as the program exe file. Any ideas on where I'm going wrong?
Are you sure you have Allegro 4.1.18? Did you try load_font()? What errors do you get?
well isn't that embarasing....no, I just realized that I'm using 4.0.3. Lemme update and then I'll let you know.
EDIT: I downloaded version 5.0.3, copied the include and lib folders into my VC98 folder, overwriting where necessary...changed load_bitmap_font to just load_font, and then built the program again...my errors were the same.
main.cpp C:\C++\allegroConsole\main.cpp(53) : error C2065: 'load_font' : undeclared identifier C:\C++\allegroConsole\main.cpp(53) : error C2440: '=' : cannot convert from 'int' to 'struct FONT *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
I've noticed that if a function isn't used correctly, it comes back as being undeclared, so I'm guessing if I fix the second error, the first one will go away...I think??
I downloaded version 5.0.3
Where did you find that? Does it have hardware accelerated mind control?
Seriously, you need to get 4.1.18, that's the latest released version right now...
This might be a bit tricky though. I'm not sure there's a binary release of 4.1.18 for VC. If there is, you'll first have to find it, if not, you will have to compile the source...
...sorry about that. I went to get the latest binary for VC++ and I guess since I already had one copy on my desktop entitled "...4.0.3", the next copy got renamed to 5.0.3. Anyway, it looks like maybe there isn't a binary for that new version. I've never compiled a source of any massive program like allegro, I'm sure it isn't easy, or there would be no need for binaries. If there's no other way to get around it, I guess I could compile the source...if I knew how.
EDIT: I went to the files portion of the site, however, the source that you download from there looks to be the 4.0.3 sorce (files are titled "all403..." and "allegro-4.0.3..."), this may just sound stupid, but where do you find the source you're talking about, becuase I don't seem to see it in the files portion of the site.
On the official Allegro site? Here: alleg.sourceforge.net
I beleive you'll also need MinGW, that's why compiling on VC is tricky. Allegro was originally made on a DOS port of GCC (DJGPP to be exact) and the VC version is basically just a hack. Anyway the source comes with installation instructions so check that out...
This thing is royally kicking my ass. It's looking for this environmental varable MSVCDIR...which I don't have declared. I figured out that if I go to run and type "edit autoexec.bat", I can add the file. I added:
SET MSVCDIR=C:\Program Files\Microsoft Visual Studio\VC98
to the file, but the make still tells me that the path is not set. I guess for starters, if you're running VC++, what's your MSVCDIR set to?
P.S. Your centipede game rules.
If you're using XP then you can add it to the environment variables under My computer -> (right click) -> Properties -> 'Advanced' tab -> Environment variables (the first button on the left at the bottom of the tab)
At least this is the path in the italian version of XP
After that, you'll have to open another DOS prompt for the new variable to take effect.
Otherwise you can do:
SET MSVCDIR=C:\Program Files\Microsoft Visual Studio\VC98
directly from the prompt
thanks, I set the variable...however make still isn't working...it says:
MSVCDIR environment variable is not set!
UGH!! So frustrating
Try executing vcvars32.bat (it should be somewhere in C:\Program Files\Microsoft Visual Studio\VC98\bin\vcvars32.bat before executing make. And you cannot set variables from the command prompt under Windows XP I believe.
Try executing vcvars32.bat (it should be somewhere in C:\Program Files\Microsoft Visual Studio\VC98\bin\vcvars32.bat before executing make. And you cannot set variables from the command prompt under Windows XP I believe.
I think you can, if you type in the SET command. But you can't with the bat-file. bat-file SET commands will have effect only on the copy of command processor, executing that bat-file. Safe way is to create one more bat-file in your project dir, that will have:
@call "C:\Program Files\MS Visual Studio .NET 2003\Common7\Tools\vsvars32.bat" @set MINGDIR=C:\MinGW @set PATH=C:\msys\1.0\bin;C:\MinGW\bin;%PATH% make
(or something like this, depends on your installation)
I don't think I'm gonna get this thing to work, I don't have the technical know-how to pull it off. Is there any other way to load a bitmapped font into Allegro? If not, I think I'm just gonna have to wait until they make a binary for a new version.
EDIT: As I mentioned earlier, I don't know a thing about compiling something as big as allegro from the source...but what would be wrong with just letting the files in the 4.1.18 include and lib folders just overwrite the 4.0.3 files that are already included in my VC98 folder? Is there something more to it that I don't understand, or do you think that would work? I'm expecting to be very wrong on this one, but I figured I might as well just throw it out there.
Yes, that would work. Except there's nothing in the lib folder, not until you compile the library.
You have two choices:
1. Get the technical knowhow to compile Allegro
2. Use old-style bitmap font loading
Compiling Allegro involves the following steps:
1. get MinGW and unzip MinGW to an arbitrary location that doesn't include any weird characters (e.g. C:\MINGW)
2. add C:\MINGGW\bin to your path and make a MINGDIR environment variable pointing to C:\MINGW. You do this in XP with start->control panel->system->advanced->environment variables, then locate "path" in system variables, double click it and add C:\MINGW\BIN; in front of what is already there, then click new and type MINGDIR for name and C:\MINGW for value and click OK as many times as it takes to close all the windows. Once you do all that typing gcc --v at the command prompt should print the version of gcc you just installed.
3. get the latest Allegro source and unpack it to an arbitrary location
4. open a command prompt and run your VC's vcvars32.bat
5. cd to the base Allegro directory and run the following commands:
fix msvc
make
make install
The old-style method of loading bitmap fonts involves the folowing steps:
1. create a font and save it as either PCX, BMP or TGA
2. run grabber.exe and create a new font
3. import your font bitmap
4. save the datafile
5. in your program load the datafile; the font will be the object at index 0; if you code in C++ you must cast the font object to FONT*
6. close the datafile only when you're done using the font
Hope that helps...
I don't remember it being this difficult to compile Allegro... then again, I use MinGW...
Yeah, that actually helped a lot. I downloaded the MinGW setup file and ran it, I followed your steps exactly, but from the command prompt, while working in the allegro directory, I typed 'fix msvc', and my output was:
C:\allegro>fix msvc Configuring Allegro for Windows/MSVC... Converting Allegro files to DOS CR/LF format... 'utod' is not recognized as an internal or external command, operable program or batch file. 'utod' is not recognized as an internal or external command, operable program or batch file. Done!
I'm not sure what I did wrong on that one.
On a second attempt, I gave it one more shot using cygwin, and I got as far as make...but the make gave me a bunch of errors.
$ make Compiling Allegro for MSVC, optimised. Please wait... obj/msvc/runner.exe cl @ -nologo -DALLEGRO_SRC -W1 -Gd -Ox -GB -MD -I. -I./inclu de -Foobj/msvc/alleg/wwnd.obj -c src/win/wwnd.c wwnd.c src/win/wwnd.c(583) : error C2065: 'TITLEBARINFO' : undeclared identifier src/win/wwnd.c(583) : error C2146: syntax error : missing ';' before identifier 'tb_info' src/win/wwnd.c(583) : error C2065: 'tb_info' : undeclared identifier src/win/wwnd.c(584) : error C2143: syntax error : missing ';' before 'type' src/win/wwnd.c(585) : error C2143: syntax error : missing ';' before 'type' src/win/wwnd.c(590) : error C2065: 'last_w' : undeclared identifier src/win/wwnd.c(590) : error C2065: 'last_h' : undeclared identifier src/win/wwnd.c(597) : error C2224: left of '.cbSize' must have struct/union type src/win/wwnd.c(599) : error C2065: 'tb_height' : undeclared identifier src/win/wwnd.c(601) : error C2224: left of '.rcTitleBar' must have struct/union type src/win/wwnd.c(601) : error C2224: left of '.rcTitleBar' must have struct/union type make: *** [obj/msvc/alleg/wwnd.obj] Error 2
So, on a third attempt, I ran the grabber program, loaded my bitmap, nothing seemed to change, I played around a bit, and hit grab from grid, afterwhich I could see my letters. I saved the datafile, and started coding again. This was the code I used:
DATAFILE * test = load_datafile("data.dat"); FONT * myFont = FONT*(test[0]);
I got the following errors:
C:\C++\allegroConsole\main.cpp(53) : error C2440: 'type cast' : cannot convert from 'struct DATAFILE' to 'struct FONT' No constructor could take the source type, or constructor overload resolution was ambiguous Error executing cl.exe.
I'm pretty sure I messed up the casting call, it says that test is of type struct, so I tried popfront-ing it, but that didn't work either. I think my best bet it to try to get the casting call to work, I don't think I'm ever gonna get 4.1.18 working properly. If you know what I did wrong, your help would be appreciated.
In grabber create a new font (!!!) and then grab the bitmap. When you cast you have to cast the dat member:
FONT *myFont = (FONT *)(test[0].dat);
...or something like that. This is actually described in the manual of all places, if you beleive it or not...
As for compiling the Allegro source, you're right, you probably won't be able to do it. You could try harder to follow the instructions but that probably only works for everyone else other than you...
wow... Major harshness there Miran...
I'm not sure what I did wrong on that one.
Nothing. Ignore what it says about utod not being available, it doesn't matter. Especially not if you downloaded the zip distribution.
If you want, you can get rid of it by passing --quick on the fix commandline. If you use CVS, you can also pass it --msvcpaths, which will fix some possible problems if the path contains spaces.
On a second attempt, I gave it one more shot using cygwin, and I got as far as make...but the make gave me a bunch of errors.
I think Andrei reported that compiling with Cygwin currently doesn't work. This particular problem is a known issue that was fixed in CVS (but is temporarily back again). You can work around it by grabbing wwnd.c from 4.1.17, or just not use Cygwin.
I tried to go both routes...but I'm not quite understanding minGW just yet. Per Miran's directions, I ran 'fix msvc' from the command prompt while working in allegro's directory. Once I added --quick, those errors indeed went away. The next direction says to just type 'make'...however that's not a command line command, that's a compiler command, so I ran that command inside the cygwin shell...but for minGW, I don't see a shell like cygwin has. Does minGW even have a shell?
EDIT: I just figured out what that PATH thing does...I think it means that if I go into any program directory, and type g++ someFile.cpp, the minGW g++ program will run since it's in C:\MINGW\bin...which is in my path. However, running 'make' doesn't work. There is no make program in C:\MINGW\bin. I tried gnatmake (not knowing what it does), but that didn't work. 'Make' only worked before because I executed it from inside the cygwin shell. If I'm not in the shell, cmd tells me that make isn't a recognized command.END EDIT
As for the other route, I figured out how to use a CVS, grabbed what I believe was the 4.1.17 version of wwnd.c, I ran a diff between the one I grabbed and the one that came from 4.1.18, there was a difference, so I think I grabbed the right one. Inside of cygwin, it compiled until the very last part. Cygwin said that there were too many arguements.
$ make Compiling Allegro for MSVC, optimised. Please wait... obj/msvc/runner.exe link @ -nologo -release -dll -def:lib/msvc/allegro.def -out: lib/msvc/alleg41.dll -implib:lib/msvc/alleg.lib obj/msvc/alleg/allegro.obj obj/m svc/alleg/blit.obj obj/msvc/alleg/bmp.obj obj/msvc/alleg/clip3d.obj obj/msvc/all eg/clip3df.obj obj/msvc/alleg/colblend.obj obj/msvc/alleg/color.obj obj/msvc/all eg/config.obj obj/msvc/alleg/datafile.obj obj/msvc/alleg/dataregi.obj obj/msvc/a lleg/digmid.obj obj/msvc/alleg/dither.obj obj/msvc/alleg/dispsw.obj obj/msvc/all eg/drvlist.obj obj/msvc/alleg/file.obj obj/msvc/alleg/fli.obj obj/msvc/alleg/flo od.obj obj/msvc/alleg/font.obj obj/msvc/alleg/fontbios.obj obj/msvc/alleg/fontbm p.obj obj/msvc/alleg/fontdat.obj obj/msvc/alleg/fontgrx.obj obj/msvc/alleg/fontt xt.obj obj/msvc/alleg/fsel.obj obj/msvc/alleg/gfx.obj obj/msvc/alleg/glyph.obj o bj/msvc/alleg/graphics.obj obj/msvc/alleg/gsprite.obj obj/msvc/alleg/gui.obj obj /msvc/alleg/guiproc.obj obj/msvc/alleg/inline.obj obj/msvc/alleg/joystick.obj ob j/msvc/alleg/keyboard.obj obj/msvc/alleg/lbm.obj obj/msvc/alleg/libc.obj obj/msv c/alleg/math.obj obj/msvc/alleg/math3d.obj obj/msvc/alleg/midi.obj obj/msvc/alle g/mixer.obj obj/msvc/alleg/modesel.obj obj/msvc/alleg/mouse.obj obj/msvc/alleg/p cx.obj obj/msvc/alleg/poly3d.obj obj/msvc/alleg/polygon.obj obj/msvc/alleg/quant ize.obj obj/msvc/alleg/quat.obj obj/msvc/alleg/readbmp.obj obj/msvc/alleg/readfo nt.obj obj/msvc/alleg/readsmp.obj obj/msvc/alleg/rle.obj obj/msvc/alleg/rotate.o bj obj/msvc/alleg/scene3d.obj obj/msvc/alleg/sound.obj obj/msvc/alleg/spline.obj obj/msvc/alleg/stream.obj obj/msvc/alleg/text.obj obj/msvc/alleg/tga.obj obj/ms vc/alleg/timer.obj obj/msvc/alleg/unicode.obj obj/msvc/alleg/vtable.obj obj/msvc alleg/vtable15.obj obj/msvc/alleg/vtable16.obj obj/msvc/alleg/vtable24.obj obj msvc/alleg/vtable32.obj obj/msvc/alleg/vtable8.obj obj/msvc/alleg/iblit16.obj ob j/msvc/alleg/iblit24.obj obj/msvc/alleg/iblit32.obj obj/msvc/alleg/iblit8.obj ob j/msvc/alleg/icpu.obj obj/msvc/alleg/icpus.obj obj/msvc/alleg/icsprite.obj obj/m svc/alleg/igfx15.obj obj/msvc/alleg/igfx16.obj obj/msvc/alleg/igfx24.obj obj/msv c/alleg/igfx32.obj obj/msvc/alleg/igfx8.obj obj/msvc/alleg/imisc.obj obj/msvc/al leg/iscan.obj obj/msvc/alleg/iscanmmx.obj obj/msvc/alleg/ispr15.obj obj/msvc/all eg/ispr16.obj obj/msvc/alleg/ispr24.obj obj/msvc/alleg/ispr32.obj obj/msvc/alleg /ispr8.obj obj/msvc/alleg/istretch.obj obj/msvc/alleg/izbuf.obj obj/msvc/alleg/i colconv.obj obj/msvc/alleg/asmlock.obj obj/msvc/alleg/dllver.obj obj/msvc/alleg/ gdi.obj obj/msvc/alleg/wddaccel.obj obj/msvc/alleg/wddbmp.obj obj/msvc/alleg/wdd bmpl.obj obj/msvc/alleg/wddraw.obj obj/msvc/alleg/wddfull.obj obj/msvc/alleg/wdd lock.obj obj/msvc/alleg/wddmode.obj obj/msvc/alleg/wddovl.obj obj/msvc/alleg/wdd win.obj obj/msvc/alleg/wdsinput.obj obj/msvc/alleg/wdsndmix.obj obj/msvc/alleg/w dsound.obj obj/msvc/alleg/wsndwo.obj obj/msvc/alleg/wdxver.obj obj/msvc/alleg/wd ispsw.obj obj/msvc/alleg/wfile.obj obj/msvc/alleg/wgdi.obj obj/msvc/alleg/wgfxdr v.obj obj/msvc/alleg/winput.obj obj/msvc/alleg/wjoydrv.obj obj/msvc/alleg/wjoydx .obj obj/msvc/alleg/wjoyhelp.obj obj/msvc/alleg/wjoyw32.obj obj/msvc/alleg/wkeyb d.obj obj/msvc/alleg/wmidi.obj obj/msvc/alleg/wmouse.obj obj/msvc/alleg/wsnddrv. obj obj/msvc/alleg/wsystem.obj obj/msvc/alleg/wthread.obj obj/msvc/alleg/wtimer. obj obj/msvc/alleg/wwnd.obj obj/msvc/alleg/colconv.obj obj/msvc/alleg/pckeys.obj kernel32.lib user32.lib gdi32.lib comdlg32.lib ole32.lib dinput.lib ddraw.lib d xguid.lib winmm.lib dsound.lib link: too many arguments Try `link --help' for more information. make: *** [lib/msvc/alleg41.dll] Error 1
Which makes sense to me, but somehow everybody else gets this thing to compile.
Back to what Miran said, I'm currently trying to figure out how to make a new font...I don't see a file>new anywhere. All I see is load, or load bitmap, which is what I figured is as close to new as I'm gonna get, but who knows. Obviously I was wrong becuase even though my program compiled, I got a runtime error and it crashed. So I'm gonna keep tweaking this thing, or try to just use the base font until a binary is released. It'll suck, but it's getting to the point where it's taking me more time to compile allegro just to get the libraries out of it than it would for me to just make my program using the base font.
Does minGW even have a shell?
Command prompt, use the command prompt! start->run, type in cmd and press enter. You will see a black window where you can type commands.
About make not working, try mingw32-make or something like that. Or look in the MinGW/bin directory and rename mingw32-make.exe to make.exe...
And please do yourself a favour and forget about cygwin...
I don't see a file>new anywhere.
No, but there's object->new->font....
Oh and congratulations on figuring out what path does...
And please do yourself a favour and forget about cygwin...
Or at least remember this rule when you have more than one version of gcc installed (cygwin and mingw are both versions of gcc). DON'T HAVE MORE THAN ONE GCC /BIN DIR ON THE PATH. The only time you would break this rule is when you are cross-compiling (compiling for another machine).
The only time you would break this rule is when you are cross-compiling (compiling for another machine).
Even then you shouldn't.
sorry about the whole cygwin thing, I'm only a college sophomore and we compile everything in cygwin...it's just what I know. Unfortunately that's all I know. However, from my experiece I see how mingw has some serious advantages. Either way, that last little addition from Miran did it for me, I'll wait til a binary comes out, I got the grabber/datafile method working fine, thanks a million Miran for your help. Sorry if I annoyed you.
Cygwin is a full *nix environment emulator, while MinGW only brings the executables. I prefer the MinGW+MSYS combo than the extremely bloated Cygwin one.
Which makes sense to me, but somehow everybody else gets this thing to compile.
As I said, Allegro currently doesn't compile with Cygwin. The problem is that link is programme that comes with Cygwin as well as the name of MSVC's linker. And it's calling the wrong one.
I think Andrei Ellman has a possible workaround, so you may want to ask him about it. This has yet to be fixed in CVS.
It's alright, I'm not a game programmer...I'm just using allegro to edit some bitmaps, getting the most recent release isn't of much concern if there's a workaround, which Miran was able to help me with, and that's I needed...although I don't see it happening, if I need to update, I'll figure it out at a later time.