// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3PointSet.cpp
// Function: gaps::R3PointSet::Draw(gaps::RNFlags) const
void R3PointSet::
Draw(const RNFlags draw_flags) const
{
  // Check if nothing to be done
  if (NPoints() == 0) return;

  // Bind vertex position buffer
  if (GLPositionBufferObject() <= 0) return;
  glBindBuffer(GL_ARRAY_BUFFER, vbo_position_buffer);
  glVertexPointer(3, GL_FLOAT, 0, 0);
  glEnableClientState(GL_VERTEX_ARRAY);
  
  // Bind vertex normal buffer
  if (draw_flags[R3_VERTEX_NORMALS_DRAW_FLAG]) {
    if (GLNormalBufferObject() > 0) {
      glBindBuffer(GL_ARRAY_BUFFER, vbo_normal_buffer);
      glNormalPointer(GL_FLOAT, 0, 0);
      glEnableClientState(GL_NORMAL_ARRAY);
    }
  }
  
  // Bind vertex color buffer
  if (draw_flags[R3_VERTEX_PICK_DRAW_FLAG]) {
    if (GLPickColorBufferObject() > 0) {
      glBindBuffer(GL_ARRAY_BUFFER, vbo_pick_color_buffer);
      glColorPointer(4, GL_UNSIGNED_BYTE, 0, 0);
      glEnableClientState(GL_COLOR_ARRAY);
    }
  }
  else if (draw_flags[R3_VERTEX_COLORS_DRAW_FLAG]) {
    if (GLRgbColorBufferObject() > 0) {
      glBindBuffer(GL_ARRAY_BUFFER, vbo_rgb_color_buffer);
      glColorPointer(4, GL_UNSIGNED_BYTE, 0, 0);
      glEnableClientState(GL_COLOR_ARRAY);
    }
  }
  
  // Draw points
  glDrawArrays(GL_POINTS, 0, NPoints());

  // Reset everything
  glBindBuffer(GL_ARRAY_BUFFER, 0);
  glDisableClientState(GL_VERTEX_ARRAY);
  glDisableClientState(GL_NORMAL_ARRAY);
  glDisableClientState(GL_COLOR_ARRAY);
}

// Assembly:
subq $0x38, %rsp
movq %rsi, 0x30(%rsp)
movq %rdi, 0x28(%rsp)
movq 0x28(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x32400
cmpl $0x0, %eax
jne 0xde1f7
jmp 0xde3d3
movq 0x8(%rsp), %rdi
callq 0xdd890
cmpl $0x0, %eax
ja 0xde20b
jmp 0xde3d3
movq 0x8(%rsp), %rcx
movq 0x14adb1(%rip), %rax    # 0x228fc8
movq (%rax), %rax
movl 0x108(%rcx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
movl $0x3, %edi
movl $0x1406, %esi           # imm = 0x1406
xorl %edx, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x23a20
movl $0x8074, %edi           # imm = 0x8074
callq 0x23610
leaq 0x20(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x33580
movq 0x20(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x53700
cmpl $0x0, %eax
je 0xde2b0
movq 0x8(%rsp), %rdi
callq 0xddb00
cmpl $0x0, %eax
jbe 0xde2ae
movq 0x8(%rsp), %rcx
movq 0x14ad44(%rip), %rax    # 0x228fc8
movq (%rax), %rax
movl 0x10c(%rcx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
movl $0x1406, %edi           # imm = 0x1406
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x241c0
movl $0x8075, %edi           # imm = 0x8075
callq 0x23610
jmp 0xde2b0
leaq 0x18(%rsp), %rdi
movl $0x800, %esi            # imm = 0x800
callq 0x33580
movq 0x18(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x53700
cmpl $0x0, %eax
je 0xde31f
movq 0x8(%rsp), %rdi
callq 0xddff0
cmpl $0x0, %eax
jbe 0xde31d
movq 0x8(%rsp), %rcx
movq 0x14acda(%rip), %rax    # 0x228fc8
movq (%rax), %rax
movl 0x114(%rcx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
movl $0x4, %edi
movl $0x1401, %esi           # imm = 0x1401
xorl %edx, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x239f0
movl $0x8076, %edi           # imm = 0x8076
callq 0x23610
jmp 0xde390
leaq 0x10(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x33580
movq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x53700
cmpl $0x0, %eax
je 0xde38e
movq 0x8(%rsp), %rdi
callq 0xddd70
cmpl $0x0, %eax
jbe 0xde38c
movq 0x8(%rsp), %rcx
movq 0x14ac6b(%rip), %rax    # 0x228fc8
movq (%rax), %rax
movl 0x110(%rcx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
movl $0x4, %edi
movl $0x1401, %esi           # imm = 0x1401
xorl %edx, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x239f0
movl $0x8076, %edi           # imm = 0x8076
callq 0x23610
jmp 0xde38e
jmp 0xde390
movq 0x8(%rsp), %rdi
callq 0x32400
movl %eax, %edx
xorl %esi, %esi
movl %esi, %edi
callq 0x23070
movl $0x8892, %edi           # imm = 0x8892
xorl %esi, %esi
movq 0x14ac15(%rip), %rax    # 0x228fc8
callq *(%rax)
movl $0x8074, %edi           # imm = 0x8074
callq 0x235a0
movl $0x8075, %edi           # imm = 0x8075
callq 0x235a0
movl $0x8076, %edi           # imm = 0x8076
callq 0x235a0
addq $0x38, %rsp
retq
nopl (%rax,%rax)