Updated to support GLES 2.0 on iOS and Android

This commit is contained in:
David G Yu 2012-12-20 10:25:41 -08:00
parent ce2f29d368
commit 1547b59570
31 changed files with 517 additions and 102 deletions

View File

@ -99,12 +99,13 @@ set(CMAKE_SUPPRESS_REGENERATION TRUE)
# Check for dependencies
find_package(OpenMP)
find_package(OpenGL)
find_package(OpenGLES)
find_package(OpenCL)
find_package(CUDA)
find_package(GLUT)
find_package(PTex)
if (NOT APPLE)
if (NOT APPLE AND NOT ANDROID)
find_package(GLEW REQUIRED)
endif()
@ -157,6 +158,12 @@ else()
"shared module in your cmake installation.")
endif()
if(OPENGLES_FOUND)
add_definitions(
-DOPENSUBDIV_HAS_OPENGLES
)
endif()
if(OPENCL_FOUND)
add_definitions(
-DOPENSUBDIV_HAS_OPENCL
@ -340,7 +347,9 @@ endmacro()
add_subdirectory(opensubdiv)
add_subdirectory(regression)
if(NOT ANDROID AND NOT IOS) # XXXdyu
add_subdirectory(regression)
endif()
add_subdirectory(examples)

95
cmake/FindOpenGLES.cmake Normal file
View File

@ -0,0 +1,95 @@
#
# Copyright (C) Pixar. All rights reserved.
#
# This license governs use of the accompanying software. If you
# use the software, you accept this license. If you do not accept
# the license, do not use the software.
#
# 1. Definitions
# The terms "reproduce," "reproduction," "derivative works," and
# "distribution" have the same meaning here as under U.S.
# copyright law. A "contribution" is the original software, or
# any additions or changes to the software.
# A "contributor" is any person or entity that distributes its
# contribution under this license.
# "Licensed patents" are a contributor's patent claims that read
# directly on its contribution.
#
# 2. Grant of Rights
# (A) Copyright Grant- Subject to the terms of this license,
# including the license conditions and limitations in section 3,
# each contributor grants you a non-exclusive, worldwide,
# royalty-free copyright license to reproduce its contribution,
# prepare derivative works of its contribution, and distribute
# its contribution or any derivative works that you create.
# (B) Patent Grant- Subject to the terms of this license,
# including the license conditions and limitations in section 3,
# each contributor grants you a non-exclusive, worldwide,
# royalty-free license under its licensed patents to make, have
# made, use, sell, offer for sale, import, and/or otherwise
# dispose of its contribution in the software or derivative works
# of the contribution in the software.
#
# 3. Conditions and Limitations
# (A) No Trademark License- This license does not grant you
# rights to use any contributor's name, logo, or trademarks.
# (B) If you bring a patent claim against any contributor over
# patents that you claim are infringed by the software, your
# patent license from such contributor to the software ends
# automatically.
# (C) If you distribute any portion of the software, you must
# retain all copyright, patent, trademark, and attribution
# notices that are present in the software.
# (D) If you distribute any portion of the software in source
# code form, you may do so only under this license by including a
# complete copy of this license with your distribution. If you
# distribute any portion of the software in compiled or object
# code form, you may only do so under a license that complies
# with this license.
# (E) The software is licensed "as-is." You bear the risk of
# using it. The contributors give no express warranties,
# guarantees or conditions. You may have additional consumer
# rights under your local laws which this license cannot change.
# To the extent permitted under your local laws, the contributors
# exclude the implied warranties of merchantability, fitness for
# a particular purpose and non-infringement.
#
# - Try to find OpenGLES
# Once done this will define
#
# OPENGLES_FOUND - system has OpenGLES
# OPENGLES_INCLUDE_DIR - the GL include directory
# OPENGLES_LIBRARIES - Link these to use OpenGLES
if(ANDROID)
FIND_PATH(
OPENGLES_INCLUDE_DIR GLES2/gl2.h
${ANDROID_STANDALONE_TOOLCHAIN}/usr/include
)
FIND_LIBRARY(
OPENGLES_LIBRARIES NAMES GLESv2
PATHS ${ANDROID_STANDALONE_TOOLCHAIN}/usr/lib
)
elseif(IOS)
FIND_LIBRARY(
OPENGLES_FRAMEWORKS OpenGLES
)
if(OPENGLES_FRAMEWORKS)
set( OPENGLES_LIBRARIES "-framework OpenGLES" )
endif()
endif()
SET( OPENGLES_FOUND "NO" )
IF(OPENGLES_LIBRARIES)
SET( OPENGLES_FOUND "YES" )
ENDIF(OPENGLES_LIBRARIES)
MARK_AS_ADVANCED(
OPENGLES_INCLUDE_DIR
OPENGLES_LIBRARIES
)

View File

@ -55,7 +55,9 @@
# a particular purpose and non-infringement.
#
add_subdirectory(tools/stringify)
if(NOT ANDROID AND NOT IOS) # XXXdyu
add_subdirectory(tools/stringify)
endif()
add_subdirectory(hbr)

79
opensubdiv/osd/Android.mk Normal file
View File

@ -0,0 +1,79 @@
#
# Copyright (C) Pixar. All rights reserved.
#
# This license governs use of the accompanying software. If you
# use the software, you accept this license. If you do not accept
# the license, do not use the software.
#
# 1. Definitions
# The terms "reproduce," "reproduction," "derivative works," and
# "distribution" have the same meaning here as under U.S.
# copyright law. A "contribution" is the original software, or
# any additions or changes to the software.
# A "contributor" is any person or entity that distributes its
# contribution under this license.
# "Licensed patents" are a contributor's patent claims that read
# directly on its contribution.
#
# 2. Grant of Rights
# (A) Copyright Grant- Subject to the terms of this license,
# including the license conditions and limitations in section 3,
# each contributor grants you a non-exclusive, worldwide,
# royalty-free copyright license to reproduce its contribution,
# prepare derivative works of its contribution, and distribute
# its contribution or any derivative works that you create.
# (B) Patent Grant- Subject to the terms of this license,
# including the license conditions and limitations in section 3,
# each contributor grants you a non-exclusive, worldwide,
# royalty-free license under its licensed patents to make, have
# made, use, sell, offer for sale, import, and/or otherwise
# dispose of its contribution in the software or derivative works
# of the contribution in the software.
#
# 3. Conditions and Limitations
# (A) No Trademark License- This license does not grant you
# rights to use any contributor's name, logo, or trademarks.
# (B) If you bring a patent claim against any contributor over
# patents that you claim are infringed by the software, your
# patent license from such contributor to the software ends
# automatically.
# (C) If you distribute any portion of the software, you must
# retain all copyright, patent, trademark, and attribution
# notices that are present in the software.
# (D) If you distribute any portion of the software in source
# code form, you may do so only under this license by including a
# complete copy of this license with your distribution. If you
# distribute any portion of the software in compiled or object
# code form, you may only do so under a license that complies
# with this license.
# (E) The software is licensed "as-is." You bear the risk of
# using it. The contributors give no express warranties,
# guarantees or conditions. You may have additional consumer
# rights under your local laws which this license cannot change.
# To the extent permitted under your local laws, the contributors
# exclude the implied warranties of merchantability, fitness for
# a particular purpose and non-infringement.
#
#
# This file is used by the Android NDK to allow OpenSubdiv libraries
# to be imported by client modules.
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE = OpenSubdivOsdCPU
LOCAL_SRC_FILES = libs/armeabi-v7a/libosdCPU.so
LOCAL_EXPORT_C_INCLUDES = $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE = OpenSubdivOsdGPU
LOCAL_SRC_FILES = libs/armeabi-v7a/libosdGPU.so
LOCAL_EXPORT_C_INCLUDES = $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

View File

@ -58,12 +58,21 @@
#-------------------------------------------------------------------------------
include_directories(
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIR}
${DXSDK_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/opensubdiv
)
if( OPENGL_FOUND )
include_directories(
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIR}
)
elseif( OPENGLES_FOUND )
include_directories(
${OPENGLES_INCLUDE_DIR}
)
endif()
#-------------------------------------------------------------------------------
# source & headers
set(CPU_SOURCE_FILES
@ -94,6 +103,7 @@ set(PRIVATE_HEADER_FILES
set(PUBLIC_HEADER_FILES
computeContext.h
computeController.h
cpuComputeContext.h
cpuComputeController.h
cpuDispatcher.h
cpuVertexBuffer.h
@ -104,6 +114,7 @@ set(PUBLIC_HEADER_FILES
drawContext.h
drawRegistry.h
vertex.h
vertexDescriptor.h
)
#-------------------------------------------------------------------------------
@ -168,7 +179,7 @@ endif()
#-------------------------------------------------------------------------------
# GL code & dependencies
if( OPENGL_FOUND )
if( OPENGL_FOUND OR OPENGLES_FOUND )
list(APPEND GPU_SOURCE_FILES
cpuGLVertexBuffer.cpp
glDrawContext.cpp
@ -182,6 +193,7 @@ if( OPENGL_FOUND )
glVertexBuffer.h
glMesh.h
)
if ( OPENGL_FOUND )
list(APPEND KERNEL_FILES
glslPatchCommon.glsl
glslPatchRegular.glsl
@ -191,8 +203,10 @@ if( OPENGL_FOUND )
glslPatchBoundaryGregory.glsl
glslPatchTransition.glsl
)
endif()
list(APPEND PLATFORM_LIBRARIES
${OPENGL_LIBRARY}
${OPENGLES_LIBRARIES}
)
endif()
@ -415,7 +429,7 @@ target_link_libraries(osd_static_gpu
if (NOT WIN32)
if (NOT WIN32 AND NOT IOS)
_add_possibly_cuda_library(osd_dynamic_cpu SHARED
${CPU_SOURCE_FILES}
${PRIVATE_HEADER_FILES}
@ -449,4 +463,10 @@ install( FILES ${PUBLIC_HEADER_FILES}
DESTINATION include/osd
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ )
if (ANDROID)
install( FILES Android.mk
DESTINATION ${LIBRARY_OUTPUT_PATH_ROOT}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ )
endif()
#-------------------------------------------------------------------------------

View File

@ -57,10 +57,10 @@
// a particular purpose and non-infringement.
//
#if not defined(__APPLE__)
#include <GL/glew.h>
#else
#if defined(__APPLE__)
#include <OpenGL/gl3.h>
#else
#include <GL/glew.h>
#endif
#include "../osd/clGLVertexBuffer.h"

View File

@ -60,7 +60,7 @@
#elif defined(__APPLE__)
#include <OpenGL/OpenGL.h>
#else
#include <GL/glx.h>
#include <GL/gl.h>
#endif
#include "../osd/clKernelBundle.h"

View File

@ -55,6 +55,22 @@
// a particular purpose and non-infringement.
//
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/glew.h>
#endif
#include "../osd/cpuGLVertexBuffer.h"
#include <string.h>
@ -141,9 +157,11 @@ OsdCpuGLVertexBuffer::map() {
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &prev);
_cpuBuffer = new float[size];
#if defined(GL_VERSION_2_1)
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glGetBufferSubData(GL_ARRAY_BUFFER, 0, size * sizeof(float), _cpuBuffer);
glBindBuffer(GL_ARRAY_BUFFER, prev);
#endif
}
void

View File

@ -60,10 +60,20 @@
#include "../version.h"
#if not defined(__APPLE__)
#include <GL/glew.h>
#else
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/gl.h>
#endif
namespace OpenSubdiv {

View File

@ -55,10 +55,10 @@
// a particular purpose and non-infringement.
//
#if not defined(__APPLE__)
#include <GL/glew.h>
#else
#if defined(__APPLE__)
#include <OpenGL/gl3.h>
#else
#include <GL/glew.h>
#endif
#include <cuda_runtime.h>

View File

@ -49,10 +49,20 @@
// (E) The software is licensed "as-is." You bear the risk of
// using it. The contributors give no express warranties,
#if not defined(__APPLE__)
#include <GL/glew.h>
#else
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/glew.h>
#endif
#include "../far/dispatcher.h"
@ -72,19 +82,12 @@ OsdGLDrawContext::OsdGLDrawContext() :
OsdGLDrawContext::~OsdGLDrawContext()
{
if (patchIndexBuffer)
glDeleteBuffers(1, &patchIndexBuffer);
if (vertexTextureBuffer)
glDeleteTextures(1, &vertexTextureBuffer);
if (vertexValenceTextureBuffer)
glDeleteTextures(1, &vertexValenceTextureBuffer);
if (quadOffsetTextureBuffer)
glDeleteTextures(1, &quadOffsetTextureBuffer);
if (patchLevelTextureBuffer)
glDeleteTextures(1, &patchLevelTextureBuffer);
if (ptexCoordinateTextureBuffer)
glDeleteTextures(1, &ptexCoordinateTextureBuffer);
if (fvarDataTextureBuffer)
glDeleteTextures(1, &fvarDataTextureBuffer);
}
@ -120,6 +123,34 @@ OsdGLDrawContext::allocate(FarMesh<OsdVertex> *farMesh,
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
numIndices * sizeof(unsigned int), &(indices[0]), GL_STATIC_DRAW);
#if defined(GL_ES_VERSION_2_0)
// OpenGLES 2 supports only triangle topologies for filled
// primitives i.e. not QUADS or PATCHES or LINES_ADJACENCY
// For the convenience of clients build build a triangles
// index buffer by splitting quads.
int numQuads = indices.size() / 4;
int numTrisIndices = numQuads * 6;
std::vector<short> trisIndices;
trisIndices.reserve(numTrisIndices);
for (int i=0; i<numQuads; ++i) {
const int * quad = &indices[i*4];
trisIndices.push_back(short(quad[0]));
trisIndices.push_back(short(quad[1]));
trisIndices.push_back(short(quad[2]));
trisIndices.push_back(short(quad[2]));
trisIndices.push_back(short(quad[3]));
trisIndices.push_back(short(quad[0]));
}
// Allocate and fill triangles index buffer.
glGenBuffers(1, &patchTrianglesIndexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, patchTrianglesIndexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
numTrisIndices * sizeof(short), &(trisIndices[0]), GL_STATIC_DRAW);
#endif
OsdPatchArray array;
array.desc.type = kNonPatch;
array.patchSize = loop ? 3 : 4;
@ -130,6 +161,7 @@ OsdGLDrawContext::allocate(FarMesh<OsdVertex> *farMesh,
// Allocate ptex coordinate buffer if requested (for non-adaptive)
if (requirePtexCoordinates) {
#if defined(GL_ARB_texture_buffer_object) || defined(GL_VERSION_3_1)
GLuint ptexCoordinateBuffer = 0;
glGenTextures(1, &ptexCoordinateTextureBuffer);
glGenBuffers(1, &ptexCoordinateBuffer);
@ -145,10 +177,12 @@ OsdGLDrawContext::allocate(FarMesh<OsdVertex> *farMesh,
glTexBuffer(GL_TEXTURE_BUFFER, GL_RG32I, ptexCoordinateBuffer);
glDeleteBuffers(1, &ptexCoordinateBuffer);
glBindTexture(GL_TEXTURE_BUFFER, 0);
#endif
}
// Allocate fvar data buffer if requested (for non-adaptive)
if (requireFVarData) {
#if defined(GL_ARB_texture_buffer_object) || defined(GL_VERSION_3_1)
GLuint fvarDataBuffer = 0;
glGenTextures(1, &fvarDataTextureBuffer);
glGenBuffers(1, &fvarDataBuffer);
@ -163,6 +197,7 @@ OsdGLDrawContext::allocate(FarMesh<OsdVertex> *farMesh,
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, fvarDataBuffer);
glDeleteBuffers(1, &fvarDataBuffer);
glBindTexture(GL_TEXTURE_BUFFER, 0);
#endif
}
return true;
@ -210,30 +245,36 @@ OsdGLDrawContext::allocate(FarMesh<OsdVertex> *farMesh,
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
totalPatchIndices * sizeof(unsigned int), NULL, GL_STATIC_DRAW);
#if defined(GL_ARB_texture_buffer_object) || defined(GL_VERSION_3_1)
GLuint patchLevelBuffer = 0;
glGenBuffers(1, &patchLevelBuffer);
glBindBuffer(GL_TEXTURE_BUFFER, patchLevelBuffer);
glBufferData(GL_TEXTURE_BUFFER,
totalPatchLevels * sizeof(unsigned char), NULL, GL_STATIC_DRAW);
#endif
// Allocate ptex coordinate buffer if requested
GLuint ptexCoordinateBuffer = 0;
if (requirePtexCoordinates) {
#if defined(GL_ARB_texture_buffer_object) || defined(GL_VERSION_3_1)
glGenTextures(1, &ptexCoordinateTextureBuffer);
glGenBuffers(1, &ptexCoordinateBuffer);
glBindBuffer(GL_ARRAY_BUFFER, ptexCoordinateBuffer);
glBufferData(GL_ARRAY_BUFFER,
totalPatchLevels * sizeof(int) * 2, NULL, GL_STATIC_DRAW);
#endif
}
// Allocate fvar data buffer if requested
GLuint fvarDataBuffer = 0;
if (requireFVarData) {
#if defined(GL_ARB_texture_buffer_object) || defined(GL_VERSION_3_1)
glGenTextures(1, &fvarDataTextureBuffer);
glGenBuffers(1, &fvarDataBuffer);
glBindBuffer(GL_UNIFORM_BUFFER, fvarDataBuffer);
glBufferData(GL_UNIFORM_BUFFER,
totalPatchLevels * sizeof(float) * farMesh->GetTotalFVarWidth()*4, NULL, GL_STATIC_DRAW);
#endif
}
int indexBase = 0;
@ -305,6 +346,7 @@ OsdGLDrawContext::allocate(FarMesh<OsdVertex> *farMesh,
}
}
#if defined(GL_ARB_texture_buffer_object) || defined(GL_VERSION_3_1)
// finalize level texture buffer
glGenTextures(1, &patchLevelTextureBuffer);
glBindTexture(GL_TEXTURE_BUFFER, patchLevelTextureBuffer);
@ -325,15 +367,19 @@ OsdGLDrawContext::allocate(FarMesh<OsdVertex> *farMesh,
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, fvarDataBuffer);
glDeleteBuffers(1, &fvarDataBuffer);
}
#endif
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
#if defined(GL_ARB_texture_buffer_object) || defined(GL_VERSION_3_1)
glBindBuffer(GL_TEXTURE_BUFFER, 0);
#endif
// allocate and initialize additional buffer data
FarPatchTables::VertexValenceTable const &
valenceTable = patchTables->GetVertexValenceTable();
if (not valenceTable.empty()) {
#if defined(GL_ARB_texture_buffer_object) || defined(GL_VERSION_3_1)
GLuint buffer = 0;
glGenBuffers(1, &buffer);
glBindBuffer(GL_TEXTURE_BUFFER, buffer);
@ -351,12 +397,14 @@ OsdGLDrawContext::allocate(FarMesh<OsdVertex> *farMesh,
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, vbo);
glBindBuffer(GL_TEXTURE_BUFFER, 0);
#endif
}
FarPatchTables::QuadOffsetTable const &
quadOffsetTable = patchTables->GetQuadOffsetTable();
if (not quadOffsetTable.empty()) {
#if defined(GL_ARB_texture_buffer_object) || defined(GL_VERSION_3_1)
GLuint buffer = 0;
glGenBuffers(1, &buffer);
glBindBuffer(GL_TEXTURE_BUFFER, buffer);
@ -370,6 +418,7 @@ OsdGLDrawContext::allocate(FarMesh<OsdVertex> *farMesh,
glDeleteBuffers(1, &buffer);
glBindBuffer(GL_TEXTURE_BUFFER, 0);
#endif
}
return true;
@ -423,13 +472,16 @@ OsdGLDrawContext::_AppendPatchArray(
}
}
#if defined(GL_ARB_texture_buffer_object) || defined(GL_VERSION_3_1)
glBufferSubData(GL_TEXTURE_BUFFER,
array.levelBase * sizeof(unsigned char),
levels.size() * sizeof(unsigned char),
&levels[0]);
*levelBase += (int)levels.size();
#endif
if (ptexCoordinateTextureBuffer) {
#if defined(GL_ARB_texture_buffer_object) || defined(GL_VERSION_3_1)
assert(ptexTable.size()/2 == levels.size());
// populate ptex coordinates
@ -437,9 +489,11 @@ OsdGLDrawContext::_AppendPatchArray(
array.levelBase * sizeof(int) * 2,
(int)ptexTable.size() * sizeof(int),
&ptexTable[0]);
#endif
}
if (fvarDataTextureBuffer) {
#if defined(GL_ARB_texture_buffer_object) || defined(GL_VERSION_3_1)
assert(fvarTable.size()/(fvarDataWidth*4) == levels.size());
// populate fvar data
@ -447,6 +501,7 @@ OsdGLDrawContext::_AppendPatchArray(
array.levelBase * sizeof(float) * fvarDataWidth*4,
(int)fvarTable.size() * sizeof(float),
&fvarTable[0]);
#endif
}
}

View File

@ -51,13 +51,20 @@
#ifndef OSD_GL_DRAW_CONTEXT_H
#define OSD_GL_DRAW_CONTEXT_H
#if not defined(__APPLE__)
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#include "../version.h"
@ -97,6 +104,11 @@ public:
}
GLuint patchIndexBuffer;
#if defined(GL_ES_VERSION_2_0)
GLuint patchTrianglesIndexBuffer;
#endif
GLuint ptexCoordinateTextureBuffer;
GLuint fvarDataTextureBuffer;

View File

@ -49,10 +49,20 @@
// (E) The software is licensed "as-is." You bear the risk of
// using it. The contributors give no express warranties,
#if not defined(__APPLE__)
#include <GL/glew.h>
#else
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/glew.h>
#endif
#include "../osd/glDrawRegistry.h"
@ -68,6 +78,7 @@ OsdGLDrawConfig::~OsdGLDrawConfig()
glDeleteProgram(program);
}
#if defined(GL_ARB_tessellation_shader) || defined(GL_VERSION_4_0)
static const char *commonShaderSource =
#include "glslPatchCommon.inc"
;
@ -89,6 +100,7 @@ static const char *boundaryGregoryShaderSource =
static const char *transitionShaderSource =
#include "glslPatchTransition.inc"
;
#endif
OsdGLDrawRegistryBase::~OsdGLDrawRegistryBase() {}
@ -97,6 +109,7 @@ OsdGLDrawRegistryBase::_CreateDrawSourceConfig(OsdPatchDescriptor const & desc)
{
OsdGLDrawSourceConfig * sconfig = _NewDrawSourceConfig();
#if defined(GL_ARB_tessellation_shader) || defined(GL_VERSION_4_0)
sconfig->commonShader.source = commonShaderSource;
{
std::ostringstream ss;
@ -228,6 +241,7 @@ OsdGLDrawRegistryBase::_CreateDrawSourceConfig(OsdPatchDescriptor const & desc)
sconfig = NULL;
break;
}
#endif
return sconfig;
}
@ -307,10 +321,14 @@ OsdGLDrawRegistryBase::_CreateDrawConfig(
sconfig->commonShader, sconfig->tessEvalShader);
#endif
GLuint geometryShader =
GLuint geometryShader = 0;
#if defined(GL_ARB_geometry_shader4) || defined(GL_VERSION_3_1)
geometryShader =
sconfig->geometryShader.source.empty() ? 0 :
_CompileShader(GL_GEOMETRY_SHADER,
sconfig->commonShader, sconfig->geometryShader);
#endif
GLuint fragmentShader =
sconfig->fragmentShader.source.empty() ? 0 :

View File

@ -52,13 +52,20 @@
#ifndef OSD_GL_DRAW_REGISTRY_H
#define OSD_GL_DRAW_REGISTRY_H
#if not defined(__APPLE__)
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#include "../version.h"

View File

@ -55,10 +55,10 @@
// a particular purpose and non-infringement.
//
#if not defined(__APPLE__)
#include <GL/glew.h>
#else
#if defined(__APPLE__)
#include <OpenGL/gl3.h>
#else
#include <GL/glew.h>
#endif
#include "../osd/glPtexTexture.h"

View File

@ -57,13 +57,20 @@
#ifndef OSD_GL_PTEX_TEXTURE_H
#define OSD_GL_PTEX_TEXTURE_H
#if not defined(__APPLE__)
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#include "../version.h"

View File

@ -55,10 +55,20 @@
// a particular purpose and non-infringement.
//
#if not defined(__APPLE__)
#include <GL/glew.h>
#else
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/glew.h>
#endif
#include "../osd/glVertexBuffer.h"
@ -85,7 +95,7 @@ OsdGLVertexBuffer::Create(int numElements, int numVertices) {
new OsdGLVertexBuffer(numElements, numVertices);
if (instance->allocate()) return instance;
delete instance;
return NULL;
return 0;
}
void

View File

@ -57,13 +57,20 @@
#ifndef OSD_GL_VERTEX_BUFFER_H
#define OSD_GL_VERTEX_BUFFER_H
#if not defined(__APPLE__)
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#include "../version.h"

View File

@ -55,13 +55,20 @@
// a particular purpose and non-infringement.
//
#if not defined(__APPLE__)
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/glew.h>
#else
#include <OpenGL/gl3.h>
#endif
#include "../osd/debug.h"

View File

@ -57,10 +57,20 @@
#ifndef OSD_GLSL_COMPUTE_CONTEXT_H
#define OSD_GLSL_COMPUTE_CONTEXT_H
#if not defined(__APPLE__)
#include <GL/gl.h>
#else
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/gl.h>
#endif
#include "../version.h"

View File

@ -55,13 +55,20 @@
// a particular purpose and non-infringement.
//
#if not defined(__APPLE__)
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/glew.h>
#else
#include <OpenGL/gl3.h>
#endif
#include "../osd/glslComputeController.h"

View File

@ -55,10 +55,20 @@
// a particular purpose and non-infringement.
//
#if not defined(__APPLE__)
#include <GL/glew.h>
#else
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/glew.h>
#endif
#include "../osd/glslComputeContext.h"

View File

@ -55,10 +55,10 @@
// a particular purpose and non-infringement.
//
#if not defined(__APPLE__)
#include <GL/glew.h>
#else
#if defined(__APPLE__)
#include <OpenGL/gl3.h>
#else
#include <GL/glew.h>
#endif
#include <stdio.h>

View File

@ -58,13 +58,20 @@
#ifndef OSD_GLSL_COMPUTE_KERNEL_BUNDLE_H
#define OSD_GLSL_COMPUTE_KERNEL_BUNDLE_H
#if not defined(__APPLE__)
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#include "../version.h"

View File

@ -55,13 +55,20 @@
// a particular purpose and non-infringement.
//
#if not defined(__APPLE__)
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/glew.h>
#else
#include <OpenGL/gl3.h>
#endif
#include "../osd/glslTransformFeedbackComputeContext.h"

View File

@ -58,10 +58,20 @@
#ifndef OSD_GLSL_TRANSFORM_FEEDBACK_COMPUTE_CONTEXT_H
#define OSD_GLSL_TRANSFORM_FEEDBACK_COMPUTE_CONTEXT_H
#if not defined(__APPLE__)
#include <GL/gl.h>
#else
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/gl.h>
#endif
#include "../version.h"

View File

@ -55,10 +55,10 @@
// a particular purpose and non-infringement.
//
#if not defined(__APPLE__)
#include <GL/glew.h>
#else
#if defined(__APPLE__)
#include <OpenGL/gl3.h>
#else
#include <GL/glew.h>
#endif
#include "../osd/glslTransformFeedbackComputeController.h"

View File

@ -55,10 +55,10 @@
// a particular purpose and non-infringement.
//
#if not defined(__APPLE__)
#include <GL/glew.h>
#else
#if defined(__APPLE__)
#include <OpenGL/gl3.h>
#else
#include <GL/glew.h>
#endif
#include "../osd/glslTransformFeedbackDispatcher.h"

View File

@ -55,10 +55,10 @@
// a particular purpose and non-infringement.
//
#if not defined(__APPLE__)
#include <GL/glew.h>
#else
#if defined(__APPLE__)
#include <OpenGL/gl3.h>
#else
#include <GL/glew.h>
#endif
#include <stdio.h>

View File

@ -57,13 +57,20 @@
#ifndef OSD_GLSL_TRANSFORM_FEEDBACK_KERNEL_BUNDLE_H
#define OSD_GLSL_TRANSFORM_FEEDBACK_KERNEL_BUNDLE_H
#if not defined(__APPLE__)
#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE or TARGET_IPHONE_SIMULATOR
#include <OpenGLES/ES2/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#elif defined(ANDROID)
#include <GLES2/gl2.h>
#else
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/gl.h>
#else
#include <OpenGL/gl3.h>
#endif
#include "../version.h"

View File

@ -58,6 +58,7 @@
#define OSD_CPU_VERTEX_DESCRIPTOR_H
#include "../version.h"
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {