Slashdot Mirror


What 2D GUI Foundation Do You Use?

Zmee writes "I am looking to build a 2D application for personal use and I will need to use a canvas to paint custom objects. I am trying to determine what foundation to use and have not located a good side-by-side comparison of the various flavors. For reference, I need the final application to work in Windows; Linux is preferred, but not required. I have looked at WPF, Qt, OpenGL, Tcl/Tk, Java's AWT, and others. I have little preference as to the language itself, but each of the tutorials appear to require significant time investment. As such, I am looking to see what the community uses and what seems to work for people prior to making that investment."

39 of 331 comments (clear)

  1. HTML and Javascript? by Anonymous Coward · · Score: 4, Informative

    HTML and Javascript?

    1. Re:HTML and Javascript? by arivanov · · Score: 5, Interesting

      I would agree.

      Investing your time into Qt is the best investment. Stick to C++ and Python. Both work.

      Avoid Perl-QT though. Not that it does not work, but it makes your brain go numb because you end up writing in pidgin-C++ intersperced with Perl. It overrides perl default OO conventions and uses C++ ones. There are parts where you have to outright put C++ snippets into the Perl code to get it work.

      Tk is also good, but obsolete by today's standards. Its one and only remaining use is writing UIs for Perl where you cannot use web ones.

      Avoid GTK: Grave danger you are in. Impatient you are. Once you start down the dark path, forever will it dominate your destiny, consume you it will. Always write Yoda code you will...

      --
      Baker's Law: Misery no longer loves company. Nowadays it insists on it
      http://www.sigsegv.cx/
    2. Re:HTML and Javascript? by g4b · · Score: 3, Informative

      You could use Googles GWT to write your GUI, and simply display a webkit window in the application, making it server-client friendly and usable via browser if needed.

      GWT is fairly cool and very advanced. You write stuff in Java, and it is translated to browser specific javascripts.

      However, I would still use Qt. For smaller projects I used wx already. PITA.

    3. Re:HTML and Javascript? by caseih · · Score: 5, Informative

      GTK+ is certainly weaker on the Windows and Mac side than Qt. But as far as speed and ease of coding, GTK+ is right up there. GTK++ is a great binding for C++, and PyGTK is quite good too. Writing Qt GUIs in PyQT is okay, but it's essentially the same as writing C++ code. In fact, it is the bindings where Qt is the weakest and where GTK+ is a bit better. Qt is written in C++ using the C++ object model and all it's features and warts. This does not always translate very well to other languages. A few years ago all Qt bindings for other languages were based on the QtC bindings because of this. Now Qt bindings are better. But GTK+, being based on a much simpler object model (the GOject) is very easy to wrap in C++, Perl, Python, Ruby, etc. PyGTK is one of the more comfortable toolkits to develop in and feels more at home in Python than Qt (PyQT; never have used pyside).

      GTK+ is hardly the "grave danger" the parent claims. For a lot of things it is a very nice toolkit to develop in. And the parent's statements on Tk are are not quite accurate. Tk is still alive and well, and looks reasonable in the modern incarnations on the big 3 platforms. It seems a bit daft to me to embed another entire language in my program (tcl) but sometimes that just might be the easiest. Many little utilities written in Python still use Tk. It's fast, easy, and always there if Python is there.

  2. How many FPS are you looking for? by CosmeticLobotamy · · Score: 3, Informative

    GDI+ is good enough for low frame rates and trivial to use if you have any C# experience. If these are static controls that need to be painted and then updated on user input, it's more than sufficient.

  3. .NET Windows Forms by peterindistantland · · Score: 4, Informative

    Nothing is easier for amateurs, even though I'm no Microsoft fan.

  4. More information by Dan+East · · Score: 5, Insightful

    You haven't provided nearly enough information. Are you talking GUI interfaces, or rendering? If rendering, is it raster or vector? If vector, then what primitives do you need? Full SVG? Is this real-time, and if so, how many polygons / pixels do you need to push and at what minimum framerate?

    As a totally shoot-from-the-hip, off-the-wall recommendation, I'd say OpenGL for portability, including support on iPhone / iPad / iPod touch. Note that you'll want to stick to the OpenGL ES subset in that case.

    --
    Better known as 318230.
    1. Re:More information by Zmee · · Score: 3, Informative

      Original poster here. I am looking to implement a customized card game (think Magic or Yu-Gi-Oh). This is my step-son's first foray into development, and my first UI requiring any custom controls. (I have done a fair bit of ASP.NET, PHP, and Windows Forms, but most of that is not applicable given what I am planning here). The idea is to be able to create the card images from a combination of stored bitmaps, text, and some general backgrounds. As such, much of the GUI will be vectored, but some must be raster (ie the bitmaps). Note that given the general structure, framerate is not a high consideration.

      Note that I have not ruled out a HTML 5 UI and if I went with Java AWT, I may wrap it as an applet. I would certainly like to stay away from Flash (& am leaning against Java for similar reasons), but have not ruled that out either.

  5. AWT or OpenGL by Philotomy · · Score: 5, Informative

    I'd use Java AWT or OpenGL. They're both cross-platform, and what you learn will can be easily leveraged elsewhere, since they're widely adopted technologies. (No matter what you pick, you're going to have some learning curve.)

    1. Re:AWT or OpenGL by timothyb89 · · Score: 3, Interesting

      Seconded. Swing is (despite what many people around here would like to believe) a very capable GUI library. It's by far the best object oriented GUI library I've come across, with a much more logical API than SWT, Qt, or GTK. Plus, Java2D for raw drawing is incredibly easy to use and it automatically gets hardware acceleration (OpenGL on *NIX systems) so the performance is good. Swing does have a bit of a learning curve, but there's excellent GUI builders for it (e.g. NetBeans) and the API really makes a lot of sense when you learn it.
      If Java isn't your thing, Qt would probably be the way to go. I find the API a bit clumsier than Swing, but the major features (hardware accel, powerful 2D, and cross platform) are there. On the other hand, raw OpenGL has a comparatively huge learning curve and wouldn't have any sort of system look and feel. It would likely be the best performance-wise, though.

    2. Re:AWT or OpenGL by peppepz · · Score: 3, Informative

      Swing's API is just horrible.

      Swing's API is not bad. It allows you to create a working mirrored, 35-rotated radio button with three lines of code. It's true that built-in layout managers suck, but BoxLayout is almost usable. And if you don't like them, then don't use them at all, and fall back to absolute positioning, which is what most other toolkits do anyway. Moreover, the original poster didn't require a widget toolkit, but rather a 2D graphics API.

      For example, why the hell does java.awt.Graphics.drawRectangle() not accept a java.awt.Rectangle as a parameter?

      Graphics.drawRectangle() does not exist. Are you talking about Graphics.drawRect()? It's a legacy API from Java 1.0 which was intended to run on machines where the overhead of converting coordinates into a heap-allocated Rectangle structure could be significant.
      Instead you should use Graphics2D.draw(), which consistently supports any Shape, including a Rectangle. It also supports floating point coodinates, transforms, etc. Please update your trolling to 2005, thank you.

      I do still agree that Java is one of the better choices for cross-platform GUI building, by virtue of not being overcomplicated and error-prone like C++ or unbearably slow like Python; but if this is the best we can do, I weep for the future of the human race.

      Instead, in my opinion Java2D is the most elegant, intuitive and powerful 2D "canvas" API I've ever used. For example, it allows you, with a few lines of code, to load an OpenType font, format a string using it, and convert it to a Shape which can be rendered using the current stroke and fill properties. Any step of the process can be customized using the same API: you can break the string in lines using a layout, you can iterate the vertices of the resulting Shape, you can apply transforms and clipping, the usual Porter-Duff composition, and you can control the rasterization from Shapes into pixels. All of this implemented mostly in pure Java, with fully commented source code available, and it's available out of the box in all Java implementations.

      Tutorial.

  6. FLTK by printman · · Score: 4, Interesting

    FLTK (www.fltk.org) is still in active development and is my cross-platform toolkit of choice - C++-based, easy to use, and works on Windows, Linux, and Mac OS X with ports for other platforms available.

    --
    I print, therefore I am.
    1. Re:FLTK by joss · · Score: 3, Interesting

      I love FLTK, I really do, but .. I dunno, now PySide is around I might have to go over to Qt..just seems that fltk progress is a little glacial and pyFLTK has not been updated since 2009. C++ for everything seems a little painful these days

      --
      http://rareformnewmedia.com/
  7. WPF, Qt, or Python by PhrostyMcByte · · Score: 3, Informative

    Out of everything I've tried (pretty much everything usable from C, C++, and C#), WPF is the best UI framework around. It is extremely flexible and can be very intimidating if you try to learn all the details too quickly, but the basics of it are easy. You should be able to pop out a good design pretty quickly. It's a shame that Mono has no plans to implement it, because everything else feels primitive in comparison.

    If you don't mind dirtying your C++ with a less-than-modern design and ugly preprocessor hijinks, Qt can be a pretty solid framework. Works well on many platforms and is full of features. Has a lot of portable non-UI things too, but I haven't used much of it.

    Python's UI stuff is simple but has a lot of features. Great for quick, portable apps. Easy integration with C++ if you need it.

    I avoid wxWidgets. The last time I tried using it (about a year ago), I ended up very frustrated rooting around their code to find that it makes a bunch of stupid assumptions about things like DPI, default fonts, etc. that fall apart pretty easily.

    I also avoid GTK, but mainly just because it always feels "off" on Windows.

    1. Re:WPF, Qt, or Python by forkazoo · · Score: 4, Interesting

      Out of everything I've tried (pretty much everything usable from C, C++, and C#), WPF is the best UI framework around. It is extremely flexible and can be very intimidating if you try to learn all the details too quickly, but the basics of it are easy. You should be able to pop out a good design pretty quickly. It's a shame that Mono has no plans to implement it, because everything else feels primitive in comparison.

      If you don't mind dirtying your C++ with a less-than-modern design and ugly preprocessor hijinks, Qt can be a pretty solid framework. Works well on many platforms and is full of features. Has a lot of portable non-UI things too, but I haven't used much of it.

      Python's UI stuff is simple but has a lot of features. Great for quick, portable apps. Easy integration with C++ if you need it.

      I avoid wxWidgets. The last time I tried using it (about a year ago), I ended up very frustrated rooting around their code to find that it makes a bunch of stupid assumptions about things like DPI, default fonts, etc. that fall apart pretty easily.

      I also avoid GTK, but mainly just because it always feels "off" on Windows.

      Hmmm... Where do I start. The "Python UI stuff" that you are talking about is probably tk. It's worth noting that you can use tk from many other languages besides python, python wasn't the first language to support tk, and tk isn't the only "UI stuff" that you can use in python. (For example, most of the GUI python stuff I've written has used Qt, which you imply requires working in C++.) For bonus points, you can even try to import Qt, catch an exception if that fails, and use tk to do your UI if Qt is unavailable on the system where you are running. All in one script, extremely portable, and nicer looking than tk whenever possible.

      As for Qt in C++, as an application developer, I don't really care if the build system is a bit wonky. When I put on my architect hat, I can certainly say that Qt is a giant monstrosity that is very different from anything I would have created on my own. But, that sort of philosophical issue doesn't really effect anything when you are making an app.

  8. Qt by goruka · · Score: 5, Informative

    Having used everything on the list and much more (such as wx, GTK, etc), as well as making my own toolkits for embedded devices and products, my personal experience tells me hands down that Qt is the best choice for anything GUI related. It's power, ease of use, tools, documentation and learning curve are unparalleled to this day and age. Any other toolkit or API I've use fails in one or more of such areas.
    Qt is the only toolkit that made me feel as if they could know in advance everything i'd ever need (so when i go to the docs it's there, right how as i imagined it should be), yet keeping the bloat down with great modularization. I have used it from C++ as well as from Python with great success.

    1. Re:Qt by Anonymous Coward · · Score: 5, Interesting

      I agree with this. Qt is seriously really awesome.

      I've also used everything on the list (Java AWT, Swing, Gtk, C# & .NET Forms, WPF, OpenGL, WxWidgets, MFC, GDI+, etc) and nothing comes even close.

      While some of the things on the list are pretty easy to use (arguably as easy as Qt), they lack something major (such is portability or speed for example). For example, I worked at a place where we used to write some apps in C# due to customer request - it turns out that we had to write several components in native C++, then export the interface to C#. That was the only way we could meet the speed requirements! So much for non-native languages...

      Since version 4.x, Qt library has been modularized into different components (e.g. GUI, Network, XML, etc) and thus it is not bloated as some people are suggesting. A Qt GUI DLL is nothing bigger than WxWidgets one for example.

      The catch is that Qt is a entire framework (something similar to Java Class Library or .NET framework) for building applications. So for example, if you were to use GTK or OpenGL for graphics, you'd have to use another library for threading and another library for network, XML, etc.

      Qt has components for all of those things.

      Oh, I also found that no other framework comes close to Qt when doing OpenGL. There are certain annoyances when programming with GLUT for example, but if you use Qt as a base for OpenGL, you just override couple of functions such are initGL() etc and you have an OpenGL application up!

      It also has excellent tools and amazing documentation! Did I mention that its portable? :)

    2. Re:Qt by Twinbee · · Score: 3, Interesting

      I initially wanted to use Qt for my latest project, but I'm rather concerned at the license which says you can't upgrade to a commercial version of the Qt license if you start the project as the free (beer) LGPL license. It makes no sense because a project may start off small, but then expand later.... and at that point, you can't then use the better (albeit expensive) full license. I moaned about the subject here:

      http://www.qtforum.org/article/34891/licensing-issue.html

      I'm hoping Nokia will adjust their stance on this issue, otherwise .NET/Winforms/WPF looks ever more tempting.

      --
      Why OpalCalc is the best Windows calc
    3. Re:Qt by simula · · Score: 5, Informative

      What do you want from the commercial license that you aren't getting with the LGPL version?

      The LGPL license allows you to close your product and distribute it without opening your source code as long as you link to the Qt dynamic libraries.

      If you make changes to Qt itself, you are required to open those changes back up, but as long as you utilize dynamic libraries, you can make your app as closed as you want.

    4. Re:Qt by Anonymous Coward · · Score: 3, Informative

      Please don't mod this informative, the GP's interpretation is correct.

      > http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License#Differences_from_the_GPL

    5. Re:Qt by ByteSlicer · · Score: 5, Informative
      Dynamic linking is certainly possible with the QT libraries.
      Just because your C++ applications contains some function signatures, symbols and constants from the QT API doesn't make it a 'real' derived work, since this is using the library as intended.
      One part of LGPL section 5 states this:

      If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work.

      On the GNU website you can find the official standpoint on this matter.

  9. Qt by simula · · Score: 5, Informative
    If you are comfortable with C++, I heavily recommend the Qt framework.
    • There is an LGPL ide Qt-Creator that has an integrated form designer.
    • The code you write is amazingly cross-platform.
    • The framework is amazingly comprehensive for when your needs expand.
    • There are top notch learning resources, including excellent books.
    • The Qt framework is LGPL.

    I use the Qt framework at home and at work and I have published a couple teeny GPL'd apps:

    Regardless of which framework you decide to use, I wish you luck!

  10. Re:Obvious choice is OpenGL by TD-Linux · · Score: 5, Informative

    OpenGL? "Lightweight"? Sure, I suppose because it's all implemented in the system, you don't have to redistribute much, but have you actually ever written anything remotely complicated in raw OpenGL? For anything resembling a GUI, the poster is going to spend months of writing low-level code that's been done a thousand times already.

    Qt is heavy, but it's heavy for a reason - it includes a very nice set of tried-and-true widgets, with all the nice features and weird corner cases thought of already. It's also fairly speedy, and even more so if you use QGraphicsView, which can be optionally accelerated via OpenGL for even more speed.

    Qt also has nice support for custom widgets. You can subclass any widget, or QWidget, and make anything you want. You can even integrate your custom widgets with Qt Designer, either by promoting a placeholder widget, or writing a Designer plugin so your widget is WYSIWYG.

    OpenGL is so low level that everything I talked in the last two paragraphs is completely beyond its scope. Even font rendering is rather arduous, and good luck with nicely word-wrapped, formatted text.

  11. More info needed by BitZtream · · Score: 3, Insightful

    If you want 'easy' with a slightly 'limited' set of options long term, then I would say Windows Forms in a .NET language, use Mono rather than VisualStudio so you have a much easier chance of it working in Linux out of the box, and most likely OSX, FreeBSD and several others in the process. Its not required, but Mono's code completion will point you in the right direction where as VisualStudio is going to point you more towards MSy things. Though VisualStudio is much more enjoyable to use in my opinion. If you've never used either, its not likely to matter for a while I suspect, though on OS X, Mono seems to miss most initial clicks I send to it, could just be me.

    That will give you all the basic controls an application gui will need and make it so you can reuse the massive amount of examples out there.

    For your custom painted widget its a little different. What kind of painting are you doing?

    Is it something that lends itself to OpenGL really well? If its fits well into geometric primatives, then I would go with OpenTK's OpenGL Control. Works pretty good in my experience.

    How often does it update the displayed data? Is it a game/animation kind of thing or are we talking about something that renders once after the user changes a setting?

    If you need a high FPS on the updates, you're going to want to use OpenGL with textures for displaying the rasterized data. You're learning curve will be a little steep I think if you're starting from no knowledge, but its probably your only solution for something that needs to be fast (I'm just flat out ignoring DirectX, which for Windows would be easier than OGL but would cut you off of Linux and the advantages on Windows aren't that great really)

    If you have real slow update rates, then you could just throw a image control on a form and paint the pixels yourself one at a time, or load images from a file/resource.

    If this is a project that has a long expected life and will become rather complex and need high performance eventually, then you're probably going to do it wrong the first time no matter WHAT you do now, at least, thats my experience. I never get it right until AT LEAST the 3rd rewrite :/

    --
    Persistent Volume manager for Kubernetes - https://github.com/dwimsey/openshift-pvmanager
  12. He's looking for drawing, not a toolkit! by spitzak · · Score: 4, Insightful

    Stop suggesting various toolkits, that is NOT what he is looking for.

    He is looking for a "canvas" widget, meaning he wants drawing API.

    It is unfortunate that most drawing apis are tied to particular toolkits, so he may have to choose one, but if you are comparing them you have to compare the 2D drawing primitives.

    There is also Cairo and OpenGL, which are not really tied to toolkits. Though you still need to jump through hoops depending on the toolkit to get it so the graphics calls draw where you want. Sigh.

  13. I second this, OpenGL and QT are both great. by joetainment · · Score: 5, Interesting

    I second the parent post. However, in my opinion, OpenGL only is pretty tough to use. It takes a lot of knowledge. (GLUT can help to get you started.)

    Where OpenGL would require you to program too much functionality from scratch, I personally recommend QT, using OpenGL only where you need it. QT is easy to learn, easy to code for, provides *tons* of functionality, and it performs great. In fact it performs well enough for very heavy 3D animation software to rely on it. (Maya has now been rewritten to use QT, and it is a big improvement.) You can paint your own custom anything, and even easily integrate 3D into your project. I really can't say enough good things about QT. It is now available under the LGPL, so you can use it for open source or closed sourced projects.

    As mentioned above by the parent, QT isn't lightweight, but it isn't a pig either. You can use as much or as little of the toolkit as you like, and it can run very fast and have very low overhead. It is light enough that Nokia is using it as their primary development framework for mobile apps with their upcoming Meego based phones. From my personal experience QT flies.

    Also, I've had great results with PyQt and with PySide. PySide is the new, "official" binding for QT on Python. They have examples in their demo folder of custom canvas based applications, and they work great and are easy to follow. You can have your own similar program, written from scratch in Python, up and running in 10 minutes.

    It should also be noted that because QT works so well cross-platform, it has a huge advantage over toolkits that are tied to a single operating system. (Particularly those from MS.) In my own work, I won't even consider using something that doesn't run on Windows, Mac, Linux, and potentially more operating systems. I use all kinds of devices, and I don't want to be tied down. QT makes cross platform development straightforward, and software like Autodesk Maya is proof that it works even for highly complex projects.

    I know I'm starting to sound like a salesman, but my experiences really have been that positive. About the only downside is that there aren't current C# or Java bindings for it. This doesn't matter to me though, because I've got C++ where I need performance and Python where I want ease of use. (With Cython, you can easily have performance and ease of use at the same time.)

    I hope that helps.

  14. Swing + Java2D by SplashMyBandit · · Score: 4, Informative

    Who suggested Java AWT? What is this, 1998? Someone is behind on their homework :).

    Java's Swing + Java2D is *fully hardware accelerated* (ever since Java 1.6.0_u10 some time ago), multi-platform, with good multi-thread support (not for rendering, you don't need that, but for the rest of the program), very customizable, and looks fantastic with the Nimbus look&feel (a standard part of Java). Swing is used a lot on the enterprise desktop (and a few shrink wrapped products too - I know I've purchased some as they were best-of-breed tools). Many of the Java Swing ttools are free and there are a lot of them (eg. Matisse in Netbeans makes creating GUIs a snap). Java2D had extensive contributions from Adobe who happen to know a thing or two about presentation. Plus, drawing in Java2D also allows printing relatively simply.

    1. Re:Swing + Java2D by SplashMyBandit · · Score: 3, Informative

      Incorrect on both counts.

      Swing was designed to use a minimal amount of AWT (to set up a rendering contents and basic window and event management). Most of AWT is deliberately not used by Swing to reduce platform-specific issues (nb. one of the reasons Swing was invented was to bypass the limitations of AWT). Swing renders using Java2D rather than the native widget rendering of AWT.

      The "Java2D is AWT" statement is incorrect. Java2D used to be a software library for rendering to a context. It is now fully hardware accelerated via DirectX or OpenGL shaders (depending on the host platform and pipeline selected). AWT includes Java2D but also a whole bunch of other stuff for window management, host system interaction, event management, input management etc etc. So, AWT includes Java2D but it is *not* the same as Java2D.

      Does that clarify it enough so you can see the inaccuracy in your statements?

  15. Qt has flaws by valkenar · · Score: 4, Informative

    I use QT and love it too, but it has some serious drawbacks, from my perspective. The biggest is that it requires a wonky special compilation system. You either have to use the build system they offer (qmake) or you have to manually run their generator yourself (moc - though if you were a masochist you could learn to write out the files moc makes yourself and avoid using it).

    I compare every IDE to Eclipse, because that's the best IDE I've seen for any language. But I've never found that CDT, the C++ plugin for Eclipse, is any good. It fails to work out of the box for me and is a pain to configure (but I haven't tried it in a few years). QT Creator, while usable, is really an immature product. There's no support for refactoring, the UI is unintuitive and awkward (for me, at least) and there's lots of little issues with it. Plus you're committed to MingW, which can be a problem depending on what libraries you want to use. Codeblocks is a pretty good IDE, but it doesn't have a QT plugin, so you're left with the problem of dealing with moc files. Visual Studio has a plugin, but it only works with the paid versions.

    All of this can be dealt with (and I do) but it's annoying.

    1. Re:Qt has flaws by TD-Linux · · Score: 3, Informative

      The "wonky" compilation system isn't bad, and the benefits it provides overcome any ideological "oh my we are corrupting the pure and wonderful C++" feelings that I might have. It's really easy to integrate into CMake, and it doesn't matter with autotools, because everything is hard with autotools.

      I also don't know where you got the idea that the VS plugin works only with paid versions. It works fine with the LGPL plugin for me.

  16. Easy Choice by fean · · Score: 3, Informative

    Adobe Air -
    Easy UI interaction framework, very powerful drawing APIs, runs on windows/linux/mac/android.

    http://www.adobe.com/products/air/

    Latest version lets you call native apps on windows/linux/mac.

  17. For "personal" Apps by ratboy666 · · Score: 4, Informative

    I don't have much time... I write the GUI, and any drawing logic with Tcl/Tk. Easy, portable. Any time critical or extensive logic gets pushed into C or FORTRAN (depending on what it is). Just standard in/standard out. Parse the output with Tcl, and display.

    A recent example -- I needed to upgrade some systems for a client (Solaris 6 to 10). We needed to identify the binary parts (non-OS) that needed to move. I wrote a GUI tool (binport) for this. Took 2 days to write, ran on Linux and MacOS X (two of us shared the work). After the job, the tool was essentially discarded.

    No time to "debug" really, and I don't typically have time for compile and test cycles. Tcl is an interpreter, with very simple syntax and semantics.

    Other examples that have used Tcl/Tk -- the GUI layer for GDB, Redhat Source Navigator, etc.

    Yes, it's not "sexy", or even particularly "new", but it works, and works well.

    --
    Just another "Cubible(sic) Joe" 2 17 3061
  18. Re:The answer by Anonymous Coward · · Score: 5, Funny

    I'll create a GUI interface using Visual Basic, see if I can track 2D canvas objects.

  19. JAVA + SWING by tgetzoya · · Score: 5, Interesting

    Personally I prefer Java + Swing. Add Java2D and you have everything you need. If you want it to look native, there's a way to do that. It will run everywhere Java is available and since you say this is a personal application you don't need to worry about end-user problems. Plus, if you ever want to get it to work on Android or Blackberry phones then you'll already have a head start.

    I'd also recommend using SpringLayout, it's the simplest way to get things looking right.

  20. Re:The answer by TeXMaster · · Score: 4, Informative
    My kingdom for a mod point!

    (For those that missed the reference, this is it)

    --
    "I'm never quite so stupid as when I'm being smart" (Linus van Pelt)
  21. Re:Obvious choice is OpenGL by Anonymous Coward · · Score: 3, Informative

    Now draw a circle.

    glPointSize(10);
    glColor3f(1.0f, 1.0f, 1.0f);
    float point[2] = {0.0, 0.0};
    glVertexPointer(2, GL_FLOAT, 0, point);
    glDrawArrays(GL_POINTS, 0, 1);

    Now draw a bezier curve.

    float lines[numberOfLines] = {0.0, 0.0, .......}
    glVertexPointer(2, GL_POINTS, 0, lines);
    glDrawArrays(GL_LINES, 0, numberOfLines);

    Now draw a circular gradient.

    uniform vec2 center;
    uniform vec4 innerColor;
    uniform vec4 outerColor;
    uniform float radius;

    void main()
    {
            float dis = distance(center, gl_FragCoord.xy);
            if (dis > radius);
                    gl_FragColor = outerColor;
            else
                    gl_FragColor = dis/radius*outerColor + (radius - dis)/radius*innerColor;
    }

    Now draw a button with the text "OK" on it.

    NSFont *font = [NSFont fontWithName:@"Helvetica" size:18.0f];
    NSDictionary *fontAttributes = [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, [NSColor whiteColor], NSForegroundColorAttributeName, [NSColor blackColor], NSBackGroundAttributeName, nil];

    NSAttributedString *string = [[NSAttributedString alloc] initWithString:@"OK" attributes:fontAttributes];

    NSImage *image = [[NSImage alloc] initWithSize:string.size];
    [image lockFocus];
    [string drawAtPoint:NSMakePoint(0.0f, 0.0f)];
    NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithFocusedViewRect:NSMakeRect(0.0f, 0.0f, image.size.width, image.size.height)];
    [image unlockFocus];

    GLint button;
    glEnable(GL_TEXTURE_RECTANGLE_ARB);
    glGenTextures(1, &button);
    glBindTexture(GL_TEXTURE_RECTANGLE_ARB, button);
    glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, bitmap.size.wigth, bitmap.size.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, [bitmap bitmapData]);

    float rectangle[8] = {0.0, 0.0, 0.0, bitmap.size.height, .....} // Make the button what ever shape you want.

    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glVertexPointer(2, GL_FLOAT, 0, rectangle);
    glTexCoordPointer(2, GL_FLOAT, 0, rectangle);
    glDrawArrays(GL_QUADS, 0, 4);

    [font release];
    [fontAttributes release];
    [string release];
    [image release];
    [bitmap release];

    Doing this all in OpenGL then makes it dead simples to animate and tranform and move around the screen.

  22. Also, don't forget Qt Quick and QML by okoskimi · · Score: 3, Informative

    Qt has recently introduced Qt Quick, a collection of technologies meant to help you create animation-rich UIs similar to those used on touch phones. The most important part is the QML language, which is used to describe the user interface of a program. QML is declarative and animation-friendly, and makes it easy to create fluid interfaces. On the downside, it is not mature yet and lacks most of the standard UI widgets at the moment (basically, you have text input and clickable areas). I wouldn't have recommended it for general application writing just yet, but the original question was not very specific on the requirements so it might be suitable already in its current form.

  23. I use wxWidgets by GeckoFood · · Score: 3, Interesting

    I have had good success with wxWidgets on both Windows and Linux. That said, it's the *only* cross-platform GUI development library I have used and I am used to it. Rather than use anchors for placing window components it uses something called sizers which are a lot harder to work with until you get used to them. It can be used with a variety of languages (C++ and Python are the two big ones, though there is support for hooking into Java as well) and the licensing is sane.

    Though I do favor wxWidgets (as it's all I really know) I believe QT is a lot more complete as a library. Depending on what you're doing, QT may be a better fit for your needs.

    --
    Be excellent to each other. And... PARTY ON, DUDES!
  24. choose Qt only after careful consideration by NuShrike · · Score: 3, Interesting

    I vote against using Qt. Having used and hacked it extensively (up to 4.8, or the master branch in git), Qt is way overboard for any simple project.

    1 QtCreator is good as a common-platform IDE vs Eclipse, but cannot be used as a selling point for programming IN Qt
    2 the code ISN'T as cross-platform as many would like to lead you to think because most here only did some simple apps in it, not full-blow production and public releases
    3 the framework is TOO comprehensive and doesn't have a modular substructure to rip out unnecessary bloat; the MFC class structure lends to that bloat
    4 it is easy to learn, but requires wrapping your head around weird idiosyncrasies of core elements that are poorly explained in the documentation and require trolling through the immense amount of source
    5 Qt's problem reporting system pretty much buries any bugs or fixes you contribute that they don't personally like

    Expanding on #2 and #3: Qt is only truly portable between Linux/MacOSX/MSWindows. It really sucks on embedded/smallMemoryCpu as they stopped supporting their qconfig modularization since 4.5. Ex. For Windows Mobile and other embedded, the smallest footprint is 12MB MINIMUM (Core, Gui, OGLES). That's > 50% of the entirely virtual memory available to a single WM app -- for a hello-world in OGLES.

    Qt uses a strict single-tree (MFC) inheritance class hierarchy (instead of recursive templating due to legacy and hard-noses) which means code for everything ends up in the shared library, used or not. It's software rasterization most of the time and then hardware-accelerates the results, so it's not a true opengl renderer. You'll have to rewrite it yourself to clean it up. This means it has some speed but a lot of bloat in code and texture memory.

    Their MOC is a nice alternative to ObjC, but it's a flawed design decision that didn't bet on the templating abilities of C++ modernization. Boost and Boost signals2 is a less magical alternative to Qt's signaling system.

    If it was truly portable on mobile, why is it used extensively ONLY on Nokia products? There's few to zero examples for Symbian and Windows Mobile, and it's not ported to Android/iOS. This means you're already limited if you invest in Qt.

    Their QGraphicsView canvas drawing layer is still immature and is still NOT multi-thread compatible (as much of Qt). This means you have to work your way around it a lot of times, or avoid it completely (and still can't compile out the software renderer) especially if you wanted a fancy multi-threaded renderer, or simply just loading textures in one thread and then drawing it in a master draw thread.

    I strongly recommend going with a lighter, less drama foundation such as Clutter (which is MORE portable than Qt), SDL, or the bindings some languages provide such as gtk.