Mail Archives: djgpp/1997/08/25/06:06:31
"moabdib" (moabdib AT arrakis DOT es) writes:
> with textout i can print string, how can i use to print variables?
Put the following in a file called something.c, compile it into a .o, and
add it to liballeg.a using ar and some arcane command line switches. :-)
(Shawn, want to test this and stick it into WIP?)
/* gfxprintf.c
Printf-alikes for graphic printing with Allegro.
Copyright (C) 1997 PGD, freely distributable, no warranty, and this might
need slight tweaking/debugging as I only have the libc/allegro references
right here right now. */
#include <stdio.h>
#include <varargs.h>
#include <allegro.h>
void gfxprintf (BITMAP *bmp,FONT *fnt,int sx,int sy,int c,char *format,...);
void gfxprintf_centre (BITMAP *bmp,FONT *fnt,int sx,int sy,int c,char *format,...);
void gfxprintf (BITMAP *bmp,FONT *fnt,int sx,int sy,int c,char *format,...) {
va_list args;
char buf[256];
va_start(args);
vsprintf(buf,format,args);
va_end(args);
textout(bmp,fnt,(unsigned char *)buf,sx,sy,c);
}
void gfxprintf_centre (BITMAP *bmp,FONT *fnt,int sx,int sy,int c,char *format,...) {
va_list args;
char buf[256];
va_start(args);
vsprintf(buf,format,args);
va_end(args);
textout_centre(bmp,fnt,(unsigned char *)buf,sx,sy,c);
}
--
.*. Where feelings are concerned, answers are rarely simple [GeneDeWeese]
-() < When I go to the theater, I always go straight to the "bag and mix"
`*' bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh
- Raw text -