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

  // Update rgb color buffer
  if (vbo_vertex_rgb_color_buffer == 0) {
    glGenBuffers(1, (GLuint *) &vbo_vertex_rgb_color_buffer);
    if (vbo_vertex_rgb_color_buffer > 0) {
      std::vector<GLubyte> rgb_colors;
      for (int i = 0; i < NVertices(); i++) {
        R3MeshVertex *vertex = Vertex(i);
        const RNRgb& rgb_color = VertexColor(vertex);
        rgb_colors.push_back(255.0 * rgb_color.R());
        rgb_colors.push_back(255.0 * rgb_color.G());
        rgb_colors.push_back(255.0 * rgb_color.B());
        rgb_colors.push_back(255);
      }
      glBindBuffer(GL_ARRAY_BUFFER, vbo_vertex_rgb_color_buffer);
      glBufferData(GL_ARRAY_BUFFER, rgb_colors.size() * sizeof(GLubyte), &rgb_colors[0], GL_STATIC_DRAW);
      glBindBuffer(GL_ARRAY_BUFFER, 0);
    }
  }

  // Return rgb color buffer identifier
  return vbo_vertex_rgb_color_buffer;
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0x98(%rsp)
movq 0x98(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x135e0
cmpl $0x0, %eax
jne 0x23576
movl $0x0, 0xa4(%rsp)
jmp 0x237d0
movq 0x48(%rsp), %rax
cmpl $0x0, 0x70(%rax)
jne 0x237c1
movq 0x48(%rsp), %rsi
movq 0x14ba17(%rip), %rax    # 0x16efa8
movq (%rax), %rax
addq $0x70, %rsi
movl $0x1, %edi
callq *%rax
movq 0x48(%rsp), %rax
cmpl $0x0, 0x70(%rax)
jbe 0x237bf
leaq 0x80(%rsp), %rdi
callq 0x38c70
movl $0x0, 0x7c(%rsp)
movq 0x48(%rsp), %rdi
movl 0x7c(%rsp), %eax
movl %eax, 0x40(%rsp)
callq 0x135e0
movl %eax, 0x44(%rsp)
jmp 0x235db
movl 0x40(%rsp), %eax
movl 0x44(%rsp), %ecx
cmpl %ecx, %eax
jge 0x23735
movq 0x48(%rsp), %rdi
movl 0x7c(%rsp), %esi
callq 0x13630
movq %rax, 0x38(%rsp)
jmp 0x23600
movq 0x48(%rsp), %rdi
movq 0x38(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rsi
callq 0x368d0
movq %rax, 0x30(%rsp)
jmp 0x23620
movq 0x30(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdi
callq 0x38cb0
movsd %xmm0, 0x28(%rsp)
jmp 0x2363c
movsd 0x28(%rsp), %xmm0
movsd 0x10fbd6(%rip), %xmm1   # 0x133220
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movb %al, 0x57(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x57(%rsp), %rsi
callq 0x38c80
jmp 0x2366a
movq 0x58(%rsp), %rdi
callq 0x38cc0
movsd %xmm0, 0x20(%rsp)
jmp 0x2367c
movsd 0x20(%rsp), %xmm0
movsd 0x10fb96(%rip), %xmm1   # 0x133220
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movb %al, 0x56(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x56(%rsp), %rsi
callq 0x38c80
jmp 0x236aa
movq 0x58(%rsp), %rdi
callq 0x38cd0
movsd %xmm0, 0x18(%rsp)
jmp 0x236bc
movsd 0x18(%rsp), %xmm0
movsd 0x10fb56(%rip), %xmm1   # 0x133220
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movb %al, 0x55(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x55(%rsp), %rsi
callq 0x38c80
jmp 0x236ea
movb $-0x1, 0x54(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x54(%rsp), %rsi
callq 0x38c80
jmp 0x23703
jmp 0x23705
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x235c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x38d20
jmp 0x237df
movq 0x48(%rsp), %rcx
movq 0x14b87f(%rip), %rax    # 0x16efc0
movq (%rax), %rax
movl 0x70(%rcx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
jmp 0x23750
movq 0x14b879(%rip), %rax    # 0x16efd0
movq (%rax), %rax
movq %rax, 0x10(%rsp)
leaq 0x80(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x38ce0
movq (%rsp), %rdi
movq %rax, 0x8(%rsp)
xorl %eax, %eax
movl %eax, %esi
callq 0x38d00
movq 0x8(%rsp), %rsi
movq %rax, %rdx
movq 0x10(%rsp), %rax
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e4, %ecx           # imm = 0x88E4
callq *%rax
jmp 0x2379d
movq 0x14b81c(%rip), %rax    # 0x16efc0
movq (%rax), %rax
movl $0x8892, %edi           # imm = 0x8892
xorl %esi, %esi
callq *%rax
jmp 0x237b2
leaq 0x80(%rsp), %rdi
callq 0x38d20
jmp 0x237c1
movq 0x48(%rsp), %rax
movl 0x70(%rax), %eax
movl %eax, 0xa4(%rsp)
movl 0xa4(%rsp), %eax
addq $0xa8, %rsp
retq
movq 0x70(%rsp), %rdi
callq 0xf890
nopl (%rax)