Skip to main content
GameDev.net gamedev.net
🔒 Locked

mouse-events on surface-objects

Started by Notschko Mar 11, 2008 at 11:52 AM 1 replies 950+ views
Original Post
Notschko
Notschko
hey folks, Finally I created my first DirectX-scene... there's my next question, already. I drew some buttons by using DirectDraw and now I want to mouseclick them. The only idea I've got: On each mouse-event, I've got to compare all button-positions with the current mouse-position. To me, this seems rather inefficient. Is there another solution to solve the mouse-surface-interaction? Thanks!
jollyjeffers
jollyjeffers
Nope, that sounds about right - remember that DirectDraw/Direct3D are simply output API's and they're not really geared towards the e2e stuff including input and so on... you could implement some sort of layered/heirarchical system to avoid the number of tests you have to perform.

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
Evil Steve
Evil Steve
All your GUI buttons will be on a GUI window. If you have buttons on the main screen, you can consider that a GUI window. You'll end up with a tree of windows, with the main screen at the root. Then you just need to test the bounding rectangle for each window, and if the point is inside it, you can test each child window and the buttons on it.
If you only have buttons on the main window, ignore all that - just test all the buttons.

A simple 2D "point in rect" test should be pretty fast anyway, and should only be a problem if you need to do it thousands of times per frame.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.