Fixed OS X build issues.

This commit is contained in:
David G Yu 2013-05-17 15:53:36 -07:00
parent 2a298442f4
commit 784b6e4475
4 changed files with 16 additions and 0 deletions

View File

@ -169,7 +169,9 @@ MyDrawDelegate::DrawElements(MyEffect &effect, OpenSubdiv::OsdDrawContext::Patch
if (true /* if config is different from previous call */) {
glUseProgram(program);
#if defined(GL_ARB_tessellation_shader) || defined(GL_VERSION_4_0)
glPatchParameteri(GL_PATCH_VERTICES, patchArray.GetDescriptor().GetNumControlVertices());
#endif
// bind patchArray state and draw
}
@ -186,8 +188,10 @@ MyDrawDelegate::DrawElements(MyEffect &effect, OpenSubdiv::OsdDrawContext::Patch
glDrawElements(GL_LINES_ADJACENCY, patchArray.GetNumIndices(), GL_UNSIGNED_INT,
(void*)(patchArray.GetVertIndex()*sizeof(GLuint)));
} else {
#if defined(GL_ARB_tessellation_shader) || defined(GL_VERSION_4_0)
glDrawElements(GL_PATCHES, patchArray.GetNumIndices(), GL_UNSIGNED_INT,
(void*)(patchArray.GetVertIndex()*sizeof(GLuint)));
#endif
}
_numDrawCalls++;
}

View File

@ -177,6 +177,8 @@ MyEffect::BindDrawConfig(MyDrawConfig *config, OpenSubdiv::OsdDrawContext::Patch
// bind uniforms
// currently, these are used only in conjunction with tessellation shaders
#if defined(GL_EXT_direct_state_access) || defined(GL_VERSION_4_1)
int patchType = desc.GetType();
int patchPattern = desc.GetPattern();
@ -220,5 +222,6 @@ MyEffect::BindDrawConfig(MyDrawConfig *config, OpenSubdiv::OsdDrawContext::Patch
}
}
}
#endif
}

View File

@ -170,6 +170,8 @@ MyEffectRegistry::_CreateDrawConfig(DescType const & desc, SourceConfigType cons
// g_gregoryQuadOffsetBaseMap[program] = glGetUniformLocation(program, "GregoryQuadOffsetBase");
// g_levelBaseMap[program] = glGetUniformLocation(program, "LevelBase");
// currently, these are used only in conjunction with tessellation shaders
#if defined(GL_EXT_direct_state_access) || defined(GL_VERSION_4_1)
GLint loc;
if ((loc = glGetUniformLocation(program, "g_VertexBuffer")) != -1) {
glProgramUniform1i(program, loc, 0); // GL_TEXTURE0
@ -183,6 +185,7 @@ MyEffectRegistry::_CreateDrawConfig(DescType const & desc, SourceConfigType cons
if ((loc = glGetUniformLocation(program, "g_ptexIndicesBuffer")) != -1) {
glProgramUniform1i(program, loc, 3); // GL_TEXTURE3
}
#endif
config->diffuseColorUniform = glGetUniformLocation(program, "diffuseColor");

View File

@ -566,7 +566,9 @@ display() {
// primitive counting
glBeginQuery(GL_PRIMITIVES_GENERATED, g_queries[0]);
#if defined(GL_VERSION_3_3)
glBeginQuery(GL_TIME_ELAPSED, g_queries[1]);
#endif
g_drawDelegate.ResetNumDrawCalls();
if (g_wire == 0) glDisable(GL_CULL_FACE);
@ -580,7 +582,9 @@ display() {
if (g_wire == 0) glEnable(GL_CULL_FACE);
glEndQuery(GL_PRIMITIVES_GENERATED);
#if defined(GL_VERSION_3_3)
glEndQuery(GL_TIME_ELAPSED);
#endif
s.Stop();
float drawCpuTime = float(s.GetElapsed() * 1000.0f);
@ -590,7 +594,9 @@ display() {
GLuint numPrimsGenerated = 0;
GLuint timeElapsed = 0;
glGetQueryObjectuiv(g_queries[0], GL_QUERY_RESULT, &numPrimsGenerated);
#if defined(GL_VERSION_3_3)
glGetQueryObjectuiv(g_queries[1], GL_QUERY_RESULT, &timeElapsed);
#endif
float drawGpuTime = timeElapsed / 1000.0f / 1000.0f;
if (g_hud.IsVisible()) {