Skip to content

Commit

Permalink
Removed support for using GLEW
Browse files Browse the repository at this point in the history
Use of GLEW has been deprecated since v3.4.3 (April 2020) when OpenSubdiv
was updated to use an internal namespace protected GL loader.

Client code is of course free to continue using GLEW or any other GL loader,

WIP PixarAnimationStudios#913 internal issue #OSD-139
  • Loading branch information
davidgyu committed Jun 6, 2024
1 parent 27bca52 commit 4f57913
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 184 deletions.
35 changes: 2 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ add_definitions(${OSD_COMPILER_FLAGS})
set(CMAKE_SUPPRESS_REGENERATION TRUE)

option(PTEX_LOCATION "Path to Ptex" "")
option(GLEW_LOCATION "Path to GLEW" "")
option(GLFW_LOCATION "Path to GLFW" "")

option(NO_LIB "Disable the opensubdiv libs build (caveat emptor)" OFF)
Expand All @@ -332,7 +331,6 @@ option(NO_METAL "Disable Metal support" OFF)
option(NO_DX "Disable DirectX support")
option(NO_TESTS "Disable all tests")
option(NO_GLTESTS "Disable GL tests")
option(NO_GLEW "Disable use of GLEW" ON)
option(NO_GLFW "Disable components depending on GLFW" OFF)
option(NO_GLFW_X11 "Disable GLFW components depending on X11" OFF)
option(NO_MACOS_FRAMEWORK "Disable generation of framework on macOS" OFF)
Expand Down Expand Up @@ -386,18 +384,7 @@ if (OPENGL_FOUND AND NOT IOS)
add_definitions(
-DOPENSUBDIV_HAS_OPENGL
)
if (NOT NO_GLEW)
if (APPLE)
find_package(GLEW)
else()
find_package(GLEW REQUIRED)
endif()
endif()
if(GLEW_FOUND)
add_definitions( -DOSD_USES_GLEW )
else()
add_definitions( -DOSD_USES_INTERNAL_GLAPILOADER )
endif()
add_definitions( -DOSD_USES_INTERNAL_GLAPILOADER )
endif()

if (WIN32 AND NOT NO_DX)
Expand Down Expand Up @@ -484,18 +471,7 @@ macro(osd_detect_gl_version header)

endmacro()

if(GLEW_FOUND AND GLEW_INCLUDE_DIR)

osd_detect_gl_version(${GLEW_INCLUDE_DIR}/GL/glew.h)
set(OPENGL_LOADER_INCLUDE_DIRS
${GLEW_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/glLoader)
set(OPENGL_LOADER_LIBRARIES
${GLEW_LIBRARY}
OpenGL::GL
${CMAKE_DL_LIBS})

elseif(OPENGL_FOUND)
if(OPENGL_FOUND)

osd_detect_gl_version(${PROJECT_SOURCE_DIR}/glLoader/glApi.h)
set(OPENGL_LOADER_INCLUDE_DIRS
Expand Down Expand Up @@ -657,13 +633,6 @@ else()
endif()

if (WIN32)
if ("${GLEW_LIBRARY}" MATCHES "glew32s(d|)")
# Link against the static version of GLEW
add_definitions(
-DGLEW_STATIC
)
endif()

if (DXSDK_FOUND AND NOT NO_DX)
add_definitions(
-DOPENSUBDIV_HAS_DX11SDK
Expand Down
107 changes: 0 additions & 107 deletions cmake/FindGLEW.cmake

This file was deleted.

27 changes: 0 additions & 27 deletions glLoader/glLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,41 +36,14 @@ namespace GLLoader {
bool
applicationInitializeGL()
{
#if defined(OSD_USES_INTERNAL_GLAPILOADER)
// -- GLAPILOADER
return OpenSubdiv::internal::GLApi::glApiLoad();

#elif defined(OSD_USES_GLEW)
// -- GLEW
#define CORE_PROFILE
#ifdef CORE_PROFILE
// this is the only way to initialize GLEW (before GLEW 1.13)
// correctly under core profile context.
glewExperimental = true;
#endif
GLenum status = glewInit();
if (status != GLEW_OK) {
printf("Failed to initialize glew. Error = %s\n",
glewGetErrorString(status));
return false;
}
#ifdef CORE_PROFILE
// clear GL errors which were generated during glewInit()
glGetError();
#endif
#endif
return true;
}

bool
libraryInitializeGL()
{
#if defined(OSD_USES_INTERNAL_GLAPILOADER)
return OpenSubdiv::internal::GLApi::glApiLoad();
#else
// otherwise do nothing
return true;
#endif
}


Expand Down
7 changes: 0 additions & 7 deletions glLoader/glLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,6 @@
#include "glApi.h"

#define OSD_OPENGL_HAS(token) (GLAPILOADER_GL_##token)

#elif defined(OSD_USES_GLEW)
// -- GLEW
#include <GL/glew.h>

#define OSD_OPENGL_HAS(token) (GLEW_##token)

#endif

namespace OpenSubdiv {
Expand Down
12 changes: 2 additions & 10 deletions opensubdiv/osd/opengl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#if defined(OSD_USES_GLEW)
#include <GL/glew.h>
#else
#include <OpenGL/gl3.h>
#endif
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
Expand All @@ -43,11 +39,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#if defined(OSD_USES_GLEW)
#include <GL/glew.h>
#else
#include <GL/gl.h>
#endif
#include <GL/gl.h>
#endif

#endif // OPENSUBDIV3_OSD_OPENGL_H

0 comments on commit 4f57913

Please sign in to comment.