// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3TriangleArray.cpp
// Function: gaps::R3TriangleArray::DrawVBO(gaps::RNFlags) const
void R3TriangleArray::
DrawVBO(const R3DrawFlags draw_flags) const
{
#if (RN_3D_GRFX == RN_OPENGL)
  // Update vbo
  ((R3TriangleArray *) this)->UpdateVBO();

  // Check vbo
  if (vbo_id == 0) return;
  if (vbo_size == 0) return;

  // Bind vbo
  glBindBuffer(GL_ARRAY_BUFFER, vbo_id);

  // Set pointers
  static const unsigned int vertex_size = 12 * sizeof(GLfloat);
  glVertexPointer(3, GL_FLOAT, vertex_size, (char *) NULL);
  glNormalPointer(GL_FLOAT, vertex_size, (char *) NULL + 3 * sizeof(GLfloat));
  glColorPointer(3, GL_FLOAT, vertex_size, (char *) NULL + 6 * sizeof(GLfloat));
  glTexCoordPointer(2, GL_FLOAT, vertex_size, (char *) NULL + 9 * sizeof(GLfloat));

  // Enable client states
  R3DrawFlags flags(Flags() & draw_flags);
  glEnableClientState(GL_VERTEX_ARRAY);
  if (flags[R3_SURFACE_NORMALS_DRAW_FLAG] || flags[R3_VERTEX_NORMALS_DRAW_FLAG])
    glEnableClientState(GL_NORMAL_ARRAY);
  else glDisable(GL_NORMAL_ARRAY);
  if (flags[R3_VERTEX_COLORS_DRAW_FLAG])
    glEnableClientState(GL_COLOR_ARRAY);
  else glDisable(GL_COLOR_ARRAY);
  if (flags[R3_SURFACE_TEXTURE_DRAW_FLAG] || flags[R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG])
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  else glDisable(GL_TEXTURE_COORD_ARRAY);
  
  // Draw triangles
  int nvertices = vbo_size / vertex_size;
  assert(nvertices == 3 * NTriangles());
  glDrawArrays(GL_TRIANGLES, 0, nvertices);
  
  // Disable client states
  glDisableClientState(GL_VERTEX_ARRAY);
  glDisableClientState(GL_NORMAL_ARRAY);
  glDisableClientState(GL_COLOR_ARRAY);
  glDisableClientState(GL_TEXTURE_COORD_ARRAY);

  glBindBuffer(GL_ARRAY_BUFFER, 0);

#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x258(%rax)
movl 0x68(%rbx), %esi
testl %esi, %esi
je 0x4c309
cmpl $0x0, 0x6c(%rbx)
je 0x4c309
movq 0x8dd1d(%rip), %r12     # 0xd9fb0
movl $0x8892, %edi           # imm = 0x8892
callq *(%r12)
pushq $0x3
popq %r15
pushq $0x30
popq %rbp
movl %r15d, %edi
movl $0x1406, %esi           # imm = 0x1406
movl %ebp, %edx
xorl %ecx, %ecx
callq 0xe490
pushq $0xc
popq %rdx
movl $0x1406, %edi           # imm = 0x1406
movl %ebp, %esi
callq 0xe7f0
pushq $0x18
popq %rcx
movl %r15d, %edi
movl $0x1406, %esi           # imm = 0x1406
movl %ebp, %edx
callq 0xe470
pushq $0x2
popq %rdi
pushq $0x24
popq %rcx
movl $0x1406, %esi           # imm = 0x1406
movl %ebp, %edx
callq 0xe910
andq 0x60(%rbx), %r14
movl $0x8074, %edi           # imm = 0x8074
callq 0xe2d0
movl $0x8075, %edi           # imm = 0x8075
testw $0x120, %r14w           # imm = 0x120
je 0x4c312
callq 0xe2d0
jmp 0x4c317
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0xe140
movl $0x8076, %edi           # imm = 0x8076
btl $0xa, %r14d
jb 0x4c32a
callq 0xe140
jmp 0x4c32f
callq 0xe2d0
movl $0x8078, %edi           # imm = 0x8078
testw $0x230, %r14w           # imm = 0x230
je 0x4c343
callq 0xe2d0
jmp 0x4c348
callq 0xe140
movl 0x6c(%rbx), %eax
xorl %edx, %edx
divl %ebp
pushq $0x4
popq %rdi
xorl %esi, %esi
movl %eax, %edx
callq 0xe060
movl $0x8074, %edi           # imm = 0x8074
callq 0xe2b0
movl $0x8075, %edi           # imm = 0x8075
callq 0xe2b0
movl $0x8076, %edi           # imm = 0x8076
callq 0xe2b0
movl $0x8078, %edi           # imm = 0x8078
callq 0xe2b0
movq (%r12), %rax
movl $0x8892, %edi           # imm = 0x8892
xorl %esi, %esi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmpq *%rax