mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2025-01-03 13:41:06 +00:00
Enabled internal GL API loader as GLEW alternative
At build time, the preprocessor symbols: OSD_USES_GLEW or OSD_USES_INTERNAL_GLAPILOADER determine the GL API loader that will be used by the OSD library.
This commit is contained in:
parent
720462a315
commit
f3f28995a5
@ -306,6 +306,7 @@ 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" OFF)
|
||||
option(NO_GLFW "Disable components depending on GLFW" OFF)
|
||||
option(NO_GLFW_X11 "Disable GLFW components depending on X11" OFF)
|
||||
|
||||
@ -351,13 +352,17 @@ if (OPENGL_FOUND AND NOT IOS)
|
||||
add_definitions(
|
||||
-DOPENSUBDIV_HAS_OPENGL
|
||||
)
|
||||
if (APPLE)
|
||||
find_package(GLEW)
|
||||
else()
|
||||
find_package(GLEW REQUIRED)
|
||||
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()
|
||||
endif()
|
||||
|
||||
@ -457,9 +462,9 @@ if(GLEW_FOUND AND GLEW_INCLUDE_DIR)
|
||||
${GLEW_LIBRARY}
|
||||
${OPENGL_gl_LIBRARY})
|
||||
|
||||
elseif(OPENGL_FOUND AND OPENGL_INCLUDE_DIR)
|
||||
elseif(OPENGL_FOUND)
|
||||
|
||||
osd_detect_gl_version(${OPENGL_INCLUDE_DIR}/GL/glext.h)
|
||||
osd_detect_gl_version(${PROJECT_SOURCE_DIR}/glLoader/glApi.h)
|
||||
set(OPENGL_LOADER_INCLUDE_DIRS
|
||||
${OPENGL_INCLUDE_DIR}
|
||||
${PROJECT_SOURCE_DIR}/glLoader)
|
||||
|
@ -28,10 +28,13 @@ endif()
|
||||
|
||||
list(APPEND GLLOADER_SOURCE_FILES
|
||||
glLoader.cpp
|
||||
glApi.cpp
|
||||
)
|
||||
|
||||
list(APPEND GLLOADER_HEADER_FILES
|
||||
glLoader.h
|
||||
glApi.h
|
||||
khrplatform.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
|
@ -36,7 +36,12 @@ namespace GLLoader {
|
||||
bool
|
||||
applicationInitializeGL()
|
||||
{
|
||||
#if defined(OSD_USES_GLEW)
|
||||
#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)
|
||||
@ -60,8 +65,12 @@ applicationInitializeGL()
|
||||
bool
|
||||
libraryInitializeGL()
|
||||
{
|
||||
// do nothing
|
||||
#if defined(OSD_USES_INTERNAL_GLAPILOADER)
|
||||
return OpenSubdiv::internal::GLApi::glApiLoad();
|
||||
#else
|
||||
// otherwise do nothing
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,6 +31,11 @@
|
||||
/// function entry points at run-time and to define types, enum values,
|
||||
/// and function prototypes needed at compile-time.
|
||||
///
|
||||
/// There are three components to this library:
|
||||
/// glLoader.h -- interface (this header file)
|
||||
/// glApi.h -- low-level generated OpenGL API loader
|
||||
/// khrplatform.h -- khronos.org abstraction for low-level platform types
|
||||
///
|
||||
/// To use:
|
||||
/// - Include "glloader.h"
|
||||
///
|
||||
@ -132,36 +137,18 @@
|
||||
/// The boolean variables described here are defined in an internal namespace.
|
||||
///
|
||||
|
||||
#if defined(OSD_USES_GLEW)
|
||||
#if defined(OSD_USES_INTERNAL_GLAPILOADER)
|
||||
// -- GLAPILOADER
|
||||
#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)
|
||||
|
||||
#else
|
||||
|
||||
// -- PLATFORM
|
||||
#if defined(__APPLE__)
|
||||
#include "TargetConditionals.h"
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
#include <OpenGLES/ES2/gl.h>
|
||||
#else
|
||||
#include <OpenGL/gl3.h>
|
||||
#endif
|
||||
#elif defined(ANDROID)
|
||||
#include <GLES2/gl2.h>
|
||||
#elif defined(_WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <GL/gl.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
#endif
|
||||
|
||||
#define OSD_OPENGL_HAS(token) (GL_##token)
|
||||
|
||||
#endif
|
||||
|
||||
namespace OpenSubdiv {
|
||||
@ -184,4 +171,9 @@ extern bool libraryInitializeGL();
|
||||
} // namespace OpenSubdiv
|
||||
|
||||
|
||||
#if defined(OSD_USES_INTERNAL_GLAPILOADER)
|
||||
using namespace OpenSubdiv::internal::GLApi;
|
||||
#endif
|
||||
|
||||
|
||||
#endif // OPENSUBDIV3_GLLOADER_H
|
||||
|
@ -38,6 +38,9 @@ CLGLVertexBuffer::CLGLVertexBuffer(int numElements,
|
||||
cl_context /* clContext */)
|
||||
: _numElements(numElements), _numVertices(numVertices),
|
||||
_vbo(0), _clQueue(0), _clMemory(0), _clMapped(false) {
|
||||
|
||||
// Initialize internal OpenGL loader library if necessary
|
||||
OpenSubdiv::internal::GLLoader::libraryInitializeGL();
|
||||
}
|
||||
|
||||
CLGLVertexBuffer::~CLGLVertexBuffer() {
|
||||
|
@ -37,6 +37,9 @@ namespace Osd {
|
||||
CpuGLVertexBuffer::CpuGLVertexBuffer(int numElements, int numVertices)
|
||||
: _numElements(numElements), _numVertices(numVertices),
|
||||
_vbo(0), _cpuBuffer(0), _dataDirty(true) {
|
||||
|
||||
// Initialize internal OpenGL loader library if necessary
|
||||
OpenSubdiv::internal::GLLoader::libraryInitializeGL();
|
||||
}
|
||||
|
||||
CpuGLVertexBuffer::~CpuGLVertexBuffer() {
|
||||
|
@ -40,6 +40,9 @@ namespace Osd {
|
||||
CudaGLVertexBuffer::CudaGLVertexBuffer(int numElements, int numVertices)
|
||||
: _numElements(numElements), _numVertices(numVertices),
|
||||
_vbo(0), _devicePtr(0), _cudaResource(0) {
|
||||
|
||||
// Initialize internal OpenGL loader library if necessary
|
||||
OpenSubdiv::internal::GLLoader::libraryInitializeGL();
|
||||
}
|
||||
|
||||
CudaGLVertexBuffer::~CudaGLVertexBuffer() {
|
||||
|
@ -130,6 +130,9 @@ GLComputeEvaluator::GLComputeEvaluator()
|
||||
_patchArraysSSBO(0) {
|
||||
memset (&_stencilKernel, 0, sizeof(_stencilKernel));
|
||||
memset (&_patchKernel, 0, sizeof(_patchKernel));
|
||||
|
||||
// Initialize internal OpenGL loader library if necessary
|
||||
OpenSubdiv::internal::GLLoader::libraryInitializeGL();
|
||||
}
|
||||
|
||||
GLComputeEvaluator::~GLComputeEvaluator() {
|
||||
|
@ -35,6 +35,9 @@ GLLegacyGregoryPatchTable::GLLegacyGregoryPatchTable() :
|
||||
_vertexTextureBuffer(0), _vertexValenceTextureBuffer(0),
|
||||
_quadOffsetsTextureBuffer(0) {
|
||||
_quadOffsetsBase[0] = _quadOffsetsBase[1] = 0;
|
||||
|
||||
// Initialize internal OpenGL loader library if necessary
|
||||
OpenSubdiv::internal::GLLoader::libraryInitializeGL();
|
||||
}
|
||||
|
||||
GLLegacyGregoryPatchTable::~GLLegacyGregoryPatchTable() {
|
||||
|
@ -37,6 +37,9 @@ namespace Osd {
|
||||
GLPatchTable::GLPatchTable() :
|
||||
_patchIndexBuffer(0), _patchParamBuffer(0),
|
||||
_patchIndexTexture(0), _patchParamTexture(0) {
|
||||
|
||||
// Initialize internal OpenGL loader library if necessary
|
||||
OpenSubdiv::internal::GLLoader::libraryInitializeGL();
|
||||
}
|
||||
|
||||
GLPatchTable::~GLPatchTable() {
|
||||
|
@ -35,6 +35,9 @@ GLVertexBuffer::GLVertexBuffer(int numElements, int numVertices)
|
||||
: _numElements(numElements),
|
||||
_numVertices(numVertices),
|
||||
_vbo(0) {
|
||||
|
||||
// Initialize internal OpenGL loader library if necessary
|
||||
OpenSubdiv::internal::GLLoader::libraryInitializeGL();
|
||||
}
|
||||
|
||||
GLVertexBuffer::~GLVertexBuffer() {
|
||||
|
@ -157,6 +157,9 @@ GLXFBEvaluator::GLXFBEvaluator(bool interleavedDerivativeBuffers)
|
||||
: _srcBufferTexture(0),
|
||||
_patchArraysUBO(0),
|
||||
_interleavedDerivativeBuffers(interleavedDerivativeBuffers) {
|
||||
|
||||
// Initialize internal OpenGL loader library if necessary
|
||||
OpenSubdiv::internal::GLLoader::libraryInitializeGL();
|
||||
}
|
||||
|
||||
GLXFBEvaluator::~GLXFBEvaluator() {
|
||||
|
Loading…
Reference in New Issue
Block a user