mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-11-08 13:30:04 +00:00
Moved GLEW dependencies to glLoader wrapper
This introduces an internal glLoader library which allows most of the implementation to be agnostic about the implementation of the GL loading library. Specifically, this removes references to the GLEW headers and libraries from the rest of the source code and build system.
This commit is contained in:
parent
16a5c3993f
commit
28f2574bc5
@ -356,6 +356,9 @@ if (OPENGL_FOUND AND NOT IOS)
|
||||
else()
|
||||
find_package(GLEW REQUIRED)
|
||||
endif()
|
||||
if(GLEW_FOUND)
|
||||
add_definitions( -DOSD_USES_GLEW )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (WIN32 AND NOT NO_DX)
|
||||
@ -423,11 +426,6 @@ 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()
|
||||
|
||||
macro(osd_detect_gl_version header)
|
||||
|
||||
if (EXISTS "${header}")
|
||||
@ -451,15 +449,28 @@ 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
|
||||
glLoader
|
||||
${GLEW_LIBRARY}
|
||||
${OPENGL_gl_LIBRARY})
|
||||
|
||||
elseif(OPENGL_FOUND AND OPENGL_INCLUDE_DIR)
|
||||
|
||||
osd_detect_gl_version(${OPENGL_INCLUDE_DIR}/GL/glext.h)
|
||||
set(OPENGL_LOADER_INCLUDE_DIRS
|
||||
${OPENGL_INCLUDE_DIR}
|
||||
${PROJECT_SOURCE_DIR}/glLoader)
|
||||
set(OPENGL_LOADER_LIBRARIES
|
||||
glLoader
|
||||
${OPENGL_gl_LIBRARY})
|
||||
|
||||
endif()
|
||||
|
||||
# note : (GLSL transform feedback kernels require GL 4.2)
|
||||
if(GLEW_FOUND AND OPENGL_4_2_FOUND)
|
||||
if(OPENGL_4_2_FOUND)
|
||||
add_definitions(
|
||||
-DOPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
|
||||
)
|
||||
@ -474,7 +485,7 @@ else()
|
||||
endif()
|
||||
|
||||
# note : (GLSL compute shader kernels require GL 4.3)
|
||||
if(GLEW_FOUND AND OPENGL_4_3_FOUND)
|
||||
if(OPENGL_4_3_FOUND)
|
||||
add_definitions(
|
||||
-DOPENSUBDIV_HAS_GLSL_COMPUTE
|
||||
)
|
||||
@ -790,6 +801,10 @@ if (NOT NO_TESTS)
|
||||
enable_testing()
|
||||
endif()
|
||||
|
||||
if (NOT NO_OPENGL)
|
||||
add_subdirectory(glLoader)
|
||||
endif()
|
||||
|
||||
add_subdirectory(opensubdiv)
|
||||
|
||||
if (NOT ANDROID) # XXXdyu
|
||||
|
@ -24,26 +24,24 @@
|
||||
|
||||
add_subdirectory(common)
|
||||
|
||||
if (NOT NO_OPENGL)
|
||||
if (OPENGL_FOUND AND (GLEW_FOUND AND GLFW_FOUND) OR (APPLE AND GLFW_FOUND))
|
||||
if (OPENGL_FOUND AND GLFW_FOUND)
|
||||
|
||||
add_subdirectory(glViewer)
|
||||
add_subdirectory(glEvalLimit)
|
||||
add_subdirectory(glShareTopology)
|
||||
add_subdirectory(glFVarViewer)
|
||||
add_subdirectory(glStencilViewer)
|
||||
add_subdirectory(glImaging)
|
||||
add_subdirectory(farViewer)
|
||||
|
||||
if (OPENGL_4_3_FOUND AND (NOT APPLE))
|
||||
add_subdirectory(glPaintTest)
|
||||
endif()
|
||||
|
||||
if (PTEX_FOUND AND ZLIB_FOUND)
|
||||
add_subdirectory(glPtexViewer)
|
||||
endif()
|
||||
add_subdirectory(glViewer)
|
||||
add_subdirectory(glEvalLimit)
|
||||
add_subdirectory(glShareTopology)
|
||||
add_subdirectory(glFVarViewer)
|
||||
add_subdirectory(glStencilViewer)
|
||||
add_subdirectory(glImaging)
|
||||
add_subdirectory(farViewer)
|
||||
|
||||
if (OPENGL_4_2_FOUND)
|
||||
add_subdirectory(glPaintTest)
|
||||
endif()
|
||||
|
||||
if (PTEX_FOUND AND ZLIB_FOUND)
|
||||
add_subdirectory(glPtexViewer)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
if (DXSDK_FOUND AND NOT NO_DX)
|
||||
@ -57,8 +55,11 @@ if (DXSDK_FOUND AND NOT NO_DX)
|
||||
endif()
|
||||
|
||||
if (METAL_FOUND AND NOT NO_METAL)
|
||||
|
||||
add_subdirectory(mtlViewer)
|
||||
|
||||
if(PTEX_FOUND)
|
||||
add_subdirectory(mtlPtexViewer)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
@ -71,7 +71,7 @@ if(CUDA_FOUND)
|
||||
)
|
||||
endif()
|
||||
|
||||
if( OPENGL_FOUND AND (GLEW_FOUND AND GLFW_FOUND) OR (APPLE AND GLFW_FOUND))
|
||||
if(OPENGL_FOUND AND GLFW_FOUND)
|
||||
|
||||
list(APPEND EXAMPLES_COMMON_GL_SOURCE_FILES
|
||||
glControlMeshDisplay.cpp
|
||||
@ -87,13 +87,7 @@ if( OPENGL_FOUND AND (GLEW_FOUND AND GLFW_FOUND) OR (APPLE AND GLFW_FOUND))
|
||||
glShaderCache.h
|
||||
)
|
||||
|
||||
if (NOT "${OPENGL_INCLUDE_DIR}" STREQUAL "")
|
||||
include_directories("${OPENGL_INCLUDE_DIR}")
|
||||
endif()
|
||||
|
||||
if (GLEW_FOUND)
|
||||
include_directories("${GLEW_INCLUDE_DIR}")
|
||||
endif()
|
||||
include_directories(${OPENGL_LOADER_INCLUDE_DIRS})
|
||||
|
||||
if (GLFW_FOUND)
|
||||
include_directories("${GLFW_INCLUDE_DIR}")
|
||||
|
@ -22,8 +22,10 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include "glControlMeshDisplay.h"
|
||||
#include "../common/glUtils.h"
|
||||
#include "glUtils.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -25,7 +25,8 @@
|
||||
#ifndef OPENSUBDIV_EXAMPLES_GL_CONTROL_MESH_DISPLAY_H
|
||||
#define OPENSUBDIV_EXAMPLES_GL_CONTROL_MESH_DISPLAY_H
|
||||
|
||||
#include <opensubdiv/osd/opengl.h>
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <opensubdiv/far/topologyLevel.h>
|
||||
|
||||
class GLControlMeshDisplay {
|
||||
|
@ -22,6 +22,8 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include "glHud.h"
|
||||
#include "glUtils.h"
|
||||
|
||||
|
@ -25,9 +25,9 @@
|
||||
#ifndef OPENSUBDIV_EXAMPLES_GL_HUD_H
|
||||
#define OPENSUBDIV_EXAMPLES_GL_HUD_H
|
||||
|
||||
#include "hud.h"
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <opensubdiv/osd/opengl.h>
|
||||
#include "hud.h"
|
||||
|
||||
class GLhud : public Hud {
|
||||
|
||||
|
@ -22,11 +22,11 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include "glPtexMipmapTexture.h"
|
||||
#include "ptexMipmapTextureLoader.h"
|
||||
|
||||
#include <opensubdiv/osd/opengl.h>
|
||||
|
||||
GLPtexMipmapTexture::GLPtexMipmapTexture()
|
||||
: _width(0), _height(0), _depth(0), _layout(0), _texels(0), _memoryUsage(0)
|
||||
{
|
||||
|
@ -25,8 +25,9 @@
|
||||
#ifndef OPENSUBDIV_EXAMPLES_GL_PTEX_MIPMAP_TEXTURE_H
|
||||
#define OPENSUBDIV_EXAMPLES_GL_PTEX_MIPMAP_TEXTURE_H
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <opensubdiv/osd/nonCopyable.h>
|
||||
#include <opensubdiv/osd/opengl.h>
|
||||
|
||||
#include <Ptexture.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -22,11 +22,12 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include "glShaderCache.h"
|
||||
#include "glUtils.h"
|
||||
|
||||
#include <vector>
|
||||
#include <opensubdiv/osd/opengl.h>
|
||||
#include <opensubdiv/far/error.h>
|
||||
|
||||
GLDrawConfig::GLDrawConfig(const std::string &version)
|
||||
|
@ -25,7 +25,8 @@
|
||||
#ifndef OPENSUBDIV_EXAMPLES_GL_SHADER_CACHE_H
|
||||
#define OPENSUBDIV_EXAMPLES_GL_SHADER_CACHE_H
|
||||
|
||||
#include <opensubdiv/osd/opengl.h>
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "./shaderCache.h"
|
||||
|
@ -22,6 +22,8 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
@ -39,12 +41,10 @@
|
||||
|
||||
namespace GLUtils {
|
||||
|
||||
// Note that glewIsSupported is required here for Core profile, glewGetExtension
|
||||
// and GLEW_extension_name will not work on all drivers.
|
||||
#ifdef OSD_USES_GLEW
|
||||
#define IS_SUPPORTED(x) \
|
||||
(glewIsSupported(x) == GL_TRUE)
|
||||
#endif
|
||||
void InitializeGL()
|
||||
{
|
||||
OpenSubdiv::internal::GLLoader::applicationInitializeGL();
|
||||
}
|
||||
|
||||
static void
|
||||
_argParseBool(bool *ret, const char *lbl, int i, int argc, char **argv)
|
||||
@ -125,7 +125,6 @@ SetMinimumGLVersion(int argc, char ** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CORE_PROFILE
|
||||
if (coreProfile) {
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
}
|
||||
@ -133,7 +132,6 @@ SetMinimumGLVersion(int argc, char ** argv) {
|
||||
if (forwardCompat) {
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (versionSet) {
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major);
|
||||
@ -203,20 +201,6 @@ WriteScreenshot(int width, int height) {
|
||||
fprintf(stdout, "Saved %s\n", fname);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SupportsAdaptiveTessellation() {
|
||||
#ifdef OSD_USES_GLEW
|
||||
return IS_SUPPORTED("GL_ARB_tessellation_shader");
|
||||
#else
|
||||
#if defined(GL_ARB_tessellation_shader) || defined(GL_VERSION_4_0)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void GetMajorMinorVersion(int *major, int *minor){
|
||||
const GLubyte *ver = glGetString(GL_SHADING_LANGUAGE_VERSION);
|
||||
if (!ver){
|
||||
@ -268,30 +252,46 @@ std::string GetShaderVersionInclude(){
|
||||
return "#version " + GetShaderVersion() + "\n";
|
||||
}
|
||||
|
||||
bool GL_ARBSeparateShaderObjectsOrGL_VERSION_4_1(){
|
||||
#if defined(OSD_USES_GLEW)
|
||||
return IS_SUPPORTED("GL_ARB_separate_shader_objects") ||
|
||||
(GLEW_VERSION_4_1 && IS_SUPPORTED("GL_ARB_tessellation_shader"));
|
||||
#else
|
||||
#if defined(GL_ARB_separate_shader_objects) || defined(GL_VERSION_4_1)
|
||||
return true;
|
||||
#else
|
||||
bool SupportsAdaptiveTessellation() {
|
||||
#if defined(GL_VERSION_4_0)
|
||||
if (OSD_OPENGL_HAS(VERSION_4_0)) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#if defined(GL_ARB_tessellation_shader)
|
||||
if (OSD_OPENGL_HAS(ARB_tessellation_shader)) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GL_ARBSeparateShaderObjectsOrGL_VERSION_4_1() {
|
||||
#if defined(GL_VERSION_4_1)
|
||||
if (OSD_OPENGL_HAS(VERSION_4_1)) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#if defined(GL_ARB_separate_shader_objects)
|
||||
if (OSD_OPENGL_HAS(ARB_separate_shader_objects)) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GL_ARBComputeShaderOrGL_VERSION_4_3() {
|
||||
#if defined(OSD_USES_GLEW)
|
||||
return IS_SUPPORTED("GL_ARB_compute_shader") ||
|
||||
(GLEW_VERSION_4_3);
|
||||
#else
|
||||
#if defined(GL_ARB_compute_shader) || defined(GL_VERSION_4_3)
|
||||
return true;
|
||||
#else
|
||||
#if defined(GL_VERSION_4_3)
|
||||
if (OSD_OPENGL_HAS(VERSION_4_3)) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#if defined(GL_ARB_compute_shader)
|
||||
if (OSD_OPENGL_HAS(ARB_compute_shader)) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef IS_SUPPORTED
|
||||
|
@ -25,32 +25,16 @@
|
||||
#ifndef OPENSUBDIV_EXAMPLES_GL_UTILS_H
|
||||
#define OPENSUBDIV_EXAMPLES_GL_UTILS_H
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if defined(OSD_USES_GLEW)
|
||||
#include <GL/glew.h>
|
||||
#else
|
||||
#include <OpenGL/gl3.h>
|
||||
#endif
|
||||
#define GLFW_INCLUDE_GL3
|
||||
#define GLFW_NO_GLU
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#include <GL/glew.h>
|
||||
#if defined(WIN32)
|
||||
#include <GL/wglew.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <opensubdiv/osd/opengl.h>
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#define CORE_PROFILE
|
||||
|
||||
namespace GLUtils {
|
||||
|
||||
void InitializeGL();
|
||||
|
||||
void SetMinimumGLVersion(int argc=0, char **argv=NULL);
|
||||
|
||||
void PrintGLVersion();
|
||||
|
@ -32,20 +32,16 @@ set(SHADER_FILES
|
||||
|
||||
include_directories(
|
||||
"${OPENSUBDIV_INCLUDE_DIR}"
|
||||
"${OPENGL_LOADER_INCLUDE_DIRS}"
|
||||
"${GLFW_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
list(APPEND PLATFORM_LIBRARIES
|
||||
"${OSD_LINK_TARGET}"
|
||||
"${OPENGL_LIBRARY}"
|
||||
"${OPENGL_LOADER_LIBRARIES}"
|
||||
"${GLFW_LIBRARIES}"
|
||||
)
|
||||
|
||||
if ( GLEW_FOUND )
|
||||
include_directories("${GLEW_INCLUDE_DIR}")
|
||||
list(APPEND PLATFORM_LIBRARIES "${GLEW_LIBRARY}")
|
||||
endif()
|
||||
|
||||
if( OPENCL_FOUND )
|
||||
include_directories("${OPENCL_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
@ -22,21 +22,7 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if defined(OSD_USES_GLEW)
|
||||
#include <GL/glew.h>
|
||||
#else
|
||||
#include <OpenGL/gl3.h>
|
||||
#endif
|
||||
#define GLFW_INCLUDE_GL3
|
||||
#define GLFW_NO_GLU
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#include <GL/glew.h>
|
||||
#if defined(WIN32)
|
||||
#include <GL/wglew.h>
|
||||
#endif
|
||||
#endif
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
GLFWwindow* g_window=0;
|
||||
@ -55,6 +41,7 @@ GLFWmonitor* g_primary=0;
|
||||
#include "../common/glUtils.h"
|
||||
#include "../common/glControlMeshDisplay.h"
|
||||
#include "../common/glHud.h"
|
||||
#include "../common/glUtils.h"
|
||||
|
||||
#include "init_shapes.h"
|
||||
#include "gl_mesh.h"
|
||||
@ -1396,23 +1383,9 @@ int main(int argc, char ** argv)
|
||||
glfwSetMouseButtonCallback(g_window, mouse);
|
||||
glfwSetWindowCloseCallback(g_window, windowClose);
|
||||
|
||||
GLUtils::InitializeGL();
|
||||
GLUtils::PrintGLVersion();
|
||||
|
||||
#if defined(OSD_USES_GLEW)
|
||||
#ifdef CORE_PROFILE
|
||||
// this is the only way to initialize glew correctly under core profile context.
|
||||
glewExperimental = true;
|
||||
#endif
|
||||
if (GLenum r = glewInit() != GLEW_OK) {
|
||||
printf("Failed to initialize glew. Error = %s\n", glewGetErrorString(r));
|
||||
exit(1);
|
||||
}
|
||||
#ifdef CORE_PROFILE
|
||||
// clear GL errors which were generated during glewInit()
|
||||
glGetError();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
initGL();
|
||||
|
||||
glfwSwapInterval(0);
|
||||
|
@ -22,6 +22,8 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include "gl_fontutils.h"
|
||||
|
||||
#include <cassert>
|
||||
|
@ -22,6 +22,8 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include "gl_mesh.h"
|
||||
#include "gl_fontutils.h"
|
||||
|
||||
|
@ -24,20 +24,17 @@
|
||||
|
||||
# *** glEvalLimit ***
|
||||
|
||||
list(APPEND PLATFORM_LIBRARIES
|
||||
"${OSD_LINK_TARGET}"
|
||||
"${GLFW_LIBRARIES}"
|
||||
)
|
||||
|
||||
include_directories(
|
||||
"${OPENSUBDIV_INCLUDE_DIR}"
|
||||
"${OPENGL_LOADER_INCLUDE_DIRS}"
|
||||
"${GLFW_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
if ( GLEW_FOUND )
|
||||
include_directories("${GLEW_INCLUDE_DIR}")
|
||||
list(APPEND PLATFORM_LIBRARIES "${GLEW_LIBRARY}")
|
||||
endif()
|
||||
list(APPEND PLATFORM_LIBRARIES
|
||||
"${OSD_LINK_TARGET}"
|
||||
"${OPENGL_LOADER_LIBRARIES}"
|
||||
"${GLFW_LIBRARIES}"
|
||||
)
|
||||
|
||||
if( OPENCL_FOUND )
|
||||
include_directories("${OPENCL_INCLUDE_DIRS}")
|
||||
|
@ -22,7 +22,7 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "../common/glUtils.h"
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
GLFWwindow* g_window=0;
|
||||
@ -86,6 +86,7 @@ GLFWmonitor* g_primary=0;
|
||||
#include "../common/simple_math.h"
|
||||
#include "../common/glControlMeshDisplay.h"
|
||||
#include "../common/glHud.h"
|
||||
#include "../common/glUtils.h"
|
||||
|
||||
#include "init_shapes.h"
|
||||
#include "particles.h"
|
||||
@ -1522,6 +1523,8 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent(g_window);
|
||||
|
||||
GLUtils::InitializeGL();
|
||||
GLUtils::PrintGLVersion();
|
||||
|
||||
// accommodate high DPI displays (e.g. mac retina displays)
|
||||
@ -1532,27 +1535,6 @@ int main(int argc, char **argv) {
|
||||
glfwSetCursorPosCallback(g_window, motion);
|
||||
glfwSetMouseButtonCallback(g_window, mouse);
|
||||
glfwSetWindowCloseCallback(g_window, windowClose);
|
||||
|
||||
#if defined(OSD_USES_GLEW)
|
||||
#ifdef CORE_PROFILE
|
||||
// this is the only way to initialize glew correctly under core profile context.
|
||||
glewExperimental = true;
|
||||
#endif
|
||||
if (GLenum r = glewInit() != GLEW_OK) {
|
||||
printf("Failed to initialize glew. Error = %s\n", glewGetErrorString(r));
|
||||
exit(1);
|
||||
}
|
||||
#ifdef CORE_PROFILE
|
||||
// clear GL errors which was generated during glewInit()
|
||||
glGetError();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//std::string & data = g_defaultShapes[ g_currentShape ].data;
|
||||
//Scheme scheme = g_defaultShapes[ g_currentShape ].scheme;
|
||||
|
||||
//createOsdMesh( data, g_level, scheme );
|
||||
|
||||
initGL();
|
||||
linkDefaultProgram();
|
||||
|
||||
|
@ -28,28 +28,22 @@ set(SHADER_FILES
|
||||
shader.glsl
|
||||
)
|
||||
|
||||
list(APPEND PLATFORM_LIBRARIES
|
||||
"${OSD_LINK_TARGET}"
|
||||
"${OPENGL_LIBRARY}"
|
||||
"${GLFW_LIBRARIES}"
|
||||
)
|
||||
|
||||
include_directories(
|
||||
"${OPENSUBDIV_INCLUDE_DIR}"
|
||||
"${OPENGL_LOADER_INCLUDE_DIRS}"
|
||||
"${GLFW_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
if ( GLEW_FOUND )
|
||||
include_directories("${GLEW_INCLUDE_DIR}")
|
||||
list(APPEND PLATFORM_LIBRARIES "${GLEW_LIBRARY}")
|
||||
endif()
|
||||
list(APPEND PLATFORM_LIBRARIES
|
||||
"${OSD_LINK_TARGET}"
|
||||
"${OPENGL_LOADER_LIBRARIES}"
|
||||
"${GLFW_LIBRARIES}"
|
||||
)
|
||||
|
||||
if( OPENCL_FOUND )
|
||||
include_directories("${OPENCL_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
osd_stringify("${SHADER_FILES}" INC_FILES)
|
||||
|
||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
@ -22,7 +22,7 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "../common/glUtils.h"
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
GLFWwindow* g_window = 0;
|
||||
@ -42,6 +42,7 @@ OpenSubdiv::Osd::GLMeshInterface *g_mesh = NULL;
|
||||
#include "../common/glControlMeshDisplay.h"
|
||||
#include "../common/glHud.h"
|
||||
#include "../common/glShaderCache.h"
|
||||
#include "../common/glUtils.h"
|
||||
#include "../common/viewerArgsUtils.h"
|
||||
|
||||
#include <opensubdiv/osd/glslPatchShaderSource.h>
|
||||
@ -1326,6 +1327,8 @@ int main(int argc, char ** argv) {
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent(g_window);
|
||||
|
||||
GLUtils::InitializeGL();
|
||||
GLUtils::PrintGLVersion();
|
||||
|
||||
// accommodate high DPI displays (e.g. mac retina displays)
|
||||
@ -1337,22 +1340,6 @@ int main(int argc, char ** argv) {
|
||||
glfwSetMouseButtonCallback(g_window, mouse);
|
||||
glfwSetWindowCloseCallback(g_window, windowClose);
|
||||
|
||||
|
||||
#if defined(OSD_USES_GLEW)
|
||||
#ifdef CORE_PROFILE
|
||||
// this is the only way to initialize glew correctly under core profile context.
|
||||
glewExperimental = true;
|
||||
#endif
|
||||
if (GLenum r = glewInit() != GLEW_OK) {
|
||||
printf("Failed to initialize glew. Error = %s\n", glewGetErrorString(r));
|
||||
exit(1);
|
||||
}
|
||||
#ifdef CORE_PROFILE
|
||||
// clear GL errors which were generated during glewInit()
|
||||
glGetError();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
g_adaptive = g_adaptive && GLUtils::SupportsAdaptiveTessellation();
|
||||
|
||||
initGL();
|
||||
|
@ -24,30 +24,22 @@
|
||||
|
||||
# *** glImaging ***
|
||||
|
||||
include_directories(
|
||||
"${OPENSUBDIV_INCLUDE_DIR}"
|
||||
"${GLFW_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
set(SHADER_FILES
|
||||
shader.glsl
|
||||
)
|
||||
|
||||
set(SOURCE_FILES
|
||||
glImaging.cpp
|
||||
include_directories(
|
||||
"${OPENSUBDIV_INCLUDE_DIR}"
|
||||
"${OPENGL_LOADER_INCLUDE_DIRS}"
|
||||
"${GLFW_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
set(PLATFORM_LIBRARIES
|
||||
"${OSD_LINK_TARGET}"
|
||||
"${OPENGL_LIBRARY}"
|
||||
"${OPENGL_LOADER_LIBRARIES}"
|
||||
"${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}"
|
||||
@ -60,7 +52,7 @@ osd_stringify("${SHADER_FILES}" INC_FILES)
|
||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
osd_add_glfw_executable(glImaging "examples"
|
||||
"${SOURCE_FILES}"
|
||||
glImaging.cpp
|
||||
"${SHADER_FILES}"
|
||||
"${INC_FILES}"
|
||||
$<TARGET_OBJECTS:regression_common_obj>
|
||||
|
@ -22,7 +22,7 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "../common/glUtils.h"
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@ -73,6 +73,7 @@
|
||||
#include "../common/patchColors.h"
|
||||
#include "../common/stb_image_write.h" // common.obj has an implementation.
|
||||
#include "../common/glShaderCache.h"
|
||||
#include "../common/glUtils.h"
|
||||
#include "init_shapes.h"
|
||||
|
||||
using namespace OpenSubdiv;
|
||||
@ -531,19 +532,9 @@ int main(int argc, char ** argv) {
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
GLUtils::PrintGLVersion();
|
||||
|
||||
#if defined(OSD_USES_GLEW)
|
||||
// this is the only way to initialize glew correctly under core profile context.
|
||||
glewExperimental = true;
|
||||
if (GLenum r = glewInit() != GLEW_OK) {
|
||||
std::cout << "Failed to initialize glew. Error = "
|
||||
<< glewGetErrorString(r) << "\n";
|
||||
exit(1);
|
||||
}
|
||||
// clear GL errors generated during glewInit()
|
||||
glGetError();
|
||||
#endif
|
||||
GLUtils::InitializeGL();
|
||||
GLUtils::PrintGLVersion();
|
||||
|
||||
// by default, test all available kernels
|
||||
if (kernels.empty()) {
|
||||
@ -561,12 +552,12 @@ int main(int argc, char ** argv) {
|
||||
kernels.push_back("CL");
|
||||
#endif
|
||||
#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
|
||||
if (GLEW_VERSION_4_1) { // check availability in current context
|
||||
if (OSD_OPENGL_HAS(VERSION_4_1)) {
|
||||
kernels.push_back("XFB");
|
||||
}
|
||||
#endif
|
||||
#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
|
||||
if (GLEW_VERSION_4_3) { // check availability in current context
|
||||
if (OSD_OPENGL_HAS(VERSION_4_3)) {
|
||||
kernels.push_back("GLSL");
|
||||
}
|
||||
#endif
|
||||
|
@ -29,19 +29,18 @@ set(SHADER_FILES
|
||||
paintShader.glsl
|
||||
)
|
||||
|
||||
list(APPEND PLATFORM_LIBRARIES
|
||||
"${OSD_LINK_TARGET}"
|
||||
"${OPENGL_LIBRARY}"
|
||||
"${GLEW_LIBRARY}"
|
||||
"${GLFW_LIBRARIES}"
|
||||
)
|
||||
|
||||
include_directories(
|
||||
"${OPENSUBDIV_INCLUDE_DIR}"
|
||||
"${GLEW_INCLUDE_DIR}"
|
||||
"${OPENGL_LOADER_INCLUDE_DIRS}"
|
||||
"${GLFW_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
list(APPEND PLATFORM_LIBRARIES
|
||||
"${OSD_LINK_TARGET}"
|
||||
"${OPENGL_LOADER_LIBRARIES}"
|
||||
"${GLFW_LIBRARIES}"
|
||||
)
|
||||
|
||||
if( OPENCL_FOUND )
|
||||
include_directories("${OPENCL_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
@ -22,8 +22,7 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
|
||||
#include "../common/glUtils.h"
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
GLFWwindow* g_window=0;
|
||||
@ -43,6 +42,7 @@ OpenSubdiv::Osd::GLMeshInterface *g_mesh;
|
||||
#include "../common/simple_math.h"
|
||||
#include "../common/glHud.h"
|
||||
#include "../common/glShaderCache.h"
|
||||
#include "../common/glUtils.h"
|
||||
|
||||
#include "init_shapes.h"
|
||||
|
||||
@ -1138,27 +1138,16 @@ int main(int argc, char ** argv) {
|
||||
glfwTerminate();
|
||||
return 1;
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent(g_window);
|
||||
|
||||
GLUtils::InitializeGL();
|
||||
GLUtils::PrintGLVersion();
|
||||
|
||||
glfwSetKeyCallback(g_window, keyboard);
|
||||
glfwSetCursorPosCallback(g_window, motion);
|
||||
glfwSetMouseButtonCallback(g_window, mouse);
|
||||
glfwSetWindowCloseCallback(g_window, windowClose);
|
||||
GLUtils::PrintGLVersion();
|
||||
|
||||
#if defined(OSD_USES_GLEW)
|
||||
#ifdef CORE_PROFILE
|
||||
// this is the only way to initialize glew correctly under core profile context.
|
||||
glewExperimental = true;
|
||||
#endif
|
||||
if (GLenum r = glewInit() != GLEW_OK) {
|
||||
printf("Failed to initialize glew. Error = %s\n", glewGetErrorString(r));
|
||||
exit(1);
|
||||
}
|
||||
#ifdef CORE_PROFILE
|
||||
// clear GL errors which were generated during glewInit()
|
||||
glGetError();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
initGL();
|
||||
|
||||
|
@ -30,36 +30,29 @@ set(SHADER_FILES
|
||||
skyshader.glsl
|
||||
)
|
||||
|
||||
include_directories(
|
||||
"${OPENSUBDIV_INCLUDE_DIR}"
|
||||
"${OPENGL_LOADER_INCLUDE_DIRS}"
|
||||
"${GLFW_INCLUDE_DIR}"
|
||||
"${PTEX_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
list(APPEND PLATFORM_LIBRARIES
|
||||
"${OSD_LINK_TARGET}"
|
||||
"${OPENGL_LIBRARY}"
|
||||
"${OPENGL_LOADER_LIBRARIES}"
|
||||
"${GLFW_LIBRARIES}"
|
||||
"${PTEX_LIBRARY}"
|
||||
"${ZLIB_LIBRARY}"
|
||||
)
|
||||
|
||||
include_directories(
|
||||
"${OPENSUBDIV_INCLUDE_DIR}"
|
||||
"${GLFW_INCLUDE_DIR}"
|
||||
"${PTEX_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
if ( GLEW_FOUND )
|
||||
include_directories("${GLEW_INCLUDE_DIR}")
|
||||
list(APPEND PLATFORM_LIBRARIES "${GLEW_LIBRARY}")
|
||||
endif()
|
||||
|
||||
if( OPENCL_FOUND )
|
||||
include_directories("${OPENCL_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
osd_stringify("${SHADER_FILES}" INC_FILES)
|
||||
|
||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
osd_add_glfw_executable(glPtexViewer "examples"
|
||||
glPtexViewer.cpp
|
||||
"${SHADER_FILES}"
|
||||
|
@ -22,21 +22,7 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if defined(OSD_USES_GLEW)
|
||||
#include <GL/glew.h>
|
||||
#else
|
||||
#include <OpenGL/gl3.h>
|
||||
#endif
|
||||
#define GLFW_INCLUDE_GL3
|
||||
#define GLFW_NO_GLU
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#include <GL/glew.h>
|
||||
#if defined(WIN32)
|
||||
#include <GL/wglew.h>
|
||||
#endif
|
||||
#endif
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
GLFWwindow* g_window = 0;
|
||||
@ -99,10 +85,10 @@ OpenSubdiv::Osd::GLMeshInterface *g_mesh;
|
||||
#include "../common/simple_math.h"
|
||||
#include "../common/glControlMeshDisplay.h"
|
||||
#include "../common/glHud.h"
|
||||
#include "../common/glUtils.h"
|
||||
#include "../common/hdr_reader.h"
|
||||
#include "../common/glPtexMipmapTexture.h"
|
||||
#include "../common/glShaderCache.h"
|
||||
#include "../common/glUtils.h"
|
||||
|
||||
#include <opensubdiv/osd/glslPatchShaderSource.h>
|
||||
static const char *g_defaultShaderSource =
|
||||
@ -1819,27 +1805,14 @@ int main(int argc, char ** argv) {
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent(g_window);
|
||||
|
||||
GLUtils::InitializeGL();
|
||||
GLUtils::PrintGLVersion();
|
||||
|
||||
glfwSetKeyCallback(g_window, keyboard);
|
||||
glfwSetCursorPosCallback(g_window, motion);
|
||||
glfwSetMouseButtonCallback(g_window, mouse);
|
||||
|
||||
#if defined(OSD_USES_GLEW)
|
||||
#ifdef CORE_PROFILE
|
||||
// this is the only way to initialize glew correctly under core profile context.
|
||||
glewExperimental = true;
|
||||
#endif
|
||||
if (GLenum r = glewInit() != GLEW_OK) {
|
||||
printf("Failed to initialize glew. error = %d\n", r);
|
||||
exit(1);
|
||||
}
|
||||
#ifdef CORE_PROFILE
|
||||
// clear GL errors which was generated during glewInit()
|
||||
glGetError();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
initGL();
|
||||
|
||||
// accommodate high DPI displays (e.g. mac retina displays)
|
||||
|
@ -28,28 +28,22 @@ set(SHADER_FILES
|
||||
shader.glsl
|
||||
)
|
||||
|
||||
list(APPEND PLATFORM_LIBRARIES
|
||||
"${OSD_LINK_TARGET}"
|
||||
"${OPENGL_LIBRARY}"
|
||||
"${GLFW_LIBRARIES}"
|
||||
)
|
||||
|
||||
include_directories(
|
||||
"${OPENSUBDIV_INCLUDE_DIR}"
|
||||
"${OPENGL_LOADER_INCLUDE_DIRS}"
|
||||
"${GLFW_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
if ( GLEW_FOUND )
|
||||
include_directories("${GLEW_INCLUDE_DIR}")
|
||||
list(APPEND PLATFORM_LIBRARIES "${GLEW_LIBRARY}")
|
||||
endif()
|
||||
list(APPEND PLATFORM_LIBRARIES
|
||||
"${OSD_LINK_TARGET}"
|
||||
"${OPENGL_LOADER_LIBRARIES}"
|
||||
"${GLFW_LIBRARIES}"
|
||||
)
|
||||
|
||||
if( OPENCL_FOUND )
|
||||
include_directories("${OPENCL_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
osd_stringify("${SHADER_FILES}" INC_FILES)
|
||||
|
||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
@ -22,7 +22,7 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "../common/glUtils.h"
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
GLFWwindow* g_window=0;
|
||||
@ -76,6 +76,7 @@ GLFWmonitor* g_primary=0;
|
||||
#include "../common/simple_math.h"
|
||||
#include "../common/glHud.h"
|
||||
#include "../common/glShaderCache.h"
|
||||
#include "../common/glUtils.h"
|
||||
|
||||
#include <opensubdiv/osd/glslPatchShaderSource.h>
|
||||
static const char *shaderSource =
|
||||
@ -1090,8 +1091,7 @@ initHUD() {
|
||||
g_hud.AddPullDownButton(compute_pulldown, "GLSL TransformFeedback", kGLSL);
|
||||
#endif
|
||||
#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
|
||||
// Must also check at run time for OpenGL 4.3
|
||||
if (GLEW_VERSION_4_3) {
|
||||
if (GLUtils::GL_ARBComputeShaderOrGL_VERSION_4_3()) {
|
||||
g_hud.AddPullDownButton(compute_pulldown, "GLSL Compute", kGLSLCompute);
|
||||
}
|
||||
#endif
|
||||
@ -1195,6 +1195,8 @@ int main(int argc, char ** argv) {
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent(g_window);
|
||||
|
||||
GLUtils::InitializeGL();
|
||||
GLUtils::PrintGLVersion();
|
||||
|
||||
// accommodate high DPI displays (e.g. mac retina displays)
|
||||
@ -1206,21 +1208,6 @@ int main(int argc, char ** argv) {
|
||||
glfwSetMouseButtonCallback(g_window, mouse);
|
||||
glfwSetWindowCloseCallback(g_window, windowClose);
|
||||
|
||||
#if defined(OSD_USES_GLEW)
|
||||
#ifdef CORE_PROFILE
|
||||
// this is the only way to initialize glew correctly under core profile context.
|
||||
glewExperimental = true;
|
||||
#endif
|
||||
if (GLenum r = glewInit() != GLEW_OK) {
|
||||
printf("Failed to initialize glew. Error = %s\n", glewGetErrorString(r));
|
||||
exit(1);
|
||||
}
|
||||
#ifdef CORE_PROFILE
|
||||
// clear GL errors which were generated during glewInit()
|
||||
glGetError();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
initShapes();
|
||||
initGL();
|
||||
|
||||
|
@ -22,12 +22,17 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include "sceneBase.h"
|
||||
#include <limits>
|
||||
|
||||
#include "../../regression/common/far_utils.h"
|
||||
|
||||
#include <opensubdiv/far/patchTableFactory.h>
|
||||
#include <opensubdiv/far/stencilTableFactory.h>
|
||||
|
||||
#include <limits>
|
||||
|
||||
using namespace OpenSubdiv;
|
||||
|
||||
|
||||
|
@ -25,10 +25,11 @@
|
||||
#ifndef OPENSUBDIV_EXAMPLES_GL_SHARE_TOPOLOGY_SCENE_BASE_H
|
||||
#define OPENSUBDIV_EXAMPLES_GL_SHARE_TOPOLOGY_SCENE_BASE_H
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <opensubdiv/far/patchDescriptor.h>
|
||||
#include <opensubdiv/far/patchTable.h>
|
||||
#include <opensubdiv/osd/bufferDescriptor.h>
|
||||
#include <opensubdiv/osd/opengl.h>
|
||||
|
||||
struct Shape;
|
||||
|
||||
|
@ -25,9 +25,11 @@
|
||||
#ifndef OPENSUBDIV_EXAMPLES_GL_SHARE_TOPOLOGY_VBO_H
|
||||
#define OPENSUBDIV_EXAMPLES_GL_SHARE_TOPOLOGY_VBO_H
|
||||
|
||||
#include <vector>
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <opensubdiv/osd/bufferDescriptor.h>
|
||||
#include <opensubdiv/osd/opengl.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
template <class VERTEX_BUFFER, class DEVICE_CONTEXT>
|
||||
class VBO {
|
||||
|
@ -24,20 +24,17 @@
|
||||
|
||||
# *** glStencilViewer ***
|
||||
|
||||
list(APPEND PLATFORM_LIBRARIES
|
||||
"${OSD_LINK_TARGET}"
|
||||
"${GLFW_LIBRARIES}"
|
||||
)
|
||||
|
||||
include_directories(
|
||||
"${OPENSUBDIV_INCLUDE_DIR}"
|
||||
"${OPENGL_LOADER_INCLUDE_DIRS}"
|
||||
"${GLFW_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
if ( GLEW_FOUND )
|
||||
include_directories("${GLEW_INCLUDE_DIR}")
|
||||
list(APPEND PLATFORM_LIBRARIES "${GLEW_LIBRARY}")
|
||||
endif()
|
||||
list(APPEND PLATFORM_LIBRARIES
|
||||
"${OSD_LINK_TARGET}"
|
||||
"${OPENGL_LOADER_LIBRARIES}"
|
||||
"${GLFW_LIBRARIES}"
|
||||
)
|
||||
|
||||
if( OPENCL_FOUND )
|
||||
include_directories("${OPENCL_INCLUDE_DIRS}")
|
||||
|
@ -22,7 +22,7 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "../common/glUtils.h"
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
GLFWwindow* g_window=0;
|
||||
@ -35,6 +35,7 @@ GLFWmonitor* g_primary=0;
|
||||
#include "../common/simple_math.h"
|
||||
#include "../common/glHud.h"
|
||||
#include "../common/glControlMeshDisplay.h"
|
||||
#include "../common/glUtils.h"
|
||||
|
||||
#include <opensubdiv/far/patchTableFactory.h>
|
||||
#include <opensubdiv/far/ptexIndices.h>
|
||||
@ -1116,6 +1117,8 @@ int main(int argc, char **argv) {
|
||||
return 1;
|
||||
}
|
||||
glfwMakeContextCurrent(g_window);
|
||||
|
||||
GLUtils::InitializeGL();
|
||||
GLUtils::PrintGLVersion();
|
||||
|
||||
// accommodate high DPI displays (e.g. mac retina displays)
|
||||
@ -1127,21 +1130,6 @@ int main(int argc, char **argv) {
|
||||
glfwSetMouseButtonCallback(g_window, mouse);
|
||||
glfwSetWindowCloseCallback(g_window, windowClose);
|
||||
|
||||
#if defined(OSD_USES_GLEW)
|
||||
#ifdef CORE_PROFILE
|
||||
// this is the only way to initialize glew correctly under core profile context.
|
||||
glewExperimental = true;
|
||||
#endif
|
||||
if (GLenum r = glewInit() != GLEW_OK) {
|
||||
printf("Failed to initialize glew. Error = %s\n", glewGetErrorString(r));
|
||||
exit(1);
|
||||
}
|
||||
#ifdef CORE_PROFILE
|
||||
// clear GL errors which were generated during glewInit()
|
||||
glGetError();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
initGL();
|
||||
linkDefaultPrograms();
|
||||
|
||||
|
@ -31,20 +31,16 @@ set(SHADER_FILES
|
||||
|
||||
include_directories(
|
||||
"${OPENSUBDIV_INCLUDE_DIR}"
|
||||
"${OPENGL_LOADER_INCLUDE_DIRS}"
|
||||
"${GLFW_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
list(APPEND PLATFORM_LIBRARIES
|
||||
"${OSD_LINK_TARGET}"
|
||||
"${OPENGL_LIBRARY}"
|
||||
"${OPENGL_LOADER_LIBRARIES}"
|
||||
"${GLFW_LIBRARIES}"
|
||||
)
|
||||
|
||||
if ( GLEW_FOUND )
|
||||
include_directories("${GLEW_INCLUDE_DIR}")
|
||||
list(APPEND PLATFORM_LIBRARIES "${GLEW_LIBRARY}")
|
||||
endif()
|
||||
|
||||
if( OPENCL_FOUND )
|
||||
include_directories("${OPENCL_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
@ -22,7 +22,7 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "../common/glUtils.h"
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
GLFWwindow* g_window=0;
|
||||
@ -79,49 +79,29 @@ bool g_legacyGregoryEnabled = false;
|
||||
#include "../common/glUtils.h"
|
||||
#include "../common/glControlMeshDisplay.h"
|
||||
#include "../common/glShaderCache.h"
|
||||
#include "../common/glUtils.h"
|
||||
#include "../common/objAnim.h"
|
||||
#include "../common/simple_math.h"
|
||||
#include "../common/stopwatch.h"
|
||||
#include "../common/viewerArgsUtils.h"
|
||||
#include <opensubdiv/osd/glslPatchShaderSource.h>
|
||||
|
||||
|
||||
|
||||
/* Function to get the correct shader file based on the opengl version.
|
||||
The implementation varies depending if glew is available or not. In case it
|
||||
is available the capabilities are queried during execution and the correct
|
||||
source is returned. If glew is not available the version is determined at
|
||||
compile time */
|
||||
static const char *shaderSource(){
|
||||
#if ! defined(OSD_USES_GLEW)
|
||||
|
||||
static const char *res =
|
||||
#if defined(GL_ARB_tessellation_shader) || defined(GL_VERSION_4_0)
|
||||
static const char *res = NULL;
|
||||
if (!res) {
|
||||
static const char *gen =
|
||||
#include "shader.gen.h"
|
||||
#else
|
||||
;
|
||||
static const char *gen3 =
|
||||
#include "shader_gl3.gen.h"
|
||||
#endif
|
||||
;
|
||||
#else
|
||||
static const char *res = NULL;
|
||||
if (!res){
|
||||
static const char *gen =
|
||||
#include "shader.gen.h"
|
||||
;
|
||||
static const char *gen3 =
|
||||
#include "shader_gl3.gen.h"
|
||||
;
|
||||
//Determine the shader file to use. Since some opengl implementations
|
||||
//define that an extension is available but not an implementation
|
||||
//for it you cannot trust in the glew header definitions to know that is
|
||||
//available, but you need to query it during runtime.
|
||||
if (GLUtils::SupportsAdaptiveTessellation())
|
||||
res = gen;
|
||||
else
|
||||
res = gen3;
|
||||
;
|
||||
if (GLUtils::SupportsAdaptiveTessellation()) {
|
||||
res = gen;
|
||||
} else {
|
||||
res = gen3;
|
||||
}
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
#include <cfloat>
|
||||
@ -1776,6 +1756,8 @@ int main(int argc, char ** argv) {
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent(g_window);
|
||||
|
||||
GLUtils::InitializeGL();
|
||||
GLUtils::PrintGLVersion();
|
||||
|
||||
// accommodate high DPI displays (e.g. mac retina displays)
|
||||
@ -1787,21 +1769,6 @@ int main(int argc, char ** argv) {
|
||||
glfwSetMouseButtonCallback(g_window, mouse);
|
||||
glfwSetWindowCloseCallback(g_window, windowClose);
|
||||
|
||||
#if defined(OSD_USES_GLEW)
|
||||
#ifdef CORE_PROFILE
|
||||
// this is the only way to initialize glew correctly under core profile context.
|
||||
glewExperimental = true;
|
||||
#endif
|
||||
if (GLenum r = glewInit() != GLEW_OK) {
|
||||
printf("Failed to initialize glew. Error = %s\n", glewGetErrorString(r));
|
||||
exit(1);
|
||||
}
|
||||
#ifdef CORE_PROFILE
|
||||
// clear GL errors which were generated during glewInit()
|
||||
glGetError();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// activate feature adaptive tessellation if OSD supports it
|
||||
if (g_adaptive) {
|
||||
g_adaptive = GLUtils::SupportsAdaptiveTessellation();
|
||||
|
49
glLoader/CMakeLists.txt
Normal file
49
glLoader/CMakeLists.txt
Normal file
@ -0,0 +1,49 @@
|
||||
#
|
||||
# Copyright 2020 Pixar
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
# with the following modification; you may not use this file except in
|
||||
# compliance with the Apache License and the following modification to it:
|
||||
# Section 6. Trademarks. is deleted and replaced with:
|
||||
#
|
||||
# 6. Trademarks. This License does not grant permission to use the trade
|
||||
# names, trademarks, service marks, or product names of the Licensor
|
||||
# and its affiliates, except as required to comply with Section 4(c) of
|
||||
# the License and to reproduce the content of the NOTICE file.
|
||||
#
|
||||
# You may obtain a copy of the Apache License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the Apache License with the above modification is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the Apache License for the specific
|
||||
# language governing permissions and limitations under the Apache License.
|
||||
#
|
||||
|
||||
if( APPLE OR UNIX )
|
||||
add_definitions(-fPIC)
|
||||
endif()
|
||||
|
||||
list(APPEND GLLOADER_SOURCE_FILES
|
||||
glLoader.cpp
|
||||
)
|
||||
|
||||
list(APPEND GLLOADER_HEADER_FILES
|
||||
glLoader.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
"${OPENGL_LOADER_INCLUDE_DIRS}"
|
||||
)
|
||||
|
||||
list(APPEND PLATFORM_LIBRARIES
|
||||
"${OPENGL_LOADER_LIBRARIES}"
|
||||
)
|
||||
|
||||
add_library(glLoader
|
||||
STATIC
|
||||
${GLLOADER_SOURCE_FILES}
|
||||
${GLLOADER_HEADER_FILES}
|
||||
)
|
70
glLoader/glLoader.cpp
Normal file
70
glLoader/glLoader.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
//
|
||||
// Copyright 2020 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
namespace OpenSubdiv {
|
||||
namespace internal {
|
||||
namespace GLLoader {
|
||||
|
||||
|
||||
bool
|
||||
applicationInitializeGL()
|
||||
{
|
||||
#if defined(OSD_USES_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()
|
||||
{
|
||||
// do nothing
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace GLLoader
|
||||
} // namespace internal
|
||||
} // namespace OpenSubdiv
|
187
glLoader/glLoader.h
Normal file
187
glLoader/glLoader.h
Normal file
@ -0,0 +1,187 @@
|
||||
//
|
||||
// Copyright 2020 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#ifndef OPENSUBDIV3_GLLOADER_H
|
||||
#define OPENSUBDIV3_GLLOADER_H
|
||||
|
||||
/// OpenGL Loading Library Support
|
||||
///
|
||||
/// An OpenGL loading library is required in order to load extended GL API
|
||||
/// function entry points at run-time and to define types, enum values,
|
||||
/// and function prototypes needed at compile-time.
|
||||
///
|
||||
/// To use:
|
||||
/// - Include "glloader.h"
|
||||
///
|
||||
/// - Initialize from example applications or from the library by calling;
|
||||
///
|
||||
/// internal::GLLoader::applicationInitializeGL();
|
||||
/// -or-
|
||||
/// internal::GLLoader::libraryInitializeGL();
|
||||
///
|
||||
/// There are distinct compile-time and run-time requirements for developing
|
||||
/// OpenGL software which will build and run in a variety of situations.
|
||||
///
|
||||
/// 1) Compile-time definitions of core types
|
||||
///
|
||||
/// These are the core data types used as the argument and return value types
|
||||
/// of GL API functions. In this implementation, they are defined in terms
|
||||
/// of the types defined by Khronos Group in "khrplatform.h"
|
||||
///
|
||||
/// These types are defined in the global namespace.
|
||||
///
|
||||
/// 2) Compile-time definitions of enum values
|
||||
///
|
||||
/// These are GLenum data values used by the GL API. They are implemented
|
||||
/// as preprocessor definitions, e.g.
|
||||
///
|
||||
/// #define GL_UNIFORM_BUFFER 0x8A0F
|
||||
///
|
||||
/// These preprocessor symbols are defined in the global namespace.
|
||||
///
|
||||
/// 3) Compile-time definitions for versions and extensions
|
||||
///
|
||||
/// The GL API and extension specifications specify standard preprocessor
|
||||
/// symbols which can be tested at compile-time to protect sections of source
|
||||
/// code which require a specific version or extension, e.g.
|
||||
///
|
||||
/// #if defined(GL_VERSION_4_0)
|
||||
/// // ... GL_VERSION_4_0 specific code
|
||||
/// #endif
|
||||
///
|
||||
/// #if defined(GL_ARB_tessellation_shader)
|
||||
/// // ... ARB_tessellation_shader specific code
|
||||
/// #endif
|
||||
///
|
||||
/// These preprocessor symbols are defined in the global namespace.
|
||||
///
|
||||
/// 4) Compile-time declarations of function prototypes
|
||||
///
|
||||
/// Each GL API function has a typedef for the function prototype and
|
||||
/// a function pointer (initialized to nullptr) which implements the
|
||||
/// function, e.g.
|
||||
///
|
||||
/// typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEPROC)(
|
||||
/// GLenum target, GLuint index, GLuint buffer);
|
||||
/// PFNGLBINDBUFFERBASEPROC glBindBufferBase;
|
||||
///
|
||||
/// These types and function pointers are defined in an internal namespace.
|
||||
///
|
||||
/// 5) Run-time loading of supported functions
|
||||
///
|
||||
/// Because a GL program may be compiled and run in different environments,
|
||||
/// GL API functions must be loaded dynamically at run time. This is taken
|
||||
/// care of by executing the low-level OpenGL API loader, e.g.
|
||||
///
|
||||
/// bool internal::GLLoader::libraryInitializeGL() {
|
||||
/// ...
|
||||
/// glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)
|
||||
/// loadFunction("glBindBufferBase");
|
||||
/// ...
|
||||
/// }
|
||||
///
|
||||
/// The loaded function pointers are defined in an internal namespace.
|
||||
///
|
||||
/// 6) Run-time queries for supported versions and extensions
|
||||
///
|
||||
/// Finally, a GL program should check for the availability of required
|
||||
/// features at run-time. Typically, this requires inspection of the
|
||||
/// strings or string lists returned by calling the glGetString functions.
|
||||
///
|
||||
/// This loader library processes these queries when loading the GL API
|
||||
/// and saves the results in boolean variables which follow a naming
|
||||
/// convention similar to the preprocessor symbols described above.
|
||||
///
|
||||
/// This loader further provides macros which wrap evaluation of these
|
||||
/// boolean variables in order to help isolate source code from details
|
||||
/// of the specific naming (prefixes, etc) of these variables, e.g.
|
||||
///
|
||||
/// #if defined(GL_VERSION_4_0)
|
||||
/// if (OSD_OPENGL_HAS(VERSION_4_0)) {
|
||||
/// // ... GL_VERSION_4_0 specific code
|
||||
/// }
|
||||
/// #endif
|
||||
///
|
||||
/// #if defined(GL_ARB_tessellation_shader)
|
||||
/// if (OSD_OPENGL_HAS(ARB_tessellation_shader)) {
|
||||
/// // ... ARB_tessellation_shader specific code
|
||||
/// }
|
||||
/// #endif
|
||||
///
|
||||
/// The boolean variables described here are defined in an internal namespace.
|
||||
///
|
||||
|
||||
#if 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 {
|
||||
namespace internal {
|
||||
namespace GLLoader {
|
||||
|
||||
|
||||
// Initialize OpenGL loader library from the application. This is used
|
||||
// only by examples and tests in this code base.
|
||||
extern bool applicationInitializeGL();
|
||||
|
||||
// Initialize OpenGL loader library from the library. This does nothing
|
||||
// for external loader libraries like GLEW, since in that case, it is
|
||||
// the application's responsibility to initialize the loader library.
|
||||
extern bool libraryInitializeGL();
|
||||
|
||||
|
||||
} // namespace GLLoader
|
||||
} // namespace internal
|
||||
} // namespace OpenSubdiv
|
||||
|
||||
|
||||
#endif // OPENSUBDIV3_GLLOADER_H
|
@ -60,14 +60,9 @@ if (NOT NO_LIB)
|
||||
endif()
|
||||
|
||||
if( OPENGL_FOUND )
|
||||
if (NOT "${OPENGL_INCLUDE_DIR}" STREQUAL "")
|
||||
include_directories("${OPENGL_INCLUDE_DIR}")
|
||||
endif()
|
||||
if (GLEW_FOUND)
|
||||
include_directories("${GLEW_INCLUDE_DIR}")
|
||||
endif()
|
||||
include_directories(${OPENGL_LOADER_INCLUDE_DIRS})
|
||||
list(APPEND PLATFORM_GPU_LIBRARIES
|
||||
${OPENGL_LIBRARY}
|
||||
${OPENGL_LOADER_LIBRARIES}
|
||||
)
|
||||
elseif( OPENGLES_FOUND )
|
||||
include_directories("${OPENGLES_INCLUDE_DIR}")
|
||||
@ -76,12 +71,6 @@ if (NOT NO_LIB)
|
||||
)
|
||||
endif()
|
||||
|
||||
if( OPENGL_4_2_FOUND OR OPENGL_4_3_FOUND)
|
||||
list(APPEND PLATFORM_GPU_LIBRARIES
|
||||
${GLEW_LIBRARY}
|
||||
)
|
||||
endif()
|
||||
|
||||
if( DXSDK_FOUND )
|
||||
include_directories( "${DXSDK_INCLUDE_DIR}" )
|
||||
list(APPEND PLATFORM_GPU_LIBRARIES
|
||||
|
@ -160,7 +160,7 @@ if( OPENGL_4_2_FOUND )
|
||||
glslXFBKernel.glsl
|
||||
)
|
||||
list(APPEND PLATFORM_GPU_LIBRARIES
|
||||
${GLEW_LIBRARY}
|
||||
${OPENGL_LOADER_LIBRARIES}
|
||||
)
|
||||
endif()
|
||||
|
||||
@ -183,7 +183,7 @@ if( OPENGL_4_3_FOUND )
|
||||
glslComputeKernel.glsl
|
||||
)
|
||||
list(APPEND PLATFORM_GPU_LIBRARIES
|
||||
${GLEW_LIBRARY}
|
||||
${OPENGL_LOADER_LIBRARIES}
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -22,12 +22,12 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include "../osd/clGLVertexBuffer.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "../osd/opengl.h"
|
||||
|
||||
namespace OpenSubdiv {
|
||||
namespace OPENSUBDIV_VERSION {
|
||||
|
||||
|
@ -22,11 +22,12 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include "../osd/cpuGLVertexBuffer.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "../osd/opengl.h"
|
||||
|
||||
namespace OpenSubdiv {
|
||||
namespace OPENSUBDIV_VERSION {
|
||||
|
@ -22,8 +22,9 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include "../osd/cudaGLVertexBuffer.h"
|
||||
#include "../osd/opengl.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#include <cuda_runtime.h>
|
||||
|
@ -22,16 +22,19 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include "../osd/glComputeEvaluator.h"
|
||||
#include "../osd/glslPatchShaderSource.h"
|
||||
|
||||
#include "../far/error.h"
|
||||
#include "../far/stencilTable.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../far/error.h"
|
||||
#include "../far/stencilTable.h"
|
||||
|
||||
namespace OpenSubdiv {
|
||||
namespace OPENSUBDIV_VERSION {
|
||||
|
@ -22,6 +22,8 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include "../osd/glLegacyGregoryPatchTable.h"
|
||||
|
||||
namespace OpenSubdiv {
|
||||
|
@ -22,10 +22,11 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include "../osd/glPatchTable.h"
|
||||
|
||||
#include "../far/patchTable.h"
|
||||
#include "../osd/opengl.h"
|
||||
#include "../osd/cpuPatchTable.h"
|
||||
|
||||
namespace OpenSubdiv {
|
||||
|
@ -22,9 +22,9 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "../osd/glVertexBuffer.h"
|
||||
#include "glLoader.h"
|
||||
|
||||
#include "../osd/opengl.h"
|
||||
#include "../osd/glVertexBuffer.h"
|
||||
|
||||
namespace OpenSubdiv {
|
||||
namespace OPENSUBDIV_VERSION {
|
||||
|
@ -22,6 +22,8 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "glLoader.h"
|
||||
|
||||
#include "../osd/glXFBEvaluator.h"
|
||||
#include "../osd/glslPatchShaderSource.h"
|
||||
|
||||
|
@ -32,7 +32,7 @@ if (NOT NO_REGRESSION)
|
||||
|
||||
add_subdirectory(far_perf)
|
||||
|
||||
if(OPENGL_FOUND AND (GLEW_FOUND OR APPLE) AND GLFW_FOUND)
|
||||
if(OPENGL_FOUND AND GLFW_FOUND)
|
||||
add_subdirectory(osd_regression)
|
||||
endif()
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
include_directories(
|
||||
"${OPENSUBDIV_INCLUDE_DIR}"
|
||||
"${OPENGL_LOADER_INCLUDE_DIRS}"
|
||||
"${GLFW_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
@ -33,15 +34,10 @@ set(SOURCE_FILES
|
||||
|
||||
set(PLATFORM_LIBRARIES
|
||||
"${OSD_LINK_TARGET}"
|
||||
"${OPENGL_LIBRARY}"
|
||||
"${OPENGL_LOADER_LIBRARIES}"
|
||||
"${GLFW_LIBRARIES}"
|
||||
)
|
||||
|
||||
if ( GLEW_FOUND )
|
||||
include_directories("${GLEW_INCLUDE_DIR}")
|
||||
list(APPEND PLATFORM_LIBRARIES "${GLEW_LIBRARY}")
|
||||
endif()
|
||||
|
||||
osd_add_executable(osd_regression "regression"
|
||||
"${SOURCE_FILES}"
|
||||
$<TARGET_OBJECTS:regression_common_obj>
|
||||
@ -53,7 +49,6 @@ target_link_libraries(osd_regression
|
||||
|
||||
install(TARGETS osd_regression DESTINATION "${CMAKE_BINDIR_BASE}")
|
||||
|
||||
|
||||
if (NOT NO_GLTESTS)
|
||||
add_test(osd_regression ${EXECUTABLE_OUTPUT_PATH}/osd_regression)
|
||||
endif()
|
||||
|
@ -22,23 +22,7 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if defined(OSD_USES_GLEW)
|
||||
#include <GL/glew.h>
|
||||
#else
|
||||
#include <OpenGL/gl3.h>
|
||||
#endif
|
||||
#define GLFW_INCLUDE_GL3
|
||||
#define GLFW_NO_GLU
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#include <GL/glew.h>
|
||||
#if defined(_WIN32)
|
||||
// XXX Must include windows.h here or GLFW pollutes the global namespace
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#endif
|
||||
#include "glLoader.h"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
GLFWwindow* g_window=0;
|
||||
@ -657,12 +641,7 @@ main(int argc, char ** argv) {
|
||||
}
|
||||
glfwMakeContextCurrent(g_window);
|
||||
|
||||
#if defined(OSD_USES_GLEW)
|
||||
if (GLenum r = glewInit() != GLEW_OK) {
|
||||
printf("Failed to initialize glew. error = %d\n", r);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
OpenSubdiv::internal::GLLoader::applicationInitializeGL();
|
||||
|
||||
printf("precision : %f\n",PRECISION);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user