mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-11-09 22:00:06 +00:00
partial solution to run-time environment configuration :
- add bool OsdGLDrawContext::SupportsAdaptiveTessellation() method - modify glViewer to use that instead of #ifdefs Note : this is not the final word on this as OSD really needs a more comprehensive system to provide run-time information about available features to the client code. fixes #111
This commit is contained in:
parent
2b12ffc447
commit
6f5d1e34be
@ -351,9 +351,6 @@ linkDefaultProgram()
|
||||
static void
|
||||
initializeShapes( ) {
|
||||
|
||||
#include <shapes/bilinear_cube.h>
|
||||
g_defaultShapes.push_back(SimpleShape(bilinear_cube, "bilinear_cube", kBilinear));
|
||||
|
||||
#include <shapes/catmark_cube_corner0.h>
|
||||
g_defaultShapes.push_back(SimpleShape(catmark_cube_corner0, "catmark_cube_corner0", kCatmark));
|
||||
|
||||
@ -462,6 +459,9 @@ initializeShapes( ) {
|
||||
#endif
|
||||
|
||||
|
||||
#include <shapes/bilinear_cube.h>
|
||||
g_defaultShapes.push_back(SimpleShape(bilinear_cube, "bilinear_cube", kBilinear));
|
||||
|
||||
|
||||
#include <shapes/loop_cube_creases0.h>
|
||||
g_defaultShapes.push_back(SimpleShape(loop_cube_creases0, "loop_cube_creases0", kLoop));
|
||||
@ -630,11 +630,7 @@ createOsdMesh( const char * shape, int level, int kernel, Scheme scheme=kCatmark
|
||||
g_scheme = scheme;
|
||||
|
||||
// Adaptive refinement currently supported only for catmull-clark scheme
|
||||
#if defined(GL_ARB_tessellation_shader) || defined(GL_VERSION_4_0)
|
||||
bool doAdaptive = (g_adaptive!=0 and g_scheme==kCatmark);
|
||||
#else
|
||||
bool doAdaptive = false;
|
||||
#endif
|
||||
|
||||
OpenSubdiv::OsdMeshBitset bits;
|
||||
bits.set(OpenSubdiv::MeshAdaptive, doAdaptive);
|
||||
@ -1585,9 +1581,11 @@ callbackFreeze(bool checked, int f)
|
||||
static void
|
||||
callbackAdaptive(bool checked, int a)
|
||||
{
|
||||
g_adaptive = checked;
|
||||
if (OpenSubdiv::OsdGLDrawContext::SupportsAdaptiveTessellation()) {
|
||||
g_adaptive = checked;
|
||||
|
||||
createOsdMesh( g_defaultShapes[g_currentShape].data, g_level, g_kernel, g_defaultShapes[ g_currentShape ].scheme );
|
||||
createOsdMesh( g_defaultShapes[g_currentShape].data, g_level, g_kernel, g_defaultShapes[ g_currentShape ].scheme );
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1810,6 +1808,9 @@ int main(int argc, char ** argv)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// activate feature adaptive tessellation if OSD supports it
|
||||
g_adaptive = OpenSubdiv::OsdGLDrawContext::SupportsAdaptiveTessellation();
|
||||
|
||||
initGL();
|
||||
linkDefaultProgram();
|
||||
|
||||
|
@ -91,6 +91,19 @@ OsdGLDrawContext::~OsdGLDrawContext()
|
||||
glDeleteTextures(1, &fvarDataTextureBuffer);
|
||||
}
|
||||
|
||||
bool
|
||||
OsdGLDrawContext::SupportsAdaptiveTessellation()
|
||||
{
|
||||
// Compile-time check of GL version
|
||||
#if (defined(GL_ARB_tessellation_shader) or defined(GL_VERSION_4_0)) and defined(GLEW_VERSION_4_0)
|
||||
// Run-time check of GL version with GLEW
|
||||
if (GLEW_VERSION_4_0) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
OsdGLDrawContext::allocate(FarMesh<OsdVertex> *farMesh,
|
||||
GLuint vbo,
|
||||
|
@ -120,6 +120,9 @@ public:
|
||||
GLuint quadOffsetTextureBuffer;
|
||||
GLuint patchLevelTextureBuffer;
|
||||
|
||||
/// true if the GL version detected supports shader tessellation
|
||||
static bool SupportsAdaptiveTessellation();
|
||||
|
||||
private:
|
||||
bool allocate(FarMesh<OsdVertex> *farMesh,
|
||||
GLuint vbo, int numElements,
|
||||
|
Loading…
Reference in New Issue
Block a user