Skip to main content
gamedev.net
🔒 Locked

Drawing GUI Elements

Started by Metorical Dec 9, 2002 at 3:09 PM 4 replies 650+ views
Original Post
Metorical
Metorical
Hi, I am designing a custom 3D GUI system using C++ which is kind of similar to the windows gui. Every thing in the GUI is an individual object and can contain other GUI elements. e.g. A window will have four borders by default but could then contain a titlebar, a scrollbar and a text area all as child objects. When an object is draw it draws itself then all of its child objects in order. I can do all this fine in 2D but the problem comes in drawing it in 3D. I am vaguely familiar with the openGL API. My plan is to create a polygon the shape of the primary container then draw to this. My first thought it: Create a 2D image of the window then render this on the polygon but I have no idea how to do this. Would I just create a bitmap in memory and then make this a texture or is there a better way to do this. Bear in mind that individual elements in a container may change and it seems a waste to redraw the entire polygon each time (although it may be and probably is quicker). My googling has came up a little blank but I''ve probably searched quite poorly. I''m off to search some more now but if anyone has anything to add I''d add apreciate it. Thanks, Meto
TDragon
TDragon
Hmm. By delving in to the concept of a 3D GUI, you're looking at some of the basic principles of "3D graphics" (at least what I think the basic principles are).

Thing is, on a flat screen everything's just a simulation of "3D" in any case; the question is: do you go with a complicated interface to your display that lets you input geometrical coordinates and the like in 3 dimensions, just to have it all turned into 2D in the end, or do you simulate it yourself with bitmaps and the like?

Now (and this is all merely my opinion), something like a GUI is not going to need to be especially realistic; therefore it would probably give better results if the 3-dimensional-ness illusion was programmed straight.

Here's where I'm not especially certain about where you're going with it: how much of a "3D look" do you want this to have? I guess you might need to describe what you want it to look like a bit more. I mean, is this all going to be modeled onto different sides of a cube, or a sphere, or what? (Or am I missing the point entirely?) Since people can only see one side of something at a time, it usually makes a lot more sense to just model that side, and in 2D (again, since it's all going to end up on a flat display anyway - unless you're working with top secret holographic technology or something).

So I have a question in return: what will your polygon containers be like, and how will users navigate this 3D GUI?

Twilight Dragon

(slap) How did that happen? Could someone get rid of that extra post, please?

[edited by - TDragon on December 9, 2002 4:28:43 PM]
Metorical
Metorical
Okay this is the premise behind the user interface.

Take your typical ''3D world''.

The user will be able to at any point in the world call up interface panes pertaining to an element on screen. e.g. if you are looking at a sphere you can click on the sphere and bring up a window describing its properties. Now if you move back the pane will remain where it was originally called so it will shrink. If you rotate your view side to side you will see the pane at an angle.

A simple analogy is that a window is like a post it note. If I stick a post it note on my monitor when I move my head the post it note stays and place and does not move with my view.

My basic thinking was render the window as 2D then draw it on to a polygon.
Metorical
Metorical
Oh using the interface in 3d is nice and easy...

The mouse click is simply converted in to a line and all the components that collide with this object are considered. The one closest to the screen is the one activated.

My idea for moving the interface is quite simple too, you simply move to the position you want the window and drag the window title bar (or select the move option). This sticks it to the current 2D plane aligned with the screen and it acts like a normal window being moved.
TDragon
TDragon
Ok, I get it now. That sounds like a reall great idea.

My advice would be, yes, do it as a texture. Create the texture on the fly using functions to create buttons, menus, etc. Create a rectangular 2d surface and texture the panel to it. Your idea for moving sounds like it''ll work fine; just move the surface according to the mouse movement and the texture-map info panel will come with it. You will have to re-draw and re-map the texture every time something changes, but it hopefully won''t be to much of a drag-down.

Twilight Dragon

Topic Locked

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

Sign in to reply to this topic.