View Full Version : Buttons with GLUT

03-19-2004, 12:58 PM
Hi, this is my first post so here i go.. http://www.opengl.org/discussion_boards/ubb/smile.gif

I am using the GLUT library to make the windows for a program written in c++.

I am trying to make ordenary buttons so that i can have a decent user interface, but i can only find info on creating the pop-up menues.

I found a function called glutButtonBoxFunc but that only specified where to find the function that will run when a button is pressed (i think).

How do i create ordenary press-down buttons with glut?

I will be very thankfull for any help anyone could give me.

Fredrik B. Kjoelstad

03-21-2004, 08:59 AM
You should check out GLUI (google for it) which is an add-on to GLUT.

03-23-2004, 09:55 AM
Thanks. :)

I read through the glui documentation and tried it out. It was a great library, but it is not excactly what i need. The glui was made for ease of use. I need to make glui windows for the controlls and i can't place the buttons where i want.

I need something that allows me to create buttons in my main glut window, at a certain xy position of my choice. I also would like to be able to set the width and height.

Does anyone know of a way to do this (another library etc?).

Fredrik Berg Kjoelstad

03-24-2004, 12:00 AM
Another library?

Hmmmm the only one that comes to mind is MUI but its even older than GLUI, mostly undocumented and wwaaayyy outdated.

I think your options are:

a.) Modify the GLUT/GLUI sources so they do what you want.

b.) Do the buttons yourself.

In pseudocode it could look like this:

for all active buttons

OnMouseClick(int x, int y)
for all active buttons
if point(x,y) is inside button
}Well you get the picture :-)

EDIT: added code tags and fixed some typo's...

03-24-2004, 09:15 PM
Thanks. That was the options i had figured out too :p

Well, i would have prefered to find a library, but on the other hand, it will be interesting making one myself :)

Thanks for the help mate

03-25-2004, 12:15 AM
You are welcome :cool: