Improve performance of "Accelerate your Widgets with OpenGL" Qt Sample? - performance

I have been studying the Qt Quarterly article about QGraphicsScene and OpenGL for the purpose of using it in a project. I have already decided to use Qt, given its all-round excellence, but have gone down the road of implementing a class derived from QGLWidget, however I would then still need to implement the UI elements. Using techniques from the quoted article would mean I could also use Qt widgets for the UI as well, making the program dependent on Qt alone (and not CEGUI or similar).
Anyway I have been running the sample under a desktop Linux machine, which has an Core i7 and a fairly good Nvidia card and it runs well, however my on my 2010 MacBook Pro (Core i5 and Nvidia 330) it runs very poorly indeed, especially when interacting with it using the mouse.
Question: can anyone suggest ways of improving the performance of this sample? I'm no Qt expert but I think the poor response is due to calls to update() from within the mouse handling code coupled with the timed calls to update() at the end of the method itself. I think what is needed is a background thread to update the object movement and a timed but constant call to update().
Can anyone comment on this?
EDIT: I have already tried removing all calls to update(), apart from the timer reset, and it makes very little difference.

Unfortunately the performance that you get when using the suggestions from that article is pretty bad. We tried that on an embedded system and it was far to slow.
For us the solution was to use QML, the new "declarative" UI capability in Qt 4.7. We have QML embedded in our C++ application. We are seeing huge speed improvements with QML widgets overlaid on top of our GL scene.
We are using the QDeclarativeView widget in our C++ application, which is capable of displaying our QML content. See: http://doc.qt.io/archives/qt-4.7/qdeclarativeview.html.
This should work fine on the desktop (works for me on Ubuntu).
More useful links:
Using QML Bindings in C++ Applications
Integrating QML Code with Existing Qt UI Code
UPDATE! 1/20/2015:
In Qt5.4 there is a new class called QOpenGLWidget that basically makes it so you can use "classic" Qt widgets with an OpenGL background with great performance. They finally adressed this issue directly! Read the blog post, and then the docs:
Qt Blog Entry about QOpenGLWidget
QOpenGLWidget Docs

Related

What is a good VR GUI toolkit?

Is there a good GUI for VR? Scaleform is no longer supported. Coherent seems like an option. I just don't know how to integrate it if it is not natively supported by the engine. IMGUI seems like it is limited in the look that can be created by it. Are there any others?
Have you looked at Qt? It's very flexible and works on a variety of different platforms. QtQuick/QML in particular is pretty nice for VR interfaces.
Here is a video of a talk from Qt World Summit 2017 that does a pretty good job of summarizing the current state of things: https://www.youtube.com/watch?v=RtcmVbicZWw (Basically, the maintainers of Qt are working on a lot of cool VR-related things). I don't work for them and have only starting using Qt recently, but from what I've seen so far it works very well for this purpose.
In particular, take a look at QQuickRenderControl (http://doc.qt.io/qt-5/qquickrendercontrol.html). This class allows full control over rendering of QML content to a framebuffer. Right now I'm using it in the creation of SteamVR overlays.

How to make a GUI in Julia?

I'm new at programming in Julia and I need to create a GUI.
I've been looking for information and I can't find anything useful. I tried to search information in the Julia official web page, but it seems to be down. I wonder if any of you guys knows where I can find information about it.
This is quite a generic question, but I'll try and layout the environment so that you can make an informed decision based on your needs. You might want to check out this article on 6 Julia Frameworks to Create Desktop GUI’s 🖥 and Web Apps.
If you are developing your code within an [Jupyter/IJulia] notebook, and need very simple interaction, such as a slider to change some input values, the Interact package is the easiest thing to get started with.
To develop full-fledged web UIs, take a look at Escher. Inspired by the Elm, it provides a functional library of UI components. Interactive web UIs are created in 100% Julia. There is no differentiation in code between the client and server sides. The framework handles all of that.
Another web framework worth looking at is Genie, which is based on the traditional MVC design pattern. It also includes an ORM.
Stipple is a reactive UI library for building interactive data applications in pure Julia. It uses Genie.jl (on the server-side) and Vue.js (on the client).
Dash ties modern UI elements like dropdowns, sliders, and graphs directly to your analytical Julia code.
All the above solutions are for creating web user interfaces, accessed via a browser. If you want to create cross-platform desktop apps, but want to work with web technologies (i.e. HTML/CSS/Javascript), use Blink. This is a Julia wrapper around the Electron. You could potentially write a Dash or Stipple application, and wrap it in Blink.jl to create a desktop app.
To create desktop UI applications using the Gtk library, use the Gtk.jl package in Julia. If you are familiar with the Gtk API, it is easy to get started. Note however that there are some significant known issues running GTK.jl on Windows.
If your UI framework of choice is QT, a Julia binding is available via QML.jl
If you are happy painting the buffer yourself and just want a window to render the pixels on the screen, then there is nothing simpler than MiniFB. Note however that this does not give you a widget library -- you are responsible for drawing each and every pixel yourself.
ClmGui.jl is a Julia wrapper around the immediate mode GUI toolkit known as Dear ImGui
And last, but not the least, the venerable Tk framework has a wrapper in Julia. The UI's created using TK are sometimes considered ugly compared with modern aesthetics, but sometimes this is the quickest way to get a window up.
[Edited Jan 2022]
QML.jl
https://github.com/barche/QML.jl
The QML.jl package enables using the QML markup language from the Qt library to build graphical user interfaces for Julia programs. The package follows the recommended Qt practices and promotes separation between the GUI code and application logic. All user-facing code is pure Julia and QML, no C++ knowledge is required to use the package.
There is a new package called Genie. It is a web framework comparable with Django in python. You can create web ui using Genie. Until now (Aug. 2017), the package is functional with some nice demos, the documentation is not quite complete though.

2D Cross-Platform Game Development Engines [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I've worked for some time with Corona SDK and love how fast and easy I can create powerful apps using Lua. But it can only compile for iOS and Android, which feels like too little now.
My main interest is for it to be able to compile to Desktop AND Mobile. At least for the following:
Windows + Mac for desktop, as standalone applications.
iOS + Android for mobile.
I'd prefer it to lean more towards Lua type scripting instead of ActionScript, but please feel free to post anything that you have worked with and love.
I've found the following engines so far:
Marmalade Quick - After further looking into it, Marmalade Quick can only build for Mobile!
IwGame - Works on top of marmalade and says it can deploy to
desktop and mobile with Lua. Any info is greatly appreciated on this
sio2 - Says "SIO2 is an OpenGLES based cross-platform 2D and 3D
game engine for iOS, Android, MacOS and Windows" and "The engine also
allows you to port your game on the Mac Store and on Windows.", but
their forum and web title is "Game Engine for Mobile Devices". Can't
find any info on if it can deploy to desktop platforms, any info is
greatly appreciated again.
Loom Engine - Loom is similar to Haxe + OpenFL (attempts to attract Flash developers) in that it uses AS3-like of ECMAScript, but it doesn't build native code from it. However it uses Cocos2D for rendering so it should in theory be as fast as Cocos2D. -- Thanks to Bojan.
SDL - I've read in multiple places that SDL can deploy to nearly any platform or device and has a Lua binding. But i can't find how this works as it's not an engine. Any one who can explain how it works and if it's possible is once again, very much appreciated.
SFML - "Windows, Linux, Mac OS X and soon Android & iOS. " doesn't use Lua but can use other languages like Java and Python etc. Anyone have any information on this?
Torgue2D - "Torque 2D was developed with OS X, Windows, and iOS devices in mind and works equally well on all the platforms." uses TorgueScript and no Android =(
Sencha - Seems to compile to all platforms, uses Javascript too which I know. But even with V8 JS would this work well performance wise compared to other options?
GameMaker - own scripting language GML and I actually remember this one as a tool for non-programmers. Has it actually grown into a real engine, I mean for serious development?
Construct2 - Same question as gamemaker
Corona - Lua but mobile only (Android and iOS only as well)
Cocos2D - Seems like it has lots of options but not sure with the same language? Seems like you'd have to re-write your entire code. Any info if cocos2D can deploy to desktop + mobile with almost the same code would be greatly appreciated.
Angel2D - Says it can deploy to everything except Android and uses Lua, anyone ever used this one before?
libgdx --- I've only seen good things about this. Here is a benchmark test for libgdx and is where I saw it reaching 40k sprites at 60fps. http://www.sparkrift.com/2012/1/love2d-vs-allegro-vs-clanlib-vs-libgdx-vs-cocos2d-x-vs-monogame-vs-xna-vs-sfml . It seems libgdx barely goes over 30k actually. But still seems amazing. This is on the same level as Qt for me, almost perfect, except I'm not really worried about performance on it. libgdx can build for everything pretty much.
XNA + MonoGame --- MonoGame's performance seems only slightly lower than libgdx, can build to most platforms. However I don't know much about XNA and I heard it won't be receiving future updates, but is quite stable? More information is welcome.
Citrus --- Don't have much information on Citrus either. AS3 game engine that can build for iOS, Android, Windows, Mac and more.
Haxe + OpenFL --- OpenFL (Haxe) builds to native on many platforms, not just to Flash. Windows, Mac, Linux and Android all get optional native deployment or OpenFL runtime called Neko which is in theory faster than Flash, and SDL 2.0 will enable iOS deployment soon(ish). -- Thanks to Bojan.
Qt-Project --- Just linking Qt project here, can build for everything and has a pretty big community with lots of third party libraries to help you even further.
Moai ---The only Lua engine that I know that can build for Desktop and Mobile. Only downside is the community isn't that big and documentation isn't the best. But if you can get passed those this is a great solution and the one I'm currently using.
Adobe --- Can't forget to add adobe here since it can build to everything that supports flash.
Unity3D --- Recently announced 2D integration looks very promising, should be released Q3-Q4 of 2013.
Cocos2d-x --- An open source engine. Supports JS, Lua, C++ and multiple platforms.
Html5 --- There seem to be a lot of emphasise on html5 mobile apps, here are just a few tools I found that can help port your html5 project to a platform:
Chromium embedded
Sencha
Phonegap
Appcelerator/Titanium
Icenium
So, I'd be happy if you could comment from your experiences with any engines and suggest which one you would recommend.
Thank you for your help!
EDIT: Since this topic is getting popular I'll be adding other options I've found over time. I suggest you choose what is most familiar to you and best for your project needs.
I would recommend V-Play (v-play.net) - it's a cross-platform game engine based on Qt for iOS, Android, Symbian, MeeGo, Blackberry10 and also can export for native desktop applications for Windows, Mac and Linux.
It's based on C++ but has a neat scripting support for QML & JavaScript. QML is a no-brainer to learn and can boost your productivity as less code is needed - just see the comparison with cocos2d-x(60% less Loc) or Corona(15% less LoC) for a comparison of the same games.
(Disclaimer: I'm one of the guys behind V-Play)
If you are into using Python, Kivy is a great solution these days. It compiles to all the platforms you ask for:
Kivy is running on Linux, Windows, MacOSX, Android and IOS. You can
run the same code on all supported platforms. It can use natively most
inputs protocols and devices like WM_Touch, WM_Pen, Mac OS X Trackpad
and Magic Mouse, Mtdev, Linux Kernel HID, TUIO. A multi-touch mouse
simulator is included.
Kivy uses lots of optimized code for graphics rendering (via Cython) so it is fast too.
Here is a speakerdeck that gives you some background and an overview (android specific).
How about HaxeFlixel? We have a great selection of demos, and of course support cross platform development via Haxe + OpenFL. This is an open source project hosted on GitHub. We support all major platforms (including iOS).
Here is my game framework Oxygine.
It is open source modern hardware accelerated 2D C++ framework for mobile and PC platforms.
Features: OpenGL(ES) 2, compressed textures, atlases, complex animations/tweens/sprites, scene graph, fonts, event handling, build tools, and others.
Can be built on top of SDL2 or Marmalade SDK.
In the basis of the engine there is a scene graph, that is similar to Flash one. To be short, You can call this as Flash for C++, but more comfortable and way faster. Initially it was developed for mobile platforms (iOS, Android), but can be also used for PC games.
No mention of App Game Kit (AGK) here so let me fill in the gap. It's a mainly 2D cross platform SDK allowing you to code once in either C++ or it's own "Basic" language. Version 2 just got over 400% funding on Kickstarter and will have full 3D support, Spine support (for 2D animated characters), bullet physics and whole bunch of other new features.
It already has Facebook, Twitter, a bunch of Ultrabook sensor commands, Box2D and more. I've been using it from the start and love it (can you tell?). No, I don't work for The Game Creators (the company that created it) although I admit I did do for a while making some apps.
One of the best features from my point of view is you can develop on Windows and broadcast from the IDE over Wi-Fi to any supported device, so while I'm coding I can (within seconds) test my code on iPad, Android, Windows, Mac or Blackberry Playbook.
If you have C# background. Have a look at Duality.
Duality is a flexible 2D game framework written entirely in C# –
and it’s here to make things a little easier for you. It provides both
an extensible game engine and a visual editor to match. There will be
no need for a level editor, testing environment or content manager
because Duality is all that by itself. And best of all: It’s free.
I'm just answering to give you some insights on how the SDL is used. As you said before it's not a game engine (it's just a library actually). Furthermore, it is not object oriented at all and you don't have some easy animation facilities (you have to code them by yourself).
How it works (I used the C version but I guess the Lua binding should be similar):
Include the headers needed to build the project on the platform you want.
Design your own game loop in which you will set up (at least) a whole event processing system, frame rate manager and a "screen cleaner (or updater)" (I'm insisting on the fact that you have to manually refresh your screen using the SDL_flip_screen routine which is something that is not one of your concerns at all with Corona).
Then, code your game using all the "mechanics" you made before.
The SDL is a low level library (don't expect to have an easy to use GUI framework or the storyboard framework of Corona for instance).
Finally, this library was used to port Civilization III to Linux, so yes it works but it will ask you a lot of energy to have something like you had with Corona ;)
PS: I am not a native English speaker, so please let me know if I wasn't clear :)
Gideros is a great Lua based 2d cross platforms engine, currently supporting both Android and IOS platforms, but more to come.
And it also has some great features as instant on device testing, auto scaling and auto image resolution to easily target various of screen sizes, as well as the option to extend each platform through native plugins.
You also have ShiVa3D, a serious competitor of Unity3D.
It uses Lua and supports many platforms from mobile to game consoles and web browsers.
Very intuitive to use and very nice UI to work with.

Compiling WebGL Into a C Library

We currently have a shared DirectX code base that renders our UI and is used in our PC side application and via an ActiveX in web pages.
I have written some WebGL demos and they perform great, no plugin mess and get rid of ancient ActiveX!
This obviously raises the problem of having a split code base for the PC application and the Web UI.
As WebGL is based on the OpenGL ES 2.0 specification would it be possible to have a standard code base and write a interpreter so that either:
-The WebGL code can be modified to compile as OpenGL
-OpenGL can be modified to work in a web page
The khronos specifications are new to me, so this is sort of speculative as I am peforming research at the moment.
Does anyone with more knowledge of 3D graphics and a better understanding of the coding syntax help me out?
One way is to have a PC app to enclose a WebGL-capable browser inside (together with a simple http server) to run the same rendering technique as the web App.
This will reduce the maintenance and development costs for both platforms.

Same QtOpenGL code runs as about 15 times slower when going to Carbon (vs Cocoa)

I'm developing a very simple application for the Mac OSX platform making use of Qt and OpenGL (and QtOpenGL) so crossplatform gets easier.
The application receive a variable number of video streams that have to be rendered to the screen. Each frame of these video streams is used as a texture for mapping a rectangle in 3D space (very similar to a videowall).
Apart from the things such as receiving, locking, uploading video data, synchronizing threads... i consider it is clear that it's a quite simple application.
The fact is that all behaves ok when using cocoa based Qt 4.7 binaries (the default ones) in a 10.5 Mac.
But my code has to run fine at all of the OSX versions starting from (and including to) 10.4. So i tried the code in a 10.4 machine and it crashed just when starting. After a few hours of internet reading, i discovered that for a Qt Application to be targeted at 10.4, carbon Qt based has to be used. So i rebuild the whole project with the new framework.
When the new resulting binary gets run, all works well except by the fact that application's fps fall to about 2 fps!! And it behaves the same at both machines (10.5 computer has sensibly better features)
I've spent quite time working on this but i have not reached a solution. Any suggest?
More information about the application and things i've tried
code has not been modified when recompiling carbon based
only two (256x256 textures) videos ar used in order to assure it's not a bandwidth limit problem (although i know it shouldn't because the first code worked)
the 2 video streams arrive from network (local)
when a video stream arrives, a signal is emmited and the data will be uploaded to an OpenGL texture (glTexSubImage2D)
a timer makes render (paintGL) happen at about 20ms (~50 fps)
the render code use the textures (updated or not) to draw the rectangles.
rendering only when a video arrives won't work because of having 2 (asynchronous) video streams; besides more things have to be draw at screen.
only basic OpenGL commands are used (no PBO,FBO,VBO,...) The only one problematic thing could be the use of shaders (available only from Qt 4.7), but its code is trivial.
i've made use of OpenGLProfiler and Instruments. Nothing special/strange was observed.
Some things i suspect (conclusions)
it's clear it's not a hardware issue. The same computer behave differently
it gives me the sensation it's a threading/locking problem but, why?
carbon is 32 bits. The 10.5 application was 64. It's not possibly develop 64 bits in carbon.
for giving away the 32 bits possible cause, i also rebuild the first project for 32 bits. It worked partically the same.
i've read something about carbon having problems (more than usual) with context switching.
maybe OpenGL implementation is Multithread and code is not? (or the opposite?) That could cause a lot of stalls.
maybe carbon handle events differently from cocoa's? (i mean signal/event dispatching, main loop...)
Ok, this is (sorry for the so long writing) my actual headache. Any suggestion, idea.. would be very appreciated.
Thx in advance.
May I ask a diagnostic question? Can you ensure that it's not being passed to the software renderer?
I remember that when 10.4 was released, there was some confusion about quartz extreme, quartz and carbon, with some of it disabled, and hardware renderers disabled by default on some of them, which required configuration by the end user to get it working correctly. I'm not sure whether this information is pertinent, because you say that, having targetted 10.4, the problem exhibits on both the 10.4 and the 10.5, yes?
It's possible (though admittedly I'm grasping at straws here) that even in 10.5 carbon doesn't use the hardware renderers by default. I'd like to think though that OSX prefers hardware renderers to software renderers in all scenarios, but it may be worth spending a little time looking into, given how thoroughly you're already looking into other options.
Good luck.
If you are using Qt, I guess your code would work on a windows or linux platform. Have you tried your application under these platforms ?
This would quickly reveal if it comes from Qt or the mac OSX version.

Resources