Introducing Qt Canvas3D

Qt Canvas3D is a fully supported Qt module starting from Qt 5.5. Just like WebGL, Canvas3D offers a low level OpenGL-like API that enables you to execute 3D drawing commands from JavaScript. It allows easy porting of WebGL content from HTML to Qt Quick or even sharing the same WebGL code between Qt Quick and HTML applications.

WebGL is a 3D rendering API defined by Khronos Group and has been gaining momentum in the HTML world. It has also been fostering innovation and development of various libraries like three.js, Scene.js and applications like the 3D view of Google Maps. Qt Canvas3D brings a WebGL-like 3D rendering API to Qt Quick JavaScript, enabling the developers to port existing WebGL based assets to Qt Quick to applify their content or to create new 3D content using skills and libraries from the WebGL development world they may already know. It is also very easy to enhance the 3D content with the Qt Quick animations and transition enablers to create interactive 3D experiences that connect to application logic seamlessly and provide beautiful, smoothly animated 3D visualizations.

Since conformance tests for WebGL are pure HTML pages, Canvas3D is not yet WebGL conformant in that it doesn’t pass the official Khronos WebGL API conformance tests. However, we’re in the process of porting those to run on top of Canvas3D and we are selectively fixing conformance issues as we find them. Since the WebGL specification, as it stands today, is tightly coupled with the HTML object system, which doesn’t exist within Qt Quick environment, we’re not sure if we will be able to claim full conformance. However, fortunately based on our experience, this specification language difference doesn’t prevent easy porting or sharing WebGL code between Qt Quick and HTML applications.

Canvas3D Planets example, implemented with three.js and Qt Canvas3D

Screenshot of Canvas3D Planets example included in Qt 5.5

Simple Example

A very simple example of Canvas3D that just paints the screen with a random color could look something like this:

import QtCanvas3D 1.0

Canvas3D {
    id: canvas3d
    anchors.fill: parent
    focus: true
    property var gl

    onInitializeGL: {
        gl = canvas3d.getContext("experimental-webgl");

        // Setup clear color to be a random color
        gl.clearColor(Math.random(), Math.random(), Math.random(), 1.0);

        // Setup viewport
        gl.viewport(0, 0, canvas3d.width * canvas3d.devicePixelRatio, canvas3d.height * canvas3d.devicePixelRatio);
    }

    onPaintGL: {
        // Clear background to current clear color
        gl.clear(gl.COLOR_BUFFER_BIT);
    }

    onResizeGL: {
        var pixelRatio = canvas3d.devicePixelRatio;
        canvas3d.pixelSize = Qt.size(canvas3d.width * pixelRatio, canvas3d.height * pixelRatio);
        if (gl)
            gl.viewport(0, 0, canvas3d.width * canvas3d.devicePixelRatio, canvas3d.height * canvas3d.devicePixelRatio);
    }
}

For those of you who are familiar with QOpenGLWidget this should look pretty familiar, as we’ve tried to keep the names of the signals aligned with the name of the QOpenGLWidget method names.

If you have tried the technology preview versions of Canvas3D, the final version differs in that Qt 5.5 now includes built-in support for JavaScript typed arrays. This means that the Canvas3D API can now get the data needed for 3D rendering more efficiently and with reduced memory footprint. In addition Canvas3D has been better integrated with the Qt Quick JavaScript engine and this shows as better performance. Your mileage may of course vary as this all depends on the content, but we have seen applications that were running around 45-50 fps with TP 1 reaching 59-60 fps with Canvas3D in Qt 5.5.

three.js

As the Canvas3D API is very low level, you may find the three.js library useful in getting started. I maintain a port of three.js on top of Canvas3D at http://ift.tt/1FXL7WO. The port includes a few of the three.js examples ported to run on top Canvas3D. These should give you an idea how to get three.js based content to run within Qt Quick on top of Canvas3D. We’ve tried to make the process as simple as possible by porting also some of the utilities included in the three.js examples to Canvas3D as many web content builders use these as well. If you visited our booth in Berlin Qt DevDays last year you may have spotted the award winning WebGL CarVisualizer application demo by Plus 360 Degrees running on top of Canvas3D prototype with just few days of effort. We even added some animations like the different fixed camera angle with transitions and animated color transitions when selecting the color of the car.

Car Visualizer application by Plus 360 Degrees, ported to run on top of Qt Canvas3D.

WebGL Car Visualizer application by Plus 360 Degrees, ported to run on top of Qt Canvas3D.

More Info

Canvas3D has been included in the Qt 5.5 Beta, you can check out the documentation at http://ift.tt/1FXL7WK

Our next blog on Canvas3D will show you how you can get started with porting three.js content so that you can run your code on top of Canvas3D.

The post Introducing Qt Canvas3D appeared first on Qt Blog.



Source :- Qt Blog http://ift.tt/1FXL8da

Qt 4.8.7 Released

I am happy to announce release of Qt 4.8.7 today bringing over 150 improvements and bug fixes. Qt 4.8.7 provides important security updates, better support for Mac OS X 10.10 and many requested error corrections. As a patch release, it does not add new functionality and maintains full compatibility with previous Qt 4.8.x releases.

Highlights of Qt 4.8.7 are:

  • Security fix for DoS vulnerability in the BMP image handler (CVE-2015-0295) as well as security fixes for vulnerabilities in image handling of BMP (CVE-2015-1858), ICO (CVE-2015-1859) and GIF (CVE-2015-1860)
  • Update 3rd party libpng to version 1.6.17 to address known vulnerabilities in previous version
  • Update 3rd party libtiff to version 4.0.3 to address known vulnerabilities in previous version
  • Better support for running Qt 4.8 applications on Mac OS X 10.10 Yosemite
  • Many customer requested bug fixes

A detailed list of the fixes and improvements in Qt 4.8.7 compared to Qt 4.8.6 can be found here.

Many users have already moved their active projects to Qt 5 and we encourage also others to do so. With a high degree of source compatibility, we have ensured that switching to Qt 5 is smooth and straightforward. It should be noted that Qt 4.8.7 provides only the basic functionality to run Qt based applications on Mac OS X 10.10, full support is in Qt 5.

Qt 4.8.7 is planned to be the last patch release of the Qt 4 series. Standard support is available until December 2015, after which extended support will be available. We recommend all active projects to migrate to Qt 5, as new operating systems and compilers with Qt 4.8 will not be supported. If you have challenges migrating to Qt 5, please contact us or some of our service partners for assistance.

The source packages and stand-alone installers for Qt 4.8.7 are available for download from Qt Account for commercial users and qt.io download server for open-source users. For Enterprise and Professional customers, the online installer can also be used for installing Qt 4.8.7.

The post Qt 4.8.7 Released appeared first on Qt Blog.



Source :- Qt Blog http://ift.tt/1erI5xD

1st Wiki Week is now over

The first ever Wiki Week on the Qt Wiki is now over, and we did over 600 edits during it. 20 new pages were created and even more moved to the ‘delete’ category.

Overall the Qt Wiki is in a good shape, but there are things that needed fixing. The structure needed some updating, and still does. It was worked on, and to me the front page looks cleaner now.

The type of content we have in the Qt Wiki varies from code examples to official release team announcements, so keeping all the information in line requires some thinking and work. Especially with  the history we have, after all Qt just turned 20! Having old code examples in the wiki isn’t good practice, and we need to make sure that old code is marked with the proper Qt version.

Our visiting statistics show that  people come to the wiki looking for official information like release dates and QtCreator guidance. These are areas that we need to keep clearly visible and easy to find. The main page changes moved release information to a more prominent status, which should help our visitors find what they are looking for.

There was a discussion on the way the Qt Wiki is translated, where I promised to take a look whether the way Wikipedia does their translations would work for us. The Qt Wiki does not provide automatic translations to multiple languages, but we do have a lot of HowTo-articles that users have translated to local languages, making those easy to find from the main structure is important.

During the week one user was above everyone else in edits, Wieland spent a lot of time cleaning the language versions of the Wiki. A big thank you for that!

Also JKSH, Julienw and SGaist were active during the week. A thank you to them as well, and everyone else who worked on the wiki during last week!

To me the Wiki Week was a success that we should do more often. Maybe twice a year would be good, so it would be in line with the Qt release cycle.

The post 1st Wiki Week is now over appeared first on Qt Blog.



Source :- Qt Blog http://ift.tt/1HrG8se

Window of opportunity | Qt World Summit 2015 Call for Papers

Our thanks to all of those who have already submitted proposals for Qt World Summit 2015!

We received several requests for a little more time. By popular demand, we’re extending the Qt World Summit 2015 Call for Papers deadline by one week. If you have been procrastinating—or distracted by other important things—you have received a reprieve. You now have until 11:59 p.m. CET on Sunday, 31 May, to submit your proposal.

So if you were thinking about writing an abstract but figured you were going to run out of time, you now have an extra week. We’ve had a fantastic response so far and look forward to receiving further papers before the final deadline.

 

The post Window of opportunity | Qt World Summit 2015 Call for Papers appeared first on Qt Blog.



Source :- Qt Blog http://ift.tt/1IOZJbz

Happy 20th Anniversary Qt!

Today, I am really happy to celebrate Qt’s 20th anniversary. On May 20, 1995, the first Qt version, 0.90, was released! I am really glad to have been part of the Qt journey since 1997, when I first got in touch with Qt through the KDE project.

Qt immediately fascinated me. It not only made development of applications a lot easier than anything I’d seen before, but it was actually fun to develop with. So I started doing quite a bit of work where I used Qt within the KDE project. In the spring of 2000, I got so lucky to be offered a position at Trolltech. I joined the company a few months later and moved to Norway.

Working with the founders of Qt, Eirik Chambe-Eng & Haavard Nord, as well as the other people we had in the company at that time was an amazing experience. Over the next few years, Trolltech grew from around 15 to 250 people. We developed new versions of Qt, worked on a mobile phone stack called Qtopia, and also started to extend Qt from being a toolkit to develop UIs to a much more comprehensive development framework, including all required tools.

From the beginning, Qt has been released with both open source and commercial licensing options. Over the years, we have worked on expanding this model, and nowadays, Qt is actually developed as an open source project. In this sense Qt is actually in a rather unique position, having a strong ecosystem with passionate people, as well as a commercial entity behind it, which backs up and funds most of the development.

The last 20 years have been an exciting ride for Qt. I’ve had the pleasure to be part of most of these, and I have had the great opportunity to work with the many passionate and driven people all with the common goal to make Qt a leading technology. I am pleased to know that some of the world’s most innovative companies we know today have built their product with Qt.

Thanks to all the amazing colleagues at Trolltech, Nokia, Digia and The Qt Company who have believed in our technology and have put their best efforts forward to make Qt the best cross-platform software development framework. To our community of engaged contributors, developers and Qt fans, we wouldn’t be around without you. I am grateful for your passion, your will to spread Qt everywhere, and your selfless drive to develop Qt together with us.

A big special thanks to our partners and ecosystem comrades who have been with Qt since the beginning. Thanks to you for sticking with us and for guiding us through the ups and downs.

Qt was created by developers for developers. Making developers’ lives easier was the reason for its birth and what Eirik and Haavard wanted to provide to the development world. This goal has not changed and throughout Qt’s history it has remained at the core. Code less. Create more. Deploy everywhere.

Please join me in wishing Qt a wonderful anniversary and a big congratulations to the Qt ecosystem! Here’s to 20 more years!

The post Happy 20th Anniversary Qt! appeared first on Qt Blog.



Source :- Qt Blog http://ift.tt/1FAj67v

You’ll Kick Yourself if You Miss the Qt World Summit Call for Papers

It is time to submit all those talks you have been thinking about! We are looking for compelling content from Qt users, customers, partners and industry analysts. Introductory talks are great when the audience is new to a subject, but beware of providing sessions that are too basic when the technology has been around for a while and there are lots of tutorials already available on the web. Also, there will be dedicated business tracks where participants are looking forward to learning how industry leaders like yourself have used Qt to create their future-proof products.

Approved speakers will receive the following benefits:

  • As a speaker, you get free access to Qt World Summit. It’s a great opportunity to spread your mindshare and have a community of industry leaders and important software developers hear your message.
  • Exposure to thousands of developers from leading enterprises across the world. We are filming the presentations, so talking at the Qt World Summit will give you an audience much wider than just the crowd in Berlin.
  • We will share your contact and professional details on the Qt World Summit web pages, giving you a large platform to network with anyone interested in your expertise or offering.

For details about the conference themes and call for papers guidelines , visit the website.

The Qt World Summit Call for Papers is closing on May 22, 2015.

Thinking about becoming a Qt World Summit sponsor? Please contact us.

Thank you in advance for your contribution to Qt World Summit. We look forward to seeing you there!

 

The post You’ll Kick Yourself if You Miss the Qt World Summit Call for Papers appeared first on Qt Blog.



Source :- Qt Blog http://ift.tt/1HsqQ8U

Google I/O Countdown with Qt Happy Hour

Google I/O is a happening event. You may or may have not snatched a ticket. Whatever the case, join The Qt Company for a pre-Google I/O Happy Hour. Mix & mingle with our Qt engineers and experts, and learn more about Qt and how you can use it to power your next desktop, embedded & mobile project.

We will be more than happy to shed some light on Qt development for Android (as well as other operating systems) in a relaxed and fun setting. Grab some hors d’oeuvre & some beer on us.

Join us at Qt’s Happy Hour!

May 27, 2015 6-8 p.m
Where: Jillian’s San Francisco
Metreon, 175 4th St
San Francisco, CA 94103
– That’s across from the San Francisco Moscone Center

Hope to see you there!

Register now

The post Google I/O Countdown with Qt Happy Hour appeared first on Qt Blog.



Source :- Qt Blog http://ift.tt/1LiVcfA

Wiki Week is here

Time to get working on the Qt Wiki.

This week is Wiki Week, the time to clean up the wiki.

The Wiki Week wiki page  has a list of things to get started with. Cleaning up much viewed pages is a good place to start.

If you have some other activities you think would benefit the Qt Wiki, please post them on the Wiki subforum on the Qt Forum.

I’ll be following the Wiki and the Forum, and you can find me as tekojo on the main Qt IRC channels (qt, qt-labs, qt-chat) on Freenode during the day (European time).

Let’s see how much we can get done on the wiki this week!

The post Wiki Week is here appeared first on Qt Blog.



Source :- Qt Blog http://ift.tt/1KfjDg5

Qt 5.5 Beta Released

It’s my pleasure to announce the release of the Qt 5.5 Beta today.

Since we released Qt 5.4, a lot of effort has been put into fixing bugs reported both by our customers and the community. With this in focus, we went through a couple weeks of dedicated bug fixing here at The Qt Company. During this time, we worked 100% on fixing as many open issues as possible. Although the focus of Qt 5.5 has been on stability and performance, it also has some interesting new features and functionality to offer.

3D and OpenGL Features

While Qt has had OpenGL integration and support for many years, the integration was mainly about low level enablers and classes. With Qt 5.5, we are now adding two new modules, that greatly extend our set of 3D APIs: Qt Canvas 3D and Qt 3D.

The first module that makes using 3D easier in Qt is Qt Canvas3D. The module first appeared as a Technology Preview in Qt 5.4, but is now fully supported in Qt 5.5. It provides a WebGL-like API that can be easily implemented using Qt Quick, which greatly simplifies 3D content integration. WebGL itself is a low level API, but Qt Canvas3D can be used in conjunction with JavaScript frameworks such as three.js making loading and displaying 3D content trivial.

Another major new feature, available as a Technology Preview, is the new Qt 3D module. Qt 3D is a module that existed during Qt 4 times, but was never added to Qt 5…yet. Thanks to our partner KDAB, it has now undergone a major refactoring and is an even better solution than the Qt 4 version.

Qt 3D takes our 3D support a good step upwards making it a lot easier to use and integrate 3D content into Qt applications. The module provides both C++ and QML APIs. For more details what Qt 3D 2.0 brings, you can check Qt 3D documentation and KDAB’s series of blogs. Being a Technology Preview, the module still has some rough edges. Please let us know what you think, so that we can turn Qt 3D into a fully supported part of Qt with Qt 5.6.

Qt Quick and Multimedia related news

A good amount of work has gone into improving the QML engine, which is the basis for Qt Quick. Apart from many bug fixes and performance improvements, it now supports JavaScript typed arrays and a new method to interface with your own value based classes.

Enterprise Controls have been folded into the base Qt Quick Controls and are also made available in the Community version. We also added a TreeView control to complete the set of controls required for building desktop applications.

A lot of work has also been put into Qt Multimedia. On Linux, we now use gstreamer 1.0 as the default backend and lots of bugs have been fixed for the other platforms. The new Video filtering framework is a great new feature that allows the integration of frameworks, such as OpenCL or CUDA with VideoOutput elements.

Qt WebEngine and WebView

Qt WebEngine has been updated to Chromium version 40 and has received new APIs for managing downloading of files, controlling cache and cookies, as well as settings. Support for Qt WebChannel is now built-in and many experimental APIs are now public and fully supported.

The Qt WebView module has some new APIs and now also supports Mac OS X in addition to Android and iOS.

Qt Location

Qt Location is another module that has made its way from Qt 4 to Qt 5 as a Technology Preview. Your feedback on this will be important to make this module an integral part of the Qt 5.6 release. Qt Location adds mapping, geocoding, routing and places support to Qt. In conjunction with the existing Qt Positioning API, it should give you all you need to create location aware applications. Qt Location can make use of different mapping providers, such as Nokia Here, Mapbox and Openstreetmap currently.

Other Improvements

Many other things have been improved with Qt 5.5, you can find description of all the new features on our wiki. For example, we now support more platforms for Bluetooth LE and there is a new SSL backend based on Secure Transport for Mac OS X and iOS.

We have also updated the supported platform and compiler configurations. On Linux we are now supporting RedHat Enterprise Linux better than before, and the binaries can also be directly used on RHEL as well as many other Linux distributions. For Mac users OS X versions 10.8, 10.9 and 10.10 are supported by Qt 5.5. We are not yet officially supporting Windows 10, as it has not been released, but we have been using the pre-releases in development and will add support to Windows 10 with Qt 5.5.x patch release after it is available.

Deprecated Modules

With all these new features coming, some older ones are being deprecated, namely Qt WebKit, Qt Script, and Qt Declarative (Qt Quick 1). All of these modules are still available with Qt 5.5, but we strongly recommend using their replacements for any new functionality: Qt WebEngine, Qt Quick, and Qt QML, which also provides a fully compliant JavaScript engine. While there are still some smaller feature gaps in a few places between these modules, we believe that the replacements are now better than the deprecated modules. We will of course continue to improve the new modules and will try to fill any remaining feature gaps from the old ones.

You can download the Qt 5.5 Beta from your Qt Account portal or via download.qt.io. Please try them out and report back to us any issues you might find, so that we can make Qt 5.5 as awesome as possible.

The post Qt 5.5 Beta Released appeared first on Qt Blog.



Source :- Qt Blog http://ift.tt/1EKiGpk

Qt Online Installer Update Released with Optional Qt Account Sign-In

The Qt online installer with optional sign-in to Qt Account is now released. Users of earlier Qt online installers will get this as an update and new users can download the online installer from qt.io or via the Qt Account web portal. Also as promised last month in Lars’ blog about the One Qt Site Unification project, we are now seeking your input (via a survey) on what additional services and features, if anything, you would find a valuable addition to your Qt developer experience (DX) and Qt Account functionality.

As announced last week, the new Qt online installer provides an option to sign into Qt Account. If you enter your Qt Account credentials, the installer will check if there is a valid commercial license associated with your Qt Account. You will then be taken through to commercial installation. If there is no commercial license associated with your Qt Account, installation will provide the open-source version of Qt. If you do not have a Qt Account yet, you can simply create one directly via the installer. Just enter your email (this is address to which your account activation email will be immediately sent upon account creation) and the password you wish to use for Qt Account access and proceed to install. If you do not have a Qt Account and do not want to create one, you can simply skip this by clicking ‘Next’ to proceed with the open source installation of Qt.

 

Unifiedv2_QtAccount

The Qt repositories and delivery networks for commercial and open source content are separate, so that users with a commercial license of Qt will have access to their commercial delivery system and the additional content their license grants them access to. Users without a commercial license will be able to install the open source version of Qt from the open source delivery system. If you are already using a Qt online installer, you will be provided the new unified installer when using the maintenance tool. You will need to update the installer (maintenance tool), before you download other items. If you do not yet have an online installer for Qt, you can get it from the qt.io Download page or via your Qt Account portal.

The new online installer is built with the brand new 2.0 version of the installer framework. We have worked hard to iron out all possible glitches of the installer, but in case you have problems with it, please file a bug to bugreports.qt.io. Offline installers are unchanged and still use the older version of installer framework.

Take 5 minutes to give us feedback on what functionality you want from Qt Account services.

We are looking at providing you additional services, as well as offering integrated dashboard-like functionality that will eventually put all your Qt services in one unified place, such as Qt Creator and/or a web portal. Qt Account credentials are currently used for signing in to the Qt Wiki and Forum. Commercial license holders can also manage Qt support tickets and downloads when signed in. We are currently working on extending the use of Qt Account for sign in to other systems, such as bugreports.qt.io. To see a list of current benefits of having Qt Account credentials, please visit our Qt Account Benefits page. We will use your input to further develop our service features road map and knowing what you find useful is integral part of planning what we should focus our resources on. We, of course, hope to implement the most popular features and functionality, but can’t make any promises as to what and when. We’ll have more info to share with you at Qt World Summit 2015.

Don’t miss the chance to give your input: Survey open thru Tuesday 19 May 2015.

The post Qt Online Installer Update Released with Optional Qt Account Sign-In appeared first on Qt Blog.



Source :- Qt Blog http://ift.tt/1RzAQTy

Integrating custom OpenGL rendering with Qt Quick via QQuickFramebufferObject

Integrating custom OpenGL rendering code, for example to show 3D models, with Qt Quick is a popular topic with Qt users. With the release of Qt 5.0 the standard approach was to use the beforeRendering and afterRendering signals to issue the custom OpenGL commands before or after the rendering of the rest of the scene, thus providing an over- or underlay type of setup.

With Qt 5.2 a new, additional approach has been introduced: QQuickFramebufferObject. This allows placing and transforming the custom OpenGL rendering like any other Quick item, providing the most flexible solution at the expense of rendering via OpenGL framebuffer objects. While it was little known at the time of its original release, it is becoming more and more popular in applications built with Qt 5.4 and 5.5. It is also one of the building blocks for Qt 3D, where the Scene3D element is in fact nothing but a QQuickFramebufferObject under the hood. We will now take a look at this powerful class, look at some examples and discuss the issues that tend to come up quite often when getting started.

First things first: why is this great?

textureinsgnode

textureinsgnode is the standard example of QQuickFramebufferObject. The Qt logo is rendered directly via OpenGL while having animated transformations applied to the QQuickFramebufferObject-derived item.

qquickviewcomparison

This QQuickWidget example also features QQuickFramebufferObject: the Qt logo is a real 3D mesh with a basic phong material rendered via a framebuffer object. The textured quad, rendered using the framebuffer’s associated texture, becomes a genuine item in the scene with other standard Qt Quick elements above and below it. It also demonstrates the usage of custom properties to control the camera.

The API

QQuickFramebufferObject is a QQuickItem-derived class that is meant to be subclassed further. That subclass is then registered to QML and used like any other standard Quick element.

However, having the OpenGL rendering moved to a separate thread, as Qt Quick does on many platforms, introduces certain restrictions on OpenGL resource management. To make this as painless as possible, the design of QQuickFramebufferObject follows the well-known split: subclasses are expected to reimplement a createRenderer() virtual function. This factory function is always called on the scenegraph’s render thread (which is either the main (GUI) thread, or a separate, dedicated one). The returned QQuickFramebufferObject::Renderer subclass belongs to this render thread. All its functions, including the constructor and destructor, are guaranteed to be invoked on the render thread with the OpenGL context bound and therefore it is always safe to create, destroy, or access OpenGL resources.

In practice this is no different than the QQuickItem – QSGNode or the QVideoFilter – QVideoFilterRunnable pattern.

The basic outline of the C++ code usually becomes something like the following:

class FbItemRenderer : public QQuickFramebufferObject::Renderer
{
    QOpenGLFramebufferObject *createFramebufferObject(const QSize &size)
    {
        QOpenGLFramebufferObjectFormat format;
        format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
        // optionally enable multisampling by doing format.setSamples(4);
        return new QOpenGLFramebufferObject(size, format);
    }

    void render()
    {
        // Called with the FBO bound and the viewport set.
        ... // Issue OpenGL commands.
    }
    ...
}

class FbItem : public QQuickFramebufferObject
{
    QQuickFramebufferObject::Renderer *createRenderer() const
    {
        return new FbItemRenderer;
    }
    ...
}

int main(int argc, char **argv)
{
    ...
    qmlRegisterType("fbitem", 1, 0, "FbItem");
    ...
}

In the QML code we can import and take the custom item into use:

import fbitem 1.0

FbItem {
    anchors.fill: parent
    ... // transform, animate like any other Item
}

This is in fact all you need to get started and have your custom OpenGL rendering shown in a Qt Quick item.

Pitfalls: context and state

When getting started with QQuickFramebufferObject, the common issue is not getting anything rendered, or getting incomplete rendering. This can almost always be attributed to the fact that QQuickFramebufferObject::Renderer subclasses use the same OpenGL context as the Qt Quick scenegraph’s renderer. This is very efficient due to avoiding context switches, and prevents unexpected issues due to sharing and using resources from multiple contexts, but it comes at the cost of having to take care of resetting the OpenGL state the rendering code relies on.

In earlier Qt versions the documentation was not quite clear on this point. Fortunately in Qt 5.5 this is now corrected, and the documentation of render() includes the following notes:

Do not assume that the OpenGL state is all set to the defaults when this function is invoked, or that it is maintained between calls. Both the Qt Quick renderer and the custom rendering code uses the same OpenGL context. This means that the state might have been modified by Quick before invoking this function.

It is recommended to call QQuickWindow::resetOpenGLState() before returning. This resets OpenGL state used by the Qt Quick renderer and thus avoids interference from the state changes made by the rendering code in this function.

What does this mean in practice?

As an example, say you have some old OpenGL 1.x fixed pipeline code rendering a not-very-3D triangle. Even in this simplest possible case you may need to ensure that certain state is disabled: we must not have a shader program active and depth testing must be disabled. glDisable(GL_DEPTH_TEST); glUseProgram(0); does the job. For rendering that is more 3D oriented, a good example of a very common issue is forgetting to re-enable depth writes via glDepthMask(GL_TRUE).

Although not necessary in many cases, it is good practice to reset all the state the Qt Quick renderer potentially relies on when leaving render(). Since Qt 5.2 a helper function is available to do this: resetOpenGLState(). To access this member function, store a pointer to the corresponding item in the Renderer and do the following just before returning from render():

    m_item->window()->resetOpenGLState();

Note that this must be the last thing we do in render() because it also alters the framebuffer binding. Issuing further rendering commands afterwards will lead to unexpected results.

Custom properties and data synchronization

Accessing the Renderer object’s associated item looks easy. All we need is to store a pointer, right? Be aware however that this can be very dangerous: accessing data at arbitrary times from the Renderer subclass is not safe because the functions there execute on the scenegraph’s render thread while ordinary QML data (like the associated QQuickFramebufferObject subclass) live on the main (GUI) thread of the application.

As an example, say that we want to expose the rotation of some model in our 3D scene to QML. This is extremely handy since we can apply bindings and animations to it, utilizing the full power of QML.

class FbItem : public QQuickFramebufferObject
{
    Q_OBJECT
    Q_PROPERTY(QVector3D rotation READ rotation WRITE setRotation NOTIFY rotationChanged)

public:
    QVector3D rotation() const { return m_rotation; }
    void setRotation(const QVector3D &v);
    ...
private:
    QVector3D m_rotation;
};

So far so good. Now, how do we access this vector in the FbItemRenderer’s render() implementation? At first, simply using m_item->rotation() may look like the way to go. Unfortunately it is unsafe and therefore wrong.

Instead, we must maintain a copy of the relevant data in the renderer object. The synchronization must happen at a well-defined point, where we know that the main (GUI) thread will not access the data. The render() function is not suitable for this. Fortunately, QQuickFramebufferObject makes all this pretty easy with the Renderer’s synchronize() function:

class FbItemRenderer : public QQuickFramebufferObject::Renderer                                                         
{                                                                                                                       
public:                                                                                                                 
    void synchronize(QQuickFramebufferObject *item) {
        FbItem *fbitem = static_cast<FbItem *>(item);
        m_rotation = fbitem->rotation();
    }
    ...
private:
    QVector3D m_rotation; // render thread's copy of the data, this is what we will use in render()
}

When synchronize() is called, the main (GUI) thread is guaranteed to be blocked and therefore it cannot read or write the FbItem’s data. Accessing those on the render thread is thus safe.

Triggering updates

To schedule a new call to render(), applications have two options. When on the main (GUI) thread, or inside JavaScript code, use QQuickItem::update(). In addition, QQuickFramebufferObject::Renderer adds its own update() function, which is only usable from the render thread, for example inside render() to schedule a re-rendering of the FBO content on the next frame.

In practice the most common case is to schedule a refresh for the FBO contents when some property changes. For example, the setRotation() function from the above example could look like this:

void FbItem::setRotation(const QVector3D &v)
{
    if (m_rotation != v) {
        m_rotation = v;
        emit rotationChanged();
        update();
    }
}

Internals

Finally, it is worth noting that QQuickFramebufferObject is also prepared to handle multisampling and screen changes.

Whenever the QOpenGLFramebufferObject returned from createFramebufferObject() has multisampling enabled (the QOpenGLFramebufferObjectFormat has a sample count greater than 0 and multisampled framebuffers are supported by the OpenGL implementation in use), the samples will be resolved with a glBlitFramebuffer call into a non-multisampled FBO after each invocation of render(). This is done transparently to the applications so they do not have to worry about it.

Resizing the window with the Qt Quick content will lead to recreating the FBO because its size should change too. The application will see this as a repeated call to createFramebufferObject() with the new size. It is possible to opt out of this by setting the textureFollowsItemSize property to false.

However, there is a special case when the FBO has to get recreated regardless: when moving the window to a screen with a different device pixel ratio. For example moving a window between a retina and non-retina screen on OS X systems will inherently need a new, double or half sized, framebuffer, even when the window dimensions are the same in device independent units. Just like with ordinary resizes, Qt is prepared to handle this by requesting a new framebuffer object with a different size when necessary. One possible pitfall here is the applications’ caching of the results of the factory functions: avoid this. createFramebufferObject() and createRenderer() must never cache their return value. Just create a new instance and return it. Keep it simple. Qt takes care of managing the returned instance and destroying it when the time comes. Happy hacking!

The post Integrating custom OpenGL rendering with Qt Quick via QQuickFramebufferObject appeared first on Qt Blog.



Source :- Qt Blog http://ift.tt/1zS7ASf

Take 10 minutes to tell them why you love Qt…please.

Fancy a new toy like an iPhone 6, an Apple Sports Watch, an Oculus Rift Dev Kit or other cool gadgets?

Now that I have caught your attention, we invite you to check this out: VisionMobile is conducting their 2015 Developer Skills Census, and would like to hear your thoughts about the latest developer trends and your views on what factors contribute to your choice of developing with Qt.

The survey takes about 10 minutes (but take your time, this is important stuff), and your answers will help to shape the future of IoT, mobile, desktop and Cloud development. Besides the draw to win amazing prices, a free chapter from one of VisionMobile’s premium paid reports will also be given immediately upon completion, taking a close look at app profits & costs.

The key findings from the survey will become available as a free research report in July 2015 and for this reason it is very important that all Qt developers have the opportunity to make their voice heard.

Get involved and don’t miss the opportunity to have your say.  Take the survey!

Vision Mobile 2015 Developer Skills Census

The post Take 10 minutes to tell them why you love Qt…please. appeared first on Qt Blog.



Source :- Qt Blog http://ift.tt/1Iln42I

Changing Qt Account to be Optional in the Online Installer

Thanks for your feedback to the new online installer asking for a Qt Account signup. We have evaluated the feedback received via the blog, various discussion forums, irc and other channels. Based on all these comments and discussions with our partners we realize that this was not our finest moment. Preventing the growth and usage of Qt in the open source community is not what we want to happen. We did already see a nice jump in the number of Qt Accounts, but it was never our intention to make our valued community and contributors upset with us or stop using and contributing to Qt. We clearly ill-calculated how asking for a Qt Account with the online installer would make our users feel. A mistake. Sincere apologies.

Based on your feedback, we will remove the enforced Qt Account requirement for open source downloads. Instead, we will make it optional. Users can proceed to download by opting out of creating a Qt Account. Just like before, the commercial users need to provide their Qt Account so that we can point them to the additional content and commercial versions of Qt. We very much hope that we will see also many open-source users creating Qt Accounts either when installing Qt, or via qt.io.

The installer team is already looking at making this change, and we hope that an update can be rolled out next week. Even though the change may look small there is quite many things that we always need to verify before we roll out an update to production. So, please bear with us while we are implementing the change.

We will continue to develop our plans of bringing integrated services to Qt via the Qt Account. Next we are aiming to provide a single sign-on solution through the Qt Account to all our services (forums, wiki, bug reporting, customer portal, etc). Some of the services already leverage Qt Account for sign-on and new services will follow in the coming months. We are committed to developing Qt Account further and want to make it valuable for all users of Qt.

We do hope that this eases your concerns, and that we can continue with your trust. The open source community is what Qt is built on and we value your efforts and feedback greatly. We are very happy to have an active ecosystem around Qt and appreciate the dialogue. So, thanks again for your feedback, discussions and for guiding us in this tough endeavor. We are glad that we have a lot of passion for Qt and for its ongoing greatness in the community.

The post Changing Qt Account to be Optional in the Online Installer appeared first on Qt Blog.



Source :- Qt Blog http://ift.tt/1zBju2T

Announcing Wiki week

Mark your calendars for 18-22.5.2015, we will have a Wiki Week to clean up the Qt Wiki.

During wiki week we will work together on these topics:

  • Cleaning up active pages
  • Marking old pages as needing updates
  • Archiving or removing completely outdated pages

Other ideas are also welcome, anything to make the wiki better! If you have something in mind, please post a new thread on the forums to the Wiki Discussions area.

I opened a page on the wiki for the Wiki Week, for lists of actively visited pages and links to the list of pages that need updating.

I will also post more information here on the blog as I update the wiki page.

The post Announcing Wiki week appeared first on Qt Blog.



Source :- Qt Blog http://ift.tt/1IJkiEX

New Unified Qt Online Installer Available

Today we released a new unified online installer for commercial and open-source versions. Previously, we have had  separate installers for each version. Now Qt Account is used for validating the Qt license and determining if a commercial  or open-source version should be installed.

Unification of Qt systems has been ongoing for a while and we have now reached a major milestone with the unified online installer. We no longer have two separate online installers to create, test and release. Also, it is now easier to migrate from open-source to commercial license of Qt.

The Qt repositories and delivery networks for commercial and open-source content are still separate, so that users with a commercial license of Qt will have access to their commercial delivery system and the additional content their license grants them access to. Users without a commercial license will be able to install the open-source version of Qt from the open-source delivery system.

If you already have a Qt Account, enter your credentials when asked:

unified_installer_1

If you do not yet have a Qt Account, you can create it conveniently from the online installer:

unified_installer_2

When you enter your Qt Account credentials, the installer will check if there is a valid commercial license associated with your Qt Account, and you will be taken through to commercial installation. If there is no commercial license associated with your Qt Account, installation will provide the open-source version of Qt. If you do not have a Qt Account yet, you can simply create one directly via the installer. Just enter your email (this is address to which your account activation email will be immediately sent upon account creation) and the password you wish to use for Qt Account access and proceed to install. Be sure to activate your Qt Account as instructed in the email. You may also create a new Qt Account at qt.io, if you prefer.

In addition to being the place to manage support tickets and downloads for commercial license holders of Qt, Qt Account credentials are used for signing in to the Qt Wiki and Forum. We are also working hard to extend the use of Qt Account for sign in to other systems, such as bugreports.qt.io. To see a list of benefits of the Qt Account, please visit our Qt Account Benefits page.

The unified online installer is built with the brand new 2.0 version of the installer framework. We have worked hard to iron out all possible glitches of the installer, but in case you have problems with it, please file a bug to bugreports.qt.io. Offline installers are unchanged and still use the older version of installer framework.

If you are already using a Qt online installer, you will be provided the new unified installer when using the maintenance tool. You will need to update the installer (maintenance tool), before you download other items. If you do not yet have an online installer for Qt, you can get it from the qt.io Download page or from the Qt Account portal.

The post New Unified Qt Online Installer Available appeared first on Qt Blog.



Source :- Qt Blog http://ift.tt/1JkcB6k