diff --git a/examples/common/CMakeLists.txt b/examples/common/CMakeLists.txt index 68ad256c..181c294b 100644 --- a/examples/common/CMakeLists.txt +++ b/examples/common/CMakeLists.txt @@ -52,17 +52,16 @@ set(EXAMPLES_COMMON_HEADER_FILES if( OPENGL_FOUND AND (GLEW_FOUND AND GLFW_FOUND) OR (APPLE AND GLFW_FOUND)) list(APPEND EXAMPLES_COMMON_SOURCE_FILES - # we will rename gl_xxx to glXxx - gl_common.cpp - gl_framebuffer.cpp - gl_hud.cpp + glFramebuffer.cpp + glHud.cpp + glUtils.cpp glShaderCache.cpp ) list(APPEND EXAMPLES_COMMON_HEADER_FILES - gl_common.h - gl_framebuffer.h - gl_hud.h + glFramebuffer.h + glHud.h + glUtils.h glShaderCache.h ) @@ -80,12 +79,14 @@ endif() if(DXSDK_FOUND) list(APPEND EXAMPLES_COMMON_SOURCE_FILES - d3d11_hud.cpp + d3d11Hud.cpp + d3d11Utils.cpp d3d11ShaderCache.cpp ) list(APPEND EXAMPLES_COMMON_HEADER_FILES - d3d11_hud.h + d3d11Hud.h + d3d11Utils.h d3d11ShaderCache.h ) diff --git a/examples/common/d3d11_hud.cpp b/examples/common/d3d11Hud.cpp similarity index 95% rename from examples/common/d3d11_hud.cpp rename to examples/common/d3d11Hud.cpp index 984e0e87..64b648e6 100644 --- a/examples/common/d3d11_hud.cpp +++ b/examples/common/d3d11Hud.cpp @@ -26,8 +26,8 @@ #include #include #include -#include "d3d11_hud.h" -#include "d3d11_compile.h" +#include "d3d11Hud.h" +#include "d3d11Utils.h" #include "font_image.h" #include "../common/simple_math.h" @@ -137,8 +137,8 @@ D3D11hud::Init(int width, int height, int frameBufferWidth, int frameBufferHeigh ID3DBlob* pVSBlob; ID3DBlob* pPSBlob; - pVSBlob = d3d11CompileShader(s_VS, "vs_main", "vs_4_0"); - pPSBlob = d3d11CompileShader(s_PS, "ps_main", "ps_4_0"); + pVSBlob = D3D11Utils::CompileShader(s_VS, "vs_main", "vs_4_0"); + pPSBlob = D3D11Utils::CompileShader(s_PS, "ps_main", "ps_4_0"); assert(pVSBlob); assert(pPSBlob); diff --git a/examples/common/d3d11_hud.h b/examples/common/d3d11Hud.h similarity index 94% rename from examples/common/d3d11_hud.h rename to examples/common/d3d11Hud.h index 59f4adce..694b39e1 100644 --- a/examples/common/d3d11_hud.h +++ b/examples/common/d3d11Hud.h @@ -22,8 +22,8 @@ // language governing permissions and limitations under the Apache License. // -#ifndef D3D11_HUD_H -#define D3D11_HUD_H +#ifndef OPENSUBDIV_EXAMPLES_D3D11_HUD_H +#define OPENSUBDIV_EXAMPLES_D3D11_HUD_H #include #include "hud.h" @@ -64,4 +64,4 @@ private: int _staticVboCount; }; -#endif // D3D11_HUD_H +#endif // OPENSUBDIV_EXAMPLES_D3D11_HUD_H diff --git a/examples/common/d3d11_compile.h b/examples/common/d3d11Utils.cpp similarity index 91% rename from examples/common/d3d11_compile.h rename to examples/common/d3d11Utils.cpp index 2340a03b..6948a981 100644 --- a/examples/common/d3d11_compile.h +++ b/examples/common/d3d11Utils.cpp @@ -22,14 +22,13 @@ // language governing permissions and limitations under the Apache License. // -#ifndef D3D11_COMPILE_H -#define D3D11_COMPILE_H - +#include "d3d11Utils.h" #include -static ID3DBlob * -d3d11CompileShader(const char *src, const char *entry, const char *spec) -{ +namespace D3D11Utils { + +ID3DBlob * +CompileShader(const char *src, const char *entry, const char *spec) { DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS; #if defined(DEBUG) || defined(_DEBUG) dwShaderFlags |= D3DCOMPILE_DEBUG; @@ -52,4 +51,4 @@ d3d11CompileShader(const char *src, const char *entry, const char *spec) return pBlob; } -#endif // D3D11_COMPILE_H +} // D3D11Utils diff --git a/examples/common/gl_common.h b/examples/common/d3d11Utils.h similarity index 80% rename from examples/common/gl_common.h rename to examples/common/d3d11Utils.h index 3fc3dfea..98e0a64a 100644 --- a/examples/common/gl_common.h +++ b/examples/common/d3d11Utils.h @@ -22,17 +22,15 @@ // language governing permissions and limitations under the Apache License. // -#ifndef GL_COMMON_H -#define GL_COMMON_H +#ifndef OPENSUBDIV_EXAMPLES_D3D11_COMPILE_H +#define OPENSUBDIV_EXAMPLES_D3D11_COMPILE_H -#include +#include -#include -#include -#include +namespace D3D11Utils { -void checkGLErrors(std::string const & where = ""); +ID3DBlob *CompileShader(const char *src, const char *entry, const char *spec); -GLuint compileShader(GLenum shaderType, const char *source); +} -#endif // GL_FRAMEBUFFER_H +#endif // OPENSUBDIV_EXAMPLES_D3D11_COMPILE_H diff --git a/examples/common/gl_framebuffer.cpp b/examples/common/glFramebuffer.cpp similarity index 97% rename from examples/common/gl_framebuffer.cpp rename to examples/common/glFramebuffer.cpp index a75b6ce4..38bf1348 100644 --- a/examples/common/gl_framebuffer.cpp +++ b/examples/common/glFramebuffer.cpp @@ -22,9 +22,9 @@ // language governing permissions and limitations under the Apache License. // -#include "gl_framebuffer.h" -#include "gl_common.h" -#include "gl_hud.h" +#include "glFramebuffer.h" +#include "glUtils.h" +#include "glHud.h" #include #include @@ -111,7 +111,7 @@ GLFrameBuffer::Init(int width, int height) { } glBindTexture(GL_TEXTURE_2D, 0); - checkGLErrors("FrameBuffer::Init"); + GLUtils::CheckGLErrors("FrameBuffer::Init"); } void @@ -133,7 +133,7 @@ GLFrameBuffer::allocateTexture() { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - checkGLErrors("FrameBuffer::allocateTexture"); + GLUtils::CheckGLErrors("FrameBuffer::allocateTexture"); return texture; } @@ -148,10 +148,10 @@ GLFrameBuffer::compileProgram(char const * src, char const * defines) { fragDefineStr[] = "#define IMAGE_FRAGMENT_SHADER\n"; std::string vertexSrc = std::string(versionStr) + vtxDefineStr + (defines ? defines : "") + src; - GLuint vs = compileShader(GL_VERTEX_SHADER, vertexSrc.c_str()); + GLuint vs = GLUtils::CompileShader(GL_VERTEX_SHADER, vertexSrc.c_str()); std::string fragmentSrc = std::string(versionStr) + fragDefineStr + (defines ? defines : "") + src; - GLuint fs = compileShader(GL_FRAGMENT_SHADER, fragmentSrc.c_str()); + GLuint fs = GLUtils::CompileShader(GL_FRAGMENT_SHADER, fragmentSrc.c_str()); glAttachShader(program, vs); glAttachShader(program, fs); @@ -383,7 +383,7 @@ SSAOGLFrameBuffer::Init(int width, int height) { SetGamma(1.0f); } - checkGLErrors("SSAOGLFrameBuffer::Init"); + GLUtils::CheckGLErrors("SSAOGLFrameBuffer::Init"); } void diff --git a/examples/common/gl_framebuffer.h b/examples/common/glFramebuffer.h similarity index 95% rename from examples/common/gl_framebuffer.h rename to examples/common/glFramebuffer.h index b051019e..e7a9729b 100644 --- a/examples/common/gl_framebuffer.h +++ b/examples/common/glFramebuffer.h @@ -22,8 +22,8 @@ // language governing permissions and limitations under the Apache License. // -#ifndef GL_FRAMEBUFFER_H -#define GL_FRAMEBUFFER_H +#ifndef OPENSUBDIV_EXAMPLES_GL_FRAMEBUFFER_H +#define OPENSUBDIV_EXAMPLES_GL_FRAMEBUFFER_H #include @@ -131,4 +131,4 @@ private: _contrast; }; -#endif // GL_FRAMEBUFFER_H +#endif // OPENSUBDIV_EXAMPLES_GL_FRAMEBUFFER_H diff --git a/examples/common/gl_hud.cpp b/examples/common/glHud.cpp similarity index 97% rename from examples/common/gl_hud.cpp rename to examples/common/glHud.cpp index d24fd0e2..730cb02b 100644 --- a/examples/common/gl_hud.cpp +++ b/examples/common/glHud.cpp @@ -22,8 +22,8 @@ // language governing permissions and limitations under the Apache License. // -#include "gl_hud.h" -#include "gl_common.h" +#include "glHud.h" +#include "glUtils.h" #include "font_image.h" #include "simple_math.h" @@ -135,8 +135,8 @@ GLhud::Init(int width, int height, int frameBufferWidth, int frameBufferHeight) glGenVertexArrays(1, &_vao); glGenVertexArrays(1, &_staticVao); - GLuint vertexShader = compileShader(GL_VERTEX_SHADER, s_VS); - GLuint fragmentShader = compileShader(GL_FRAGMENT_SHADER, s_FS); + GLuint vertexShader = GLUtils::CompileShader(GL_VERTEX_SHADER, s_VS); + GLuint fragmentShader = GLUtils::CompileShader(GL_FRAGMENT_SHADER, s_FS); _program = glCreateProgram(); glAttachShader(_program, vertexShader); @@ -191,7 +191,7 @@ GLhud::Init(int width, int height, int frameBufferWidth, int frameBufferHeight) glBindBuffer(GL_ARRAY_BUFFER, 0); - checkGLErrors("GLhud::Init"); + GLUtils::CheckGLErrors("GLhud::Init"); } void diff --git a/examples/common/gl_hud.h b/examples/common/glHud.h similarity index 93% rename from examples/common/gl_hud.h rename to examples/common/glHud.h index 7ef08bb6..b18e0c17 100644 --- a/examples/common/gl_hud.h +++ b/examples/common/glHud.h @@ -22,14 +22,14 @@ // language governing permissions and limitations under the Apache License. // -#ifndef GL_HUD_H -#define GL_HUD_H +#ifndef OPENSUBDIV_EXAMPLES_GL_HUD_H +#define OPENSUBDIV_EXAMPLES_GL_HUD_H #include "hud.h" #include -#include "gl_framebuffer.h" +#include "glFramebuffer.h" class GLhud : public Hud { @@ -75,4 +75,4 @@ private: GLint _aPosition, _aColor, _aUV; }; -#endif // GL_HUD_H +#endif // OPENSUBDIV_EXAMPLES_GL_HUD_H diff --git a/examples/common/gl_common.cpp b/examples/common/glUtils.cpp similarity index 79% rename from examples/common/gl_common.cpp rename to examples/common/glUtils.cpp index c266742c..05670457 100644 --- a/examples/common/gl_common.cpp +++ b/examples/common/glUtils.cpp @@ -1,5 +1,5 @@ // -// Copyright 2013 Pixar +// Copyright 2015 Pixar // // Licensed under the Apache License, Version 2.0 (the "Apache License") // with the following modification; you may not use this file except in @@ -22,11 +22,12 @@ // language governing permissions and limitations under the Apache License. // -#include "gl_common.h" +#include "glUtils.h" + +namespace GLUtils { void -checkGLErrors(std::string const & where) { - +CheckGLErrors(std::string const & where) { GLuint err; while ((err = glGetError()) != GL_NO_ERROR) { std::cerr << "GL error: " @@ -36,8 +37,7 @@ checkGLErrors(std::string const & where) { } GLuint -compileShader(GLenum shaderType, const char *source) { - +CompileShader(GLenum shaderType, const char *source) { GLuint shader = glCreateShader(shaderType); glShaderSource(shader, 1, &source, NULL); glCompileShader(shader); @@ -54,4 +54,17 @@ compileShader(GLenum shaderType, const char *source) { return shader; } +bool +SupportsAdaptiveTessellation() { +#ifdef OSD_USES_GLEW + return (glewIsSupported("GL_ARB_tessellation_shader") == GL_TRUE); +#else +#if defined(GL_ARB_tessellation_shader) || defined(GL_VERSION_4_0) + return true; +#else + return false; +#endif +#endif +} +} // namesapce GLUtils diff --git a/examples/common/glUtils.h b/examples/common/glUtils.h new file mode 100644 index 00000000..62a7f516 --- /dev/null +++ b/examples/common/glUtils.h @@ -0,0 +1,46 @@ +// +// Copyright 2015 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 OPENSUBDIV_EXAMPLES_GL_UTILS_H +#define OPENSUBDIV_EXAMPLES_GL_UTILS_H + +#include + +#include +#include +#include + +namespace GLUtils { + +void CheckGLErrors(std::string const & where = ""); + +GLuint CompileShader(GLenum shaderType, const char *source); + +bool SupportsAdaptiveTessellation(); + +}; + +#endif // OPENSUBDIV_EXAMPLES_GL_UTILS_H + + diff --git a/examples/dxPtexViewer/dxPtexViewer.cpp b/examples/dxPtexViewer/dxPtexViewer.cpp index 4c7514de..5e2e77e9 100644 --- a/examples/dxPtexViewer/dxPtexViewer.cpp +++ b/examples/dxPtexViewer/dxPtexViewer.cpp @@ -61,7 +61,7 @@ OpenSubdiv::Osd::D3D11MeshInterface *g_mesh; #include #include "../common/stopwatch.h" #include "../common/simple_math.h" -#include "../common/d3d11_hud.h" +#include "../common/d3d11Hud.h" #include "../common/d3d11PtexMipmapTexture.h" #include "../common/d3d11ShaderCache.h" diff --git a/examples/dxViewer/dxviewer.cpp b/examples/dxViewer/dxviewer.cpp index 2a2cb4c3..4ff50317 100644 --- a/examples/dxViewer/dxviewer.cpp +++ b/examples/dxViewer/dxviewer.cpp @@ -62,7 +62,8 @@ OpenSubdiv::Osd::D3D11MeshInterface *g_mesh; #include #include "../common/stopwatch.h" #include "../common/simple_math.h" -#include "../common/d3d11_hud.h" +#include "../common/d3d11Hud.h" +#include "../common/d3d11Utils.h" #include "../common/d3d11ShaderCache.h" #include diff --git a/examples/farViewer/farViewer.cpp b/examples/farViewer/farViewer.cpp index 81d4315a..637c8c60 100644 --- a/examples/farViewer/farViewer.cpp +++ b/examples/farViewer/farViewer.cpp @@ -61,8 +61,8 @@ GLFWmonitor* g_primary=0; #include "../common/stopwatch.h" #include "../common/simple_math.h" -#include "../common/gl_common.h" -#include "../common/gl_hud.h" +#include "../common/glUtils.h" +#include "../common/glHud.h" #include "init_shapes.h" #include "gl_mesh.h" @@ -1610,7 +1610,7 @@ int main(int argc, char ** argv) initHUD(); rebuildOsdMeshes(); - checkGLErrors("before loop"); + GLUtils::CheckGLErrors("before loop"); while (g_running) { idle(); display(); diff --git a/examples/farViewer/gl_fontutils.cpp b/examples/farViewer/gl_fontutils.cpp index 28340874..675826b6 100644 --- a/examples/farViewer/gl_fontutils.cpp +++ b/examples/farViewer/gl_fontutils.cpp @@ -78,9 +78,12 @@ void GLFont::bindProgram() { gsSrc = std::string(versionStr) + geoDefineStr + shaderSource, fsSrc = std::string(versionStr) + fragDefineStr + shaderSource; - GLuint vertexShader = compileShader(GL_VERTEX_SHADER, vsSrc.c_str()), - geometryShader = compileShader(GL_GEOMETRY_SHADER, gsSrc.c_str()), - fragmentShader = compileShader(GL_FRAGMENT_SHADER, fsSrc.c_str()); + GLuint vertexShader = + GLUtils::CompileShader(GL_VERTEX_SHADER, vsSrc.c_str()), + geometryShader = + GLUtils::CompileShader(GL_GEOMETRY_SHADER, gsSrc.c_str()), + fragmentShader = + GLUtils::CompileShader(GL_FRAGMENT_SHADER, fsSrc.c_str()); glAttachShader(_program, vertexShader); glAttachShader(_program, geometryShader); diff --git a/examples/farViewer/gl_fontutils.h b/examples/farViewer/gl_fontutils.h index ce06f22d..c327eca9 100644 --- a/examples/farViewer/gl_fontutils.h +++ b/examples/farViewer/gl_fontutils.h @@ -25,7 +25,7 @@ #ifndef GL_FONT_UTILS_H #define GL_FONT_UTILS_H -#include "../common/gl_common.h" +#include "../common/glUtils.h" #include diff --git a/examples/farViewer/gl_mesh.cpp b/examples/farViewer/gl_mesh.cpp index e5c6cf50..84ed69d0 100644 --- a/examples/farViewer/gl_mesh.cpp +++ b/examples/farViewer/gl_mesh.cpp @@ -744,7 +744,7 @@ createTextureBuffer(T const &data, GLint format, int offset=0) { glBindTexture(GL_TEXTURE_BUFFER, 0); glDeleteBuffers(1, &buffer); - checkGLErrors("createTextureBuffer"); + GLUtils::CheckGLErrors("createTextureBuffer"); return texture; } @@ -791,7 +791,7 @@ GLMesh::InitializeDeviceBuffers() { glBufferData(GL_ELEMENT_ARRAY_BUFFER, _eao[i].size()*sizeof(int), &_eao[i][0], GL_STATIC_DRAW); } - checkGLErrors("init"); + GLUtils::CheckGLErrors("init"); } if (not _faceColors.empty()) { @@ -856,9 +856,12 @@ bindProgram( char const * shaderSource, gsSrc = std::string(versionStr) + geoDefineStr + shaderSource, fsSrc = std::string(versionStr) + fragDefineStr + shaderSource; - GLuint vertexShader = compileShader(GL_VERTEX_SHADER, vsSrc.c_str()), - geometryShader = geometry ? compileShader(GL_GEOMETRY_SHADER, gsSrc.c_str()) : 0, - fragmentShader = compileShader(GL_FRAGMENT_SHADER, fsSrc.c_str()); + GLuint vertexShader = + GLUtils::CompileShader(GL_VERTEX_SHADER, vsSrc.c_str()), + geometryShader = geometry ? + GLUtils::CompileShader(GL_GEOMETRY_SHADER, gsSrc.c_str()) : 0, + fragmentShader = + GLUtils::CompileShader(GL_FRAGMENT_SHADER, fsSrc.c_str()); glAttachShader(*program, vertexShader); if (geometry) { diff --git a/examples/farViewer/gl_mesh.h b/examples/farViewer/gl_mesh.h index c04dddfb..064d70be 100644 --- a/examples/farViewer/gl_mesh.h +++ b/examples/farViewer/gl_mesh.h @@ -29,7 +29,7 @@ #include #include -#include "../common/gl_common.h" +#include "../common/glUtils.h" #include diff --git a/examples/glEvalLimit/glEvalLimit.cpp b/examples/glEvalLimit/glEvalLimit.cpp index 8084aa32..8c21f6d0 100755 --- a/examples/glEvalLimit/glEvalLimit.cpp +++ b/examples/glEvalLimit/glEvalLimit.cpp @@ -60,7 +60,7 @@ GLFWmonitor* g_primary=0; #include #include "../common/stopwatch.h" #include "../common/simple_math.h" -#include "../common/gl_hud.h" +#include "../common/glHud.h" #include "init_shapes.h" #include "particles.h" diff --git a/examples/glFVarViewer/glFVarViewer.cpp b/examples/glFVarViewer/glFVarViewer.cpp index 95076665..0ea0dcd9 100644 --- a/examples/glFVarViewer/glFVarViewer.cpp +++ b/examples/glFVarViewer/glFVarViewer.cpp @@ -54,7 +54,8 @@ OpenSubdiv::Osd::GLMeshInterface *g_mesh = NULL; #include #include "../common/stopwatch.h" #include "../common/simple_math.h" -#include "../common/gl_hud.h" +#include "../common/glHud.h" +#include "../common/glUtils.h" #include "../common/glShaderCache.h" #include @@ -1061,7 +1062,7 @@ callbackModel(int m) { static void callbackAdaptive(bool checked, int /* a */) { - if (OpenSubdiv::Osd::GLDrawContext::SupportsAdaptiveTessellation()) { + if (GLUtils::SupportsAdaptiveTessellation()) { g_adaptive = checked; rebuildOsdMesh(); } @@ -1114,7 +1115,7 @@ initHUD() { g_hud.AddPullDownButton(shading_pulldown, "Shaded", kShaded, g_displayStyle==kShaded); g_hud.AddPullDownButton(shading_pulldown, "Wire+Shaded", kWireShaded, g_displayStyle==kWireShaded); - if (OpenSubdiv::Osd::GLDrawContext::SupportsAdaptiveTessellation()) + if (GLUtils::SupportsAdaptiveTessellation()) g_hud.AddCheckBox("Adaptive (`)", g_adaptive != 0, 10, 250, callbackAdaptive, 0, '`'); for (int i = 1; i < 11; ++i) { diff --git a/examples/glPaintTest/glPaintTest.cpp b/examples/glPaintTest/glPaintTest.cpp index 52986874..65761066 100644 --- a/examples/glPaintTest/glPaintTest.cpp +++ b/examples/glPaintTest/glPaintTest.cpp @@ -55,7 +55,7 @@ OpenSubdiv::Osd::GLMeshInterface *g_mesh; #include #include "../common/stopwatch.h" #include "../common/simple_math.h" -#include "../common/gl_hud.h" +#include "../common/glHud.h" #include "../common/glShaderCache.h" #include "init_shapes.h" diff --git a/examples/glPtexViewer/glPtexViewer.cpp b/examples/glPtexViewer/glPtexViewer.cpp index da60ca27..b8f22071 100644 --- a/examples/glPtexViewer/glPtexViewer.cpp +++ b/examples/glPtexViewer/glPtexViewer.cpp @@ -97,7 +97,8 @@ OpenSubdiv::Osd::GLMeshInterface *g_mesh; #include #include "../common/stopwatch.h" #include "../common/simple_math.h" -#include "../common/gl_hud.h" +#include "../common/glHud.h" +#include "../common/glUtils.h" #include "../common/hdr_reader.h" #include "../common/glPtexMipmapTexture.h" #include "../common/glShaderCache.h" @@ -1662,7 +1663,7 @@ callbackCheckBox(bool checked, int button) { switch (button) { case HUD_CB_ADAPTIVE: - if (OpenSubdiv::Osd::GLDrawContext::SupportsAdaptiveTessellation()) { + if (GLUtils::SupportsAdaptiveTessellation()) { g_adaptive = checked; rebuild = true; } @@ -1976,7 +1977,7 @@ int main(int argc, char ** argv) { reshape(); // activate feature adaptive tessellation if OSD supports it - g_adaptive = OpenSubdiv::Osd::GLDrawContext::SupportsAdaptiveTessellation(); + g_adaptive = GLUtils::SupportsAdaptiveTessellation(); int windowWidth = g_width, windowHeight = g_height; @@ -2018,7 +2019,7 @@ int main(int argc, char ** argv) { g_hud.AddRadioButton(HUD_RB_SCHEME, "CATMARK", true, 10, 190, callbackScheme, 0); g_hud.AddRadioButton(HUD_RB_SCHEME, "BILINEAR", false, 10, 210, callbackScheme, 1); - if (OpenSubdiv::Osd::GLDrawContext::SupportsAdaptiveTessellation()) + if (GLUtils::SupportsAdaptiveTessellation()) g_hud.AddCheckBox("Adaptive (`)", g_adaptive, 10, 300, callbackCheckBox, HUD_CB_ADAPTIVE, '`'); diff --git a/examples/glShareTopology/glShareTopology.cpp b/examples/glShareTopology/glShareTopology.cpp index a7bfd91d..b8809e00 100644 --- a/examples/glShareTopology/glShareTopology.cpp +++ b/examples/glShareTopology/glShareTopology.cpp @@ -87,7 +87,7 @@ GLFWmonitor* g_primary=0; #include "../common/stopwatch.h" #include "../common/simple_math.h" -#include "../common/gl_hud.h" +#include "../common/glHud.h" #include "../common/glShaderCache.h" #include diff --git a/examples/glShareTopology/sceneBase.cpp b/examples/glShareTopology/sceneBase.cpp index c66d35a2..147b5df4 100644 --- a/examples/glShareTopology/sceneBase.cpp +++ b/examples/glShareTopology/sceneBase.cpp @@ -40,7 +40,7 @@ SceneBase::~SceneBase() { if (_indexBuffer) glDeleteBuffers(1, &_indexBuffer); if (_patchParamTexture) glDeleteTextures(1, &_patchParamTexture); - for (int i = 0; i < _patchTables.size(); ++i) { + for (int i = 0; i < (int)_patchTables.size(); ++i) { delete _patchTables[i]; } } diff --git a/examples/glStencilViewer/glStencilViewer.cpp b/examples/glStencilViewer/glStencilViewer.cpp index ef240eb4..25d92836 100644 --- a/examples/glStencilViewer/glStencilViewer.cpp +++ b/examples/glStencilViewer/glStencilViewer.cpp @@ -45,8 +45,8 @@ GLFWmonitor* g_primary=0; #include #include "../common/stopwatch.h" #include "../common/simple_math.h" -#include "../common/gl_common.h" -#include "../common/gl_hud.h" +#include "../common/glUtils.h" +#include "../common/glHud.h" #include #include @@ -418,8 +418,10 @@ public: _program = glCreateProgram(); - GLuint vertexShader = compileShader(GL_VERTEX_SHADER, _vtxSrc); - GLuint fragmentShader = compileShader(GL_FRAGMENT_SHADER, _frgSrc); + GLuint vertexShader = + GLUtils::CompileShader(GL_VERTEX_SHADER, _vtxSrc); + GLuint fragmentShader = + GLUtils::CompileShader(GL_FRAGMENT_SHADER, _frgSrc); glAttachShader(_program, vertexShader); glAttachShader(_program, fragmentShader); diff --git a/examples/glViewer/glViewer.cpp b/examples/glViewer/glViewer.cpp index 92af6cc7..19c7c318 100644 --- a/examples/glViewer/glViewer.cpp +++ b/examples/glViewer/glViewer.cpp @@ -88,7 +88,8 @@ OpenSubdiv::Osd::GLMeshInterface *g_mesh; #include #include "../common/stopwatch.h" #include "../common/simple_math.h" -#include "../common/gl_hud.h" +#include "../common/glHud.h" +#include "../common/glUtils.h" #include "../common/objAnim.h" #include "../common/glShaderCache.h" @@ -1511,7 +1512,7 @@ callbackModel(int m) { static void callbackCheckBox(bool checked, int button) { - if (OpenSubdiv::Osd::GLDrawContext::SupportsAdaptiveTessellation()) { + if (GLUtils::SupportsAdaptiveTessellation()) { switch(button) { case kHUD_CB_ADAPTIVE: g_adaptive = checked; @@ -1620,7 +1621,7 @@ initHUD() { g_hud.AddPullDownButton(compute_pulldown, "GLSL Compute", kGLSLCompute); } #endif - if (OpenSubdiv::Osd::GLDrawContext::SupportsAdaptiveTessellation()) { + if (GLUtils::SupportsAdaptiveTessellation()) { g_hud.AddCheckBox("Adaptive (`)", g_adaptive!=0, 10, 190, callbackCheckBox, kHUD_CB_ADAPTIVE, '`'); g_hud.AddCheckBox("Single Crease Patch (S)", g_singleCreasePatch!=0, @@ -1834,7 +1835,7 @@ int main(int argc, char ** argv) { #endif // activate feature adaptive tessellation if OSD supports it - g_adaptive = OpenSubdiv::Osd::GLDrawContext::SupportsAdaptiveTessellation(); + g_adaptive = GLUtils::SupportsAdaptiveTessellation(); initGL(); linkDefaultProgram(); diff --git a/opensubdiv/osd/glDrawContext.cpp b/opensubdiv/osd/glDrawContext.cpp index 2d8dd9fa..afef5b43 100644 --- a/opensubdiv/osd/glDrawContext.cpp +++ b/opensubdiv/osd/glDrawContext.cpp @@ -48,21 +48,6 @@ GLDrawContext::~GLDrawContext() glDeleteTextures(1, &_fvarDataTextureBuffer); } -bool -GLDrawContext::SupportsAdaptiveTessellation() -{ -#ifdef OSD_USES_GLEW - // XXX: uncomment here to try tessellation on OSX - // if (GLEW_ARB_tessellation_shader) - // return true; -#endif - static const GLubyte *version = glGetString(GL_VERSION); - if (version and version[0] == '4') - return true; - - return false; -} - template static GLuint createTextureBuffer(T const &data, GLint format, int offset=0) { diff --git a/opensubdiv/osd/glDrawContext.h b/opensubdiv/osd/glDrawContext.h index 0ed7e4e6..a62f6eb1 100644 --- a/opensubdiv/osd/glDrawContext.h +++ b/opensubdiv/osd/glDrawContext.h @@ -74,9 +74,6 @@ public: updateVertexTexture(vbo->BindVBO()); } - /// true if the GL version detected supports shader tessellation - static bool SupportsAdaptiveTessellation(); - /// Returns the GL texture buffer containing the patch control vertices array GLuint GetPatchIndexBuffer() const { return _patchIndexBuffer;