#include #include #include using namespace std; #ifndef BUFFERING #define BUFFERING class buffering { private: // we'l need a buffer and a vector to hold reference to location of bitmaps. BITMAP * buffer; vector bitmaps; public: buffering() { // the buffer needs to be the entire screen // so we use allegro defined variables to make it so. buffer=create_bitmap(SCREEN_W,SCREEN_H); } void mark_bitmap_for_deletion(BITMAP *picture) { bitmaps.push_back(picture); } // this is just a wrapper for load_bitmap so we can add their memory locations // into a vector for automatic deletion later on. void add_bitmap(BITMAP *picture,int x=0,int y=0) { draw_sprite(buffer,picture,x,y); } // same thign as above void add_stretched_bitmap(BITMAP * picture,int x=0, int y=0,int width=SCREEN_W, int height=SCREEN_H) { stretch_sprite(buffer,picture,x,y,width,height); } // draw the buffer to the screen void render() { vsync(); blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H); rest(5); } //dynamically destroy all the bitmaps. good stuff. :-D // beats the hell out of 20 million calls to destroy_bitmap ~buffering() { for(int i=0;i