Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Bmp flicker, noob question

Credits go to Ceagon Xylas and CosmicR for helping out!
This thread is locked; no one can reply to it. rss feed Print
Bmp flicker, noob question
Nelson Cole
Member #6,043
July 2005

For some reason I've got this flicker on my mouse pointer, I'm not for sure why everything else draw to the screen seems to be perfectly fine. The following code is all located in the main loop, with the latter in the while. Maybe you can tell me what I've done wrong, thanks.

// Load the custom mouse pointer
BITMAP *reticle = load_bitmap("reticle.bmp", NULL);
set_mouse_sprite(reticle);
set_mouse_sprite_focus(reticle->w/2,reticle->h/2);
show_mouse(screen);

// Blit the double buffer 
vsync();
acquire_screen();
blit(buffer, screen, 0, 0, 0, 0, WIDTH-1, HEIGHT-1);
release_screen();

Ceagon Xylas
Member #5,495
February 2005
avatar

You're drawing the mouse to the screen, not the buffer. Draw it to the buffer and then draw the buffer on the screen like you're already doing.

show_mouse(buffer);
or

show_mouse(NULL); //not sure if you're allowed to use this line...

while(game_loop) {
  draw_spirte(buffer,mouse_sprite,mouse_x,mouse_y);
}

CosmicR
Member #6,889
February 2006
avatar

you can still show the mouse to the screen, but you have to hide it first before blitting the buffer.

ie

hidemouse
blit buffer to screen
showmouse

Nelson Cole
Member #6,043
July 2005

Yo guys thanks, i got it working.

Kitty Cat
Member #2,815
October 2002
avatar

Don't use show_mouse on the buffer. It's not safe, and just wastes the CPU by redrawing a lot when it'll never show. Use the show_mouse(NULL) and draw_sprite method.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Go to: