Jump to content
  • Advertisement
Sign in to follow this  
davek20

OpenGL OpenGL Menus??

This topic is 3635 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

Hey everyone. I've just recently created a Pacman clone (the game part at least) and am now looking to add a main menu to it (and possible sub-menus from the main menu). I've been searching around for some already implemented menu systems in OpenGL and haven't come across any. What I am intending to do is make a bunch of small little projects which I can use parts of towards a game later on instead of tackling the game right away. So with that in mind, what would you guys suggest? I know it probably would be best if I made it myself since I would know what kind of actions the menus will have but it will probably take a long time. Or would it be better to used something like wxWidgets for "main menus" by using buttons for each option (this would allow for other widgets in the GUI like sliders, textboxes...).

Share this post


Link to post
Share on other sites
Advertisement
Can't you just make a menu class.
class menu {
public:
void Draw
void Add
void Remove
};
where every entry in the menu is another class where there is a function available to be implemented.
Then the menu can have a x and y coordinates where to be drawn on screen and maybe even sizes.
You get my point? :)

- Mads Ravn

Share this post


Link to post
Share on other sites
I'm also thinking about making my own menu class like the above, but I'm concerned about the font width. If your depending on a system dependent font, the font width and height can change. Then drawing a box around the font would be impossible?

Share this post


Link to post
Share on other sites
With most font systems you can usually get global ascender, descender, and line heights for fonts to get the y space. The x (advancement) can be trickier but not impossible. You usually have to know individual glyph widths (including spaces) and sum these values while iterating over your sting. Once done you basically know the minimum bounding box for your sting. Pad this a little and you can get a box nicely around any text in a custom ui. If you need to guarantee a fixed font size you might have to pack your own font ahead of time in a texture. Doing this you basically already know the bounding box per glyph and can design accordingly.

Share this post


Link to post
Share on other sites
Is there any way to get the width of individual glyphs in NEHE's lesson #13
I found documentation about wglUseFontBitmaps (which the tutorial uses)
http://msdn.microsoft.com/en-us/library/ms537557(VS.85).aspx
I just can't figure out how to access the information, or am I misreading the documentation.

Share this post


Link to post
Share on other sites
You can get the widths of your glyphs with GetCharABCWidths with A+B+C being your total glyph width with leading and tailing whitespace if you want to create your own function for finding string space usage but you would need a lot more info to get it to come out. For what you have you could possibly get away with just using GetTextExtentPoint32 to get a bounding box for your string as is. Keep in most of these functions only work with the currently selected font so if you switch back to the old font before you use these functions you will only end up getting the info for the font you are NOT using to draw with. And be wise since these values will only help you in pixel units in screen space.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!