From 176edaf896f17a5dabdbee0b0e7390cc58a25a09 Mon Sep 17 00:00:00 2001 From: Leonardo Florez Valencia Date: Fri, 26 Dec 2014 22:52:56 +0100 Subject: [PATCH] The beast is alive on MSWin!!! --- COMPILATION | 23 +++++-- appli/ImageMPR/ImageMPR.cxx | 14 ++-- .../Visualization/OpenGLMeshMapper.hxx | 64 ++++++------------- 3 files changed, 49 insertions(+), 52 deletions(-) diff --git a/COMPILATION b/COMPILATION index 96717fa..eeb844a 100644 --- a/COMPILATION +++ b/COMPILATION @@ -6,15 +6,30 @@ @prerequisites 1. CMake (>=2.8.12.2) - 3. Visualization Toolkit -VTK- (>=6.1.0) - 3.1 Required cmake flags: + 2. Visualization Toolkit -VTK- (>=6.1.0) + 2.1 Required cmake flags: BUILD_SHARED_LIBS:BOOL=ON - 4. Insight Toolkit -ITK- (>=4.6.0) - 4.1 Required cmake flags: + 3. Insight Toolkit -ITK- (>=4.6.0) + 3.1 Required cmake flags: BUILD_SHARED_LIBS:BOOL=ON Module_ITKVtkGlue:BOOL=ON + 4. WARNING: Notes on compilation on MS-Windows + As the time being (circa dec 2014), I've been using MSVC-2013 + (compiler version 12). As expected, weird behavior is related to + this config. Please take into account the following in order to + have a successful compilation: + 4.1 If you want to build the Qt-based code, please be sure that + it was compiled with EXACTLY the same compiler you are using. + 4.2 Since the dll load-unload procedure in MSWin is kind of magic, + VTK should be compiled as shared libraries and ITK should be + compiled as static libraries. This allows a correct + execution of the SmartPointer's thus preventing anoying crashes. + 4.3 If you found more problems in any MSWin config, please let us know at + florez-l@javeriana.edu.co + + @cmake_flags BUILD_DEMOS:BOOL Build example applications? (most of them are command line) diff --git a/appli/ImageMPR/ImageMPR.cxx b/appli/ImageMPR/ImageMPR.cxx index 1d05703..025b8c8 100644 --- a/appli/ImageMPR/ImageMPR.cxx +++ b/appli/ImageMPR/ImageMPR.cxx @@ -6,6 +6,14 @@ #include #include +#ifdef _WIN32 +# define PLUGIN_EXT "dll" +# define PLUGIN_REGEX "Plugins file (*.dll);;All files (*)" +#else +# define PLUGIN_EXT "so" +# define PLUGIN_REGEX "Plugins file (*.so);;All files (*)" +#endif // _WIN32 + // ------------------------------------------------------------------------- ImageMPR::ImageMPR( QWidget* parent ) : QMainWindow( parent ), @@ -56,10 +64,8 @@ _triggered_actionOpenPlugins( ) QFileDialog dialog( this ); dialog.setFileMode( QFileDialog::ExistingFile ); dialog.setDirectory( "." ); - dialog.setNameFilter( - tr( "Plugins file (*.so);;All files (*)" ) - ); - dialog.setDefaultSuffix( tr( "so" ) ); + dialog.setNameFilter( tr( PLUGIN_REGEX ) ); + dialog.setDefaultSuffix( tr( PLUGIN_EXT ) ); if( !( dialog.exec( ) ) ) return; diff --git a/lib/cpPlugins/Extensions/Visualization/OpenGLMeshMapper.hxx b/lib/cpPlugins/Extensions/Visualization/OpenGLMeshMapper.hxx index f1f0468..3ad1bc7 100644 --- a/lib/cpPlugins/Extensions/Visualization/OpenGLMeshMapper.hxx +++ b/lib/cpPlugins/Extensions/Visualization/OpenGLMeshMapper.hxx @@ -39,17 +39,6 @@ PFNGLUNMAPBUFFERARBPROC pglUnmapBuffer = 0; #endif // _WIN32 -#ifdef _WIN32 - -typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); -typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); -PFNWGLSWAPINTERVALEXTPROC pwglSwapIntervalEXT = 0; -PFNWGLGETSWAPINTERVALEXTPROC pwglGetSwapIntervalEXT = 0; -#define wglSwapIntervalEXT pwglSwapIntervalEXT -#define wglGetSwapIntervalEXT pwglGetSwapIntervalEXT - -#endif // _WIN32 - // some definitions for what the polydata has in it #define CPPLUGINS_VTK_PDM_NORMALS 0x0001 #define CPPLUGINS_VTK_PDM_COLORS 0x0002 @@ -563,28 +552,27 @@ _ConfigureOpenGL( ) if( input == NULL ) return( false ); -#ifdef _WIN32 - // get pointers to GL functions - glGenBuffers = - ( PFNGLGENBUFFERSARBPROC )wglGetProcAddress( "glGenBuffers" ); - glBindBuffer = - ( PFNGLBINDBUFFERARBPROC )wglGetProcAddress( "glBindBuffer" ); - glBufferData = - ( PFNGLBUFFERDATAARBPROC )wglGetProcAddress( "glBufferData" ); - glBufferSubData = - ( PFNGLBUFFERSUBDATAARBPROC )wglGetProcAddress( "glBufferSubData" ); - glDeleteBuffers = - ( PFNGLDELETEBUFFERSARBPROC )wglGetProcAddress( "glDeleteBuffers" ); +#ifdef _WIN32 + // Get pointers to GL functions + glGenBuffers = reinterpret_cast< PFNGLGENBUFFERSARBPROC > + ( wglGetProcAddress( "glGenBuffers" ) ); + glBindBuffer = reinterpret_cast< PFNGLBINDBUFFERARBPROC > + ( wglGetProcAddress( "glBindBuffer" ) ); + glBufferData = reinterpret_cast< PFNGLBUFFERDATAARBPROC > + ( wglGetProcAddress( "glBufferData" ) ); + glBufferSubData = reinterpret_cast< PFNGLBUFFERSUBDATAARBPROC > + ( wglGetProcAddress( "glBufferSubData" ) ); + glDeleteBuffers = reinterpret_cast< PFNGLDELETEBUFFERSARBPROC > + ( wglGetProcAddress( "glDeleteBuffers" ) ); glGetBufferParameteriv = - ( PFNGLGETBUFFERPARAMETERIVARBPROC )wglGetProcAddress( - "glGetBufferParameteriv" - ); - glMapBuffer = - ( PFNGLMAPBUFFERARBPROC )wglGetProcAddress( "glMapBuffer" ); - glUnmapBuffer = - ( PFNGLUNMAPBUFFERARBPROC )wglGetProcAddress( "glUnmapBuffer" ); - - // check once again VBO extension + reinterpret_cast< PFNGLGETBUFFERPARAMETERIVARBPROC > + ( wglGetProcAddress( "glGetBufferParameteriv" ) ); + glMapBuffer = reinterpret_cast< PFNGLMAPBUFFERARBPROC > + ( wglGetProcAddress( "glMapBuffer" ) ); + glUnmapBuffer = reinterpret_cast< PFNGLUNMAPBUFFERARBPROC > + ( wglGetProcAddress( "glUnmapBuffer" ) ); + + // Check once again VBO extension if( glGenBuffers != NULL && glBindBuffer != NULL && @@ -598,18 +586,6 @@ _ConfigureOpenGL( ) this->VBOSupported = true; else this->VBOSupported = false; - - // check EXT_swap_control is supported - /* TODO: really needed? - wglSwapIntervalEXT = - ( PFNWGLSWAPINTERVALEXTPROC )wglGetProcAddress( "wglSwapIntervalEXT" ); - wglGetSwapIntervalEXT = - ( PFNWGLGETSWAPINTERVALEXTPROC )wglGetProcAddress( - "wglGetSwapIntervalEXT" - ); - if( wglSwapIntervalEXT != NULL && wglGetSwapIntervalEXT != NULL ) - wglSwapIntervalEXT( 0 ); - */ #else // _WIN32 // Check if VBO ( Vertex Buffer Object ) is supported std::string str = ( const char* )( glGetString( GL_EXTENSIONS ) ); -- 2.47.1