// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rdi, %rbx
cmpl $0x2, %esi
movl %esi, 0x4(%rsp)
jne 0x1bdce
movl $0xb57, %edi            # imm = 0xB57
callq 0x11540
movl $0x408, %edi            # imm = 0x408
movl $0x1602, %esi           # imm = 0x1602
callq 0x113b0
movl $0xb50, %edi            # imm = 0xB50
callq 0x11540
movl 0x4(%rsp), %esi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x80(%rax)
movq 0x80(%rbx), %rdi
testq %rdi, %rdi
je 0x1bdf9
movq (%rdi), %rax
movl $0x772, %esi            # imm = 0x772
callq *0xa8(%rax)
jmp 0x1bf0a
cmpq $0x0, 0x88(%rbx)
je 0x1bf0a
movl $0x4, %edi
callq 0x11150
movq 0x88(%rbx), %rdi
cmpl $0x0, 0x34(%rdi)
jle 0x1bf05
xorl %r14d, %r14d
movq 0x28(%rdi), %rax
movq (%rax,%r14,8), %rbp
movq 0x8(%rbp), %r13
movq 0x10(%rbp), %r12
movq 0x18(%rbp), %r15
movl 0x4(%rsp), %eax
cmpl $0x1, %eax
jne 0x1bea4
movsd 0x58(%r13), %xmm0
movsd 0x60(%r13), %xmm1
movsd 0x68(%r13), %xmm2
callq 0x11900
addq $0x18, %r13
movq %r13, %rdi
callq 0x11170
movsd 0x58(%r12), %xmm0
movsd 0x60(%r12), %xmm1
movsd 0x68(%r12), %xmm2
callq 0x11900
addq $0x18, %r12
movq %r12, %rdi
callq 0x11170
movsd 0x58(%r15), %xmm0
movsd 0x60(%r15), %xmm1
movsd 0x68(%r15), %xmm2
callq 0x11900
jmp 0x1bee2
cmpl $0x2, %eax
jne 0x1beca
testb $0x4, 0xa8(%rbp)
jne 0x1bebe
movq (%rdi), %rax
movq %rbp, %rsi
callq *0x2c8(%rax)
addq $0x38, %rbp
movq %rbp, %rdi
callq 0x118d0
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 %r14
movq 0x88(%rbx), %rdi
movslq 0x34(%rdi), %rax
cmpq %rax, %r14
jl 0x1be25
callq 0x117d0
cmpl $0x2, 0x4(%rsp)
jne 0x1bf33
movl $0xb57, %edi            # imm = 0xB57
callq 0x11180
movl $0xb50, %edi            # imm = 0xB50
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11180
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq