in ReplicaSDK/ptex/PTexLib.cpp [86:125]
void PTexMesh::RenderSubMesh(
size_t subMesh,
const pangolin::OpenGlRenderState& cam,
const Eigen::Vector4f& clipPlane) {
ASSERT(subMesh < meshes.size());
Mesh& mesh = *meshes[subMesh];
shader.Bind();
shader.SetUniform("MVP", cam.GetProjectionModelViewMatrix());
shader.SetUniform("tileSize", (int)tileSize);
shader.SetUniform("exposure", exposure);
shader.SetUniform("gamma", 1.0f / gamma);
shader.SetUniform("saturation", saturation);
shader.SetUniform("clipPlane", clipPlane(0), clipPlane(1), clipPlane(2), clipPlane(3));
shader.SetUniform("widthInTiles", int(mesh.atlas.width / tileSize));
glActiveTexture(GL_TEXTURE0);
mesh.atlas.Bind();
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, mesh.abo.bo);
mesh.vbo.Bind();
glVertexAttribPointer(0, mesh.vbo.count_per_element, mesh.vbo.datatype, GL_FALSE, 0, 0);
glEnableVertexAttribArray(0);
mesh.vbo.Unbind();
mesh.ibo.Bind();
// using GL_LINES_ADJACENCY here to send quads to geometry shader
glDrawElements(GL_LINES_ADJACENCY, mesh.ibo.num_elements, mesh.ibo.datatype, 0);
mesh.ibo.Unbind();
glDisableVertexAttribArray(0);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, 0);
glActiveTexture(GL_TEXTURE0);
mesh.atlas.Unbind();
shader.Unbind();
}