Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile under Mac #1

Open
leylekz opened this issue Jul 17, 2018 · 11 comments
Open

Compile under Mac #1

leylekz opened this issue Jul 17, 2018 · 11 comments

Comments

@leylekz
Copy link

leylekz commented Jul 17, 2018

Hi,

I just compiled the code in Mac but when I ran it I got:

vtkExternalOpenGLRenderWindow (0x7f862e1e7200): VTK is designed to work with OpenGL version 3.2 but it appears it has been given a context that does not support 3.2. VTK will run in a compatibility mode designed to work with earlier versions of OpenGL but some features may not work.

Searching the web I found a possible solution which was to insert:

QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());

before main app is generated. This time the error message I got was:

QVTKFramebufferObjectItem::setVtkFboRenderer
QVTKFramebufferObjectRenderer::initScene()
QVTKFramebufferObjectRenderer::generatePlatform()
QVTKFramebufferObjectRenderer::updatePlatform()
Segmentation fault: 11

Any ideas?

Also, I was getting error when reading in an obj file (under Linux). Changing:
if (modelFilePathExtension == ".obj")
to
if (modelFilePathExtension == "obj")
fixed the problem....

Z

@nicanor-romero
Copy link
Owner

Hi @ZaferL,

Thanks for the OBJ files fix, I have already committed the change.

I'll have a look at the changes needed in macOS to run the example.

@leylekz
Copy link
Author

leylekz commented Jul 22, 2018

Just got it working on Mac, I upgraded Qt from 5.9.3 to 5.11.1. I also added the following line:

QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());

to CanvasHandler.cpp before QApplication app(argc, argv); is called.

@ihowell
Copy link

ihowell commented Aug 29, 2018

@ZaferL, While this does fix the problem in the instance, do you have any idea why this would be necessary in this instance? This doesn't work for my solution, as I'm staying away from widgets entirely, so is there a better way of doing it? Does QVTKOpenGL have somewhere else we could get the format?

@ihowell
Copy link

ihowell commented Aug 29, 2018

If you look at the source code for where QVTKOpenGLWidget::defaultFormat() leads, it calls the defaultFormat function from QVTKOpenGLWindow, which returns the following custom surface format (which I copied and pasted to get my personal project to work). It would be nice if VTK output this from some other endpoint, so that it is easier to integrate into QtQuick.

QSurfaceFormat QVTKOpenGLWindow::defaultFormat()
{
  QSurfaceFormat fmt;
  fmt.setRenderableType(QSurfaceFormat::OpenGL);
  fmt.setVersion(3, 2);
  fmt.setProfile(QSurfaceFormat::CoreProfile);
  fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
  fmt.setRedBufferSize(8);
  fmt.setGreenBufferSize(8);
  fmt.setBlueBufferSize(8);
  fmt.setDepthBufferSize(24);
  fmt.setStencilBufferSize(8);
  fmt.setAlphaBufferSize(0);
  fmt.setStereo(false);
  fmt.setSamples(vtkOpenGLRenderWindow::GetGlobalMaximumNumberOfMultiSamples());
#ifdef DEBUG_QVTKOPENGL_WIDGET
  fmt.setOption(QSurfaceFormat::DebugContext);
#endif
  return fmt;
}

Source: https://gitlab.kitware.com/vtk/vtk/blob/master/GUISupport/Qt/QVTKOpenGLWindow.cxx

@haampie
Copy link

haampie commented Feb 9, 2019

On the Mac with the changes of above the screen looks very poorly rendered and interaction with the scene (selecting, rotating) is impossible. Any ideas what might cause this problem?

Scroll events do work though, so I can zoom in, but not rotate or select.

bildschirmfoto 2019-02-09 um 21 37 44

@kshahim
Copy link

kshahim commented May 25, 2019

In Mac, I receive this error :
"ERROR: In .../VTK-8.1.1/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx, line 785
vtkGenericOpenGLRenderWindow (0x109966c00): GLEW could not be initialized.

@haampie
Copy link

haampie commented May 25, 2019 via email

@kshahim
Copy link

kshahim commented May 25, 2019 via email

@kshahim
Copy link

kshahim commented May 25, 2019

the problem was related to VTK compilation, I enabled VTK_USE_SYSTEM_GLEW and now I received this error :

VTK is designed to work with OpenGL version 3.2 but it appears it has been given a context that does not support 3.2. VTK will run in a compatibility mode designed to work with earlier versions of OpenGL but some features may not work.

then, I added
QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat())

it workes but the rendering quality compare to windows version is poor

@kshahim
Copy link

kshahim commented May 26, 2019

Ie the rendering quality in Mac, somehow related to this?
https://gitlab.kitware.com/vtk/vtk/issues/17154

@kshahim
Copy link

kshahim commented Jun 29, 2019

I think I find the reason why in Mac, the rendering quality is less than in windows,
in the following line, the macSize was divided by two while in windows, it is not the case:

QOpenGLFramebufferObject *QVTKFramebufferObjectRenderer::createFramebufferObject(const QSize &size)
{
QSize macSize = QSize(size.width() / 2, size.height() / 2);
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants