// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDSurface.cpp
// Function: gaps::RGBDSurface::DrawFaces(int) const
void RGBDSurface::
DrawFaces(int color_scheme) const
{
  // Enable lighting and material
  if (color_scheme == RGBD_RENDER_COLOR_SCHEME) {
    glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
    glEnable(GL_LIGHTING);
  }

  // Load color
  LoadColor(color_scheme);

  // Draw faces
  if (rectangle) {
    rectangle->Draw();
  }
  else if (mesh) {
    RNGrfxBegin(RN_GRFX_TRIANGLES);
    for (int i = 0; i < mesh->NFaces(); i++) {
      R3MeshFace *face = mesh->Face(i);
      R3MeshVertex *v0 = mesh->VertexOnFace(face, 0);
      R3MeshVertex *v1 = mesh->VertexOnFace(face, 1);
      R3MeshVertex *v2 = mesh->VertexOnFace(face, 2);
      if (color_scheme == RGBD_PHOTO_COLOR_SCHEME) {
        RNLoadRgb(mesh->VertexColor(v0));
        R3LoadPoint(mesh->VertexPosition(v0));
        RNLoadRgb(mesh->VertexColor(v1));
        R3LoadPoint(mesh->VertexPosition(v1));
        RNLoadRgb(mesh->VertexColor(v2));
        R3LoadPoint(mesh->VertexPosition(v2));
      }
      else if (color_scheme == RGBD_RENDER_COLOR_SCHEME) {
        R3LoadNormal(mesh->FaceNormal(face));
        R3LoadPoint(mesh->VertexPosition(v0));
        R3LoadPoint(mesh->VertexPosition(v1));
        R3LoadPoint(mesh->VertexPosition(v2));
      }
      else {
        R3LoadPoint(mesh->VertexPosition(v0));
        R3LoadPoint(mesh->VertexPosition(v1));
        R3LoadPoint(mesh->VertexPosition(v2));
      }
    }
    RNGrfxEnd();
  }

  // Disable lighting and material
  if (color_scheme == RGBD_RENDER_COLOR_SCHEME) {
    glDisable(GL_COLOR_MATERIAL);
    glDisable(GL_LIGHTING);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
cmpl $0x2, %esi
jne 0x1a92e
movl $0xb57, %edi            # imm = 0xB57
callq 0x11550
movl $0x408, %edi            # imm = 0x408
movl $0x1602, %esi           # imm = 0x1602
callq 0x113b0
movl $0xb50, %edi            # imm = 0xB50
callq 0x11550
movq (%r14), %rax
movq %r14, %rdi
movl %ebx, %esi
callq *0x80(%rax)
movq 0x80(%r14), %rdi
testq %rdi, %rdi
je 0x1a95b
movq (%rdi), %rax
movl $0x772, %esi            # imm = 0x772
callq *0xa8(%rax)
jmp 0x1aa19
cmpq $0x0, 0x88(%r14)
je 0x1aa19
pushq $0x4
popq %rdi
callq 0x11150
xorl %ebp, %ebp
movq 0x88(%r14), %rdi
movslq 0x34(%rdi), %rax
cmpq %rax, %rbp
jge 0x1aa14
movq 0x28(%rdi), %rax
movq (%rax,%rbp,8), %rsi
movq 0x8(%rsi), %r13
movq 0x10(%rsi), %r12
movq 0x18(%rsi), %r15
cmpl $0x1, %ebx
jne 0x1a9d6
leaq 0x58(%r13), %rdi
callq 0x1b8bb
addq $0x18, %r13
movq %r13, %rdi
callq 0x11170
leaq 0x58(%r12), %rdi
callq 0x1b8bb
addq $0x18, %r12
movq %r12, %rdi
callq 0x11170
leaq 0x58(%r15), %rdi
callq 0x1b8bb
jmp 0x1aa00
cmpl $0x2, %ebx
jne 0x1a9e8
callq 0x1ba04
movq %rax, %rdi
callq 0x118e0
addq $0x18, %r13
movq %r13, %rdi
callq 0x11170
addq $0x18, %r12
movq %r12, %rdi
callq 0x11170
addq $0x18, %r15
movq %r15, %rdi
callq 0x11170
incq %rbp
jmp 0x1a973
callq 0x117d0
cmpl $0x2, %ebx
jne 0x1aa40
movl $0xb57, %edi            # imm = 0xB57
callq 0x111a0
movl $0xb50, %edi            # imm = 0xB50
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x111a0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop