Slashdot Mirror


Making a GUI for OpenGL Games?

stuck in a bind asks: "I am currently coding a civilization-type game (in C) but on a galactic scale. OpenGL is used to draw everything so far. However I have been unable to find a decent, nice GUI, practically all of them are coded in C++. The only other options I can think of is coding my own toolkit (too much work, and I would hate to reinvent the wheel here), using SDL to draw 2D bitmaps on top of my OpenGL window. The last option would be to switch to GTK and use the GTK GL widget. What would the educated gamer/programmers of Slashdot recommend?"

96 comments

  1. Stick with GTK by larley · · Score: 0, Offtopic

    I mean, it's kinda old, and really in need of a re-vamp, but it's still a classic. If you're willing to put up with the way it seems to work around all of its inadequacies.

    1. Re:Stick with GTK by sn0wman3030 · · Score: 0

      Why not use GTK+2? It uses C, and it's just so pretty!

      --
      Life is offtopic.
    2. Re:Stick with GTK by Anonymous Coward · · Score: 0

      Pretty like Windows 95.

      Even worse with "skins".

  2. It's been done by obeythefist · · Score: 2, Informative

    It's been done before: Galactic Civilizations

    --
    I am government man, come from the government. The government has sent me. -- G.I.R.
    1. Re:It's been done by larley · · Score: 1

      Yeah, for WINDOWS. Who said he's not making a Galactic Civilizations clone for Linux?

    2. Re:It's been done by BrookHarty · · Score: 4, Insightful

      Why is it someone wants to design a game, its "Been done".. Maybe he has new ideas. Let the guy try. What would of happened if Linus said "Well, Minix is good enough for me"....

      Exactly...

    3. Re:It's been done by Tanktalus · · Score: 1

      I have GalCiv for OS/2 ... don't use it anymore ... any offers? ;-)

    4. Re:It's been done by Anonymous Coward · · Score: 0

      What would of happened if Linus said "Well, Minix is good enough for me"..

      Umm, SCO wouldn't have anyone to sue? :o)

    5. Re:It's been done by Stevyn · · Score: 1

      Or if Gates said the Lisa was good enough

    6. Re:It's been done by menkhaura · · Score: 1

      FreeBSD comes to mind... If there were no Linux (God forbid!), probably FreeBSD (or some fork of it) would be the main free operating system today, and our beloved McBride would sue them.

      --
      Stupidity is an equal opportunity striker.
      Fellow slashdotter Bill Dog
  3. SDL overlays by hitchhacker · · Score: 4, Informative


    using SDL to draw 2D bitmaps on top of my OpenGL window.

    don't use SDL's method for blitting SDL_Surface's over OpenGL.. it's too slow.
    do your 2D with OpenGL (textured polys).

    -metric

    1. Re:SDL overlays by BrynM · · Score: 3, Interesting
      As a level designer and player - not a gaming coder, I vote for textured polygons as well for a few reasons:
      • You can avoid changing between 2D and 3D and the resolution pop/time delay for some configurations.
      • The same artists that create your entities and environments can create your GUI widgets giving the game a consistant look and feel. A good example of this can be found in Primal Software's I of the Dragon tech demo (read their news for the demo download).
      • You can probably leverage some of your existing code instead of building something from complete scratch
      • An idea... Work a menu editor into your level editor
      --
      US Democracy:The best person for the job (among These pre-selected choices...)
    2. Re:SDL overlays by Paladin128 · · Score: 1

      Not only is it too slow, but it's harder to get to work. It's fine and dandy using SDL to setup everything and encapsulate your OpenGL environment in a neat and platform-independant way, but don't use SDL to blit on top of OpwnGL. I tried this for my senior project, and it was nearly the death of me.

      --
      Lex orandi, lex credendi.
    3. Re:SDL overlays by molo · · Score: 1

      do your 2D with OpenGL (textured polys).

      FYI, this is what the Quake series does. It ends up being highly portable.

      -molo

      --
      Using your sig line to advertise for friends is lame.
    4. Re:SDL overlays by GuyWithLag · · Score: 1

      Why not create a SDL target for GDK? The bulk of the work is already there (in the directfb target), you just need to implement setup/teardown. This way, you'll have both portability (SDL/OpenGL) and skinnability (GTK themes).

  4. Why not use C++ by bsmoor01 · · Score: 5, Interesting

    OO is pretty much ideal for GUI programming. So why not code up your GUI in C++ and leave the rest of your game in C?

    Is there some reason you're opposed to C++?

    1. Re:Why not use C++ by T-Ranger · · Score: 0, Flamebait

      Do you need a good reason to be opposed to C++?

    2. Re:Why not use C++ by Gherald · · Score: 2, Informative

      > Do you need a good reason to be opposed to C++?

      Most emphatically YES when the universe of discourse is game programming!

    3. Re:Why not use C++ by EzInKy · · Score: 2, Insightful

      OO is pretty much ideal for GUI programming. So why not code up your GUI in C++ and leave the rest of your game in C?

      I can't say as I blame guy. Twelve years ago, before I decided to make healthcare my career and relegate programming as a hobby I thought C++ was the greatest thing since sliced bread since it wrapped up both the power of C and object orientation all in one nice tidy little package.

      But now just when I've got some time on my hands that I want to devote to creating some programs I've got in mind I find someone has gone and mucked the whole thing up with namespaces and what not. Hell, they even changed the way standard header files are included.

      But anyway, in the end you are right. Use just enough C++ for the gui and encapsulating the units and get on with the business of actually writing the game (this is aimed as much at me who has been spending way too much time writing macros trying to turn C into the great language that C++ used to be).

      --
      Time is what keeps everything from happening all at once.
    4. Re:Why not use C++ by Pseudonym · · Score: 1

      Why?

      One of the design criteria of C++ is that you don't pay for what you don't use. If you write in the subset of C++ which is also in C, you get C (modulo some corner cases, like not being able to use "class" as a keyword). Indeed, you can't really get a C compiler these days; they're almost all C++ compilers with an internal command-line switch, or multiple-frontend compilers like GCC.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    5. Re:Why not use C++ by Gherald · · Score: 1

      > Why?

      C++ is by far the most common and (it would seem) regarded as the best choice for low level game programming. So if you are OPOSSED to using C++, you'd better have a good reason/explanation.

      As for the rest of your post, it's true but doesn't address why someone would be OPOSSED to C++ for game progamming, which is what is so confusing about this story.

    6. Re:Why not use C++ by Anonymous Coward · · Score: 0


      "[Power of C + OO]...all in one nice tidy little package..."

      This C++ you're talking about here, right?

      Nice?

      Tidy?

      Little?

    7. Re:Why not use C++ by Anonymous Coward · · Score: 0

      no. C++ is a bloated hunk of shit. Bjarne Stroustrup is a sadist.

    8. Re:Why not use C++ by Anonymous Coward · · Score: 0

      "opposed"

    9. Re:Why not use C++ by Gherald · · Score: 1

      ty

  5. what you kind of want is GLUI.... by johnjones · · Score: 3, Informative

    see Gui toolkits

    GLUI would be a good one GLUI website

    try it out

    regards

    John Jones
    --
    http://www.johnjones.me.uk/

    1. Re:what you kind of want is GLUI.... by Xetrov · · Score: 2, Interesting

      From the first line on the GLUI page: "GLUI is a GLUT-based C++..." :)

      I didn't like any of the openGL GUI packages out there so I made my own. It really isn't difficult to draw your own textured QUADs etc over the top of the scene. You can push/pop the attributes as well as the projection matrix, so you can make sure lighting etc is turned off when you draw the gui... RTFM ;)

    2. Re:what you kind of want is GLUI.... by Xetrov · · Score: 2, Informative

      Of course you probably want some text/fonts too. The easiest way is to use a texture font (eg an image with all the characters on it), but I found that using freetype2 was also pretty easy and the results are fantastic (blended true-type fonts, mmmmm).

      I think the freetype2 dist has an example openGL application in it, otherwise I'm sure something is available via google.

  6. Develop in a more modern language. by Anonymous Coward · · Score: 4, Informative

    What would the educated gamer/programmers of Slashdot recommend?

    Choose one:

    (1) Switch to C++. Problem solved. Nobody in their right mind (outside of tiny platforms such as the Gameboy and certain icky parts of the Playstation 2) is still writing games in straight C. C++ does a much better job of encapsulation and maintaining a clear codebase - particularly if you expect the codebase to be worked on by more than one person.

    Besides, UI programming is a pain in the ass without object-orientated encapsulation.

    (2) If you're amazingly stubborn and still don't want to modernize your codebase, you can still use C++ without C++ features (you can ignore language features like classes, for example). This will let you use the C++ toolkits that you want.

    (3) Write your own. If you really have the incentive and dedication to write a game, you should be able to write a UI toolkit for it.

  7. Does it all have to be in C? by brianjcain · · Score: 0, Redundant

    Can you write the GUI in C++, or just utilize an existing GUI written in C++? I can't see any problem linking your C code with someone else's C++ stuff.

  8. what about OpenGL for the TUI? by gumbi+west · · Score: 1
    I always just use OpenGL for my TUI, I don't need one of those new-fangled GUI things.

    yiesh, kids these days.

    1. Re:what about OpenGL for the TUI? by Anonymous Coward · · Score: 0

      I actually wrote a MUD client that used OpenGL for all the drawing. I implemented my own ANSI emulator and TELNET client, with text pre-drawn using FreeType into textures, and individual letters rendered using texture coordinate changes on individual polygons. (In retrospect, it might have been better to have 1 polygon+texture per scroll area, and just use 2D rendering into the texture, Quartz-style.)

      The idea was to eventually have some sort of 3D component, but I never got that far. :)

    2. Re:what about OpenGL for the TUI? by Yert · · Score: 1

      no chance you've got the source laying around for download, I suppose...

      --
      Truck driver, plumber, Linux systems engineer.
  9. Evaluations of some toolkits supporting OpenGL by jncook · · Score: 5, Informative

    I know that what you want is a C-based UI toolkit that can render widgets in OpenGL. I recently had to research this, and my impression is that you're stuck. As others have suggested, you might consider switching to a C++ compiler and just linking in your C code. You'll be hard pressed to find an advanced UI toolkit that isn't based in C++. Object orientation just matches user interface coding too well.

    Here's the results of my search. This was for an application which had a very large number of Windows-like UI elements, but had to be able to render a 3D world using OpenGL.

    FLTK -- Unsuitable. LGPL. Can open GL windows. Uses direct calls to OS line-drawing routines, so could be adapted to render directly to GL. Reasonable number of widgets, but ugly. No skin support. Development slow (two check-ins in last month).

    wxWidgets(aka wxWindows) -- Good. LGPL. Can open GL windows.Used by Mitch Kapor's Chandler PIM project. Would require separate UI thread not to block. Requires awkward preprocessor macros in UI classes. Third-party graphical widget layout tools.

    GLOW -- Unsuitable. Renders to GL. Not actively maintained. Uses advanced C++ (STL, RTTI). Clean code. No access to OS features, based on GLUT. Very simple, ugly widgets. Small library of widgets

    Qt -- Very good. Commercial license. Can open GL windows. Included graphical UI layout tools. XML-based UI files, but compiled into code rather than loaded at runtime.

    GLUI -- Unsuitable. LGPL. Renders to GL. Not actively maintained. Simplistic C++ code. No access to OS features, based on GLUT. Very simple, ugly widgets. Small library of widgets.

    XPToolkit(aka Mozilla/XUL) -- Unsuitable. Tri-license MPL/LGPL/GPL. No GL support. Would need to ship Mozilla or Firefox as part of app. Excellent ideas for XML-based UI layout, though.

    Full-custom with XML library -- Good. Renders to GL. Easiest for migration. Could do in-game UI editing, both for default skin, user skins, and script UI controls. Probably more work for you.

    Also, if you're new to UI library development, I strongly suggest you read the Qt whitepapers. Their concept of signals and slots seems quite powerful (though I have not used it myself).

    Qt 3.3 whitepaper:
    http://www.trolltech.com/products/whi tepapers.html

    James

    1. Re:Evaluations of some toolkits supporting OpenGL by Cthefuture · · Score: 2, Informative

      I think if you have ever made a wxWidgets application then you wouldn't call it "good".

      It would be easier to just write separate GUI's for each platform and #ifdef all the code as needed.

      That's what wxWidgets code looks like anyway. Ugh, too many special cases, not all the widgets work the same way depending on platform (with more or less features and different behaviours; it's a nightmare). It it's fat, really fat, too many layers.

      Qt is by far the best cross-platform kit out there but insanely expensive (compared to other non-cross commercial kits like MSDN or something).

      Gtk would be next in line but it tends to be buggy and coding GUI's in C sucks. There is Gtkmm but that just adds an extra layer that makes the bugs ever harder to find. Plus it's not really very cross-platform. On MacOS it runs under X11 and on Windows it's buggy as hell and slow. It's probably at or near the top feature-wise as far as free toolkits go. Unfortunately.

      Fltk is hyperlightweight and the code is very tweakable allowing you to make it look like whatever you want. That does take extra work though. Like I said, it's very easy to hack on. I like it for simple projects or projects where you're creating a custom GUI. It works on the main 3 platforms flawlessly.

      And don't forget the FOX toolkit. It's sorta like a free Qt clone but it mostly sucks (limited Mac support and it's ugly as sin).

      In the end Qt wins if you can afford it.

      --
      The ratio of people to cake is too big
    2. Re:Evaluations of some toolkits supporting OpenGL by puddpunk · · Score: 1

      "In the end, Qt wins if you can afford it."

      Don't forget, if your writing your game and releasing it under a GPL compatable licence you may use Qt for Free (beer/speech). GPL doesn't mean you have to give it to everyone, you just need to give the source to whoever you sell it to.

      If not, the Qt fees _aren't_ that expensive.

      Cheers,
      Chris.

    3. Re:Evaluations of some toolkits supporting OpenGL by Anonymous Coward · · Score: 0
      I think if you have ever made a wxWidgets application then you wouldn't call it "good".

      I have done several and been *VERY* happy. My programs work on Windows, Linux and Mac. They do printing, online help, preferences etc and look and feel like a native application.

      It would be easier to just write separate GUI's for each platform and #ifdef all the code as needed.

      Unless you are a true master of all the different APIs, that is extremely difficult to do. In fact it is so difficult that people who did understand them created toolkits such as wxWidgets, QT etc.

      Speaking specifically about wxWidgets, I am impressed with the variety of widgets available, and how little time I spend dealing with GUI issues. Just the other week I coded an app in pure MFC and it was a reminder of just how horrid that API is. Sure I sometimes have to spend effort on wxWidgets issues, but it never hurts as much as pure platform stuff.

      To get an idea of how rich wxWidgets is, download wxPython and run the demo. It shows all the different controls.

      I did learn QT once when I was exploring programming for the Zaurus. As you stated, ignoring licensing and cost issues, they are the best technically, as well as very complete. For me the license and cost issues could not be ignored, so I settled on wxWidgets instead.

    4. Re:Evaluations of some toolkits supporting OpenGL by Anonymous Coward · · Score: 0
      I hate to throw a bucket of cold water on you guys but...

      QT does not support OpenGL widgits.

      let me say this again for clarity:
      QT is a great library. I also happens to support cross platform development in a very clean manner ( very few #IFDEFs ). As a bonus they have a nice license that allow you to play with if for free on linux. It supports OpenGL In the sence that they have a QGLWidget that allows you to do windowed OpenGL. It does not have any Graphical User Interface elements that display in its QGLWidget.

      Considering how clean the QT code is I am sure there GUI could be 'ported' to OpenGL as a 'platform'. There is a package called SoQT that looks close to what I am describing. ( at least the beginning).

    5. Re:Evaluations of some toolkits supporting OpenGL by Anonymous Coward · · Score: 0

      Well, for starters, who are you? For all I know you're just spewing a bunch of crap on /. for giggles.

      Just the other week I coded an app in pure MFC and it was a reminder of just how horrid that API is.

      OK, this dispite the fact that wxWidgets feels a lot like MFC. Hmmm.

      For simple applications sure, it's not that bad. For anything that actually uses and needs to manipulate complex GUI applications then wxWidgets sucks.

      And you can't ignore the fact that's it's a superheavyweight API. Layers on layers of crap. You inherit all of Gtk's bugs when using it on UNIX systems.

    6. Re:Evaluations of some toolkits supporting OpenGL by Cthefuture · · Score: 1

      Don't forget, if your writing your game and releasing it under a GPL compatable licence you may use Qt for Free (beer/speech). GPL doesn't mean you have to give it to everyone, you just need to give the source to whoever you sell it to.

      True but you can't restrict redistribution. That means the first person you sell it to can redistribute to anybody. This effectively nullifies your commercial software. GPL just doesn't work for commercial apps unless all you plan to sell is support.

      If not, the Qt fees _aren't_ that expensive.

      Hmmm, a MSDN Professional subscription is $900. That's every single Microsoft operating system, all the development tools, packages, languages, compilers etc. How much does Qt cost for just a GUI toolkit alone?

      Or maybe you like Apple? How much is the full development kit for Apple? Free. Yeah, how much does Qt cost again?

      The the 3-platform Qt development kit should be around $1000 to $1500 or less. The current price is like $3300 plus $1000 per year for the very basic version with no database support, etc. The higher end versions go up to nearly $7500 and $2300 per year (per developer!). Insane! Especially considering what you can get elseware. Consider the MSDN Universal at $2800 for every single damn product that Microsoft makes!

      There is a reason that most of Apple's developer stuff is free. They are the underdogs and that's a good way to gain support. Qt is the underdog and they will continue to languish there unless they set more reasonal prices. The Opera web browser is suffering from the same thing ($40 for a $20 product? Fuck you).

      I still don't understand why they charge so much. It's obviously a good and popular toolkit, if it were half the price it would completely take over as the GUI toolkit of choice for many software products.

      --
      The ratio of people to cake is too big
    7. Re:Evaluations of some toolkits supporting OpenGL by Anonymous Coward · · Score: 0

      Here you are, stuck in the Linux world, having the choice of 300000 different ui toolkits and each one sucks more than the other.

      Why not write the damn thing in C# where you could concentrate on just writing the game instead of having to write the ui toolkit and debug it too?

    8. Re:Evaluations of some toolkits supporting OpenGL by Anonymous Coward · · Score: 0

      I'd have to agree with your assessment of FOX. It pretends to be a C++ toolkit but the designer really did not appear to have a fundamental understanding of how C++ works. Every GUI event in FOX is an untyped int or void* and the user is supposed to know what set of events every widgets expects. FOX uses static method maps for events - much like MFC. There is little use of virtual functions in FOX - and when it is used it is not consistant. Many of the widgets are not easily extended. Every new FOX release seems to change its API in some non-backwards compatible way. As far as the look - it's not so bad if you like the Windows 98/2000 look on every platform.

      Qt is the gold standard of cross platform GUI toolkits. You actually waste so much time and effort on the other toolkits trying to get your code to behave as Qt does "out of the box" that you might as well bite the bullet and just use Qt instead. I speak from painful experience.
      The cost of Qt is insignificant compared to the sheer frustration of using the alternatives.

    9. Re:Evaluations of some toolkits supporting OpenGL by Quattro+Vezina · · Score: 1

      Qt -- Very good. Commercial license. Can open GL windows. Included graphical UI layout tools. XML-based UI files, but compiled into code rather than loaded at runtime.

      One correction: Qt is a tri-license, GPL/QPL/commercial. It hasn't been purely commercial in years (since around 1998 or so, IIRC).

      --
      I support the Center for Consumer Freedom
    10. Re:Evaluations of some toolkits supporting OpenGL by Fnkmaster · · Score: 1

      For anything that actually uses and needs to manipulate complex GUI applications then wxWidgets sucks.

      Okay, but it's better and much faster to develop in than the alternatives, with the exception of Qt. wxWidgets apps come out excellently in Windows, they just generally require some tweaking to make them work well in Linux as well because it's a native widget wrapping library. But it's _because_ it uses native widgets that wxWidgets has become so popular - compare to using something like Swing (ugh).

      OK, this dispite the fact that wxWidgets feels a lot like MFC. Hmmm.

      People keep saying this, but wxWidgets is FAR simpler to learn and use than MFC and doesn't suffer from many of the severely annoying things in MFC. I find MFC event maps to be heinous - wxWidgets feels much more usable to me (I admit that I still prefer the Qt signal/slot model).

      I picked up and wrote my first fairly complex wxWidgets application in a few weeks. No way I could have done that in MFC.

      As for your "superheavyweight" accusation, I don't see it. wxWidgets apps feel qualitatively just as fast as native apps to me, and the performance gap from hand-coded native apps is not terribly noticeable to me, and apparently not to the many other people using wxWidgets either, since they frequently cite this as a reason they use it. Yes, you inherit platform-specific bugs and issues that you have to work around at times, but this is far easier than maintaining separate GUIs for each platform, and do you really think anybody in their right mind would write Gtk apps with a mostly Windows target market?

      Qt just isn't an option for cross-platform Open Source projects, shareware or other low cost software, or hobbyists that can't afford the entry cost. Thus wxWidgets is "good enough" for many people. For large commercial projects, sure I'd recommend Qt, which I agree deals better with complicated composite widgets and complex GUI applications in general.

    11. Re:Evaluations of some toolkits supporting OpenGL by zorander · · Score: 1

      In my experiences with the wxWidgets code, I found it to be actively maintained, even more actively supported, and not rife with #ifdefs.

      There's a separate directory for each target in the tree that contains sensibly named source files like "notebook.cpp" which implement their name.

      It is true that wxWidgets does not behave identically on each platform. These issues, where they arise, are often dealt with or documented, but it comes down to this--In the several thousand lines of wxWidgets-using code that I've written, I've never once had to detect the platform explicitly. I've occasionally had to tweak something, or fix a bug in my code that one toolkit forgave and another did not, but I've always ended up with one set of code that works on all three platforms. This speaks well of the wxWidgets codebase, as well.

      To be fair, Qt is better at this, but I'm not comfortable with the licensing. Qt was the first toolkit I learned, back in the 1.0 days, and I still remember it as one of the most sanely implemented C++ libraries I've ever encountered...and of course the documentation is among the best.

      I just don't like the limitations on the licensing of software that links against Qt. A library shouldn't affect its applications' licensing in such an overt fashion (GPL or cough up the $$$, pretty much).

      Brian

  10. Does it all have to be in C?-Blender. by Anonymous Coward · · Score: 0

    Why doesn't he look at the blender source code? Their GUI is done using OpenGL.

    1. Re:Does it all have to be in C?-Blender. by Eideewt · · Score: 1

      As I recall, it uses OpenGL's 2d capabilities, which don't work well at all on many graphics cards. I've had trouble with flickering menus and mouse cursors on a couple of computers.

  11. Invent a new wheel by presearch · · Score: 3, Insightful

    If you're taking the time and effort to write "a galactic scale civilization-type" game that's written well enough that it's worth the time for others to play, why not go all the way and do the GUI from scratch too?

    Are you in a hurry to get it out? Running out of steam? Face it. Odds are it's largely an academic exercise and your game isn't going to be the next Unreal super-hit anyway , so why go the extra mile and innovate instead of imitate? If it does turn out to be a super hit, wouldn't it be best to hand-craft a quality game from the ground up?

    Besides, If you were really clever you've got most of the hard part already done in the game components,
    so perhaps you can use the game engine itself, and it's active elements, to build the GUI as well and come up with something that's totally new.

    --
    Looking for short term neural disruption? Play tranquility

    1. Re:Invent a new wheel by Watcher · · Score: 2, Insightful

      Are you in a hurry to get it out? Running out of steam?

      As a counter point to this: he probably wants to build the game, not the GUI. If he was focused on writing the best darned GL GUI out there, then he wouldn't have asked this question. Most game projects die because they get into writing horrid amounts of generic game code (sound mixers, UIs, cross platform IO, so on) that isn't specific to what they're doing. All that accomplishes is making it a much longer path to get to writing the game they want, and the project usually dies from boredom or lack of momentum. If you're paid to write that code, its one thing, but when its something you're doing in your own (generally limited) spare time, you really just want to write the game you want and not have to worry about all of the boring code until much later.

    2. Re:Invent a new wheel by presearch · · Score: 2, Insightful

      If I'm writing a game (or any application) and I'm footing the cost and time, and I see parts of it as boring to write, or not as part of the unifed whole, it's a clue that I might have a design error.

    3. Re:Invent a new wheel by Watcher · · Score: 2, Insightful

      Or maybe you've just discovered that some sort of code isn't all that interesting to write. Maybe would much rather concentrate on getting your application written than writing the XML parser you need. It sounds to me like you're the type who ends up writing the end all be all libraries to write your application. That's all well and good if the libary is something you're interested in writing, but I've seen more than a few folks who wrote an impressive library to get some dinky little application written, burned out, and never got anything done. Personally, I'd much rather use something off the shelf so I can concentrate on getting the goal of the project done, then go back and write a new library later if the old one just isn't up to scratch. Better to ship something that works than never ship something because you burned out making some dinky part of it function.

  12. Ask on the FreeCiv Mailing List by craXORjack · · Score: 1
    I thought that years ago I read someone ranting about how he started writing a game (FreeCiv, I thought) in C and realized later that without any OOP facilities the project had gotten out of hand and he was debating whether he should rewrite it in C++ so that expanding it and maintaining it would be easier. But when I went to FreeCiv.org to doublecheck my memory I couldn't find any info on it and their compiling requirements only call for C, see?
    Specific compiling requirements

    All:

    1. ANSI C compiler (gcc will do)
    2. make

    Unices:

    1. The X Window System
    2. Xaw/Xaw3d and Xpm (3.4k) -or-
    Glib (1.2.6), GTK+ (1.2.6) and Imlib (1.9.7)
    --
    Liberals call everyone Nazis yet they are the closest thing to it.
    1. Re:Ask on the FreeCiv Mailing List by Anonymous Coward · · Score: 0

      Last time I played FreeCiv, it wasn't OpenGl at all ... used standard GtK dialogs.

    2. Re:Ask on the FreeCiv Mailing List by craXORjack · · Score: 1

      Yeah, I meant to suggest he write the game in C++ and use one of the C++ GUI's that he all ready found. That way he gets benefits of object programming as well as a pre-written OpenGL GUI toolkit.

      --
      Liberals call everyone Nazis yet they are the closest thing to it.
  13. GTK + gtkglarea by photon317 · · Score: 3, Informative


    That would be your easiest route. It's all C, it's a decent toolkit, it's fairly portable, etc...

    If it were me, I'd explore that first - but if that didn't work out right (say you want odd shaping of how the GUI overlays the GL stuff), then I'd switch to rendering the GUI into textures and letting OpenGL put the GUI on the screen. Just about anything (GTK or what-have-you) can be made to render to a bitmap in memory which serves as the texture for an OpenGL polygon that's placed where it needs to be for the GUI to look right.

    --
    11*43+456^2
  14. Because he prefers to remain blissfully ignorant. by devphil · · Score: 1


    I suspect he's one of the hordes of (mostly C) coders who believe that using a C++ library requires you to write your entire application in C++.

    Then again, if he's writing in straight C these days, I suspect that learning new and inconvenient facts might not be what he's looking for right now.

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
  15. gtkglext by Apreche · · Score: 1

    I made an opengl C program for my computer graphics 2 class called opengl building blocks. It's a really simple program where you make 3 models consisting of 24 bit colored evenly sized cubes.

    I used gtkglext. Pretty much I write the opengl app. Then I write the gtk gui. I make a drawing area widget and use gtkglext to put the opengl app in the drawing area. It's a beautiful thing.

    Then if I want people to interact with the drawing area I can register gtk callback functions with any events on it. voila.

    Also there is glut, but it is very simplistic. There is a slightly better thing called glutui or some such I forget. It is slightly better than glut with more gui elements. gtkglext I prefer because I get the full gtk2 library right there.

    --
    The GeekNights podcast is going strong. Listen!
  16. GTK + gtkglarea-Evas. by Anonymous Coward · · Score: 0

    He could use evas, and edje.

  17. Re:Because he prefers to remain blissfully ignoran by alienw · · Score: 1

    Even then, C is probably one of the worst languages to write a game in (except maybe assembler). If you are using C because you are too lazy to learn C++, you're in for a world of pain. It's possible to do OOP in C -- it's just a horrible, horrible pain in the ass.

    Seriously, people, read one of Bruce Eckel's books or something. They are available for free on his website and they are the the best programming books I have seen so far.

  18. Re:Because he prefers to remain blissfully ignoran by doctormetal · · Score: 2, Insightful


    I suspect he's one of the hordes of (mostly C) coders who believe that using a C++ library requires you to write your entire application in C++


    In most cases you have to. Rather impossible to call C++ classes from plain C, unless you make a wrapper around them.

    Then again, if he's writing in straight C these days, I suspect that learning new and inconvenient facts might not be what he's looking for right now.

    What wrong with plain c? OO languages aren't suitable for everything.

  19. write your own or use C++ by nickos · · Score: 2, Insightful

    If I was in your shoes, I would think carefully about exactly what GUI elements you want to use. Most likely you'll find you only really need a small subset of the ones that you'd find in a full toolkit (maybe buttons, menus, text fields and comboboxes/dropdowns). If you insist on using C (and I guess you do), you'll probably find that you can code these in quite an efficient way (because your code won't have to be as flexible as code used in a full toolkit). A basic "toolkit" designed especially for your game isn't as much work or as hard as you think.

    On the other hand you could just bite the bullet and use C++. Personally I really like C++, but it took me a long time to lose the prejudice I had towards it.

    Good luck!

  20. Had a similar problem... by AlXtreme · · Score: 2, Informative
    this list contains both toolkits for OpenGL and others, but you're right: C OpenGL UI toolkits aren't very common. PUI, GLUI, GLOW, the more well-known OpenGL TKs are all C++.

    I did find one written in C however: Agar. It's also being actively developed, so might be worth a shot.

    --
    This sig is intentionally left blank
  21. Re:Because he prefers to remain blissfully ignoran by gsasha · · Score: 2

    OO languages aren't suitable for everything.
    Right. But they are frigging darn good for GUI programming, and that's the problem in question.
    Actually, it's hard to find a problem for which plain C would be a better fit, since you can always stick with the C subset of the language. Except maybe when a C++ compiler is not available.

  22. Re:Because he prefers to remain blissfully ignoran by excessive · · Score: 2, Insightful
    Actually, it's hard to find a problem for which plain C would be a better fit
    I'd like to see you suggest that on the Linux kernel mailing list...
  23. Try: irrlicht by tod_miller · · Score: 2, Informative

    has a zlib[?] licence, no obligations really, and you can redist for commercial use.

    Has a full UI set of things.[buttons sliders]

    Yep written in C++ but can use DX 8.1, 9.0, OpenGL1.2 and somethign else, and software.

    And has skeletal animated or quake 2 style meshes. and loads quake 3 maps, objs or 3ds, jpgs and even psd.

    Scenegraph and special effects you can turn on [water, fire etc]

    http://irrlicht.sourceforge.net/screenshots.html

    --
    #hostfile 0.0.0.0 primidi.com 0.0.0.0 www.primidi.com 0.0.0.0 radio.weblogs.com
    1. Re:Try: irrlicht by Wizarth · · Score: 1

      Sorry, I don't think this should get modded up. Irrlicht is a "game engine" (Well, mostly a graphics engine). Its not the answer to the question. He would have to redo all his code to fit in the Irrlicht framework.

      I was going to say, use CEGUI but it isn't pure C. It is a very actively developed GUI system, with renderers for DirectX, OpenGL, Ogre3D and Irrlicht.

    2. Re:Try: irrlicht by tod_miller · · Score: 1

      As far as I saw - he was writing a graphical component to his 'engine' or whatever he was doing. I just pointed to a resource - he can adapt the code or whatever.

      I realise his main reason to make the engine is probably interest and self challenging, but push comes to shove, he has a nice example there.

      Soooooooooooo aaaaand why do you care about the status of moderation? perhaps someone else would have found it interesting...

      --
      #hostfile 0.0.0.0 primidi.com 0.0.0.0 www.primidi.com 0.0.0.0 radio.weblogs.com
  24. Re:Because he prefers to remain blissfully ignoran by Arkaein · · Score: 1

    You can call C++ code just from from what is essentially C code, except for these calls. While that technically makes it C++ code, it doesn't require specific changes to existing C code except where you choose to use you C++ library.

    C++ and C mix just fine. If a programmer afraid to call C++ code from mostly C code without a wrapper for some reason of language purity, I suspect that the problem is with that programmer and not the languages, which work just fine together.

  25. Java2d / 3d? by Anonymous Coward · · Score: 0

    Is moving from c to Java an option? I know that Java supports OpenGL as part of its graphic packages.

    You did, however, say you needed c. Anyone out here is slash-space have any opinions of writing games in Java?

    1. Re:Java2d / 3d? by Anonymous Coward · · Score: 0
      Yeah, don't. Writing games in Java is only slightly less cruel than creating a backend for GCC that generates object code for an architecture that doesn't exist and then compiling your game for that.

      At least one of them is advertised right out of the box as something that will never work for you no matter how hard to try or how many esoteric environment variables and paths you set up.

  26. Write your own AND use C++ by grumbel · · Score: 1

    There is basically no reason to not use C++ these days, sure ABI compatibilty can be worse than C's and there are a few other minor compability issues, but hardly any of them matter for game programming. So pick a good C++ book (ie. Acceleraled C++) and learn the language, there is really no reason to avoid it, especially when the alternative is plain C.

    About the GUI, I would recomment to write your own. Games after all often need some special properties (zoomability, transparency, pie-menus, WiW) that some normal GUI can't match or only if you write almost all of your widgets yourself. Writing your own GUI will save you the time to workaround the limitations of some premade GUI, especially since the benefits of a premade GUI toolkit won't be of much use for a game (no need for uniform look and such).

    Last not least, if you really want to go C and a premade GUI toolkit, you could go for GTK+ and GtkGLArea (or however that OpenGL widget is called) and then just run your game in the GL widget which is surrounded by normal GTK+ GUI elements. Sure it won't look as pretty as native OpenGL stuff, but it might be the easiest alternative, see FreeCiv for example which does this (well, beside it doesn't use OpenGL).

  27. Re:Because he prefers to remain blissfully ignoran by doctormetal · · Score: 1

    You can call C++ code just from from what is essentially C code, except for these calls. While that technically makes it C++ code, it doesn't require specific changes to existing C code except where you choose to use you C++ library.

    That is only true if you compile your C code with a C++ compiler, otherwise you will get in a lot of trouble (name mangling, class constructors/destructors that are not being called, etc).

    C++ and C mix just fine

    Only if you pass them both through the same compiler.

  28. SDL + OpenGL + GUI by ggambett · · Score: 2, Informative

    Write your own, in C++. It's easier than it sounds if you design the controls correctly. I wrote the UI for our games (see Betty's Beer Bar for an example) and it didn't take too much time. It's not OpenGL but the idea is the same, only the drawing part changes.

    As for OpenGL, keep it generic - you can hook a SDL window and Direct3D (I submitted a mini howto but I think Sam never included it, check the mailing list archives), so a good idea may be to create or use an abstraction library that can use either OpenGL or Direct3D. Since Direct3D 8+ is almost a copy of OpenGL, writting one is also easier than it sounds. And if your license is compatible, there's a simple wrapper in the Doomsday Engine project.

    Of course, you can always use a 3D engine which already includes a GUI (we are currently using OGRE) and which solves the OpenGL/D3D/Whatever abstraction.

    Good luck!

  29. Perfect Solution...But by skally · · Score: 1

    It seems to have disapeared off the net, but there was a project on lisdl.org called SymphonieNG Link This project was basically a tracker using SDL & OpenGL which used a 2D OpenGL GUI. AND it was written in standard C. Maybe it is cached somewhere, but I can't find it at present. It was also linked on opengl.org

  30. I think it isn't that hard to build your own.. by FractalPenguin · · Score: 1, Informative

    Of cource it is bothering job when you invent wheel that already exist.

    But it is better. Fast. Smaller code. And it makes your code *SIMPLER*.

    You don't have to learn GUI developer's coding style.

    I also doing my GUI job on my own using OpenGL Ortho + GL_RECT + Textures.
    It didn't took that long time. Almost 2 weeks passed and I managed to make the GUI controls that is very simple button, text, editing area, list control for the long text, combobox for the my 3D modeler and popup style menu...
    Every control shares most part of their elements so you don't need any hard job to make new component, just a simple modification you get new one. I use C++ so just one inherit I get new one.
    And you can and will use this codes all over the game. Because game need not only windows style GUI that is hard to manage with GUI library.

    Well what I wanted talk about is.. it doesn't take that long time and it worth it. Just make your own.

  31. The quick answers are... by devphil · · Score: 1


    1. DUH. Wrappers are implied here. They can even be automaticlly generated, if the C++ library in question doesn't already provide them.
    2. "Mu." One can use plenty of C++ without using OO... but since the discussion is about GUIs, which are inherently OO, it'd be kinda moot.
    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
  32. Re:Because he prefers to remain blissfully ignoran by mikefe · · Score: 1

    Yes, but what about non-systems programming?

    --
    There: Something at a specific location.
    Their: Owned by someone.
    Please make sure your english compiles.
  33. Not on all platforms by tepples · · Score: 1

    Even then, C is probably one of the worst languages to write a game in (except maybe assembler).

    Not always. For example this situation: Your boss has given you an 8-bit microcontroller clocked at 1.8 MHz, a video controller, and a video game design. Implement the game engine. Will you choose anything but assembly language on an 8-bit CPU, especially when you have to fit video memory updates into vertical blank time?

    1. Re:Not on all platforms by alienw · · Score: 1

      True, but a game for an 1.8MHz microcontroller won't be very complex as far as design. Basically, it's programmer time and effort versus computer power. Programmer time is much more expensive for anything except mass-market products. In short, on a today's PC, it's better to program in a higher-level, possibly less efficient language.

    2. Re:Not on all platforms by tepples · · Score: 2, Funny

      but a game for an 1.8MHz microcontroller won't be very complex as far as design.

      I'm sure you didn't realize it, but you just insulted NES developers and retrogamers everywhere.

    3. Re:Not on all platforms by daft_one · · Score: 1

      Did he really? I mean, I enjoy those old games BECAUSE they're not very complex as far as design ;-)

    4. Re:Not on all platforms by alienw · · Score: 1

      First, an NES has a relatively powerful graphics processor. So it isn't exactly an 8-bit microcontroller application. 8-bit micros appeared long before the NES. Second, I've yet to see a Doom port or an MMORPG for the NES. Third, none of the homebrew NES stuff is even close to the real capabilities of the NES -- it's more like Atari 2600 games.

      I think it just about proves my point -- it's a waste of time for a developer to try to compensate for a slow processor by excessively optimizing code. This might make sense for mass-market products where a penny saved on manufacturing translates to millions. It does not make any sense for an open-source developer.

    5. Re:Not on all platforms by tepples · · Score: 1

      Second, I've yet to see a Doom port or an MMORPG for the NES.

      The "destroy hordes of baddies" theme of Doom was alive and well in Smash TV, an arcade port, as well as many other similar overhead-view shooter games. Remember that even Wolfenstein started out as a 2D game. As for MMORPGs, people weren't willing to tie up phone lines during those years when the NES was commercial.

    6. Re:Not on all platforms by ultranova · · Score: 1

      First, an NES has a relatively powerful graphics processor.

      Not to mention a separate memory controller chip, which was located in the game cartridge. You couldn't scroll back the level in Super Mario 1, because the controller didn't support it, but Mario 2+ had a more advanced version.

      So it isn't exactly an 8-bit microcontroller application. 8-bit micros appeared long before the NES.

      I seem to recall those micros also using auxiliary chips. Could be wrong here...

      Second, I've yet to see a Doom port or an MMORPG for the NES.

      Kinda difficult to make online games for a device which lacked any sort of connetivity...

      NES has Zelda 1 & 2, Megaman series, Metroid, and Super Mario 2 & 3, all of which are arguably far more complex games than Doom, as far as gameplay and gameworld mechanics go.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

  34. Re:Because he prefers to remain blissfully ignoran by tepples · · Score: 1

    > C++ and C mix just fine

    Only if you pass them both through the same compiler.

    And what popular platform with OpenGL doesn't have a decent C++ compiler?

  35. Re:Because he prefers to remain blissfully ignoran by tepples · · Score: 2, Insightful

    Game programming has more in common with systems programming than some may think. In fact, I come from environments where all game programmers also must be systems programmers, namely Apple II, NES, MS-DOS, and Game Boy Advance.

  36. Try Tcl/Tk by rmadhuram · · Score: 0, Offtopic

    Years ago, I wrote a flight sim type application using Embedded Tk (in C) and OpenGL. Tcl was very handy to build a decent GUI very rapidly.

  37. You might check out blender's sourcecode.... by Zphbeeblbrox · · Score: 3, Informative

    It's UI is completely done in opengl and the library (Ghost) hasn't been mentioned. The blender developers wrote it when Glut didn't quite fit the bill for them.

    Blender

    --
    If you see spelling or grammatical errors don't blame me. I tried to preview but IE here at work borked the CSS
  38. Re:Because he prefers to remain blissfully ignoran by Anonymous Coward · · Score: 0

    OS X, freebsd, netbsd, and solaris just that I know of. Gcc is barely a capable C compiler, nevermind C++.

  39. Re:Because he prefers to remain blissfully ignoran by Monkelectric · · Score: 1
    Even then, C is probably one of the worst languages to write a game in (except maybe assembler). If you are using C because you are too lazy to learn C++, you're in for a world of pain. It's possible to do OOP in C -- it's just a horrible, horrible pain in the ass. Seriously, people, read one of Bruce Eckel's books or something. They are available for free on his website and they are the the best programming books I have seen so far.

    Amen! The correct way is of course to write the engine in somethign fast C/C++ then design the GAME in something easy like lua or python. Thats how its been since the begining of time.

    --

    Religion is a gateway psychosis. -- Dave Foley

  40. GUI by Anonymous Coward · · Score: 0

    If you want something quick you can always use Tk alongside ToGL http://togl.sourceforge.net/...

    You basically write your GUI in Tcl/Tk and use ToGL for the OpenGL rendering window...

  41. Need a better analogy by Anonymous Coward · · Score: 0

    If Minix was good enough for Linus then Minix would have been what Linux was(and is). It wasn't.

  42. GUIs are not easy by UnConeD · · Score: 3, Insightful

    I'd strong recommend against making your own UI toolkit. Many programmers seem to have the idea that anything involving GUIs is easy, because it's designed for 'stupid users'. Not so.

    UI's are complex beasts that need to be fast, consistent, flexible and powerful. 'Designing' a UI is not about making pretty skins for the buttons, but defining the behaviour and actions in the UI so that they form a harmonious whole.

    Take for example, the 'simple' scrollbar. It consists of 4 areas to click on: the up/down arrows, the thumb to drag around and the gray area outside of the thumb which you can click to go up/down a page. The thumb's length should represent the visible portion of the document/item. If the view shows 75% of the item, then the thumb should cover 75% of the scroll 'gutter'. When viewing a list of lines or items, scrolling should stop as soon as the last item has appeared at the bottom. The granularity of the scrollbar should match the contents that are being scrolled (don't make a smooth scrolling bar if the contents only skip up/down line per line).

    Nearly every Flash brochure site and computer game out there which implements its own widgets violate at least one of these rules for scrollbars. Think about all those tiny little implicit rules about buttons, checkboxes, menus, ...

    If all you want to do is make a GUI, then by all means, code one. If you want to make a game, find a good, existing toolkit and use it.

  43. Other programming projects you may enjoy: by joblessjunkie · · Score: 1

    Macintosh System 6 Toolkit Applications
    IBM CGA Games with PC Speaker audio
    Mouseless User Interfaces

    ... and other technologies which are twenty years obsolete....

  44. Check this engine comparison site by phearlez · · Score: 1
    DevMaster has an engine comparison database you should check out. User reviews, prices, features, etc.

    You may want to just go for the Torque engine that Tribes2 and on uses. It's not free but it's full featured and well reviewed.

    --
    Bad management trumps ideology - Show the world you want better leadership. http://www.timefornewmanagement.com
  45. Re:Because he prefers to remain blissfully ignoran by No+Tears+In+The+End · · Score: 1
    • What wrong with plain c? OO languages aren't suitable for everything.


    They might not be preferable, but that's not the same as suitable.

    C++ is an OOL. You have the option of using OOP, it's not mandatory. With minor changes to things like your includes and namespace declarations, it doesn't take too much work to get an old C program to compile with a C++ compiler.

    --

    -You can cry, but you'll still die. There'll be no tears in the end.