Sign in to follow this  

making an in-game UI or hud

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

Well, you need two things. Or three, ... A decent Font System, to print text, clip it, size it, format it, a 2D overlay system, usually quads should be enough, to do the frames and backgrounds, icons, a menu and user inputs, to handle mouse inputs, detect what object is underneath the mouse cursor, and run context sensitive scripted commands on events (like mouse clicks opens a menu, drag and drops, scrolls, ect...), open windows and modal dialog boxes, off the menu system, a set of controls, like scroll bars, buttons, text boxes, sliders, lists, tables for inventory... The typical UI design. If you programmed in Win32, or with any other UI, it should become a bit clearer.

Share this post


Link to post
Share on other sites
Or use an off-the-shelf system; Ogre uses Crazy Eddie's, which looks pretty decent http://www.cegui.org.uk/modules/news/.

There's a great deal of different UIs, depending on different needs. GameSWF, for example, is a pretty complete Flash implementation for HW accelerated cards, usefull for UIs.


So you milage may wary.

Allan

Share this post


Link to post
Share on other sites
It'd be easier to answer you if you told us what APIs you are using etc. You will only get general answers because your question is not specific enough.

Example, if you are using OpenGL, you can use glRaster to draw bitmaps to the screen or switch to a 2D ortho projection to draw aligned to the screen.

The rest of the UI depends on your framework, how you handle mouse and keyboard, and then it is simply drawing the menus on the screen and having the mouse select items and move them from menu to world and back. It is not complex I just find it to be the more boring parts of programming.

Share this post


Link to post
Share on other sites
Well im currently in the early stages of writing a HUD api called THUD for DirectX, i have the basic components done, like a standard quad, a button draggable boxes and a font engine etc,

The general method i am using is to have the user register components with the thud_frame class during loading (whenever that may be for the user) and at run time have the user request by a component id, what they want rendered at run time. I plan to invoke a 'pages' system so that entire pages of objects can be set up at load time. I also plan to write a scripting system so that scripts describing pages can be loaded either on the fly or preferably at load time. Pages can then be requested at run time using the premade vertex buffer. The user also has to register the textures that they wish to use for the components. These are all managed by the renderer.

The font engine is the latest component under developement, but is nearly done.

The hardest thing in writing anything like this is coming up with the idea of how to link it all together. I have got std::vectors representing the render requests for that frame and for the textures.

I also plan to add components like message and text boxes to the API but i am having a problem thinking up a suitable way to integrate a box, a button and text all into one component (using the other components) and them all render properly.

Lasty one last thing you will need to think about is how to implement a layers system, so that components will appear in the right 'z' order on the screen. I havn't decide whether this should be done by changing the order in which things are rendered or by actually altering the Z component of the vertices.

I also found it necessary to write a wrapper for the standard vertex buffer because there is alot of vertex buffer handling going on.

Well i hope my comments have given u some insight into ur problem.

Check out my journel for more info.

ace

Share this post


Link to post
Share on other sites
What you're looking for for 2d overlays are orthographic projection matrices. With OpenGL you can get one using glOrtho on your projection matrix. You can change the matrix mode in OpenGL using glMatrixMode with the parameter of GL_PROJECTION for a projection matrix. In Direct3D use D3DXMatrixOrthoLH/RH/OffCenterLH/OffCenterRH to get a matrix and set it to your D3DTS_PROJECTION matrix.

If you don't want to use D3DX for some reason, you can also write your own matrix library and use that directly.

This is all assuming your game is 3d, otherwise, disregard this.

Share this post


Link to post
Share on other sites

This topic is 4691 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this