FreeCAD Qt5 plan for deprecated WebKit?

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
ian.rees
Posts: 696
Joined: Sun Jun 15, 2014 3:28 am
Contact:

Re: FreeCAD Qt5 plan for deprecated WebKit?

Post by ian.rees »

Thanks Werner! I'm looking forward to trying this out soon.

You've probably seen this already, but in case not: "QGLPixelBuffer is deprecated and implemented by using a hidden QGLWidget and a QOpenGLFramebufferObject. For offscreen rendering to a texture, switch to using QOpenGLFramebufferObject directly to improve performance." QOpenGLFramebufferObject looks like it's mainly intended for making textures, so will probably need to be configured differently than default (add depth buffer, I guess change target from texture2d to renderbuffer [somehow]). -Ian-
wmayer
Founder
Posts: 20245
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FreeCAD Qt5 plan for deprecated WebKit?

Post by wmayer »

You've probably seen this already, ...
Yes. QOpenGLFramebufferObject is already used as alternative for the missing/not working QGLPixelBuffer but fails when transparencies are set. But as wrote in the EDIT I found the class QOffscreenSurface which apparently internally uses pixel buffer. I will give this a try.
User avatar
f3nix
Posts: 346
Joined: Sat May 30, 2015 11:58 am

Re: FreeCAD Qt5 plan for deprecated WebKit?

Post by f3nix »

Hi Werner! Great! :)
wmayer wrote: Currently there are some open points:
[*]Get the 3d view working again
In my initial testing I have found that commenting some lines did help. I do not know which one causes this (GL_DEPTH_TEST probably) or what a proper fix is. (Have not tested on your branch yet. Need one hour to finish building) EDIT: This is in QuarterWidget.cpp

Code: Select all

     std::clock_t begin = std::clock();
 
     if(!initialized) {
-        glEnable(GL_DEPTH_TEST);
+//        glEnable(GL_DEPTH_TEST);
         this->getSoRenderManager()->reinitialize();
         initialized = true;
     }
 
     getSoRenderManager()->activate();
 
-    glEnable(GL_DEPTH_TEST);
-    glMatrixMode(GL_PROJECTION);
+//    glEnable(GL_DEPTH_TEST);
+//    glMatrixMode(GL_PROJECTION);
wmayer wrote: [*]Find a replacement for qglColor
[*]Find a replacement for QGLWidget::renderText
I have been playing with this: Migration to QOpenGLWidget

HTH.

Cheers,
Mateusz
blacey
Posts: 370
Joined: Tue Dec 08, 2015 11:28 pm

Re: FreeCAD Qt5 plan for deprecated WebKit?

Post by blacey »

wmayer wrote:Now to the QOpenGL* port:
I have moved this branch https://github.com/wwmayer/FreeCAD/tree/qtopengl

If someone wants to test you have to set the option BUILD_QT5 of course and additionally the option FREECAD_USE_QTOPENGL_WIDGET which is off by default.
Gave this a shot with clang on macOS but it fails to compile - probably an easy fix but haven't had a chance to dig into it and won't until this evening but here is the pertinent information.

Code: Select all

/Users/blacey/Projects/FreeCAD-MacOS-CI/src/Gui/Flag.cpp:154:6: error: member access into incomplete type 'QOpenGLFunctions'
    f->glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF());
     ^
/usr/local/Cellar/qt@5.6/5.6.2/lib/QtGui.framework/Headers/qopenglcontext.h:68:7: note: forward declaration of 'QOpenGLFunctions'
class QOpenGLFunctions;
      ^
/Users/blacey/Projects/FreeCAD-MacOS-CI/src/Gui/Flag.cpp:168:6: error: member access into incomplete type 'QOpenGLFunctions'
    f->glBlendColor(c.redF(), c.greenF(), c.blueF(), c.alphaF());
     ^
/usr/local/Cellar/qt@5.6/5.6.2/lib/QtGui.framework/Headers/qopenglcontext.h:68:7: note: forward declaration of 'QOpenGLFunctions'
class QOpenGLFunctions;
      ^
2 errors generated.
make[2]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/Flag.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/all] Error 2
make: *** [all] Error 2
An offending line in OpenGLImageBox.cpp - https://github.com/wwmayer/FreeCAD/blob ... x.cpp#L127
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: FreeCAD Qt5 plan for deprecated WebKit?

Post by triplus »

I wanted to test this for a while now:
QOpenGLWidget.png
QOpenGLWidget.png (38.39 KiB) Viewed 2170 times
P.S. Looking good and thanks.
User avatar
f3nix
Posts: 346
Joined: Sat May 30, 2015 11:58 am

Re: FreeCAD Qt5 plan for deprecated WebKit?

Post by f3nix »

blacey wrote: Gave this a shot with clang on macOS but it fails to compile

Code: Select all

diff --git a/src/Gui/Flag.cpp b/src/Gui/Flag.cpp
index f3fb4ce46..6ddffe73a 100644
--- a/src/Gui/Flag.cpp
+++ b/src/Gui/Flag.cpp
@@ -30,6 +30,10 @@
 #include <Inventor/SbVec2s.h>
 #include "View3DInventorViewer.h"
 
+#if defined(HAVE_QT5_OPENGL)
+#include <QOpenGLFunctions>
+#endif
+
 #include "Flag.h"
 
 using namespace Gui;
HTH.

Cheers,
Mateusz
wmayer
Founder
Posts: 20245
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FreeCAD Qt5 plan for deprecated WebKit?

Post by wmayer »

Gave this a shot with clang on macOS but it fails to compile - probably an easy fix but haven't had a chance to dig into it and won't until this evening but here is the pertinent information.
Damn! I added the line

Code: Select all

#include <QOpenGLFunctions>
to the generated QtOpenGL.h instead of QtOpenGL.h.cmake. So, just add it to the latter file which you will find under FreeCAD/src so that it looks like this:

Code: Select all


#ifndef QUARTER_QTOPENGL_H
#define QUARTER_QTOPENGL_H

/* QtOpenGL.h.  Generated from QtOpenGL.h.cmake by cmake.  */

#cmakedefine HAVE_QT5_OPENGL

#if defined(HAVE_QT5_OPENGL)

#include <QOpenGLContext>
#include <QSurfaceFormat>
#include <QOpenGLWidget>
#include <QOpenGLFramebufferObject>
#include <QOpenGLVersionProfile>
#include <QOpenGLFunctions>

typedef QOpenGLContext QtGLContext;
typedef QSurfaceFormat QtGLFormat;
typedef QOpenGLWidget QtGLWidget;
typedef QOpenGLFramebufferObject QtGLFramebufferObject;
typedef QOpenGLFramebufferObjectFormat QtGLFramebufferObjectFormat;

#else // HAVE_QT5_OPENGL

#include <QGLContext>
#include <QGLFormat>
#include <QGLWidget>
#include <QGLPixelBuffer>
#include <QGLFramebufferObject>

typedef QGLContext QtGLContext;
typedef QGLFormat QtGLFormat;
typedef QGLWidget QtGLWidget;
typedef QGLPixelBuffer QtGLPixelBuffer;
typedef QGLFramebufferObject QtGLFramebufferObject;
typedef QGLFramebufferObjectFormat QtGLFramebufferObjectFormat;

#endif // HAVE_QT5_OPENGL

#endif //QUARTER_QTOPENGL_H
wmayer
Founder
Posts: 20245
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FreeCAD Qt5 plan for deprecated WebKit?

Post by wmayer »

In my initial testing I have found that commenting some lines did help. I do not know which one causes this (GL_DEPTH_TEST probably) or what a proper fix is. (Have not tested on your branch yet. Need one hour to finish building) EDIT: This is in QuarterWidget.cpp
Thanks a lot! This is a big step forward since the 3d viewer basically works again. However, there are two problems:
  • When resizing the 3d viewer it flickers heavily
  • In debug mode it creates a lot of error messages: Coin error in SoNode::GLRenderS(): GL error: 'GL_INVALID_OPERATION', nodetype: Separator (set envvar COIN_GLERROR_DEBUGGING=1 and re-run to get more information)
And now the ported Image view can coexist with the 3d viewer.

I have pushed a new commit to the opengl branch.
blacey
Posts: 370
Joined: Tue Dec 08, 2015 11:28 pm

Re: FreeCAD Qt5 plan for deprecated WebKit?

Post by blacey »

wmayer wrote: Thanks a lot! This is a big step forward since the 3d viewer basically works again. However, there are two problems:
  • When resizing the 3d viewer it flickers heavily
  • In debug mode it creates a lot of error messages: Coin error in SoNode::GLRenderS(): GL error: 'GL_INVALID_OPERATION', nodetype: Separator (set envvar COIN_GLERROR_DEBUGGING=1 and re-run to get more information)
And now the ported Image view can coexist with the 3d viewer.

I have pushed a new commit to the opengl branch.
@wmayer, I just returned home and pulled your latest OpenGL branch and it works well on macOS. I do not see the the 3d viewer flicker or the coin errors. I am using the following:
Perhaps the issues you are seeing are due to a differences in dependencies?

Here is a short video of it in action NOTE: - I was compiling in the background so performance wasn't the best.

I agree this is a bit step forward ;)

Code: Select all

OS: Mac OS X
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.10460 (Git)
Build type: DEBUG
Branch: qtopengl
Hash: af120636c7d386193fa226a875334369c7f7e506
Python version: 2.7.13
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.1.0
wmayer
Founder
Posts: 20245
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FreeCAD Qt5 plan for deprecated WebKit?

Post by wmayer »

I do not see the the 3d viewer flicker or the coin errors. I am using the following:
I guess that the flickering and the GL errors are related somehow. When I resize the 3d window I can see the flickering and in the output window hundreds of these errors are printed. So maybe on your system everything seems to be fine.

And can you confirm that it finally fixes issue #1401?
Post Reply