vtk 8.2 MFC examples don't work

I am trying to upgrade to vtk8.2.0 (VS2017) and tested it with vtkMFC examples. Now run into some problems. I just couldn’t execute any of the three projects (vtkDLG, vtkMDI, and vtkSDI) with vtk error messages:

Generic Warning: In C:\VTK-8.2.0\Rendering\Core\vtkPolyDataMapper.cxx, line 28
Error: no override found for ‘vtkPolyDataMapper’.

Warning: In C:\VTK-8.2.0\Rendering\Core\vtkInteractorStyleSwitchBase.cxx, line 39
vtkInteractorStyleSwitchBase (0000021D4A64FA00): Warning: Link to vtkInteractionStyle for default style selection.

and then stop at (as an example for vtkDLG)

void vtkOpenGLRenderWindow::ActivateTexture(vtkTextureObject *texture)
–> glActiveTexture(GL_TEXTURE0 + activeUnit);

with error:

Exception thrown at 0x0000000000000000 in vtkDLG.exe: 0xC0000005: Access violation executing location 0x0000000000000000.

I tried added the following code based on some suggestions, no luck for me

#include “vtkAutoInit.h”
VTK_MODULE_INIT(vtkRenderingOpenGL2); // VTK was built with vtkRenderingOpenGL2
VTK_MODULE_INIT(vtkInteractionStyle);

Any things I missed? Please help!

Thank you very much.

Sean

Should VTK_DEFINTIONS be used in the examples?

Thanks for your prompt reply. Could you further explain how to use VTK_DEFINITIONS?

Something like compile_definitions(${VTK_DEFINITIONS}). This is where the normal autoinit stuff comes into play for 8.2.

Thanks. I tried and it is still the same issue.

Hmm. I’m not sure then. Are you seeing -D<blahblah>_AUTOINIT= arguments on the command lines compiling the sources?

I copy and paste my Preprocessor Definitions as following, for your reference. I just tried SampleMFC example and it worked well after I removed some obsolete MFC code. I am trying to compare the code between these two project (vtkMFC and SampleMFC), and hopefully can find the issue. Thanks.

WIN32
_WINDOWS
vtkDomainsChemistry_AUTOINIT=1(vtkDomainsChemistryOpenGL2)
vtkIOExport_INCLUDE=“C:/OS20190322/VTKExamples/CMakeFiles/vtkIOExport_AUTOINIT_vtkIOExportOpenGL2_vtkIOExportPDF.h”
vtkRenderingContext2D_AUTOINIT=1(vtkRenderingContextOpenGL2)
vtkRenderingCore_INCLUDE=“C:/OS20190322/VTKExamples/CMakeFiles/vtkRenderingCore_AUTOINIT_vtkInteractionStyle_vtkRenderingFreeType_vtkRenderingOpenGL2.h”
vtkRenderingOpenGL2_AUTOINIT=1(vtkRenderingGL2PSOpenGL2)
vtkRenderingVolume_AUTOINIT=1(vtkRenderingVolumeOpenGL2)
_AFXDLL
GLEW_STATIC
CMAKE_INTDIR=“Debug”

I could not figure out exactly what went wrong. However, after I switch Visual Studio from 2017 to 2019 (express), all issues are gone.