Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » allegro mouse distortion question

This thread is locked; no one can reply to it. rss feed Print
allegro mouse distortion question
kholdstayr
Member #7,575
August 2006

I am a complete Allegro newbie and I am trying to start making a simple Solitaire card game just to have some fun with Allegro. Anyway, I am having some troubles with the mouse cursor in Allegro. I have a simple program that just displays a screen with a black background and a green box. If I move the mouse cursor over the box the box gets erased by the mouse cursor, and turns black (which is the color of the area behind the box).

I was thinking that the problem was that I wasn't hiding the mouse cursor properly, but I think I am doing it correctly. Here is my code:

1#include <pc.h>
2#include <allegro.h>
3using namespace std;
4 
5int main()
6{
7 allegro_init();
8 set_color_depth(16);
9 set_gfx_mode (GFX_AUTODETECT, 640, 480, 0, 0);
10 install_timer();
11 install_mouse();
12 select_mouse_cursor(MOUSE_CURSOR_ARROW);
13 enable_hardware_cursor();
14 
15 show_mouse (screen);
16 
17 BITMAP* bmp = create_bitmap(640, 480);
18 clear_to_color (bmp, makecol16(0,0,0));
19 
20 
21 rectfill(bmp, 150, 400, 230, 450, makecol16(0,255,0));
22 show_mouse(0);
23 blit(bmp, screen, 0, 0, 0, 0, 640, 480);
24 show_mouse(screen);
25 
26 sleep(5);
27 
28}

I am using the sleep function just to have the graphics run for a few seconds so I can test the mouse out. It's not necessary at all.

Kitty Cat
Member #2,815
October 2002
avatar

The mouse will be hidden automatically if it needs to be. Once you call show_mouse(screen); you can't call show_mouse again without losing the hardware cursor.

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

kholdstayr
Member #7,575
August 2006

When I try it without the show_mouse(0) it makes it worse, and the mouse messes up even more.

Richard Phipps
Member #1,632
November 2001
avatar

Change the last part of your code to this:

show_mouse (screen);

BITMAP* bmp = create_bitmap(640, 480);
clear_to_color (bmp, makecol16(0,0,0));

rectfill(bmp, 150, 400, 230, 450, makecol16(0,255,0));

scare_mouse();
blit(bmp, screen, 0, 0, 0, 0, 640, 480);
unscare_mouse();

Evert
Member #794
November 2000
avatar

Quote:

#include <pc.h>

What compiler are you using?

kholdstayr
Member #7,575
August 2006

I am using DJGPP.

Matthew Leverton
Supreme Loser
January 1999
avatar

DJGPP doesn't work right under Windows XP.

kholdstayr
Member #7,575
August 2006

I fixed the problem. I didn't know about the individual graphics drivers you could load up, only the GFX_AUTODETECT. I did some searching and found out about the selection of video drivers for each platform. I tried loading up the GFX_VESA1 driver and now the mouse corruption problem went away.

Matthew Leverton
Supreme Loser
January 1999
avatar

You worked around the problem for your installation of XP on your hardware, which is far from fixing it. If you plan to let other people running Windows XP use your project, then you need to switch to a Windows compiler.

DOS applications can be coaxed to run on Windows XP, but usually not very well. They won't work at all on 64-bit versions.

kholdstayr
Member #7,575
August 2006

I use DJGPP because my university computer science classes/professors use DJGPP actually.

Christopher Bludau
Member #5,401
January 2005

You should use Mingw.
It´s a windows compiler.

djgpp = gcc for dos
Mingw = gcc for windows

IIRC. So it won´t be much of a change, but your games will work correct under windows

Kauhiz
Member #4,798
July 2004

Quote:

my university computer science classes/professors use DJGPP

You sure that they're really professors, and not just some random guy with a fake beard?

---
It's Ridge Racer! RIIIIIDGE RAAAAACER!

kholdstayr
Member #7,575
August 2006

Yeah, we haven't needed anything else really besides DJGPP. For instance, if you are doing data structures like trees, linked lists, basic AI stuff like searching through mazes, sorting, hash functions, etc, you don't need fancy graphics or capabilities.

Anyway, I took the time tonight to get MINGW installed, as I had some problems when I tried to get allegro working with it in the past. Well, I got Allegro successfully working with MINGW now so I will continue my solitaire game development using MINGW instead of djgpp.

*EDIT*

I have a Windows related question. If I want to run a Windows based Allegro program on another computer, what do I need to do? Is the Allegro library statically linked into the program or do I need to include a DLL if I want to run the program on another PC?

Christopher Bludau
Member #5,401
January 2005

Depends on the way you compiled allegro.
I guess you compiled it the way you have to include the dll.
Which is the way to go, IMO.

If you make one change to your exefile, people only have to download the small exe file, because they already have the dll.

Otherwise your exe will be bigger and the people will redownload the dll (in the exe) everytime they download the exe.

Go to: