Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Buttons with GLUT

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2004
    Posts
    4

    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

  2. #2
    Intern Contributor
    Join Date
    Mar 2004
    Posts
    62

    Re: Buttons with GLUT

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

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2004
    Posts
    4

    Re: Buttons with GLUT

    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

  4. #4
    Intern Contributor
    Join Date
    Mar 2004
    Posts
    62

    Re: Buttons with GLUT

    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:
    Code :
    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 :-)

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

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2004
    Posts
    4

    Re: Buttons with GLUT

    Thanks. That was the options i had figured out too

    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

  6. #6
    Intern Contributor
    Join Date
    Mar 2004
    Posts
    62

    Re: Buttons with GLUT

    You are welcome

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •