Using 'raw' OpenGLES2.0-3.0 API in Qt - qt

I have the following situation.I have a renderer based on OpenGLES 2.0-3.0 APIs.I need to embed it into Qt based desktop widget app.I have read about Qt GL wrappers ,which is one way to use GL ES API in Qt App.But in my case I cannot afford rewriting the whole engine rendering code to use Qt's GL wrappers not only because of the scope, but mostly because of portability issues.So I tried to include GL/GLES3.0/gl3.h headers which are exposed in Qt SDK. Doing this I am getting all sort of header collision errors, for example like this one:
D:\Qt\5.8\msvc2015\include\QtANGLE\GLES3\gl3.h:73: error: C2371:
'GLsizeiptr': redefinition; different basic types
So how can I use just raw OpenGL ES API in Qt?
For Desktop OpenGL I know I should build the SDK with desktop opengl flag on,and then use some GL loader lib like GLEW to init all the GL func pointers.Does it mean I must do something similar for GLES? For example ,building the SDK without ANGLE,then link with ANGLE lib explicitly?
I have asked this question also on Qt's forums.Received no answer.
UPDATE:
I examined some Qt headers to see where the above mentioned collision happens.So Qt has qopengl.h header which declares GL functions and types.But it also has ANGLE's gl headers,which I try to include and which declare the same stuff.So this causes the collision.I don't understand why they allow both headers into the SDK.How to get rid of qopengl.h and run with ANGLE headers only?

Related

qt3d and the oculus sdk

Given qt3d's structure, is it possible to integrate the oculus sdk with a qt3d application?
I have tried but my two main obstacles are:
I cant use the textures from the texture swap chain created by the oculus sdk as a render target attachment
I am not able to call ovr_SubmitFrame at the end of each frame since qt3d doesnt have a signal that would allow me to do so.
Has anyone successfully gotten the oculus sdk to work with qt3d? If so, how did you overcome these issues?
Are there any plans for allowing the integration of VR SDKs (not just oculus') in qt3d in further releases?
You could probably do it with some sort of custom framegraph that encapsulated the stereo rendering functionality and included a custom component that could take the currently rendered content and submitted it to the SDK prior to the swapbuffer call.
Alternatively you could dive into the code that processes the framegraph itself and see how hard it would be to customize it to work against a VR API. I've done significant work with integrating Qt apps with VR, but not specifically with Qt3D.
The frame graph will indeed provide one part of the solution for the stereoscopic rendering setup. There is already an anaglyphic stereo example showing most of what you need that ships with Qt 3D.
To integrate the swap chain of the occulus SDK will require deeper integration. I do not know the details of the Occulus SDK as yet but we can take a look.
From what I can see you should be able to do something analogous to the Scene3D custom Qt Quick 2 item to be able to render to the textures provided by the Occulus SDK and to tell Qt 3D which OpenGL Context to use. See
http://code.qt.io/cgit/qt/qt3d.git/tree/src/quick3d/imports/scene3d?h=5.7
Nicolas, I also do not appreciate you publicly saying that KDAB are not much help. I only received an email from Karsten on Friday which I responded to despite being on vacation saying that we can help but it will be on a best efforts basis since you are not paying and I have a very full workload preparing Qt 3D for release at the end of the month along with Qt 5.7. Today is a public holiday in the UK, as you are aware, yet you are already saying detrimental things about us.
You were also directed to post to the interest#qt-project.org mailing list on the qt-forums as I do not tend to monitor SO or the qt-forums on a regular basis. You could have also emailed us directly or via the development#qt-interest mailing list.
We would be more than happy to set up a support agreement with you.

How to support multiple language in Qt Based Application

I am trying to develop a Qml based QT application which will support multiple languages.In the application there will be drop down list from where on select of language whole language family of the application will be changed.Can anyone help me on that giving idea how to proceed?
Is there any example? and is QTranslator() is the convenient way to do this?
The localization system of Qt is well documented: Internationalization with Qt
Simply you put your text directly in the C++ code, using the tr() method of QObject (or qsTr() in QML). Than there are some tools (lupdate and lrelease) to generate the translation files. I suggest to read the documentation, it's very easy.
Some useful links:
Hello tr: and example
Qt Linguist manual
QTranslator works well with Qt UI as you can use languageChanged() signal to update the UI. This isn't possible with QML.
See this QML WiKi, it is the recommended workaround (for now!).

How to Interact with a Qt C++ library inside a QML/QtQuick application?

I recently wrote a Qt based library to manage requests to TheMovieDB.org for a professional desktop application.
Not really experienced with QML and QtQuick, I think about migrating this application to QML which seems to be really adapted for.
I began few tutorials with QML...Amazing.
And now, I wonder if I can integrage my wrapper library into a QML application ?
Basically, let the user capture a movie name into a nice QML interface, froward the input parameters to the c++ wrapper, and retrieve the resulting json results + QPixmap object.
Is it something possible ? I found some piece of codes to access QML components from a Qt c++ application but the inverse yet.
Or maybe am I thinking the things the wrong way ?
Have you ever wrote something similar, I mean regarding the interaction mechanism?

QT for OpenglEs on Desktop

I have an existing project which uses openglEs library (libGLESv2.lib) on DESKTOP platform.
Now I want to use QT as its user interface by using QGLwidget. However after calling any OpenGL function in QGLwidget::initializeGL function I get Access violation executing location 0x00000000 error at the code below,
void MyGLWidget::initializeGL()
{
if (!context()->create())
throw std::exception("no context :)");
context()->makeCurrent();
glViewport(0, 0, 640, 480);
}
If I also include the library opengl32.lib then glviewport function works but when I hit to glGenFramebuffers then I get the same error.
Could you please let me know how can I configure my project to use QT with opengles on desktop platform.
If I also include the library opengl32.lib then glviewport function works but when I hit to glGenFramebuffers then I get the same error.
glViewport is a OpenGL function found in every OpenGL version and profile since version 1. As such it's immediately available simply by linking against the basic OpenGL interface library.
glGenFramebuffers is a function introduced only with OpenGL-3 (OpenGL-ES 2, BTW, OpenGL-ES is not natively supported on Windows) and before you can use it, you have to
check that it is actually supported
load the OpenGL context dependent function pointer at runtime into the variable symbol you're actually calling
Failing to do the second step will give you the error you encounter. Failing to do the first step you try to load it, but loading may fail leading to the same result as if you didn't do (2) at all.
Qt provides all the function loading checks and executions for you, so I suggest you use it: http://doc.qt.io/qt-4.8/qglfunctions.html
It's not perfect, but it gets the job done.
Update (from comments)
Most likely you already have some OpenGL loader library in your project, that actually resolves everything, but before using Qt you did properly initialize it. Now using Qt you've got a mix of statically resolved symbols through opengl32.lib and symbols provided by that loader, yet the loader is not initialized. Look through the code as it was before integrating Qt and look for some initializing call (called after creating the OpenGL context/window but before doing any OpenGL work).
My best guest would be, that the EGL bindings you use also implement the OpenGL-ES wrapper/loader. As I already explained, Windows doesn't natively support OpenGL-ES (only regular OpenGL) and some kind of compatibility layer is required. It is most likely this layer that's getting in your way now. The good news is, that since you're on Windows you can use regular native OpenGL-3 instead; for the most part OpenGL-ES is a subset of OpenGL-3. You'll still need to runtime load GL-3 functions, but as already said, Qt can do that for you.
What to do:
Replace all occurrences of #include <EGL/egl.h> with #include <GL/gl.h> – that should get rid of the symbol shadowing.
Next, for all classes in which use of OpenGL functions is made, add an inheritance of QGLFunctions so that in the classes' namespaces the dynamically loaded functions are used.
Note that every class that inherits QGLFunctions must be instanced only when the target OpenGL context is made current OR you call initializeFunctions on the instances from QGLWidget::initializeGL (or its derivatives). you have to do the function initialization once for each instance of the class inheriting QGLFunctions and the initialization function must be called when the OpenGL context that's to be used is currently active. Like I said, Qt's QGLFunctions is not perfect; if it were it would do the necessary function pointer loading on demand, cache the result and in case of a OpenGL context switch automatically reinitialize.

qtwebkit qt5 beta webgl

I was trying to run WebGL application on QtWebKit (Qt 5.0 beta Version). I am using eglfs plugin on a mips based platform. I used QtTestBrowser as the test browser.
I ran an webgl site-
./QtTestBrowser -webgl -graphicsbased http://jsbin.com/ulazel
It reported no-webgl support.
I did a bit of debugging and found that in file
qtwebkit/Source/WebKit/qt/WebCoreSupport/PageClientQt.cpp
it returns as it cannot find glViewport:
QGLWidget* glViewport = qobject_cast<QGLWidget*>(scrollArea->viewport());
if (!glViewport) {
//Returns from here....
return;
}
By enabling “-gl-viewport” I was able to get the glContext in HTML page. But it was not properly displayed. Also since every widget (launcherWindow etc) it was trying to create a “Window” intern calling eglCreateWindow() and resulting in memory issues (Around 12 window was created all full size of 1920×1080. Finally the displayed image is also not proper.
Any one have suggestion? where i am going wrong?
WebGL is functional with additional patches on top of Qt5. You might want to take a look at the patchset for WebGL for eglfs, at the below link.
https://bugreports.qt-project.org/browse/QTBUG-30405
(Note - I have validated this only on ARMv7, but I cannot see a dependency on arch for this patchset)

Resources