Buttons with GLUT

Hi, this is my first post so here i go…

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

You should check out GLUI (google for it) which is an add-on to GLUT.

Thanks. :slight_smile:

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

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:

Render()
{
  clear()
  draw3dstuff()
  glOrtho()
  disableZbuffer()
  drawCursor()
  for all active buttons
  {
    drawbutton()
  }
}

OnMouseClick(int x, int y)
{
  for all active buttons
    if point(x,y) is inside button
      DoSomeButtonAction()
}

Well you get the picture :slight_smile:

EDIT: added code tags and fixed some typo’s…

Thanks. That was the options i had figured out too :stuck_out_tongue:

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

Thanks for the help mate

You are welcome :cool:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.