mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-12-23 08:20:06 +00:00
remove SupportsAdaptiveTessellation from OsdDrawContext, and example cleanups
As a preparation for retiring DrawContext, move SupportsAdaptiveTessellation method to examples/common/glUtils, which is renamed and namespaced from gl_common.{cpp,h} to be consistent to other files. Same renamings applied to other example files.
This commit is contained in:
parent
de358d7f82
commit
c3aa00e706
@ -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
|
||||
)
|
||||
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <cassert>
|
||||
#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);
|
||||
|
@ -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 <D3D11.h>
|
||||
#include "hud.h"
|
||||
@ -64,4 +64,4 @@ private:
|
||||
int _staticVboCount;
|
||||
};
|
||||
|
||||
#endif // D3D11_HUD_H
|
||||
#endif // OPENSUBDIV_EXAMPLES_D3D11_HUD_H
|
@ -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 <D3DCompiler.h>
|
||||
|
||||
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
|
@ -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 <osd/opengl.h>
|
||||
#include <D3DCompiler.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
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
|
@ -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 <cstdlib>
|
||||
#include <cassert>
|
||||
@ -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
|
@ -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 <osd/opengl.h>
|
||||
|
||||
@ -131,4 +131,4 @@ private:
|
||||
_contrast;
|
||||
};
|
||||
|
||||
#endif // GL_FRAMEBUFFER_H
|
||||
#endif // OPENSUBDIV_EXAMPLES_GL_FRAMEBUFFER_H
|
@ -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
|
@ -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 <osd/opengl.h>
|
||||
|
||||
#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
|
@ -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
|
46
examples/common/glUtils.h
Normal file
46
examples/common/glUtils.h
Normal file
@ -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 <osd/opengl.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
namespace GLUtils {
|
||||
|
||||
void CheckGLErrors(std::string const & where = "");
|
||||
|
||||
GLuint CompileShader(GLenum shaderType, const char *source);
|
||||
|
||||
bool SupportsAdaptiveTessellation();
|
||||
|
||||
};
|
||||
|
||||
#endif // OPENSUBDIV_EXAMPLES_GL_UTILS_H
|
||||
|
||||
|
@ -61,7 +61,7 @@ OpenSubdiv::Osd::D3D11MeshInterface *g_mesh;
|
||||
#include <common/vtr_utils.h>
|
||||
#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"
|
||||
|
||||
|
@ -62,7 +62,8 @@ OpenSubdiv::Osd::D3D11MeshInterface *g_mesh;
|
||||
#include <common/vtr_utils.h>
|
||||
#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 <osd/hlslPatchShaderSource.h>
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -25,7 +25,7 @@
|
||||
#ifndef GL_FONT_UTILS_H
|
||||
#define GL_FONT_UTILS_H
|
||||
|
||||
#include "../common/gl_common.h"
|
||||
#include "../common/glUtils.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <common/hbr_utils.h>
|
||||
#include <far/patchTables.h>
|
||||
|
||||
#include "../common/gl_common.h"
|
||||
#include "../common/glUtils.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -60,7 +60,7 @@ GLFWmonitor* g_primary=0;
|
||||
#include <common/vtr_utils.h>
|
||||
#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"
|
||||
|
@ -54,7 +54,8 @@ OpenSubdiv::Osd::GLMeshInterface *g_mesh = NULL;
|
||||
#include <common/vtr_utils.h>
|
||||
#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 <osd/glslPatchShaderSource.h>
|
||||
@ -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) {
|
||||
|
@ -55,7 +55,7 @@ OpenSubdiv::Osd::GLMeshInterface *g_mesh;
|
||||
#include <common/vtr_utils.h>
|
||||
#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"
|
||||
|
@ -97,7 +97,8 @@ OpenSubdiv::Osd::GLMeshInterface *g_mesh;
|
||||
#include <common/vtr_utils.h>
|
||||
#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, '`');
|
||||
|
||||
|
@ -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 <osd/glslPatchShaderSource.h>
|
||||
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ GLFWmonitor* g_primary=0;
|
||||
#include <common/vtr_utils.h>
|
||||
#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 <far/patchTablesFactory.h>
|
||||
#include <far/ptexIndices.h>
|
||||
@ -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);
|
||||
|
@ -88,7 +88,8 @@ OpenSubdiv::Osd::GLMeshInterface *g_mesh;
|
||||
#include <common/vtr_utils.h>
|
||||
#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();
|
||||
|
@ -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 <typename T> static GLuint
|
||||
createTextureBuffer(T const &data, GLint format, int offset=0)
|
||||
{
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user