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

  // Update position buffer object
  if (vbo_position_buffer == 0) {
    glGenBuffers(1, (GLuint *) &vbo_position_buffer);
    if (vbo_position_buffer > 0) {
      std::vector<GLfloat> positions;
      for (int i = 0; i < NPoints(); i++) {
        const R3Point& position = PointPosition(i);
        positions.push_back(position.X());
        positions.push_back(position.Y());
        positions.push_back(position.Z());
      }
      glBindBuffer(GL_ARRAY_BUFFER, vbo_position_buffer);
      glBufferData(GL_ARRAY_BUFFER, positions.size() * sizeof(GLfloat), &positions[0], GL_STATIC_DRAW);
      glBindBuffer(GL_ARRAY_BUFFER, 0);
    }
  }
  
  // Return buffer object identifier
  return vbo_position_buffer;
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0x98(%rsp)
movq 0x98(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x32400
cmpl $0x0, %eax
jne 0xdd8c6
movl $0x0, 0xa4(%rsp)
jmp 0xddade
movq 0x48(%rsp), %rax
cmpl $0x0, 0x108(%rax)
jne 0xddacc
movq 0x48(%rsp), %rsi
movq 0x14b6c4(%rip), %rax    # 0x228fa8
movq (%rax), %rax
addq $0x108, %rsi            # imm = 0x108
movl $0x1, %edi
callq *%rax
movq 0x48(%rsp), %rax
cmpl $0x0, 0x108(%rax)
jbe 0xddaca
leaq 0x80(%rsp), %rdi
callq 0xaf8f0
movl $0x0, 0x7c(%rsp)
movq 0x48(%rsp), %rdi
movl 0x7c(%rsp), %eax
movl %eax, 0x40(%rsp)
callq 0x32400
movl %eax, 0x44(%rsp)
jmp 0xdd934
movl 0x40(%rsp), %eax
movl 0x44(%rsp), %ecx
cmpl %ecx, %eax
jge 0xdda37
movq 0x48(%rsp), %rdi
movl 0x7c(%rsp), %esi
callq 0x359b0
movq %rax, 0x38(%rsp)
jmp 0xdd959
movq 0x38(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdi
callq 0x34870
movsd %xmm0, 0x30(%rsp)
jmp 0xdd975
movsd 0x30(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x5c(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x5c(%rsp), %rsi
callq 0xaf900
jmp 0xdd999
movq 0x60(%rsp), %rdi
callq 0x33190
movsd %xmm0, 0x28(%rsp)
jmp 0xdd9ab
movsd 0x28(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x58(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0xaf900
jmp 0xdd9cf
movq 0x60(%rsp), %rdi
callq 0x34910
movsd %xmm0, 0x20(%rsp)
jmp 0xdd9e1
movsd 0x20(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x54(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x54(%rsp), %rsi
callq 0xaf900
jmp 0xdda05
jmp 0xdda07
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0xdd91c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
leaq 0x80(%rsp), %rdi
callq 0xaf970
jmp 0xddaed
movq 0x48(%rsp), %rcx
movq 0x14b585(%rip), %rax    # 0x228fc8
movq (%rax), %rax
movl 0x108(%rcx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
jmp 0xdda55
movq 0x14b57c(%rip), %rax    # 0x228fd8
movq (%rax), %rax
movq %rax, 0x18(%rsp)
leaq 0x80(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0xaf930
movq 0x8(%rsp), %rdi
shlq $0x2, %rax
movq %rax, 0x10(%rsp)
xorl %eax, %eax
movl %eax, %esi
callq 0xaf950
movq 0x10(%rsp), %rsi
movq %rax, %rdx
movq 0x18(%rsp), %rax
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e4, %ecx           # imm = 0x88E4
callq *%rax
jmp 0xddaa8
movq 0x14b519(%rip), %rax    # 0x228fc8
movq (%rax), %rax
movl $0x8892, %edi           # imm = 0x8892
xorl %esi, %esi
callq *%rax
jmp 0xddabd
leaq 0x80(%rsp), %rdi
callq 0xaf970
jmp 0xddacc
movq 0x48(%rsp), %rax
movl 0x108(%rax), %eax
movl %eax, 0xa4(%rsp)
movl 0xa4(%rsp), %eax
addq $0xa8, %rsp
retq
movq 0x70(%rsp), %rdi
callq 0x24250
nopw (%rax,%rax)