• Create Account

## OpenGL GUI anyone? Updated on 11/17/05

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

207 replies to this topic

### #181mrbastard  Members

1576
Like
0Likes
Like

Posted 22 November 2005 - 03:35 PM

Hi, I've been messing around with OpenGLUI and have got it working within my own framework. It's based on SDL, and it was pretty simple to write a function to convert SDL events to ones for the GUI. It doesn't handle all cases, but does the things the glut demo does - mouse clicks and key events. I've also made a new vc2003 project file that builds openglui as a seperate lib (with some changes, see below).

Big thanks to JavaCoolDude for a great piece of work!

I do have a couple of suggestions to make things more convenient though:

Take GLee and TinyXML out of the gui lib code. I was already using TinyXML, and an extra copy of it in another header was a pain. Similarly there's no reason to build GLee into the gui. I can see why it was convenient to do it that way so that people could just download and use it without having to get the dependencies to compile seperately, but for existing projects modularity is key. It was just a matter of removing the GLee and TinyXML code from the gui files and linking to the existing GLee lib and a lib version of TinyXML I built.

I'm happy to release my work on all of the above if anyone would find it useful. If JCD doesn't have the time or inclination to make it more modular (man, he's already put in lots of work for everyone else's benefit), I'd be happy to help.

One last thing: running OpenGLUI with glintercept it looks like your font code isn't releasing it's textures or display lists. That said, so does my framework, which uses FTGL. Maybe a common ancestor in font code, or maybe a problem with glintercept.

### #182JavaCoolDude  Members

670
Like
0Likes
Like

Posted 22 November 2005 - 04:07 PM

The only reason why I decided to merge TinyXML into the XMLUtils files is because I didn't want the final user to deal with a great lot of files while including this GUI into an existing project.
About the fonts not being released properly, I simply forgot to add a clear function to the GUIFontManager. Let me go ahead and fix that up.
PS: Woah what happened to the forums look =)

### #183mrbastard  Members

1576
Like
0Likes
Like

Posted 22 November 2005 - 04:33 PM

Quote:
 Original post by JavaCoolDudeThe only reason why I decided to merge TinyXML into the XMLUtils files is because I didn't want the final user to deal with a great lot of files while including this GUI into an existing project.

Yeah, it was a very good decision to lower the learning curve. On the other hand, it causes problems for people who already have an extension loading mechanism in place, or who are already using TinyXML. Actually, it's probably only a problem for people whose projects are built from several libs, I guess if you're building a single exe and simply adding all the gui code to the project it's fine.

I do think though that there's a lot of code in there that doesn't need to be. That's entirely understandable, because you wrote it for your own use. In fact for many people the extras probably add value. Would you mind someone producing a stripped down version, possibly for the sourceforge site? I may be being presumptuous, but I think a more compact version may be useful to others as well.

Quote:
 Original post by JavaCoolDudeAbout the fonts not being released properly, I simply forgot to add a clear function to the GUIFontManager. Let me go ahead and fix that up.

Great stuff, thanks. And thanks again for releasing your work. I have spent quite some time evaluating various GUIs for opengl and this is by far the best, both in terms of features and clean design.

### #184MizRaeL  Members

216
Like
0Likes
Like

Posted 24 November 2005 - 08:41 AM

still fighting with your gui :D (again great work!)
small question: i've a panel that contains only buttons. is it possible to set the dimension of the panel and have something like a slide bar ? this way some buttons are visible and others not, and the user has to lower or raise the slide bar to show those..

Or maybe using buttons instead of text items in a combo box...

P.S. a demo is coming! :D

### #185MizRaeL  Members

216
Like
0Likes
Like

Posted 26 November 2005 - 03:45 AM

i think i've found a bug: seems that the TABBED_PANEL message is never sent, though the tabbed panels work perfectly.. but this way i don't know how to capture the widget message :/

### #186JavaCoolDude  Members

670
Like
0Likes
Like

Posted 26 November 2005 - 05:58 AM

Indeed that message is never sent because it's captured by the TabbedPanel and redirected to its subcomponents: It was the easiest, most-obvious solution to implement at that time.
=/

### #187MizRaeL  Members

216
Like
0Likes
Like

Posted 26 November 2005 - 06:25 AM

doh -___-

this is a problem because when i want to move a unit (a tank or a jeep or whatever it is) and i click on the map, everything works fine. if i click on a button it's the same, but if i click on the tabbed panel the selected unit moves to the zone of the map directly under the tab :/

### #188JavaCoolDude  Members

670
Like
0Likes
Like

Posted 26 November 2005 - 06:42 AM

A temporary fix would be to retrieve the windowBounds of your tabbed panel and cancel your orders if the mouse event falls within that area.
void SceneFrame::mouseClicked(MouseEvent evt){   guiFrame.checkMouseEvents(event, Mouse::CLICKED);  if(userControls)  {    const Tuple4i &windowBounds = userControls->getWindowBounds();    if((evt.getY() >= windowBounds.y) && (evt.getY() <= windowBounds.w) &&       (evt.getX() >= windowBounds.x) && (evt.getX() <= windowBounds.z) )      return;  }}

### #189clinix  Members

364
Like
0Likes
Like

Posted 09 December 2005 - 08:04 PM

I feel so noobish :( But I downloaded the zip file that is linked to in the first post, and I just saw the scengraph project file (visual studio is what I'm using). I opened it and it wouldn't compile because something about a wrong opengl function (I think it's some headers I changed), but then I assumed that that project file was for the actual demo of the GUI. So my question is, is there a library I'm supposed to compile, or do I just use the headers/sources...sorry, I'm just lost. :(

### #190JavaCoolDude  Members

670
Like
0Likes
Like

Posted 10 December 2005 - 04:45 AM

You should be able to use the vcproj file and compile the project right away.
I'm not sure about the GL function error that you were getting; care to elaborate a little more on the issue?

### #191sckoobs  Members

157
Like
0Likes
Like

Posted 10 December 2005 - 05:16 AM

The scenegraph demo uses glut so perhaps you don't have the glut32.dll and lib files? Try the opengl website to get the archive containing all the neccessaries; http://www.opengl.org/resources/libraries/glut.html

### #192clinix  Members

364
Like
0Likes
Like

Posted 10 December 2005 - 05:56 AM

Yeah, that's what I was saying. I dont want to compile the scenegraph thing, I want to compile/get the actual librarires heh, any help appreciated.

### #193sckoobs  Members

157
Like
0Likes
Like

Posted 10 December 2005 - 10:50 AM

Heh, yeah thats a problem, at the moment there is no separate project that compiles a lib for example, you'll just have to prise the cpp and h files from the scenegraph project, you'll either have to copy the misc tools files as well or go through the code and replace them with your own tools. Maybe a lib project would be a good addition to the archive? Not sure how easy that would be though!

### #194clinix  Members

364
Like
0Likes
Like

Posted 10 December 2005 - 11:41 AM

I dont get it then. Do I just include the header files or is there a library I need.

### #195xargon123  Members

138
Like
0Likes
Like

Posted 10 December 2005 - 12:32 PM

where can I find the latest version of this project? looks very interesting...

### #196relpats_eht  Members

138
Like
0Likes
Like

Posted 10 December 2005 - 03:24 PM

Rather than make a lib, you could just include all the files (excluding main.cpp) into your project.

The latest version can be found on the first post of this topic

### #197xargon123  Members

138
Like
0Likes
Like

Posted 10 December 2005 - 09:02 PM

Cool. Thanks!

You guys seem like GUI experts. I have been trying to create a rounded rectangle button in OpenGL for quite a while now. The closest I came to was using anti-aliasing along with alpha test. However, the corners still look a bit pixelised. I am putting the code here. Maybe someone has a better idea...

glColor3f(0.0, 0.0, 0.5);

glPointSize(10.0);
glDisable(GL_BLEND);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5);

glBegin(GL_POINTS);

glVertex2f(50.0, 15.0);
glVertex2f(50.0, 25.0);

glVertex2f(250.0, 15.0);
glVertex2f(250.0, 25.0);

glEnd();
glDisable(GL_POINT_SMOOTH);
glDisable(GL_ALPHA_TEST);

glLineWidth(10.0);
glBegin(GL_LINES);

glVertex2f(50.0, 15.0);
glVertex2f(50.0, 25.0);
glVertex2f(250.0, 15.0);
glVertex2f(250.0, 25.0);

glVertex2f(50.0, 15.0);
glVertex2f(250.0, 15.0);

glVertex2f(50.0, 25.0);
glVertex2f(250.0, 25.0);
glEnd();

glRectf(50.0, 15.0, 250.0, 25.0);
glDisable(GL_ALPHA_TEST);

cheers,
xargy

### #198relpats_eht  Members

138
Like
0Likes
Like

Posted 11 December 2005 - 04:34 AM

I might just be misreading that code from lack of sleep, but did you forget to glEnable(GL_LINE_SMOOTH)?

I am not really a GUI expert, I just know the code to this thing quite well, and am currently in the process of overhauling it to parse something very similar to xhtml, so there would be a much lower learning curve and such.

*edit* Oh yes, and if you want smooth corners, you should not use points, in OpenGL, a point is a square, a point of size ten will just be a 10x10 square, so even with point smoothing, it will come out rough. You are better off using many short line segments, or using a triangle fan if the button is filled in.

### #199xargon123  Members

138
Like
0Likes
Like

Posted 11 December 2005 - 05:48 AM

Hi, well, anti-aliasing these lines is not useful as they are pretty straight..

The reason for using a point of size 10 with anti-aliasing was that I could run it through the alpha function and kinda receive a circular point... However, the output was not very good :(

This is very frustrating as I have spend the whole weekend on this problem trying varied approaches with little success :((

### #200 Anonymous Poster_Anonymous Poster_*   Guests

0Likes

Posted 12 December 2005 - 08:40 AM

@xargon123

why do not simply use a quad with a texture (with alpha)?
so you can draw the button how you like in your graphics-app., and the rendered result should also good enough

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.