![]() |
|
Mouse access violation? |
BrknPhoenix
Member #7,304
June 2006
|
Whenever I try to run a program that uses allegro's mouse functions, it crashes with an access violation. Always. I won't bother posting code, because it just always happens with whatever it is. It happened with my own programs using the mouse, so I figured I was just doing something wrong. So I broke out my copy of Game Programming All in One which has a CD with example programs on it, and compiled a program out of that book that uses the mouse. Same thing happened, access violation |
Ultio
Member #1,336
April 2001
|
Does the example program crash as well (exmouse)? What version of Allegro are you running? I'm also assuming this is in Windows. --- |
BrknPhoenix
Member #7,304
June 2006
|
Shared dll, compiling with dev-c++ mingw32, and what happens is the program crashes with an access fault on exit. And the mouse doesn't display. I just tested it a little more and it appears it only happens when show_mouse is used with the buffer as the parameter. Nothing else crashes besides the program on exit. |
Ultio
Member #1,336
April 2001
|
Did you try the exmouse.exe example program? If that works without failure then the access violation is with whatever you're compiling. If not, then it could potentially be a problem with your system or (unlikely) Allegro. If you're using an ancient version of Allegro, that would be bad. What version are you using (eg: 4.2.1, etc)? What flavor of Windows are you running under? --- |
BrknPhoenix
Member #7,304
June 2006
|
Allegro version 4.2.0, windows xp, and unfortunately I haven't heard of this exmouse test program. Does it come with allegro? Perhaps I don't have it because I downloaded the devpak... |
Ultio
Member #1,336
April 2001
|
Hm. I'm not sure if the devpak builds the example programs. If it did, it would be in the allegro directory structure under examples. Here's the code and you can just compile it yourself and see if it works. After that test we can better figure out what the real problem is.
--- |
BrknPhoenix
Member #7,304
June 2006
|
Hm, the exmouse program works. And the error only seems to occur when I draw to the buffer. Perhaps I shall post the code tomorrow. I can't right now because it's a long day at work tomorrow, and it's late and I need sleep, hehe. It's spread over 14 files so it'd take awhile to get up here. I'll post it tomorrow though |
Ultio
Member #1,336
April 2001
|
Don't mention it. Your code will definitely help debug. What I think is that you're either blitting to an improperly created/loaded bitmap (are you checking for NULL return on create_bitmap and load_bitmap?) or you're trying to draw on an already destroy()'ed bitmap. Post the code and you'll get some more help. Good luck. --- |
Kitty Cat
Member #2,815
October 2002
![]() |
Sounds like you're using show_mouse on a non-screen buffer (which there's not real point to, BTW, you'll never see it until you blit the buffer wasting resources in the mean-time (ie. draw_sprite the mouse_sprite to the buffer manually before showing the buffer)), then destroying the buffer while the mouse is still trying to draw to it. -- |
BrknPhoenix
Member #7,304
June 2006
|
Well, it's fixed now. Not how I was hoping for but it is :p 1) After what Kitty Cat said, I drew to the screen instead of the buffer and that part worked. |
miran
Member #2,407
June 2002
|
Quote: So I broke out my copy of Game Programming All in One... I stopped reading right there and skipped down to the reply box. Don't use examples from that book and expect them to work. The problem you're having is this: 1. Make the mouse draw to your back buffer. Possible solutions: 1. Use hardware cursors. -- |
|