How do I create graphics for WebAssembly in C++14, that are implemented similarly to X11? - c++14

I'm currently working on building Chess in C++ for a school project. It's coming along really well, and I'm going to need to implement graphics pretty soon. Although I'm going to implement the graphics in X11, I was wondering how I might do it with WebAssembly, specifically which libraries are most similar to X11 that I could use. The GraphicsDisplay would just be an Observer to my Game class.

You cannot program in X11 with WebAssembly, you need graphics frameworks.
Currently the only GUI framework that officially support WebAssembly is Qt. Have a look at its official documentation on WebAssembly. I recommend learning Qt Widgets in a common desktop environment (Linux, Windows, Mac...) then try to port it in WebAssembly.
The other way to implement graphics with WebAssembly is using frameworks for game. Emscripten (C/C++ to WebAssembly toolchain) has a strong support for OpenGL-based games. You probably want to look at SDL.

Related

Best framework for creating desktop applications with dynamic GUI

Sorry for the unusual question, but I don't know where else to ask this.
Basically I would like to know what a good framework is for creating applications(mostly Windows, but wouldn't hurt if it would be cross platform) that would allow to do fancy GUI animations, transitions and is easily modifiable.
I worked with the swing library for java so far. Its a solid GUI library but its completely static.
Here an examples for showing off what I mean: Atom.io
QT is an excellent choice for app and UI development. The API is C++ (though many other bindings are available) and it has a solid IDE and UI building. It is free to use for non-commercial work. https://www.qt.io/

Can I use OpenCL with Monogame?

I'm looking at Monogame for developing with. The site mentions it has OpenTK "under the hood". Does this mean I could have solid access to OpenCL using Monogame, or has OpenCL been split off into Cloo? My primary objectives are cross-platform, high-performance OpenGL ES & OpenCL.
Ah, my understanding is that Cloo is a .NET wrapper for OpenCL, so if you are doing MonoGame development, I would think you would use Cloo which should give you access to everything you need in OpenCL. Looking through the source code a bit, I noticed XNA libraries are used a lot. As far as OpenTK goes, I mostly noticed the use of it for audio in linux and MacOS. Also it makes use of the Tao.SDL wrapper. To answer your question, afik, yes you can use OpenCL in MonoGame, and yes I think this will do very nicely for your purposes. CHEERS

How do you write a cross platform GUI toolkit?

Like with toolkits such as qT, wxwidgets and such, how does an API designer provide and api that is the same, even though it calls totally different system calls to do so? For example, in Windows OS you have to mess around with a whole lot of functions in the GDI. On Linux you have to mess around with a whole lot of functions in XLib and whatever other layers the distribution has on top of in. So how how can you design an widgit kit that can unify all that functionality? so that say CreateWindow() will create a windon on any platform? I don't comprehend how this can be done.
Instead of using Xlib or GDI, you could use something that is more universal. For example, you could use OpenGL, which is supported everywhere. I think that is what Blender's UI does.
Some toolkits can be modified to use some kind of backend for each platform they support. This is basically what Qt does. On Mac OS X, Qt apps use Cocoa as a backend. Qt for OS X was made specifically for that OS. However, there are other Qt implementations on other platforms, so that's what makes Qt work on more than one platform. SWT for Java works the same way (using the OS's native toolkit as a backend).
Other toolkits can use some kind of high-level layer to render. For example, Swing for Java is rendered purely using Java APIs, and is not tied to any platform at all.

Is there any framework that allows me to develop applications for Qt and GTK?

I am thinking about something that would allow to develop applications independent of the GUI library, but allow Qt and GTK being plugged in as needed.
I'd just use Qt. It includes a Gtk-like style, mimics Gtk standard dialogs and even uses Gtk file dialogs if run under Gnome, so basically it integrates itself into Gtk as good as anything (except Gtk of course), or at least it integrates itself better into Gtk than Gtk does into Qt.
You can try to use wxWidgets but you tend to get "lowest common denominator" if you go that route. Your better bet is to design your software such that you can plug in an implementation of the necessary "views" in the desired toolkit, and keep your core UI toolkit independant.
Obviously this is more work, but if there is a strong business need, then so be it.
I don't know of any framework doing something like that (I don't know how it could possibly be done without suffering from a heavy "lowest-common-denominator" syndrome), but I do "cross toolkit" development (applications that use more than one GUI toolkit) and I wrote an article about why and how to do it:
http://www.hardcoded.net/articles/cross-toolkit-software.htm
You can try Tk, which supports themes. There is a tile-qt and tile-gtk theme. There is a 2010 Google Summer of Code project to improve these themes. And, of course, when you use Tk you also get support for Windows and OSX out of the box.
Qt is a framework, it uses GTK underneath (at least on Unix).
There was a mobile toolkit that let you write everything in JS but compiled to the native code on each platform. I forget the name but it was a victim of the iPhone lockdown.

Transferring from web programming to GUI programming?

I've been doing web development for about six years now, and somehow have entirely avoided ever developing a desktop application.
I am considering writing a desktop application (I'm thinking something similar to a Word clone) on Linux but have no idea where to start. I hear of Qt and GTK+, but I'm curious if there are any frameworks that are similar to web development. Language isn't a problem, as long as it isn't Java.
You really want to go with Qt these days. Both Nokia and Intel are now pushing it as the main GUI in their new distro Meego. This means, if you are using Qt, you'll be able to target all their platforms (both desktop, embedded and phone domain), including all the platforms already supported by Qt.
Qt also comes with a GUI Designer and an IDE which will support you in the whole process, and soon there will be QML, which is a declarative UI language, for even more rapid development of apps.
Take a look here:
http://qt.nokia.com/products
http://www.youtube.com/watch?v=U7IgwNrcln8
http://www.youtube.com/watch?v=xoo_Ows1ExU
http://www.youtube.com/watch?v=Fr5FuGhTqm8
GTK+ and QT are GUI frameworks. They use xlib under the hood and encapsulate the nuances of xlib and provide you with an easier interface.
For rapid development you can use GLADE and quickly build GUI applications in C/C++.
Check out wxWidgets, it's another framework that is usually compared with Qt & GTK+
Go for Qt. And, if you are webdev, you will find in QML one of the best instruments EVER.
It has:
A Declarative approach to UI definition and Graphics elements Behavious/Animations
It's cool and simple at the same time
For now is only available in a couple of (old) binary drops, or by clone-compiling qt.gitorious.com/qt, branch ">4.7"
If you don't have to release today, but do you have time to develop and test, then QML should be "stable" by end H1 2010. If I got the schedule right ;-)

Resources