Fixed crash in GL viewers w/ LegacyGregory

Fixed a crash (assertion failure on Windows) that occurs when
creating GLLegacyGregoryPatchTable for a mesh that requires
no Gregory patches.
This commit is contained in:
David G. Yu 2015-06-11 17:26:21 -07:00
parent 34fab03921
commit d4a18a6c98

View File

@ -57,27 +57,33 @@ GLLegacyGregoryPatchTable::Create(Far::PatchTable const *farPatchTable) {
Far::PatchTable::QuadOffsetsTable const & Far::PatchTable::QuadOffsetsTable const &
quadOffsetsTable = farPatchTable->GetQuadOffsetsTable(); quadOffsetsTable = farPatchTable->GetQuadOffsetsTable();
GLuint buffers[2]; if (not valenceTable.empty()) {
glGenBuffers(2, buffers); GLuint buffer;
glBindBuffer(GL_ARRAY_BUFFER, buffers[0]); glGenBuffers(1, &buffer);
glBufferData(GL_ARRAY_BUFFER, valenceTable.size() * sizeof(int), glBindBuffer(GL_ARRAY_BUFFER, buffer);
&valenceTable[0], GL_STATIC_DRAW); glBufferData(GL_ARRAY_BUFFER, valenceTable.size() * sizeof(int),
&valenceTable[0], GL_STATIC_DRAW);
glBindTexture(GL_TEXTURE_BUFFER, result->_vertexValenceTextureBuffer); glBindTexture(GL_TEXTURE_BUFFER, result->_vertexValenceTextureBuffer);
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32I, buffers[0]); glTexBuffer(GL_TEXTURE_BUFFER, GL_R32I, buffer);
glBindTexture(GL_TEXTURE_BUFFER, 0); glBindTexture(GL_TEXTURE_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDeleteBuffers(1, &buffer);
}
glBindBuffer(GL_ARRAY_BUFFER, buffers[1]); if (not quadOffsetsTable.empty()) {
glBufferData(GL_ARRAY_BUFFER, quadOffsetsTable.size() * sizeof(int), GLuint buffer;
&quadOffsetsTable[0], GL_STATIC_DRAW); glGenBuffers(1, &buffer);
glBindBuffer(GL_ARRAY_BUFFER, buffer);
glBufferData(GL_ARRAY_BUFFER, quadOffsetsTable.size() * sizeof(int),
&quadOffsetsTable[0], GL_STATIC_DRAW);
glBindTexture(GL_TEXTURE_BUFFER, result->_quadOffsetsTextureBuffer); glBindTexture(GL_TEXTURE_BUFFER, result->_quadOffsetsTextureBuffer);
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32I, buffers[1]); glTexBuffer(GL_TEXTURE_BUFFER, GL_R32I, buffer);
glBindTexture(GL_TEXTURE_BUFFER, 0); glBindTexture(GL_TEXTURE_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0); glDeleteBuffers(1, &buffer);
}
glDeleteBuffers(2, buffers);
result->_quadOffsetsBase[0] = 0; result->_quadOffsetsBase[0] = 0;
result->_quadOffsetsBase[1] = 0; result->_quadOffsetsBase[1] = 0;