// Display handles all drawing per frame. We first call the setupForDisplay // helper method to setup some uninteresting GL state and then bind the mesh // using the buffers provided by our OSD objects // void display() { setupForDisplay(g_width, g_height, g_size, g_center); // // Bind the GL vertex and index buffers // glBindBuffer(GL_ARRAY_BUFFER, g_vertexBuffer->BindVBO()); OpenSubdiv::OsdDrawContext::PatchArrayVector const & patches = g_drawContext->patchArrays; for (int i=0; i<(int)patches.size(); ++i) { OpenSubdiv::OsdDrawContext::PatchArray const & patch = patches[i]; // // Bind the solid shaded program and draw elements based on the buffer contents // bindProgram(g_quadFillProgram); glDrawElements(GL_LINES_ADJACENCY, patch.GetNumIndices(), GL_UNSIGNED_INT, NULL); // // Draw the wire frame over the solid shaded mesh // bindProgram(g_quadLineProgram); glUniform4f(glGetUniformLocation(g_quadLineProgram, "fragColor"), 0, 0, 0.5, 1); glDrawElements(GL_LINES_ADJACENCY, patch.GetNumIndices(), GL_UNSIGNED_INT, NULL); } // // This isn't strictly necessary, but unbind the GL state // glUseProgram(0); glBindBuffer(GL_ARRAY_BUFFER, 0); //glDisableClientState(GL_VERTEX_ARRAY); // // Draw the HUD/status text // //glColor3f(1, 1, 1); drawString(10, 10, "LEVEL = %d", g_level); drawString(10, 30, "# of Vertices = %d", g_farmesh->GetNumVertices()); drawString(10, 50, "KERNEL = CPU"); drawString(10, 70, "SUBDIVISION = %s", "CATMARK"); // // Finish the current frame // glFinish(); }
// Display handles all drawing per frame. We first call the setupForDisplay // helper method to setup some uninteresting GL state and then bind the mesh // using the buffers provided by our OSD objects // void display() { setupForDisplay(g_width, g_height, g_size, g_center); // // Bind the GL vertex and index buffers // glBindBuffer(GL_ARRAY_BUFFER, g_vertexBuffer->GetGpuBuffer()); // // Bind the solid shaded program and draw elements based on the buffer contents // bindProgram(g_quadFillProgram); glDrawElements(GL_LINES_ADJACENCY, g_elementArrayBuffer->GetNumIndices(), GL_UNSIGNED_INT, NULL); // // Draw the wire frame over the solid shaded mesh // bindProgram(g_quadLineProgram); glUniform4f(glGetUniformLocation(g_quadLineProgram, "fragColor"), 0, 0, 0.5, 1); glDrawElements(GL_LINES_ADJACENCY, g_elementArrayBuffer->GetNumIndices(), GL_UNSIGNED_INT, NULL); // // This isn't strictly necessary, but unbind the GL state // glUseProgram(0); glBindBuffer(GL_ARRAY_BUFFER, 0); //glDisableClientState(GL_VERTEX_ARRAY); // // Draw the HUD/status text // //glColor3f(1, 1, 1); drawString(10, 10, "LEVEL = %d", g_level); drawString(10, 30, "# of Vertices = %d", g_osdmesh->GetFarMesh()->GetNumVertices()); drawString(10, 50, "KERNEL = CPU"); drawString(10, 70, "SUBDIVISION = %s", "CATMARK"); // // Finish the current frame // glFinish(); }