I'm having really slow reaction time when the mouse goes over my buttons. I'm using a timer for the drawing and the mouse will be over the image it will take 2 or 3 draw function calls for the over state of the button to show up. this is another window from the original, I'm not sure if that has anything to do with it. I tried increasing the timer speed but that doesn't really do anything.
I don't see anything wrong with the code you posted so far. What is the code for the IsMouseOver function?
Right when I put my mouse over the image over became true and i confirmed it using cout. Could the main window be slowing this window down? When you click a button another window appears and calls a run function that has a loop so you are in that until you close it. I set the backbuffer to the new window and I'm pretty sure you can't do anything in the main window until you get rid of this one(this is how I wanted it)
There's nothing wrong with that either. The hover state should be showing up instantaneously.
Show the code for your draw function.
heres most of the functions
if i remove the timer and put draw before al_wait_for_event it doesnt even respond. I can't even x out the window it just hangs and I have to force exit using the stop debugger.
EDIT: these functions are part of a class and most of the variables are too. the buttons have their own class
I still don't see anything wrong. Your timer is a bit slow, usual timer speed matches the refresh rate of the monitor, typically 60 or 70 Hz.
Are all your buttons slow to show the hover?
You should try timing how long it takes from when your button changes to the hover state to when the display is shown next. Then use a kind of binary search to find out what is taking so long for it to display.
the over state changes immediately, but the over state doesn't draw for 5 seconds or so
hi,
I've not read and understood all your code but you should do the following steps in order to run quickly your images:
1) Preload everything you need from the HD with a load process.
2) Format everything you need to be quickly accessible (i.e. transform BMP into texture and MP3 into the first chunk of wave...)
3) create the main loop using POINTERS to the Graphic and the other data. Every method and function that passes parameters should use pointers unless you are transmitting int/short int/1 char/or Bool.
4) your main loop is ended, destroy everything you created , and quit.
hope this help.
Ok so I exported this whole module class to a standalone program and everything worked perfect with the code unchanged. What does this tell us edgar?
the over state changes immediately, but the over state doesn't draw for 5 seconds or so
Did you measure the time using the method I posted in the post before the one I just quoted? If you did, and it took 5 seconds, then it was your Draw() method taking 5 seconds to complete.
Ok so I exported this whole module class to a standalone program and everything worked perfect with the code unchanged. What does this tell us edgar?
It depends. There has to be something different. In the program that was slow to visually update, you were using a second display. Did you load any resources used in it in the same thread that you created the display in? Or if there were any resources, were they loaded in a separate thread? That would cause them to be slow memory bitmaps. In fact, I don't see you loading your card images anywhere in the code you posted.
Your resources may be attached to another display - you'd have to ask the Allegro devs about that - that might be causing part of the problem.
The first display shouldn't be taking any processor power except for the allegro thread that runs it's window process, which should be minimal.
Still not sure what's wrong though.
all the images are loaded when the main program is starting. Should I load it after I create the window that these images are being drawn to?
I'm not sure, but I would guess that the answer is yes, you should load the resources used when your new display is active.
I think the whole problem is that your resources are not attached to the display that is in use. You should be able to test that fairly easily.
the process of loading is connected to the color depth of your screen...
The Setup of Allegro is always the first step to do...
No I would initialize allegro then load all content including for the sub windows. then when the user clicks the button to bring up the window and i initialize that window so it shows up. I changed it so when the sub window initializes i made it load the sub windows content and now it works. I really need to learn about threads
I originally wanted to load all the images in the beginning so when you open a sub window your not sitting with a blank window waiting for all the images to load.
It's not about threads, and they aren't very useful with Allegro 5 as far as I can see. The problem here was that your resources were attached to a different display.