Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » drawing on a loaded image

This thread is locked; no one can reply to it. rss feed Print
drawing on a loaded image
Sylvarant
Member #7,886
October 2006

I want to draw a self created bitmap ( I created it in allegro and drew some stuff on to it) onto the screen, wich is filled with an image (I used draw sprite for that). But my self created bitmap keeps flickering.

HardTranceFan
Member #7,317
June 2006
avatar

code?

--
"Shame your mind don't shine like your possessions do" - Faithless (I want more part 1)

Sylvarant
Member #7,886
October 2006

"code?"

1// window class constructor
2 
3 // set custom bitmap
4window_bitmap = create_bitmap(width,height);
5clear_bitmap(window_bitmap);
6 
7// buffer
8declarations::frame_create(0,0,width,height,window_bitmap);
9set_background(2,2,width-4,height-4,"Window_skin.bmp");
10set_item(item_x,item_y,item_path);
11set_text(text_x,text_y,window_font,text);
12 
13// draw to screen
14vsync();
15blit(window_bitmap,screen,0,0,x,y,window_bitmap->w,window_bitmap->h);
16 
17 
18-----------------------------------------------------------------------
19// main loop
20 
21 while (!key[KEY_ESC]) {
22 BITMAP * map = declarations::bitmap_load("testmap.bmp");
23 draw_sprite(screen,map,0,0);
24 Window * win = new Window(100,249,400,100);
25 win->draw_item(2,2,"Face.bmp");
26 win->draw_text(5,5,antique,"Hello there.");}
27}

Rick
Member #3,572
June 2003
avatar

You want to double buffer this. Create another bitmap that you draw everything to. Call it say buffer. Then after you are done drawing everything, draw this buffer to the screen. Then clear this buffer bitmap and start all over again. That's called double buffering and is a basic idea of game programming.

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

HardTranceFan
Member #7,317
June 2006
avatar

Why are you loading testmap.bmp within the while loop? Do it once before the loop.

--
"Shame your mind don't shine like your possessions do" - Faithless (I want more part 1)

Go to: