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

User Interface

Started by BePolite Feb 1, 2003 at 11:09 PM 1 replies 300+ views
Original Post
BePolite
BePolite
Hi, I''m creating a billiard game in OpenGL and VC++. I would like to know how to create a User Interface apart from using the GLUI lib. Thx
Trienco
Trienco
so you want to do it all yourself? i hope you dont need more than buttons, edit fields and text (and know about function pointers).

a button could look like this:

vec2d position (upper left corner), width, height, texture (or textures for normal, pressed, mouse over), click-function etc..

your gui could check if your cursor is above an element. if so i would set a selected element pointer to it. if the mouse moves, check if its still above that element. if not, deselect it and check the rest. if its clicked call the click-function (for edit fields you might want a changed-function or return-pressed-function whatever... and of course it should have a string).

and i prefer to store everything as value between 0 and 1, so all positions and sizes are relative to the screen and it wont wander into the upper left part of the screen in a higher resolution. of course extreme differences like 320x200 and 1600x1200 might require different textures to look good. for longer texts you might want to implement a system to wrap the text, so it will make use of the fact that higher resolutions offer more space (and not just increase the font size). but those are details i wouldnt worry about yet ,-)
f@dzhttp://festini.device-zero.de
beaton_john
beaton_john
take a look at the one i just posted... its not the best example, but you can use it and screw with it till you get it working.

Topic Locked

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

Sign in to reply to this topic.