OpenGL Menus??

Started by
5 comments, last by Corman 15 years, 9 months ago
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...).
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
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?
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.
Developer Journal: The Life of Corman
You can always use something like Crazy Eddie's GUI library. It has an OpenGL renderer.
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.
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.
Developer Journal: The Life of Corman

This topic is closed to new replies.

Advertisement