From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: Any Allegro users want to help? Date: Mon, 30 Dec 1996 19:49:14 +0000 Organization: None Lines: 70 Distribution: world Message-ID: References: <01bbf45d$777df560$932449c2 AT default> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp >Anyway, is there anyone who is feeling charitable enough to help me with a >few Allegro basics? All I want to do is initiate a graphics mode (basic VGA >will do, but I'd prefer to have the option), write filled triangles to a >virtual RAM buffer, and copy this buffer to the video ram. Just a few Try this. Compile with something along the lines of: gcc foobar.c -o foobar.exe -lalleg ---- cut here, foobar.c ---- #include "allegro.h" int main() { /* current object position */ int x = 100, y = 100; /* an offscreen buffer for drawing the image */ BITMAP *buffer; /* initialise Allegro and select a 640x480 video mode */ allegro_init(); install_keyboard(); set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0); set_palette(desktop_palette); /* create the offscreen buffer */ buffer = create_bitmap(SCREEN_W, SCREEN_H); /* repeat until ESC is pressed */ while (!key[KEY_ESC]) { /* clear the offscreen buffer */ clear(buffer); /* draw a triangle onto it */ triangle(buffer, x, y, x+20, y, x, y+20, 255); /* synchronise with retrace, then copy buffer to the screen */ vsync(); blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); /* use arrow keys to move the triangle around */ if (key[KEY_LEFT]) x--; if (key[KEY_RIGHT]) x++; if (key[KEY_UP]) y--; if (key[KEY_DOWN]) y++; } /* shutdown and free the buffer memory */ destroy_bitmap(buffer); allegro_exit(); return 0; } ---- end of foobar.c ---- Hope that helps... /* * Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ * Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'. */