Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

alchemar

OpenGL Button in OpenGL

This topic is 5228 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a button struct that has a bool for button up or down a texture Id a rect to know where the button is and how big and a mouse hit test function. The texture is top half button up, bottom half button down. Now for my problem, I render, I hit test the button, I set the button to down and do some function, set the button to up (as I have finished what ever the button is supposed to do), I render. As you can see the button doesn''t get drawn in the down possition at all. and I can''t see an easy way to draw it then do the function. Any ideas? I don''t want to do a full gui system, if I can help it.

Share this post


Link to post
Share on other sites
Advertisement
What most UI toolkits do:

Make the button "down" when the user clicks down on it.
If the mouse moves out with button down, make the button go "up" without activating.
If the mouse button goes "down" while user still inside button, make button go up, and activate.

If you''re really a stickler, you support the case of dragging the mouse back in while still holding the button down, and re-down-ing the button.

The important part is activate-on-mouse-up, and rendering the button each frame based on its down state (which is state), not activation (which is transition).

Share this post


Link to post
Share on other sites
Well that was easy, Thank you hplus0603, I wonder why I didn''t think about that. I just have to mouse test on mouse button up and if the buttondown is already true then do my function.

Thanks again.

Share this post


Link to post
Share on other sites
Actually when making a GUI, it''s easy to just look at how these controls behave in windows itself.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!