Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: GUI with OpenGL

  1. #1
    Join Date
    Jan 2008
    Location
    Whenever the food is.
    Beans
    1,203
    Distro
    Kubuntu

    Exclamation GUI with OpenGL

    I want GUI and OpenGL, and I found two ways to have OpenGL+GTK in the same window:
    -GtkGLExt
    -GtkGLArea

    But there's a huge problem with both libraries.

    With GtkGLExt, I can't use it because it doesn't find it when including.
    And yes, I have checked a million times I have the packages installed.
    I found out some other people also have the same issue. That's weird.

    And I do exactly as GtkGLExt's tiny reference manual says:
    http://gtkglext.sourceforge.net/refe...gtkglinit.html
    Here's the code:
    Code:
    #include <gtk/gtkgl.h>
    
    ...
    And he says:
    error: gtk/gtkgl.h: No such file or directory
    When I check the place manually, I find gtkgl.h where it should be.
    I am supposed to be programming my game, not fixing these issues!

    And there are very few examples or any help pages for GtkGLExt.
    But enough I could do something with it if I'd play around for a while.



    So, GtkGLExt does not work. How about GtkGLArea then? No idea.
    Because there is not a single tutorial, reference manual, forum thread,nothing about it.

    I don't even know which library to include! I googled sooo long I thought my head blows.

    Just some download links where to download it from.
    And it's homepage gives 404, and has been down for a while, according to google.

    So I can't use GtkGLArea either because I don't know which header to include, where from,
    or how to use the whole library.



    Anybody has a better idea how to mix OGL and GUI? Or maybe tutorials for those libraries?
    Solution for missing GtkGLExt header? Anything?


    I originally was making a game. Then a map editor for the game.
    But I can't do anything right now because there doesn't seem to be a way to create the map editor.
    And that game was supposed to be a Soldat clone for Linux. Currently it's just lying on my hard drive.
    Working map system, physics, textures, water, some basic stuff:

    Thanks.
    Keyboard not found!

    Press any key to continue...

  2. #2

    Re: GUI with OpenGL

    Wright your own GUI lib which renders using OGL, like Blender for example.
    im dyslexic, please don't comment on my spelling
    blender 3d artist, visit my portfolio
    Quad-Ren, Open source, resolution independent 2D graphics engine
    Screen space is a precious resource, don't waste it

  3. #3
    Join Date
    Jan 2006
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: GUI with OpenGL

    FLTK is a widget toolkit written using OpenGL.
    I am infallible, you should know that by now.
    "My favorite language is call STAR. It's extremely concise. It has exactly one verb '*', which does exactly what I want at the moment." --Larry Wall
    (02:15:31 PM) ***TimToady and snake oil go way back...
    42 lines of Perl - SHI - Home Site

  4. #4
    Join Date
    Jan 2008
    Location
    Whenever the food is.
    Beans
    1,203
    Distro
    Kubuntu

    Re: GUI with OpenGL

    FLTK is for C++, I use C (and Python).

    And writing my own GUI lib... Why to reinvent wheel the 10000th time?
    Keyboard not found!

    Press any key to continue...

  5. #5
    Join Date
    May 2005
    Location
    Lecce, Italy
    Beans
    6,168
    Distro
    Ubuntu

    Re: GUI with OpenGL

    Maybe you can try Clutter.

  6. #6
    Join Date
    Jul 2007
    Beans
    43

    Re: GUI with OpenGL

    Quote Originally Posted by hessiess View Post
    Wright your own GUI lib which renders using OGL, like Blender for example.
    Thats a tad excessive for a solution.


    The error is because the compiler cant find the header file, gtk/gtkgl.h. Which I can see you are aware off. This header file in not in the default search location, /usr/local/include or /usr/include. It is in a sub directory of the base folder gtkglext or something so gtk/gtkgl wont find it.

    On my computer to compile a c program using said library I would need to do something like -

    Code:
    gcc -I/usr/include/atk-1.0 -I/usr/include/gtkglext-1.0 -I/usr/lib64/gtkglext-1.0/include -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/pixman-1  -Wl,--export-dynamic -latk-1.0 -lgdkglext-x11-1.0 -lGLU -lGL -lXmu -lXt -lSM -lICE -lgdk-x11-2.0 -lpangox-1.0 -lX11 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -o hello bob.c
    for example, now that is a pain in the ... so you can store it in your build file or you can just use pkg-config if you have it installed.

    Code:
    gcc `pkg-config --cflags --libs gdkglext-1.0` -I/usr/include/atk-1.0/ -latk-1.0 -o hello bob.c

    That is how I do it when I'm playing with this stuff, whether that is the best solution or not, I don't know

  7. #7
    Join Date
    Jan 2008
    Location
    Whenever the food is.
    Beans
    1,203
    Distro
    Kubuntu

    Re: GUI with OpenGL

    Clutter didn't want to compile, it just gave a ton of errors.

    But I found GLUI, which is GUI done in pure OpenGL. Perfect for my needs,
    except it doesn't compile either. Errors and warnings again

    Unfortunately newest version of GLUI download link is broken, so I had to grab an older version.

    But when I run "make" or "./configure" or anything I could compile it, it doesn't work.

    All tools are installed, build-essentials, gcc, everything.


    And linking with GtkGLExt didn't work. gcc didn't complain about gtk_gl_init() but it segfaulted.
    Keyboard not found!

    Press any key to continue...

  8. #8
    Join Date
    Jan 2007
    Beans
    552

    Re: GUI with OpenGL

    I've used gtkglext a good bit without any problems. I do recall having to install gtkglextmm from source, so I could use C++; I'm not sure if that's still the case or if it's in the repositories now.

    One question - do you want an opengl drawing area inside of a normal GTK application window, with other GTK widgets around it; or do you want something like a fullscreen OpenGL window and the GUI drawn in OpenGL inside it?

    If the latter, you could also try Crazy Eddie's GUI, which is used in the Ogre and Irrlicht engines: http://www.cegui.org.uk/wiki/index.php/Main_Page

  9. #9
    Join Date
    Feb 2007
    Beans
    19

    Re: GUI with OpenGL

    Try using pkg-config. Compiling gtk and friends usually requires a whole list of libraries too numerous to remember and too tedious to type by hand every time you compile.

    Something like this should work:

    Code:
    gcc yourprogram.c -o yourprogram `pkg-config gtkglext-1.0 --cflags --libs`
    If you're curious as to what the output of pkg-config actually looks like, you can type

    Code:
    pkg-config gtkglext-1.0 --libs
    at the command prompt to get a list of the required libraries. These just get appended as arguments to the gcc command.

    Remember that the ticks surrounding the pkg-config argument are not your normal single quotes. They are actually backticks which you type using the unshifted "tilde" (~) key. Single quotes will not work.

    A makefile might also be something to consider...


    I just noticed that bobrocks gave essentially the same answer a few days ago...reading too fast, too late at night I guess...
    Last edited by wdk; January 4th, 2009 at 05:07 AM.

  10. #10
    Join Date
    Feb 2007
    Beans
    19

    Re: GUI with OpenGL

    I don't know if you've resolved the segfault issue with gtk_gl_init(), but you might try calling gtk_init() before calling gtk_gl_init().

    My first attempt at a program that only calls gtk_gl_init() and closes gave me a segfault as well. Then I found a nice bit of sample code here:

    http://www.cairographics.org/OpenGL/ (The "Beef it up a little" example actually uses GtkGlExt)

    Here gtk_init() is called before gtk_gl_init(). Adding that to my tiny test program fixed the segfault. It may in your code too.

    My sample code (compile using pkg-config as mentioned before):

    Code:
    #include <gtk/gtk.h>
    #include <gtk/gtkgl.h>
    
    int main(int argc, char ** argv)
    {
        gtk_init(&argc, &argv);
        gtk_gl_init(&argc, &argv);
    
        return 0;
    }
    Good Luck!

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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