PDA

View Full Version : OpenGL - Message box or Pop up Message box



pgm_girl
08-30-2011, 04:50 PM
Hi,

I am writing a program in C using openGl. I am using gcc on linux.

My program needs to pop up a window with two options (i.e Yes or No) when the user clicks on 'Exit' button on the screen.

Can anyone please help

g0bl1n
08-30-2011, 05:30 PM
I'm no expert on OpenGl but there are a few ways of doing this. One (which I recommend) is that you create it yourself. Create the window images, save them as a strip of some sort (bmp), then draw them to the screen. Get the mouse coordinates, then check if the mouse is within the images, based on if that is true do what you need to do. Another option is to use GLUI, which is pretty much a gui system made with OpenGl (I think there is another one called GLOW, but I'm not quite sure).

LINK (http://sourceforge.net/projects/glui/)

remdul
08-31-2011, 11:02 AM
On windows this is pretty simple (MessageBox function) but on Linux it is a bit more involving.

The simplest way I can think of is to use system() to execute xmessage() (see http://linux.die.net/man/3/system , http://linux.die.net/man/1/xmessage ). You may also need to call fork() if you want the message box to be non-modal, but that will probably not be necessary in this case.

The alternative is to use an OpenGL GUI library, or implement it yourself (as the other poster suggested above), but this is probably a bit more work.

uruk
09-01-2011, 04:50 AM
You could also use kdialog (http://techbase.kde.org/Development/Tutorials/Shell_Scripting_with_KDE_Dialogs) (for kde) or zenity (http://library.gnome.org/users/zenity/stable/) (for gnome) instead of xmessage.