0

Graphics.UI.GLUT has a Dial and Button callback. I don't find any example of use of this callback. I wanted to have one because currently I use the keyboard and the mouse callbacks and this is not enough and not user-friendly.

I've tried to do one such callback. In my program:

dial :: IORef GLdouble -> DialAndButtonBoxCallback
dial zoom index =
  case index of
    DialAndButtonBoxDial 1 1 -> zoom $~! (+1)
    _                        -> return ()

Then I expect to see a button (button 1) in the OpenGL window which would increment zoom when I press on this button (zoom $~! (+1) zooms the graphic, I use it in the keyboard callback currently, no problem with that).

Then in my main file:

  zoom <- newIORef 0.0
  dialAndButtonBoxCallback $= Just (dial zoom)

The code compiles. But when I run the program, there's no dialog box appearing anywhere.

I would appreciate any help. Maybe I have to create a dialog box first ? I don't see anything like this in the documentation.

1
  • I'm afraid OpenGL is not a GUI and this is not possible. So what is the purpose of this callback ? Otherwise is there something to create buttons and use the mouse callback with the help of the position of the cursor ?.. Commented Mar 24, 2018 at 7:50

1 Answer 1

2

A dial and button box is not a dialog box. It’s a special purpose type of hardware, like a mouse, keyboard, joystick, or steering wheel. Eg this company makes some.

Glut is not a gui library like gtk. It lets you get user input and draw things on the screen. You need to figure out exactly how to draw all your user interface components if you want to use glut

Sign up to request clarification or add additional context in comments.

7 Comments

Ok, thank you. Finally I've found another solution: I use attachMenu to create some menus. That works fine.
So I guess the `"Tablet button" is also some type of hardware ?
GLUT is mainly about talking to hardware. Either peripherals, speakers (?) or graphics cards.
@DanRobertson: Actually GLUT is a extremly simplistic framework to create bare bones OpenGL applications. It creates windows and OpenGL contexts for you, does have very limited support for showing popup menus and allows you to register callbacks for a very narrow set of events. It was never meant for developing "serious" applications, but rather provide a scaffolding for quick and dirty OpenGL demo hacks, or if you want to show off specific functions of a library that interfaces with OpenGL. Don't use it in anything serious!
Ok, so I wasted my time with these callbacks. Fortunately, attachMenu is my savior :-)
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.