mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-12-23 16:30:07 +00:00
Fix some portability issues on OSX. (GLEW will be used if exists)
This commit is contained in:
parent
b636660b88
commit
dd91b2de8c
@ -227,8 +227,12 @@ find_package(PythonInterp 2.6)
|
||||
find_package(SWIG 1.3.40)
|
||||
find_package(Doxygen 1.8.4)
|
||||
find_package(Docutils 0.6)
|
||||
if (NOT APPLE AND OPENGL_FOUND)
|
||||
find_package(GLEW REQUIRED)
|
||||
if (OPENGL_FOUND)
|
||||
if (APPLE)
|
||||
find_package(GLEW)
|
||||
else()
|
||||
find_package(GLEW REQUIRED)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
|
@ -90,7 +90,7 @@ if (GLEW_INCLUDE_DIR AND EXISTS "${GLEW_INCLUDE_DIR}/GL/glew.h")
|
||||
|
||||
file(STRINGS "${GLEW_INCLUDE_DIR}/GL/glew.h" GLEW_4_2 REGEX "^#define GL_VERSION_4_2.*$")
|
||||
if (GLEW_4_2)
|
||||
SET(OPENGL_4_2_FOUND TRUE)
|
||||
set(OPENGL_4_2_FOUND TRUE)
|
||||
else ()
|
||||
message(WARNING
|
||||
"glew-1.7.0 or newer needed for supporting OpenGL 4.2 dependent features"
|
||||
@ -108,9 +108,8 @@ if (GLEW_INCLUDE_DIR AND EXISTS "${GLEW_INCLUDE_DIR}/GL/glew.h")
|
||||
|
||||
endif ()
|
||||
|
||||
find_package_handle_standard_args(GLEW DEFAULT_MSG
|
||||
GLEW_INCLUDE_DIR
|
||||
GLEW_LIBRARY
|
||||
find_package_handle_standard_args(GLEW
|
||||
REQUIRED_VARS
|
||||
GLEW_INCLUDE_DIR
|
||||
GLEW_LIBRARY
|
||||
)
|
||||
|
||||
mark_as_advanced( GLEW_FOUND )
|
||||
|
@ -32,8 +32,7 @@ if( OPENGL_FOUND AND (GLEW_FOUND AND GLFW_FOUND) OR (APPLE AND GLFW_FOUND))
|
||||
# the paintTest example requires GL functionality not available on OSX
|
||||
add_subdirectory(paintTest)
|
||||
endif()
|
||||
if(PTEX_FOUND AND (NOT APPLE))
|
||||
# the ptexViewer example requires GL functionality not available on OSX
|
||||
if(PTEX_FOUND)
|
||||
add_subdirectory(ptexViewer)
|
||||
endif()
|
||||
else()
|
||||
|
@ -33,17 +33,20 @@ set(SHADER_FILES
|
||||
set(PLATFORM_LIBRARIES
|
||||
${OSD_LINK_TARGET}
|
||||
${OPENGL_LIBRARY}
|
||||
${GLEW_LIBRARY}
|
||||
${GLFW_LIBRARIES}
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/opensubdiv
|
||||
${PROJECT_SOURCE_DIR}/regression
|
||||
${GLEW_INCLUDE_DIR}
|
||||
${GLFW_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
if ( GLEW_FOUND )
|
||||
include_directories(${GLEW_INCLUDE_DIR})
|
||||
list(APPEND PLATFORM_LIBRARIES ${GLEW_LIBRARY})
|
||||
endif()
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Shader Stringification
|
||||
# We want to use preprocessor include directives to include GLSL and OpenCL
|
||||
|
@ -33,17 +33,20 @@ set(SHADER_FILES
|
||||
set(PLATFORM_LIBRARIES
|
||||
${OSD_LINK_TARGET}
|
||||
${OPENGL_LIBRARY}
|
||||
${GLEW_LIBRARY}
|
||||
${GLFW_LIBRARIES}
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/opensubdiv
|
||||
${PROJECT_SOURCE_DIR}/regression
|
||||
${GLEW_INCLUDE_DIR}
|
||||
${GLFW_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
if ( GLEW_FOUND )
|
||||
include_directories(${GLEW_INCLUDE_DIR})
|
||||
list(APPEND PLATFORM_LIBRARIES ${GLEW_LIBRARY})
|
||||
endif()
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Shader Stringification
|
||||
# We want to use preprocessor include directives to include GLSL and OpenCL
|
||||
|
@ -27,17 +27,20 @@
|
||||
|
||||
set(PLATFORM_LIBRARIES
|
||||
${OSD_LINK_TARGET}
|
||||
${GLEW_LIBRARY}
|
||||
${GLFW_LIBRARIES}
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/opensubdiv
|
||||
${PROJECT_SOURCE_DIR}/regression
|
||||
${GLEW_INCLUDE_DIR}
|
||||
${GLFW_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
if ( GLEW_FOUND )
|
||||
include_directories(${GLEW_INCLUDE_DIR})
|
||||
list(APPEND PLATFORM_LIBRARIES ${GLEW_LIBRARY})
|
||||
endif()
|
||||
|
||||
add_executable(limitEval
|
||||
main.cpp
|
||||
../common/font_image.cpp
|
||||
|
@ -35,7 +35,6 @@ set(SHADER_FILES
|
||||
set(PLATFORM_LIBRARIES
|
||||
${OSD_LINK_TARGET}
|
||||
${OPENGL_LIBRARY}
|
||||
${GLEW_LIBRARY}
|
||||
${GLFW_LIBRARIES}
|
||||
${PTEX_LIBRARY}
|
||||
)
|
||||
@ -47,11 +46,15 @@ endif()
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/opensubdiv
|
||||
${PROJECT_SOURCE_DIR}/regression
|
||||
${GLEW_INCLUDE_DIR}
|
||||
${GLFW_INCLUDE_DIR}
|
||||
${PTEX_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
if ( GLEW_FOUND )
|
||||
include_directories(${GLEW_INCLUDE_DIR})
|
||||
list(APPEND PLATFORM_LIBRARIES ${GLEW_LIBRARY})
|
||||
endif()
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Shader Stringification
|
||||
# We want to use preprocessor include directives to include GLSL and OpenCL
|
||||
|
@ -29,9 +29,9 @@
|
||||
uniform float displacementScale = 1.0;
|
||||
uniform float bumpScale = 1.0;
|
||||
|
||||
vec4 GeneratePatchCoord(vec2 localUV) // for non-adpative
|
||||
vec4 GeneratePatchCoord(vec2 localUV, int primitiveID) // for non-adpative
|
||||
{
|
||||
ivec2 ptexIndex = texelFetch(OsdPatchParamBuffer, gl_PrimitiveID).xy;
|
||||
ivec2 ptexIndex = texelFetch(OsdPatchParamBuffer, primitiveID).xy;
|
||||
int faceID = ptexIndex.x;
|
||||
int lv = 1 << ((ptexIndex.y & 0xf) - ((ptexIndex.y >> 4) & 1));
|
||||
int u = (ptexIndex.y >> 17) & 0x3ff;
|
||||
@ -192,10 +192,10 @@ void main()
|
||||
vec3 normal[4];
|
||||
|
||||
// need to generate patch coord for non-patch quads
|
||||
patchCoord[0] = GeneratePatchCoord(vec2(0, 0));
|
||||
patchCoord[1] = GeneratePatchCoord(vec2(1, 0));
|
||||
patchCoord[2] = GeneratePatchCoord(vec2(1, 1));
|
||||
patchCoord[3] = GeneratePatchCoord(vec2(0, 1));
|
||||
patchCoord[0] = GeneratePatchCoord(vec2(0, 0), gl_PrimitiveID);
|
||||
patchCoord[1] = GeneratePatchCoord(vec2(1, 0), gl_PrimitiveID);
|
||||
patchCoord[2] = GeneratePatchCoord(vec2(1, 1), gl_PrimitiveID);
|
||||
patchCoord[3] = GeneratePatchCoord(vec2(0, 1), gl_PrimitiveID);
|
||||
|
||||
#ifdef USE_PTEX_DISPLACEMENT
|
||||
position[0] = displacement(inpt[0].v.position, inpt[0].v.normal, patchCoord[0]);
|
||||
@ -242,6 +242,10 @@ void main()
|
||||
emit(3, position[3], normal[3], patchCoord[3], edgeVerts);
|
||||
emit(2, position[2], normal[2], patchCoord[2], edgeVerts);
|
||||
#else
|
||||
outpt.edgeDistance[0] = 0;
|
||||
outpt.edgeDistance[1] = 0;
|
||||
outpt.edgeDistance[2] = 0;
|
||||
outpt.edgeDistance[3] = 0;
|
||||
emit(position[0], normal[0], patchCoord[0]);
|
||||
emit(position[1], normal[1], patchCoord[1]);
|
||||
emit(position[3], normal[3], patchCoord[3]);
|
||||
@ -353,7 +357,7 @@ layout(std140) uniform Lighting {
|
||||
uniform bool overrideColorEnable = false;
|
||||
uniform vec4 overrideColor;
|
||||
|
||||
#if USE_PTEX_NORMAL
|
||||
#ifdef USE_PTEX_NORMAL
|
||||
uniform sampler2DArray textureDisplace_Data;
|
||||
uniform samplerBuffer textureDisplace_Packing;
|
||||
uniform isamplerBuffer textureDisplace_Pages;
|
||||
@ -476,7 +480,7 @@ edgeColor(vec4 Cfill, vec4 edgeDistance)
|
||||
void
|
||||
main()
|
||||
{
|
||||
#if USE_PTEX_COLOR
|
||||
#ifdef USE_PTEX_COLOR
|
||||
vec4 texColor = PTexLookup(inpt.v.patchCoord,
|
||||
textureImage_Data,
|
||||
textureImage_Packing,
|
||||
@ -486,7 +490,7 @@ main()
|
||||
vec4 texColor = vec4(1);
|
||||
#endif
|
||||
|
||||
#if USE_PTEX_NORMAL
|
||||
#ifdef USE_PTEX_NORMAL
|
||||
vec3 normal = perturbNormalFromDisplacement(inpt.v.position.xyz,
|
||||
inpt.v.normal,
|
||||
inpt.v.patchCoord);
|
||||
@ -501,7 +505,7 @@ main()
|
||||
return;
|
||||
}
|
||||
|
||||
#if USE_IBL
|
||||
#ifdef USE_IBL
|
||||
#ifdef USE_PTEX_OCCLUSION
|
||||
float occ = PTexLookup(inpt.v.patchCoord,
|
||||
textureOcclusion_Data,
|
||||
|
@ -32,17 +32,20 @@ set(SHADER_FILES
|
||||
set(PLATFORM_LIBRARIES
|
||||
${OSD_LINK_TARGET}
|
||||
${OPENGL_LIBRARY}
|
||||
${GLEW_LIBRARY}
|
||||
${GLFW_LIBRARIES}
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/opensubdiv
|
||||
${PROJECT_SOURCE_DIR}/regression
|
||||
${GLEW_INCLUDE_DIR}
|
||||
${GLFW_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
if ( GLEW_FOUND )
|
||||
include_directories(${GLEW_INCLUDE_DIR})
|
||||
list(APPEND PLATFORM_LIBRARIES ${GLEW_LIBRARY})
|
||||
endif()
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Shader Stringification
|
||||
# We want to use preprocessor include directives to include GLSL and OpenCL
|
||||
|
@ -32,8 +32,12 @@ include_directories(
|
||||
if( OPENGL_FOUND )
|
||||
include_directories(
|
||||
${OPENGL_INCLUDE_DIR}
|
||||
${GLEW_INCLUDE_DIR}
|
||||
)
|
||||
if (GLEW_FOUND)
|
||||
include_directories(
|
||||
${GLEW_INCLUDE_DIR}
|
||||
)
|
||||
endif()
|
||||
elseif( OPENGLES_FOUND )
|
||||
include_directories(
|
||||
${OPENGLES_INCLUDE_DIR}
|
||||
|
@ -52,13 +52,15 @@ OsdGLDrawContext::~OsdGLDrawContext()
|
||||
bool
|
||||
OsdGLDrawContext::SupportsAdaptiveTessellation()
|
||||
{
|
||||
// Compile-time check of GL version
|
||||
#if (defined(GL_ARB_tessellation_shader) or defined(GL_VERSION_4_0)) and defined(GLEW_VERSION_4_0)
|
||||
// Run-time check of GL version with GLEW
|
||||
if (GLEW_VERSION_4_0) {
|
||||
return true;
|
||||
}
|
||||
#ifdef OSD_USES_GLEW
|
||||
// XXX: uncomment here to try tessellation on OSX
|
||||
// if (GLEW_ARB_tessellation_shader)
|
||||
// return true;
|
||||
#endif
|
||||
static const GLubyte *version = glGetString(GL_VERSION);
|
||||
if (version and version[0] == '4')
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,10 @@
|
||||
|
||||
#define M_PI 3.14159265359f
|
||||
|
||||
#if __VERSION__ < 420
|
||||
#define centroid
|
||||
#endif
|
||||
|
||||
struct ControlVertex {
|
||||
vec4 position;
|
||||
centroid vec4 patchCoord; // u, v, level, faceID
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/opensubdiv
|
||||
${GLEW_INCLUDE_DIR}
|
||||
${GLFW_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
@ -36,10 +35,14 @@ set(SOURCE_FILES
|
||||
set(PLATFORM_LIBRARIES
|
||||
${OSD_LINK_TARGET}
|
||||
${OPENGL_LIBRARY}
|
||||
${GLEW_LIBRARY}
|
||||
${GLFW_LIBRARIES}
|
||||
)
|
||||
|
||||
if ( GLEW_FOUND )
|
||||
include_directories(${GLEW_INCLUDE_DIR})
|
||||
list(APPEND PLATFORM_LIBRARIES ${GLEW_LIBRARY})
|
||||
endif()
|
||||
|
||||
if ( OPENCL_FOUND )
|
||||
list(APPEND PLATFORM_LIBRARIES
|
||||
${OPENCL_LIBRARIES}
|
||||
|
Loading…
Reference in New Issue
Block a user