--- a/src/hugin1/hugin/ProjectionGridTool.cpp +++ b/src/hugin1/hugin/ProjectionGridTool.cpp @@ -24,12 +24,10 @@ #ifdef _WIN32 #include "wx/msw/wrapwin.h" #endif -#include +#include #ifdef __WXMAC__ -#include #include #else -#include #include #endif #ifdef __APPLE__ @@ -323,7 +321,7 @@ if (!checked_anisotropic) { // check if it is supported - if (GLEW_EXT_texture_filter_anisotropic) + if (epoxy_has_gl_extension("GL_EXT_texture_filter_anisotropic")) { has_anisotropic = true; glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &anisotropy); --- a/src/hugin1/hugin/TextureManager.cpp +++ b/src/hugin1/hugin/TextureManager.cpp @@ -48,15 +48,13 @@ // The OpenGL Extension wrangler libray will find extensions and the latest // supported OpenGL version on all platforms. -#include +#include #include #include #ifdef __WXMAC__ -#include #include #else -#include #include #endif @@ -628,7 +626,7 @@ if (!checked_anisotropic) { // check if it is supported - if (GLEW_EXT_texture_filter_anisotropic) + if (epoxy_has_gl_extension("GL_EXT_texture_filter_anisotropic")) { has_anisotropic = true; glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &anisotropy); --- a/src/hugin_base/hugin_utils/utils.cpp +++ b/src/hugin_base/hugin_utils/utils.cpp @@ -57,9 +57,9 @@ #include /* dirname */ #endif -#include +#include #ifdef _WIN32 -#include +#include #elif defined __APPLE__ #include #endif @@ -584,6 +584,7 @@ { return false; }; + epoxy_handle_external_wglMakeCurrent(); return true; } @@ -592,6 +593,7 @@ if (context.renderingContext != NULL) { wglMakeCurrent(NULL, NULL); + epoxy_handle_external_wglMakeCurrent(); wglDeleteContext(context.renderingContext); } if (context.window != NULL && context.dc != NULL) @@ -628,7 +630,7 @@ #else #if defined HAVE_EGL && HAVE_EGL -#include +#include struct ContextSettings { @@ -714,7 +716,7 @@ #else #include #include -#include +#include struct ContextSettings { @@ -811,26 +813,17 @@ { return false; }; - int err = glewInit(); - if (err != GLEW_OK) - { - std::cerr << argv[0] << ": an error occurred while setting up the GPU:" << std::endl; - std::cerr << glewGetErrorString(err) << std::endl; - std::cerr << argv[0] << ": Switching to CPU calculation." << std::endl; - DestroyContext(); - return false; - } std::cout << hugin_utils::stripPath(argv[0]) << ": using graphics card: " << glGetString(GL_VENDOR) << " " << glGetString(GL_RENDERER) << std::endl; - const GLboolean has_arb_fragment_shader = glewGetExtension("GL_ARB_fragment_shader"); - const GLboolean has_arb_vertex_shader = glewGetExtension("GL_ARB_vertex_shader"); - const GLboolean has_arb_shader_objects = glewGetExtension("GL_ARB_shader_objects"); - const GLboolean has_arb_shading_language = glewGetExtension("GL_ARB_shading_language_100"); - const GLboolean has_ext_framebuffer = glewGetExtension("GL_EXT_framebuffer_object"); - const GLboolean has_arb_texture_rectangle = glewGetExtension("GL_ARB_texture_rectangle"); - const GLboolean has_arb_texture_border_clamp = glewGetExtension("GL_ARB_texture_border_clamp"); - const GLboolean has_arb_texture_float = glewGetExtension("GL_ARB_texture_float"); + const GLboolean has_arb_fragment_shader = epoxy_has_gl_extension("GL_ARB_fragment_shader"); + const GLboolean has_arb_vertex_shader = epoxy_has_gl_extension("GL_ARB_vertex_shader"); + const GLboolean has_arb_shader_objects = epoxy_has_gl_extension("GL_ARB_shader_objects"); + const GLboolean has_arb_shading_language = epoxy_has_gl_extension("GL_ARB_shading_language_100"); + const GLboolean has_ext_framebuffer = epoxy_has_gl_extension("GL_EXT_framebuffer_object"); + const GLboolean has_arb_texture_rectangle = epoxy_has_gl_extension("GL_ARB_texture_rectangle"); + const GLboolean has_arb_texture_border_clamp = epoxy_has_gl_extension("GL_ARB_texture_border_clamp"); + const GLboolean has_arb_texture_float = epoxy_has_gl_extension("GL_ARB_texture_float"); if (!(has_arb_fragment_shader && has_arb_vertex_shader && has_arb_shader_objects && has_arb_shading_language && has_ext_framebuffer && has_arb_texture_rectangle && has_arb_texture_border_clamp && has_arb_texture_float)) { const char * msg[] = {"false", "true"}; --- a/src/hugin_base/vigra_ext/ImageTransformsGPU.cpp +++ b/src/hugin_base/vigra_ext/ImageTransformsGPU.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include #ifdef _WIN32 @@ -54,6 +54,16 @@ }; #endif #include + +#ifdef __WXMAC__ +#include +#else +// after windows.h +#include +#endif +#ifdef __APPLE__ + #include +#endif #include @@ -798,7 +808,7 @@ const int viewportHeight = std::max(destChunks[0].height(), sourceChunks[0].height()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - gluOrtho2D(0.0, viewportWidth, 0.0, viewportHeight); + glOrtho(0.0, viewportWidth, 0.0, viewportHeight, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glViewport(0, 0, viewportWidth, viewportHeight); --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -255,9 +255,9 @@ INCLUDE_DIRECTORIES(${GLUT_INCLUDE_DIR}) SET(OPENGL_GLEW_LIBRARIES ${OPENGL_GLEW_LIBRARIES} ${GLUT_LIBRARIES}) ENDIF() -FIND_PACKAGE(GLEW REQUIRED) -INCLUDE_DIRECTORIES(${GLEW_INCLUDE_DIR}) -SET(OPENGL_GLEW_LIBRARIES ${OPENGL_GLEW_LIBRARIES} ${GLEW_LIBRARIES}) +PKG_SEARCH_MODULE(EPOXY epoxy REQUIRED) +INCLUDE_DIRECTORIES(${EPOXY_INCLUDE_DIR}) +SET(OPENGL_GLEW_LIBRARIES ${OPENGL_GLEW_LIBRARIES} ${EPOXY_LIBRARIES}) IF(NOT HUGIN_SHARED OR NOT WIN32) ADD_DEFINITIONS(-DGLEW_STATIC) ENDIF() --- a/src/hugin1/hugin/GLPreviewFrame.cpp +++ b/src/hugin1/hugin/GLPreviewFrame.cpp @@ -28,8 +28,6 @@ #include #include "hugin_config.h" - -#include #include "panoinc_WX.h" #include "panoinc.h" --- a/src/hugin1/hugin/GLViewer.cpp +++ b/src/hugin1/hugin/GLViewer.cpp @@ -25,7 +25,7 @@ #include "panoinc.h" #include "hugin_config.h" -#include +#include #include #include #include @@ -39,7 +39,6 @@ #include "GLPreviewFrame.h" #include "hugin/huginApp.h" -bool GLViewer::initialised_glew=false; ViewState * GLViewer::m_view_state = NULL; size_t GLViewer::m_view_state_observer = 0; @@ -121,24 +120,8 @@ // It appears we are setting up for the first time. started_creation = true; - if (!initialised_glew) - { - // initialise the glew library, if not done it before. - GLenum error_state = glewInit(); - initialised_glew = true; - if (error_state != GLEW_OK) - { - // glewInit failed - started_creation=false; - DEBUG_ERROR("Error initialising GLEW: " - << glewGetErrorString(error_state) << "."); - frame->Close(); - wxMessageBox(_("Error initializing GLEW\nFast preview window can not be opened."),_("Error"), wxOK | wxICON_ERROR); - return; - } - } // check the openGL capabilities. - if (!(GLEW_VERSION_1_1 && GLEW_ARB_multitexture)) + if (epoxy_gl_version() < 11 && !epoxy_has_gl_extension("GL_ARB_multitexture")) { started_creation=false; wxConfigBase::Get()->Write(wxT("DisableOpenGL"), 1l); --- a/src/hugin1/hugin/GLViewer.h +++ b/src/hugin1/hugin/GLViewer.h @@ -99,7 +99,6 @@ virtual void setUp() = 0; bool started_creation, redrawing, m_toolsInitialized; - static bool initialised_glew; vigra::Diff2D offset; double m_scale = 1.0; GLPreviewFrame *frame; --- a/src/hugin1/hugin/MeshManager.cpp +++ b/src/hugin1/hugin/MeshManager.cpp @@ -23,15 +23,10 @@ #include #include -#include - -#ifdef __WXMAC__ -#include -#else +#include + #ifdef __WXMSW__ #include -#endif -#include #endif #include "panoinc.h" --- a/src/hugin1/hugin/OverviewOutlinesTool.cpp +++ b/src/hugin1/hugin/OverviewOutlinesTool.cpp @@ -22,12 +22,10 @@ #ifdef _WIN32 #include "wx/msw/wrapwin.h" #endif -#include +#include #ifdef __WXMAC__ -#include #include #else -#include #include #endif #ifdef __APPLE__ --- a/src/hugin1/hugin/PanosphereSphereTool.cpp +++ b/src/hugin1/hugin/PanosphereSphereTool.cpp @@ -24,12 +24,10 @@ #ifdef _WIN32 #include "wx/msw/wrapwin.h" #endif -#include +#include #ifdef __WXMAC__ -#include #include #else -#include #include #endif #ifdef __APPLE__ --- a/src/hugin1/hugin/PreviewDifferenceTool.cpp +++ b/src/hugin1/hugin/PreviewDifferenceTool.cpp @@ -24,13 +24,8 @@ #endif #include "PreviewDifferenceTool.h" #include "hugin_config.h" -#include +#include #include -#ifdef __WXMAC__ -#include -#else -#include -#endif // This is the number of times to double the result of the difference. It should // be between 0 and 7. Note that with values > 0 no extra colours are used @@ -46,9 +41,9 @@ /** call this function only after OpenGL context was created */ bool PreviewDifferenceTool::CheckOpenGLCanDifference() { - if(GLEW_ARB_imaging) + if(epoxy_has_gl_extension("GL_ARB_imaging")) return true; - if((glBlendEquation!=NULL) && (GLEW_EXT_blend_subtract)) + if((glBlendEquation!=NULL) && (epoxy_has_gl_extension("GL_EXT_blend_subtract"))) return true; return false; } --- a/src/hugin1/hugin/PreviewIdentifyTool.cpp +++ b/src/hugin1/hugin/PreviewIdentifyTool.cpp @@ -31,14 +31,10 @@ #include -//multitexture feature requires glew on some systems -#include - +#include #ifdef __WXMAC__ -#include #include #else -#include #include #endif