Making a GUI for OpenGL Games? 96
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?"
Invent a new wheel (Score:4, Insightful)
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 [tqworld.com]
Re:It's been done (Score:5, Insightful)
Exactly...
Re:Because he prefers to remain blissfully ignoran (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.
write your own or use C++ (Score:3, Insightful)
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!
Re:Because he prefers to remain blissfully ignoran (Score:2, Insightful)
Re:Why not use C++ (Score:3, Insightful)
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).
Re:Invent a new wheel (Score:3, Insightful)
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.
Re:Invent a new wheel (Score:3, Insightful)
Re:Because he prefers to remain blissfully ignoran (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.
GUIs are not easy (Score:3, Insightful)
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.
Re:Invent a new wheel (Score:3, Insightful)