![]() |
|
mouse flicker problem |
Charles256
Member #8,370
February 2007
|
Whenever I run my program in windowed mode the mouse is fine but when I go full screen it flickers... allegro_init(); set_color_depth(32); install_keyboard(); install_mouse(); if (set_gfx_mode(GFX_AUTODETECT_WINDOWED,1024,768,0,0)!=0) { set_gfx_mode(GFX_TEXT,0,0,0,0); allegro_message(allegro_error); exit(1); } show_mouse(screen); and the screen rendering part. I do rest as a way of slowing the game down, I tried to use the tick method but I couldn't even get that to compile so if you think that's the issue let me know and if you know of where a tutorial is off the top of your head let em know, if not, I'll google. :-D |
Jakub Wasilewski
Member #3,653
June 2003
![]() |
Read about those two functions: You should "scare" the mouse prior to drawing to the screen, and unscare it after you're done using screen. --------------------------- |
Charles256
Member #8,370
February 2007
|
That helped some, it went from being invisible (unless i moved it), to being visible for flickering like a mad man,ideas? |
Jakub Wasilewski
Member #3,653
June 2003
![]() |
Show all the code you have for the main loop (where drawing happens). --------------------------- |
Charles256
Member #8,370
February 2007
|
buffering code
|
Tobias Dammers
Member #2,604
August 2002
![]() |
In a fully double buffering system (read: anything other than dirty rectangles), I found the best solution for the mouse pointer is to just draw the mouse sprite manually by calling the following right before blitting / flipping: draw_sprite(backbuffer, mouse_sprite, mouse_x, mouse_y); ...and not activate the built-in mouse pointer at all (call show_mouse(NULL) just to be sure). As long as the double buffering system works reasonably fast, you get smooth, flicker-free mouse movement without any buffering artifacts (the odd wrong-color rectangles you sometimes see under the mouse cursor in windows). --- |
Jakub Wasilewski
Member #3,653
June 2003
![]() |
Think about the order of things. scare_mouse() // ... vsync() blit(...) // ... unscare_mouse() So, you hide the mouse, and then execute vsync, which waits (potentially a long time) for a vertical refresh, and only then you show it again. This means the mouse stays hidden for the whole time of the wait. Instead, reorder the calls so that the mouse is hidden for the shortest interval neccessary: class buffering{ //... void render() { vsync(); scare_mouse(); blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H); unscare_mouse(); }; }; That might help, but I'm not sure at that point - I haven't used Allegro's built-in mouse handling for a long while. --------------------------- |
Tobias Dammers
Member #2,604
August 2002
![]() |
And on a side note: What's with the bitmap vector in the buffering class? --- |
|