diff --git a/CMakeLists.txt b/CMakeLists.txt index 7378fcea..5c552dc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -296,6 +296,11 @@ if(GLFW_FOUND AND (GLFW_VERSION VERSION_EQUAL 3.0 OR GLFW_VERSION VERSION_GREATE add_definitions( -DGLFW_VERSION_3 ) endif() +# note: perhaps rename this to be more consistent, e.g. OPENSUBDIV_USES_GLEW +if(GLEW_FOUND) + add_definitions( -DOSD_USES_GLEW ) +endif() + # note : (GLSL transform feedback kernels require GL 4.2) if(GLEW_FOUND AND OPENGL_4_2_FOUND) add_definitions( diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 54f40640..e0646c94 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -60,7 +60,7 @@ if( OPENGL_FOUND AND (GLEW_FOUND AND GLFW_FOUND) OR (APPLE AND GLFW_FOUND)) add_subdirectory(glBatchViewer) add_subdirectory(simpleCpu) add_subdirectory(limitEval) - if(OPENGL_4_3_FOUND) + if(OPENGL_4_3_FOUND AND (NOT APPLE)) # the paintTest example requires GL functionality not available on OSX add_subdirectory(paintTest) endif() diff --git a/examples/common/gl_hud.cpp b/examples/common/gl_hud.cpp index 4681655f..764b85f8 100644 --- a/examples/common/gl_hud.cpp +++ b/examples/common/gl_hud.cpp @@ -55,27 +55,13 @@ // a particular purpose and non-infringement. // -#if defined(__APPLE__) - #include "TargetConditionals.h" - #if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR - #include - #else - #include - #endif -#elif defined(ANDROID) - #include -#else - #if defined(_WIN32) - #include - #endif - #include -#endif +#include "gl_hud.h" + +#include "font_image.h" +#include "simple_math.h" #include #include -#include "gl_hud.h" -#include "font_image.h" -#include "simple_math.h" static const char *s_VS = #if defined(GL_VERSION_3_1) diff --git a/examples/common/gl_hud.h b/examples/common/gl_hud.h index 773729bb..9befd330 100644 --- a/examples/common/gl_hud.h +++ b/examples/common/gl_hud.h @@ -57,24 +57,10 @@ #ifndef GL_HUD_H #define GL_HUD_H -#if defined(__APPLE__) - #include "TargetConditionals.h" - #if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR - #include - #else - #include - #endif -#elif defined(ANDROID) - #include -#else - #if defined(_WIN32) - #include - #endif - #include -#endif - #include "hud.h" +#include + class GLhud : public Hud { public: diff --git a/examples/glBatchViewer/delegate.cpp b/examples/glBatchViewer/delegate.cpp index 346453c6..491259aa 100644 --- a/examples/glBatchViewer/delegate.cpp +++ b/examples/glBatchViewer/delegate.cpp @@ -54,24 +54,11 @@ // exclude the implied warranties of merchantability, fitness for // a particular purpose and non-infringement. // -#if defined(__APPLE__) - #include "TargetConditionals.h" - #if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR - #include - #else - #include - #endif -#elif defined(ANDROID) - #include -#else - #if defined(_WIN32) - #include - #endif - #include -#endif #include "delegate.h" +#include + MyDrawContext::MyDrawContext() { glGenVertexArrays(1, &_vao); } diff --git a/examples/glBatchViewer/effect.cpp b/examples/glBatchViewer/effect.cpp index b73ce476..cd3aaad5 100644 --- a/examples/glBatchViewer/effect.cpp +++ b/examples/glBatchViewer/effect.cpp @@ -54,26 +54,14 @@ // exclude the implied warranties of merchantability, fitness for // a particular purpose and non-infringement. // -#if defined(__APPLE__) - #include "TargetConditionals.h" - #if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR - #include - #else - #include - #endif -#elif defined(ANDROID) - #include -#else - #if defined(_WIN32) - #include - #endif - #include -#endif #include "effect.h" + #include "../common/simple_math.h" #include "../common/patchColors.h" +#include + #include #include diff --git a/examples/glBatchViewer/effect.h b/examples/glBatchViewer/effect.h index 8b209e64..56750a09 100644 --- a/examples/glBatchViewer/effect.h +++ b/examples/glBatchViewer/effect.h @@ -57,24 +57,10 @@ #ifndef EFFECT_H #define EFFECT_H -#if defined(__APPLE__) - #include "TargetConditionals.h" - #if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR - #include - #else - #include - #endif -#elif defined(ANDROID) - #include -#else - #if defined(_WIN32) - #include - #endif - #include -#endif - #include +#include + union EffectDesc { public: struct { diff --git a/examples/glBatchViewer/effectRegistry.cpp b/examples/glBatchViewer/effectRegistry.cpp index 72c1dd6e..a262ddb2 100644 --- a/examples/glBatchViewer/effectRegistry.cpp +++ b/examples/glBatchViewer/effectRegistry.cpp @@ -54,24 +54,11 @@ // exclude the implied warranties of merchantability, fitness for // a particular purpose and non-infringement. // -#if defined(__APPLE__) - #include "TargetConditionals.h" - #if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR - #include - #else - #include - #endif -#elif defined(ANDROID) - #include -#else - #if defined(_WIN32) - #include - #endif - #include -#endif #include "effectRegistry.h" +#include + static const char *shaderSource = #if defined(GL_ARB_tessellation_shader) || defined(GL_VERSION_4_0) #include "shader.inc" diff --git a/examples/glBatchViewer/viewer.cpp b/examples/glBatchViewer/viewer.cpp index 825a595d..02bbaee6 100644 --- a/examples/glBatchViewer/viewer.cpp +++ b/examples/glBatchViewer/viewer.cpp @@ -56,7 +56,11 @@ // #if defined(__APPLE__) - #include + #if defined(OSD_USES_GLEW) + #include + #else + #include + #endif #define GLFW_INCLUDE_GL3 #define GLFW_NO_GLU #else @@ -993,7 +997,7 @@ int main(int argc, char ** argv) glfwSetWindowSizeCallback(reshape); #endif -#if not defined(__APPLE__) +#if defined(OSD_USES_GLEW) #ifdef CORE_PROFILE // this is the only way to initialize glew correctly under core profile context. glewExperimental = true; diff --git a/examples/glViewer/viewer.cpp b/examples/glViewer/viewer.cpp index 856e2c51..acddd2d3 100644 --- a/examples/glViewer/viewer.cpp +++ b/examples/glViewer/viewer.cpp @@ -56,7 +56,11 @@ // #if defined(__APPLE__) - #include + #if defined(OSD_USES_GLEW) + #include + #else + #include + #endif #define GLFW_INCLUDE_GL3 #define GLFW_NO_GLU #else @@ -1825,7 +1829,7 @@ int main(int argc, char ** argv) #endif -#if not defined(__APPLE__) +#if defined(OSD_USES_GLEW) #ifdef CORE_PROFILE // this is the only way to initialize glew correctly under core profile context. glewExperimental = true; diff --git a/examples/limitEval/main.cpp b/examples/limitEval/main.cpp index 49b5c6bb..94302990 100644 --- a/examples/limitEval/main.cpp +++ b/examples/limitEval/main.cpp @@ -56,7 +56,11 @@ // #if defined(__APPLE__) - #include + #if defined(OSD_USES_GLEW) + #include + #else + #include + #endif #define GLFW_INCLUDE_GL3 #define GLFW_NO_GLU #else @@ -1223,7 +1227,7 @@ int main(int argc, char **argv) { glfwSetWindowCloseCallback(windowClose); #endif -#if not defined(__APPLE__) +#if defined(OSD_USES_GLEW) #ifdef CORE_PROFILE // this is the only way to initialize glew correctly under core profile context. glewExperimental = true; diff --git a/examples/paintTest/main.cpp b/examples/paintTest/main.cpp index d0936be1..3e2559e0 100644 --- a/examples/paintTest/main.cpp +++ b/examples/paintTest/main.cpp @@ -56,7 +56,11 @@ // #if defined(__APPLE__) - #include + #if defined(OSD_USES_GLEW) + #include + #else + #include + #endif #define GLFW_INCLUDE_GL3 #define GLFW_NO_GLU #else @@ -1369,7 +1373,7 @@ int main(int argc, char ** argv) #endif -#if not defined(__APPLE__) +#if defined(OSD_USES_GLEW) #ifdef CORE_PROFILE // this is the only way to initialize glew correctly under core profile context. glewExperimental = true; diff --git a/examples/ptexViewer/viewer.cpp b/examples/ptexViewer/viewer.cpp index a76bb6b5..a4162d64 100644 --- a/examples/ptexViewer/viewer.cpp +++ b/examples/ptexViewer/viewer.cpp @@ -56,7 +56,11 @@ // #if defined(__APPLE__) - #include + #if defined(OSD_USES_GLEW) + #include + #else + #include + #endif #define GLFW_INCLUDE_GL3 #define GLFW_NO_GLU #else @@ -2077,7 +2081,7 @@ int main(int argc, char ** argv) { glfwSetMouseButtonCallback(mouse); #endif -#if not defined(__APPLE__) +#if defined(OSD_USES_GLEW) #ifdef CORE_PROFILE // this is the only way to initialize glew correctly under core profile context. glewExperimental = true; diff --git a/examples/simpleCpu/glhelpers.h b/examples/simpleCpu/glhelpers.h index 6bcde841..8fea18ba 100644 --- a/examples/simpleCpu/glhelpers.h +++ b/examples/simpleCpu/glhelpers.h @@ -16,7 +16,11 @@ // The following is to ensure the example runs on Linux, Windows and OS X // #if defined(__APPLE__) - #include + #if defined(OSD_USES_GLEW) + #include + #else + #include + #endif #define GLFW_INCLUDE_GL3 #define GLFW_NO_GLU #include diff --git a/examples/simpleCpu/main.cpp b/examples/simpleCpu/main.cpp index d19477ad..ff9f77d4 100644 --- a/examples/simpleCpu/main.cpp +++ b/examples/simpleCpu/main.cpp @@ -1,18 +1,23 @@ #if defined(__APPLE__) - #include + #if defined(OSD_USES_GLEW) + #include + #else + #include + #endif #define GLFW_INCLUDE_GL3 #define GLFW_NO_GLU - #include #else #include - #include #include #if defined(WIN32) #include #endif #endif +#include +#include + #if defined(GLFW_VERSION_3) #include GLFWwindow* g_window=0; @@ -128,7 +133,7 @@ int main(int argc, char ** argv) -#if not defined(__APPLE__) +#if defined(OSD_USES_GLEW) #ifdef CORE_PROFILE // this is the only way to initialize glew correctly under core profile context. glewExperimental = true; diff --git a/opensubdiv/osd/CMakeLists.txt b/opensubdiv/osd/CMakeLists.txt index f814e0cc..d4cb9e32 100644 --- a/opensubdiv/osd/CMakeLists.txt +++ b/opensubdiv/osd/CMakeLists.txt @@ -63,7 +63,6 @@ include_directories( ) if( OPENGL_FOUND ) - add_definitions( -DOSD_USES_GLEW ) include_directories( ${OPENGL_INCLUDE_DIR} ${GLEW_INCLUDE_DIR} diff --git a/opensubdiv/osd/opengl.h b/opensubdiv/osd/opengl.h index 3609a97b..e3a8843a 100644 --- a/opensubdiv/osd/opengl.h +++ b/opensubdiv/osd/opengl.h @@ -62,7 +62,11 @@ #if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR #include #else - #include + #if defined(OSD_USES_GLEW) + #include + #else + #include + #endif #endif #elif defined(ANDROID) #include diff --git a/regression/osd_regression/main.cpp b/regression/osd_regression/main.cpp index 5b3be5b3..ffe1fa70 100644 --- a/regression/osd_regression/main.cpp +++ b/regression/osd_regression/main.cpp @@ -56,7 +56,11 @@ // #if defined(__APPLE__) - #include + #if defined(OSD_USES_GLEW) + #include + #else + #include + #endif #define GLFW_INCLUDE_GL3 #define GLFW_NO_GLU #else @@ -762,7 +766,7 @@ main(int argc, char ** argv) { } #endif -#if not defined(__APPLE__) +#if defined(OSD_USES_GLEW) if (GLenum r = glewInit() != GLEW_OK) { printf("Failed to initialize glew. error = %d\n", r); exit(1);